
/* > > > > > > > > > > > > > > > > > > > > > >#

Author:     Midium - Tecnologia da Informação
WebSite:    www.midium.com.br
E-mail:     contato@midium.com.br
Date:       17/04/2011
Comments:   Galeria de produtos versão 2.6

#< < < < < < < < < < < < < < < < < < < < < < */

window.load_requires = 0;
window.gotop = 0;

$winevent.add('error',function()
	{ return true }
);

/* CLASS */

var Midium_ProdGallery = {
	Start : function(method, paths, disableAutoSelect)
	{
		var source = $class.Paths.Source = paths['Source'];
		var files  = $class.Paths.Files  = paths['Files'];
		//
		$class.ElementsHTML.BudgetFlap('embed');
		//
		$winevent.add('load',function()
		{
			$importscript(source + 'Requires/reference.php');
			//
			if($elmt('prodStage'))
			{
				var loadint = setInterval(function()
					{
						if(load_requires)
						{
							method == 'ShowAllProducts' ? $class.Show(0) : (method = method.split(':')) & ($class.Show(0,method[1]));
							//
							var i = 1;
							//
							while($R[i + '#0'])
							{
								$gethtml('prodMenu','<a id="lineMenu_' + i + '" class="prodLink" href="javascript:void(0);">' + $R[i + '#0'] + '</a>',1);
								//
								i++;
							};
							$class.ElementsHTML.Menu();
							//
							clearInterval(loadint);
						};
					}
				,10);
				//
				$class.GoTop();
				$class.ElementsHTML.Control();
				$class.ElementsHTML.BudgetFlap('show');
				//
				$gethtml('prodStage','<span style="font:12 Arial; color:#333333"> Carregando banco de dados... </span>');
			};
			$class.ElementsHTML.SearchField();
		});
		document.write('<script src="' + source + 'Requires/settings.js" type="text/javascript"></script>');
	},
	Show : function(id,searchMethod)
	{
		if(Number(id)){
			//
			$class.BuildContent([id],searchMethod);
			//
		} else {
			//
			var i = 1;
			//
			var combo = Array();
			//
			while($R[i + '#0']){ combo[combo.length] = i; i++ }
			//
			$class.BuildContent(combo.length == 1 ? [combo[0]] : combo,searchMethod); 
		};
	},
	Search : {
		Find : function(string)
		{
			if(string == 'Digite o nome do produto...' || !string){
				return false;
			}
			setTimeout(function(){
				//
				window.location.href = (window.location.href.indexOf('search') == -1 ? 'search/' : '') + $class.Search.Handle(string);
				//
			}, 800);
			//
			return false;	
		},
		Handle : function(string)
		{
			string = string.replace(/[á|ã|â|à]/gi,'a');
			string = string.replace(/[é|ê|è]/gi,'e');
			string = string.replace(/[í|ì|î]/gi,'i');
			string = string.replace(/[õ|ò|ó|ô]/gi,'o');
			string = string.replace(/[ú|ù|û]/gi,'u');
			string = string.replace(/[ç]/gi,'c');
			string = string.replace(/[ñ]/gi,'n');
			string = string.replace(/[\ ]/gi,'-');
			//
			return string.toLowerCase();
		}
	},
	BuildContent : function(combo,searchMethod)
	{
		var bool, add;
		var html = '';
		var counter = 0;
		var thumbs = '';
		var endLine = 1;
		var stageHeight = 0;
		var stage = $elmt('prodStage');
		var oldProdStageHeight = $elmt('prodStage').offsetHeight;
		//
		var width = $S["# Largura"] + ($S["# TamanhoBorda"] * 2);
		var height = $S["# Altura"] + ($S["# TamanhoBorda"] * 2);
		var margin = $S["# DistanciaY"];
		//
		var rows = Math.round(stage.offsetWidth / width) - 1;
		//
		for(i1=0;i1<combo.length;i1++)
		{
			var i2 = 0;
			var showGoTop = 1;
			var cacheid = !searchMethod ? combo[i1] : 'result';
			//
			if(!$class.Cache['#' + cacheid])
			{
				if(!searchMethod)
				{
					thumbs = '';
				};
				while(1)
				{
					var data = $R[combo[i1] + '#' + (i2 + 1)];
					//
					if(searchMethod){
						//
						if(data){
							//
							add = $class.Search.Handle(data[1]).indexOf(searchMethod) != -1;
							//
						} else {
							//
							add = 0;
						};
						endLine = !data && combo.length - 1 == i1;
						//
					} else {
						//
						add = data ? 1 : 0;
					};
					if(add){
						//
						thumbs += '<div class="line"><div class="name">' + data[1] + '</div><div class="sname"> &nbsp; </div><a class="slot" href="javascript:void(0);" ' + (data[4] ? 'onClick="$class.Action.View(' + combo[i1] + ',' + (i2 + 1) + ');"' : 'style="cursor:default;"') + '><div class="loading"></div><div class="thumb" style="background-color:white; z-index:1;"></div><div class="thumb" style="background-image:url(' + $class.Paths.Files + 'TMB-' + data[2] + '); z-index:3;"></div></a>' + (data[0] ? '<a class="addbudget" href="javascript:void(0);" onClick="$class.Action.Add(' + combo[i1] + ',' + (i2 + 1) + ');" title="Adicionar produto em sua lista de orçamentos"><div class="budgetico"></div></a>' : '<div class="addbudget" style="cursor:default; background-image:none;"></div>') + (data[3] ? '<a class="data" href="javascript:void(0);" onClick="$class.Action.OpenPopup(' + combo[i1] + ',' + (i2 + 1) + ')"> Detalhes </a>' : '') + '</div>';
						//
						counter++;
						//
					} else if(!data) { break }; i2++;
				};
				if(endLine)
				{
					bool = ((searchMethod ? counter : i2) / rows).toString().indexOf('.') == -1;
					//
					stageHeight += rows * (height + margin) + 40;
					//
					if(!thumbs)
					{
						thumbs = '<div style="font:bold 12 Arial; color:#838383; height:40px;"> Nenhum produto encontrado... </div>';
						//
						showGoTop = 0;
						//
					} else {
						//
						showGoTop = stageHeight > 750;
					};
					cache = '<div class="combo"><div class="title">' + (searchMethod ? 'Resultado da Pesquisa' : $R[combo[i1] + '#0']) + '</div><div class="underline"></div>' + thumbs  + (showGoTop ? '<a href="javascript:void(0);" onClick="window.gotop=1" class="gotop" style="background-color:transparent; margin-top:' + (bool ? 0 : height + 3) + ';' + (bool ? ' margin-left:' + (((rows * width) - $S["# DistanciaX"] + $S["# TamanhoBorda"]) - 75) + 'px' : 'height:80px;') + '"><div class="gotop"></div></a>' : '') + '</div>';
					//
					$class.Cache['#' + cacheid] = searchMethod ? 0 : cache;
					//
					html += cache;
				};
			} else {
				//
				html += $class.Cache['#' + cacheid];
			};
		};
		$gethtml(stage.id,html);
		//
		setTimeout(function()
		{
			var menuHeight = $elmt('prodMenu').offsetHeight + 50;
			var stgHeight = $elmt('prodStage').offsetHeight;
			//
			stgHeight = menuHeight > stgHeight ? menuHeight : stgHeight;
			//
			if(stgHeight > oldProdStageHeight && stgHeight > 360)
			{
				if(ele = $elmt($S["# DivConteudo"][0]))
				{
					ele.style.height = (stgHeight + $S["# DivConteudo"][1]) + 'px';
					$elmt('rodape').style.top = stgHeight + 400;
				};
			};
		},50);
	},
	Control : {
		Load : function(disableAlert)
		{
			var list = '';
			var listName = '';
			var cookieValue = $class.BudgetCookie.Get('splitlist');
			var len = cookieValue.length;
			//
			if(cookieValue)
			{
				for(i=1;i<len;i++)
				{
					var value = cookieValue[i];
					//
					value = value.split('-');
					//
					listName = unescape(value[0]);
					//
					list += '<div id="SAVELIST_' + i + '" style="cursor:pointer; width:100%; height:24px; font-family:Segoe UI; font-weight:bold; font-style:italic; font-size:12px; line-height:23px;" onmouseover="this.style.backgroundColor=\'#FDF3AD\'" onmouseout="this.style.backgroundColor=\'transparent\'" ondblclick="this.style.color=\'red\'; setTimeout(\'Midium_EngineResources.WindowOutside.Exit(); $class.Action.ReadList(' + i + '); $class.Action.RemoveList(0);\',400);" title="Dê um duplo click para carregar lista"><div style="position:absolute; margin-top:0px; color:red; font-style:normal; width:70px; height:24px; right:15px;" onmouseover="this.style.color=\'#FFADAD\'" onmouseout="this.style.color=\'red\'" onclick="this.onmouseout=\'\'; this.style.color=\'red\'; var ele = $elmt(\'SAVELIST_' + i + '\'); ele.style.backgroundColor=\'#FFB2B2\'; ele.onmouseout=\'\'; if(confirm(\'Remover esta lista salva neste computador? \')){ $class.Action.RemoveList(1,' + i + '); }; this.onmouseout=function(){ this.style.color=\'red\'; }; var ele = $elmt(\'SAVELIST_' + i + '\'); ele.onmouseout=function(){ this.style.backgroundColor=\'transparent\'; }; ele.style.backgroundColor=\'#FDF3AD\';" title="Deleta sua lista salva neste computador"> Excluir Lista </div> &nbsp; ' + listName + '</div>';
				};
				Midium_EngineResources.WindowOutside.Get('<div style="position:absolute; width:475px; height:323px; background-color:#FFFFFF"><div style="position:absolute; width:445px; height:18px; top:14px; left:15px; background-image:url(' + $class.Paths.Source + 'Includes/Images/_loadTitle.gif)">  </div><div id="budgetSaveList" style="position:absolute; overflow:hidden-x; overflow-y:scroll; width:445px; height:230px; top:44px; left:15px; font:bold italic 12 Segoe UI">' + list + '</div><div id="submitNewList" onclick="$class.Action.RemoveList(0); Midium_EngineResources.WindowOutside.Exit();" onmouseover="Midium_EngineResources.AlphaMotion.Opacity(this,80)" onmouseout="Midium_EngineResources.AlphaMotion.Opacity(this,100)" style="cursor:pointer; position:absolute; width:143px; height:27px; bottom:8px; right:15px; font:bold 11 Arial; color:red; text-align:center; line-height:26px; -moz-opacity:1; -khtml-opacity:1; opacity:1; background-color:#FFFEE8;"> &bull; ' + ( $class.Data.BudgetListStarted ? 'Fechar listas salvas' : 'Iniciar uma nova lista') + '</div></div>', 475, 323, 80, 1);
				//
			} else if(!disableAlert){
				//
				alert("Não há listas salvas neste computador.");	
			};
		},
		Save : function(onError)
		{
			if(!$class.Data.BudgetList.length)
			{ alert('Sua lista está vazia!') }
			else if(!$class.Data.BudgetListChanged)
			{ alert('Sua lista não foi alterada.') }
			else
			{
				var date = new Date();
				//
				var hour = $class.LeadingZero(date.getHours());
				var minute = $class.LeadingZero(date.getMinutes());
				var monthDay = $class.LeadingZero(date.getDate());
				var month = $class.LeadingZero(date.getMonth()+1);
				var year = date.getFullYear().toString();
				//
				var hourString = hour + ":" + minute;
				var dateString = monthDay + "/" + month + "/" + year . substr(2,2);
				//
				var newList = 1;
				var listName = '';
				var save = 0;
				var newSave = 1;
				//
				if($class.Data.BudgetListLoaded && !onError)
				{
					var spt = $class.BudgetCookie.Get('readlist',$class.Data.BudgetListID).split('-');
					//
					listName = unescape(spt[0]);
					//
					newList = confirm('Você deseja salvar as modificações de "' + listName + '"? \nObs: Clique cancelar para criar uma nova lista.');
					//
					save = newList;
					//
					newSave = !newList;
				};
				if(!newList || !$class.Data.BudgetListLoaded || onError)
				{
					var spt;
					var i = 1;
					var counter = 0;
					//
					while(1)
					{
						spt = $class.BudgetCookie.Get('readlist',i);
						//
						if(spt)
						{
							spt = spt . split('-');
							//
							namearr = unescape(spt[0]).split(' -');
							//
							moreName = namearr[0] ? namearr[0].split('(') : null;
							//
							if((namearr[0] == 'Meus Orçamentos') || ((namearr[0] ? moreName[0] : 0) == 'Meus Orçamentos'))
							{
								counter++;
							};
						} else { break }; i++;
					};
					var newList = prompt('Digite o nome de sua lista de orçamentos. Nota: Na opção "Minhas listas salvas" será exibido todas as listas salvas neste computador e você identificará sua lista pelo nome.','Meus Orçamentos' + (counter > 0 ? '(' + (counter + 1) + ')' : ''));
					//
					i = 1;
					//
					if(newList)
					{
						if(newList.length > 22)
						{
							alert('Nome muito extenso! Digite um nome com menos caracteres.');
							$class.Control.Save(1);
							return 0;
						};
						newList += ' - Criado em ' + dateString + ' às ' + hourString;
					};
					!$class.Data.BudgetListLoaded ? ($class.Data.BudgetListLoaded = newList != null) : null;
					//
					listName = newList;
					//
					save = newList != null;
				}
				if(save)
				{
					var listValue = '';
					var listLen = $class.Data.BudgetList.length;
					//
					for(i=0;i<listLen;i++)
					{
						listValue += $class.Data.BudgetList[i][0];
					};
					var createList = 0;
					var value = escape(listName) + '-' + listValue;
					//
					if(!newSave)
					{
						var methodstr = 'alterada';
						var cookieValue = $class.BudgetCookie.Get('content');
						var spt = cookieValue.split('_');
						//
						spt[$class.Data.BudgetListID] = value;
						//
						value = '';
						//
						for(i=1;i<spt.length;i++)
						{
							value += "_" + spt[i];
						};
						$class.BudgetCookie.Save('__BUDGETLIST', value);
					};
					if(newSave || createList)
					{ 
						var methodstr = 'salva';
						var cookieValue = $class.BudgetCookie.Get('content');
						var spt = cookieValue . split('_');
						//
						$class.Data.BudgetListID = spt.length;
						$class.BudgetCookie.Save('__BUDGETLIST', '_' + value + cookieValue);
					};
					$class.Data.BudgetListChanged = 0;
					//
					alert('Sua lista foi ' + methodstr + ' com sucesso!');
				};
			};
			$class.ElementsHTML.BudgetFlap('open');
		},
		Clear : function()
		{
			if($class.Data.BudgetList.length)
			{
				if(confirm('Remover todos os itens de sua lista de orçamentos?'))
				{
					$class.Data.BudgetList = Array();
					$class.Data.BudgetListChanged = 1;
				};
			};
			$gethtml('budgetList','<span style="color:red;"> Lista excluída </span>');
			$class.ElementsHTML.BudgetFlap('open');
		},
		Send : function()
		{
			if($class.Data.BudgetList.length){ Midium_EngineResources.WindowOutside.Get('<div title="Click para sair" onClick="javascript:Midium_EngineResources.WindowOutside.Exit()" style="position:absolute;cursor:pointer;font:bold 13 Arial;width:40px;margin-top:-17px;margin-left:680px;color:white;"><font color="red">X</font> Sair</div><iframe src="' + $class.Paths.Source + 'Includes/Components/form.php" width="720" height="435" allowtransparency="1" frameborder="0" scrolling="no"></iframe>',710,435,80,1) } else { alert('Sua lista está vazia!'); $class.ElementsHTML.BudgetFlap('open'); }
		}
	},
	Action : {
		View : function(line, id, controller)
		{
			var sizeWidth = 50;
			var sizeHeight = 50;
			var prodImage = new Image();
			var width, height, woContStyle, piContStyle, int, scrollPos;
			//
			prodImage.onerror = function()
			{
				alert('Imagem não encontrada');
				Midium_EngineResources . WindowOutside . Exit();
			};
			prodImage . onload = function()
			{
				width = this.width + 20;
				height = this.height + 39;
				//
				woContStyle = $elmt('WOContainer').style;
				piContStyle = $elmt('PIContent').style;
				//
				$elmt('PIContent').removeChild($elmt('loadStatus'));
				//
				int = setInterval(function()
				{
					sizeWidth += (width - sizeWidth) / 10;
					sizeHeight += (height - sizeHeight) / 10;
					//
					woContStyle.width = sizeWidth + "px";
					woContStyle.height = sizeHeight + "px";
					woContStyle.marginLeft = (-(sizeWidth / 2)) + "px";
					woContStyle.marginTop = (-(sizeHeight / 2)) + "px";
					//
					piContStyle.width = sizeWidth + "px";
					piContStyle.height = sizeHeight + "px";
					//
					if(sizeWidth >= width - 10 && sizeHeight >= height - 10)
					{
						clearInterval(int);
						//
						$gethtml('PIContent',($R[line + '#' + id][0] ? '<div onClick="javascript:$class.Action.Add(' + line + ',' + id + '); Midium_EngineResources.AlphaMotion.Opacity($elmt(\'addIcon\'),40); this.style.cursor = \'default\'; this.onclick = \'\'; var ele = $elmt(\'addIcon\'); ele.onmouseover=\'\'; ele.onmouseout=\'\'" style="position:absolute; cursor:pointer; width:205px; height:24px; margin-top:-24px; background-color:white;"><div id="addIcon" style="width:205px; height:24px; background-image:url(' + $class.Paths.Source + 'Includes/Images/_displayAdd.gif)" onmouseover="Midium_EngineResources.AlphaMotion.Opacity(this, 60)" onmouseout="Midium_EngineResources.AlphaMotion.Opacity(this,100)"></div></div>' : '') + '<div title="Click para sair" onClick="javascript:Midium_EngineResources.WindowOutside.Exit()" style="position:absolute; cursor:pointer; font:bold 13 Segoe UI; width:36px; margin-top:-17px; margin-left:' + (width - 46)+ 'px; color:white;"><font color="red">X</font> Sair</div><img style="position:absolute; margin-top:5px; margin-left:5px;" src="' + prodImage.src + '"><div style="position:absolute; font:bold 15 Arial; left:6px; top:' + (sizeHeight - 22) + 'px; color:#FF0000"> ' + $R[line + '#' + id][1] + ' </div><div style="position:absolute; cursor:pointer; width:31px; height:53px; top:' + ((height / 2) - 40) + 'px; margin-left:' + (width + 10) + 'px;" onmouseover="Midium_EngineResources.AlphaMotion.Opacity(this,40)" onmouseout="Midium_EngineResources.AlphaMotion.Opacity(this,100)" ' + ($R[line + '#' + (id + 1)] ? 'onclick="$class.Action.View(' + line + ',' + (id + 1) + ',1);"' : '') + ' title="Próxima"><img src="' + $class.Paths.Source + 'Includes/Images/_next.png"  width="31" height="53"></div><div style="position:absolute; cursor:pointer; width:31px; height:53px; top:' + ((height / 2) - 40) + 'px; margin-left:-50px;" onmouseover="Midium_EngineResources.AlphaMotion.Opacity(this,40)" onmouseout="Midium_EngineResources.AlphaMotion.Opacity(this,100)" ' + (id != 1 ? ' onclick="$class.Action.View(' + line + ',' + (id - 1) + ',1);")' : '') + ' title="Anterior"><img src="' + $class.Paths.Source + 'Includes/Images/_prev.png" width="31" height="53"></div></div>');
					};
				}, 1);
			};
			setTimeout(function(){
				//
				Midium_EngineResources.WindowOutside.Get('<div id="PIContent" style="width:' + sizeWidth + 'px; height:' + sizeHeight + 'px; background-color:white;"><img id="loadStatus" style="margin-left:13px; margin-top:13px;" src="' + $class.Paths.Source + 'Includes/Images/_loading.gif"></div>', sizeWidth, sizeHeight, 80, 1, 0, controller);
				setTimeout(function(){ prodImage.src = $class.Paths.Files + 'IMG-' + $R[line + '#' + id][2]; },600);
				//
			}, 100);
		},
		OpenPopup : function(line,id)
		{
			window . open('information.php?lid=' + line + '&pid=' + id, '', 'width=836,height=338, scrollbars=no, menubar=no, status=yes, titlebar=no, toolbar=no, resizable=no');
		},
		Add : function(line, id)
		{
			var add = 1;
			var br, len, obj;
			var arr = $class.Data.BudgetList;
			var name = $R[line +'#'+ id][1];
			//
			$class.Data.BudgetListChanged = 1;
			$class.Data.BudgetListStarted = 1;
			//
			for(i=0;i<arr.length;i++)
			{
				if(arr[i][1] == name)
				{
					alert('Este produto já foi adicionado!');
					add = 0;
				};
			};
			obj = $elmt('budgetList');
			arr = $class.Data.BudgetList;
			len = arr.length;
			//
			if(add)
			{
				$class.ElementsHTML.BudgetFlap('open');
				len == 0 ? (obj.innerHTML = '') : null;
				arr[len] = Array($class.LeadingZero(line) + $class.LeadingZero(id),name);
				obj.innerHTML += '<div id="LIST_' + line + '_' + id + '"><div onClick="$class.Action.Delete(' + line + ',' + id + ')" onMouseOver="this.style.color=\'#FF9A9A\'; $elmt(\'LIST_' + line + '_' + id + '\').style.color=\'#A6A6A6\';" onMouseOut="this.style.color=\'red\'; $elmt(\'LIST_' + line + '_' + id + '\').style.color=\'#000000\';" title="Retirar da lista" style="cursor:pointer; position:absolute; font:bold 12 Segoe UI; height:12px; width:10px; margin-left:' + (obj.clientWidth - 10) + 'px; color:red;"> x </div> ' + name + ' </div>';
			};
		},
		Delete : function(line, id)
		{
			var name = $R[line + '#' + id][1];
			//
			if(confirm('Remover "' + name + '" de sua lista de orçamentos?'))
			{
				$class.Data.BudgetListChanged = 1;
				//
				var allow = 0;
				var arr = $class.Data.BudgetList;
				var len = arr.length;
				//
				for(i = 0; i < len; i++)
				{
					arr[i][1] == name ? (allow = 1) : null;
					//
					if(allow)
					{
						$class.Data.BudgetList[i] = arr[i+1];
					};
				};
				$class.Data.BudgetList . pop();
				$elmt('budgetList').removeChild($elmt('LIST_' + line + '_' + id));
				//
				if(!$class.Data.BudgetList.length)
				{
					$elmt('budgetList').innerHTML = '<span style="color:red;"> Lista excluída </span>';
				};
				$class.ElementsHTML.BudgetFlap('open');
			};
		},
		ReadList : function(id)
		{
			var line, name;
			var obj = $elmt('budgetList');
			//
			var cookie = $class.BudgetCookie.Get('readlist', id).split('-');
			var code = cookie[2].toString();
			//
			$class.Data.BudgetListLoaded = 1;
			$class.Data.BudgetListID = id;
			//
			obj.innerHTML = '';
			$class.Data.BudgetList = Array(); 
			//
			for(i=1;i<=code.length/4;i++)
			{
				line = code.substr((i * 4) - 4, 2);
				id = code.substr((i * 4) - 2, 2);
				//
				sptline = line.split('');
				sptid = id.split('');
				//
				line = sptline[0] == '0' ? line.substr(1,1) : line;
				id = sptid[0] == '0' ? id.substr(1,1) : id;
				//
				name = $R[line + '#' + id][1];
				//
				$class.Data.BudgetList[i - 1] = Array($class.LeadingZero(line) + $class.LeadingZero(id),name);
				//
				obj.innerHTML += '<div id="LIST_' + line + '_' + id + '"><div onClick="$class.Action.Delete(' + line + ',' + id + ')" onMouseOver="this.style.color=\'#FF9A9A\'; $elmt(\'LIST_' + line + '_' + id + '\').style.color=\'#A6A6A6\';" onMouseOut="this.style.color=\'red\'; $elmt(\'LIST_' + line + '_' + id + '\').style.color=#000000\';" title="Retirar da lista" style="cursor:pointer; position:absolute; font:bold 12 Segoe UI; height:12px; width:10px; margin-left:' + (obj.clientWidth - 10) + 'px; color:red;"> x </div> ' + name + ' </div>';
			};
			$class.ElementsHTML.BudgetFlap('open');
		},
		RemoveList : function(method, id)
		{
			if(method){
				//
				$class.Data.BudgetSaveListDelete[$class.Data.BudgetSaveListDelete.length] = id;
				//
				$elmt('budgetSaveList').removeChild($elmt('SAVELIST_' + id));
				//
			} else {
				//
				setTimeout(function(){
					//
					var add;
					var value = '';
					//
					var spt = $class.BudgetCookie.Get('content').split('_');
					var deleteList = $class.Data.BudgetSaveListDelete;
					//
					for(i1=1;i1<spt.length;i1++)
					{
						if($class.Data.BudgetListID == i1)
						{
							$class.Data.BudgetListChanged = 1;
							$class.Data.BudgetListLoaded = 0;
						};
						add = 1;
						//
						for(i2 = 0; i2 < deleteList . length; i2++)
						{
							if(i1 == deleteList[i2])
							{
								add = 0;
							};
						};
						if(add)
						{
							value += "_" + spt[i1];
						};
					};
					$class.BudgetCookie.Save('__BUDGETLIST', value);
					//
					$class.Data.BudgetSaveListDelete = Array();
					//
				},100);
			};
		}
	},
	ElementsHTML : {
		Menu : function()
		{
			var i = 0;
			//
			while(1)
			{
				buttom = $elmt('lineMenu_' + i);
				//
				if(buttom)
				{
					buttom.onclick = function(){ var string = this.id.split('_'); $class.Show(string[1]) };
					//
					$style(buttom.id,'cursor','pointer');
					//
					i++;
					//
				} else { break };
			};
		},
		Control : function()
		{
			var i = 0;
			var arr = Array('load', 'save', 'clear', 'send');
			//
			while(1)
			{
				buttom = $elmt('budgetMenu_' + arr[i]);
				//
				if(buttom){
					//
					Midium_EngineResources.AlphaMotion.Opacity(buttom,0);
					//
					buttom.onmouseover = function(){ Midium_EngineResources.AlphaMotion.Opacity(this,35) }
					buttom.onmouseout  = function(){ Midium_EngineResources.AlphaMotion.Opacity(this,0) }
					//
					var titles = new Array();
					//
					titles[0] = 'Carrega sua lista virtual salva neste computador.';
					titles[1] = 'Salva sua lista virtual neste computador.';
					titles[2] = 'Deleta todos os produtos de sua lista de orçamentos.';
					titles[3] = 'Envia seus pedidos de orçamentos para que possamos lhe informar sobre os preços.';
					//
					buttom.title = titles[i];
					//
					buttom.onclick = function(){ var string = this.id.split('_'); var strarr = string[1].split(''); $class.Control[strarr[0].toUpperCase() + string[1].substr(1,strarr.length)]() }
					//
					i++;
					//
				} else { break };
			};
		},
		SearchField : function()
		{
			var form = $elmt('search');
			//
			if(form)
			{
				var i = 0;
				var index, color;
				var findIndex = 'Digite o nome do produto...';
				//
				var html = '<div id=\'LOCLINK\' class="ProdGallery_SelectOption" style="background-color:#F4F9FD" onClick="Midium_ProdGallery.Action.Find(1);" onMouseOver="this.style.backgroundColor=\'#E6F2FB\'; this.style.fontWeight=\'bold\'" onMouseOut="this.style.backgroundColor=\'#F4F9FD\'; this.style.fontWeight=\'normal\'""><span style="margin-left:6px;"><b>&bull;</b> Buscar produto </span></div>';
				//
				form.innerHTML = '<input name="findstr" style="position:absolute; width:100%; height:100%; border:0px; font:11 Arial; color:#CCC; background-color:transparent; z-index:2" onFocus="this.value ? onFieldFocus() : null" onKeyUp="this.value ? onFieldFocus() : onFieldBlur() & this.blur()" onBlur="onFieldBlur()" autoComplete="off"><style type="text/css"> .ProdGallery_SelectOption{ cursor:pointer; height:22px; width:98%; margin-bottom:1px; font: 12 Arial; line-height:22px; } </style><div id="ProdGallery_SelectFlap" style="position:absolute; width:' + ($isIE ? 100 : 99) + '%; left:0px; top:19px; border:solid 1px #7F9DB9; background-color:white; filter:alpha(opacity=0); -moz-opacity:0; -khtml-opacity:0; opacity:0; z-index:1;"></div><div id="ProdGallery_FlapContent" style="position:absolute; display:none; width:100%; left:0px; top:27px; filter:alpha(opacity=0); -moz-opacity:0; -khtml-opacity:0; opacity:0; z-index:2"><div id=\'LOCLINK\' class="ProdGallery_SelectOption" style="background-color:#F4F9FD" onClick="$class.Search.Find($elmt(\'search\').findstr.value)" onMouseOver="this.style.backgroundColor=\'#E6F2FB\'; this.style.fontWeight=\'bold\'" onMouseOut="this.style.backgroundColor=\'#F4F9FD\'; this.style.fontWeight=\'normal\'""><span style="margin-left:6px; color:#333333"><b>&bull;</b> Buscar produto </span></div></div>';
				form.findstr.value = findIndex; 
				//
				var maxh, maxx, eleh, posx;
				var allowFocus = 1;
				var flap = $elmt('ProdGallery_SelectFlap').style;
				var content = $elmt('ProdGallery_FlapContent').style;
				var indexLink = $elmt('LOCLINK').style;
				//
				posx = maxx = -6;
				eleh = maxh = 0;
				//
				onFieldFocus = function()
				{
					if(allowFocus)
					{
						if(form.findstr.value == findIndex){
							//
							form.findstr.value = "";
							//
						} else {
							//
							maxh = 45;
							allowFocus = 0;
							content.display = 'block';
							indexLink.fontWeight = 'bold';
							indexLink.backgroundColor = '#E6F2FB';
							//
							Midium_EngineResources.AlphaMotion.Fade('ProdGallery_SelectFlap','in',100,80);
							//
							setTimeout(function(){ maxx = 3; Midium_EngineResources.AlphaMotion.Fade('ProdGallery_FlapContent','in',100,80,100) },370);
						};
						form.findstr.style.color = '#333333';
					};
				};
				onFieldBlur = function ()
				{
					if(!allowFocus)
					{
						setTimeout(function()
						{
							setTimeout(function(){ maxx = -6 }, 100);
							//
							Midium_EngineResources.AlphaMotion.Fade('ProdGallery_FlapContent','out',0,100);
							//
							setTimeout(function(){ maxh = 0; Midium_EngineResources.AlphaMotion.Fade('ProdGallery_SelectFlap','out',0,100) },370);
							setTimeout(function(){ !form.findstr.value ? form.findstr.value = findIndex : null; content.display = 'none'; allowFocus = 1; form.findstr.style.color = form.findstr.value ? '#CCC' : '#333' },600);
							//
						}, 100);
						//
					} else {
						setTimeout(function(){
							//
							form.findstr.style.color = '#CCCCCC';
							form.findstr.value = findIndex;
							//
						}, 300);
					};
				};
				setInterval(function(){
					//
					eleh += (maxh - eleh)/10;
					posx += (maxx - posx)/10;
					flap.height = eleh + 'px';
					content.marginLeft = posx + 'px';
					//
				},10);
			}
		},
		ProdStage : function()
		{
			var width = $S["# Largura"] + ($S["# TamanhoBorda"] * 2);
			var height = $S["# Altura"] + ($S["# TamanhoBorda"] * 2);
			//
			var css = '<style type="text/css">';
			//
			css += '.combo { position:relative; clear:both; width:100%; height:auto; }\n';
			//
			css += '.title { position:relative; font:bold italic 18 Arial; color:' + $S["# CorTitulo"] + '; }\n';
			//
			css += '.underline { position:relative; width:85%; height:5px; margin-bottom:12px; border-top:solid 1px #DFDFDF; font-size:0px; }\n';
			//
			css += '.thumb { position:absolute; width:' + $S["# Largura"] + 'px; height:' + $S["# Altura"] + 'px; top:' + $S["# TamanhoBorda"] + 'px; left:' + $S["# TamanhoBorda"] + 'px; background-position:center; background-repeat:no-repeat; }\n';
			//
			css += '.line { position:relative; float:left; margin-right:' + $S["# DistanciaX"] + 'px; margin-bottom:' + $S["# DistanciaY"] + 'px; }\n';
			//
			css += '.sname { position:relative; height:2px; width:13px; font-size:1px; }\n';
			//
			css += '.name { position:absolute; font:11 Arial; width:' + $S["# Largura"] + 'px; color:' + $S["# CorNome"] + '; }\n';
			//
			css += '.slot { display:block; cursor:pointer; outline:none; position:relative; width:' + width + 'px; height:' + height + 'px; margin-top:13px; background-color:' + $S["# CorBorda"] + '; }\n';
			//
			css += '.loading { position:absolute; width:100%; height:100%; background-image:url(' + $class.Paths.Source + 'Includes/Images/_loading.gif); background-repeat:no-repeat; background-position:center; z-index:2; }\n';
			//
			css += '.addbudget { display:block; cursor:pointer; outline:none; position:relative; width:69px; height:17px; margin-top:1px; margin-left:' + (width - 69) + 'px; }\n';
			//
			css += '.budgetico { width:69px; height:17px; background-image:url(' + $class.Paths.Source + 'Includes/Images/_iconAdd.png); background-color:white; }\n';
			//
			css += 'a.data { display:block; cursor:pointer; outline:none; position:absolute; bottom:2px; font:11 Arial; color:#3F3F3F; }\n';
			//
			css += 'a.data:hover { color:#A1A1A1; }\n';
			//
			vers = navigator.appVersion;
			//
			test = parseFloat(vers.indexOf("MSIE")) + 1;
			//
			css += '.gotop { display:block; cursor:pointer; outline:none; position:relative; ' + ((navigator.appName == "Microsoft Internet Explorer") && (parseFloat(vers.substring(test + 4,test + 7)) < 7) ? '' : 'float:left;') + ' width:118px; height:25px; background-image:url(' + $class.Paths.Source + 'Includes/Images/_gotop.png); background-repeat:no-repeat; background-color:' + $S["# CorIrAoTopo"] + '; }';
			//
			document.write(css + '</style>');
		},
		BudgetFlap : function(action)
		{
			switch(action)
			{
				case 'embed':
					//
					document . write('<div id="BF" style="position:absolute;width:315px;height:362px;left:-350px;margin-top:-111px;background-image:url(' + $class.Paths.Source + 'Includes/Images/_budgetFlap.png); z-index:49"><div id="budgetList" style="position:absolute;overflow-y:scroll;width:236px;height:240px;top:41px;left:26px;font:11 Verdana;color:#333333"><span style="color:red;"> Nenhum orçamento </span></div><div style="position:absolute;bottom:18px;left:5px;width:259px;height:46px;"><div id="budgetMenu_clear" style="cursor:pointer;float:left;width:92px;height:20px;margin-right:6px;background-color:white"></div><div id="budgetMenu_load" style="cursor:pointer;float:left;width:160px;height:20px;background-color:white"></div><div id="budgetMenu_save" style="cursor:pointer;float:left;width:92px;height:20px;margin-top:6px;margin-right:6px;background-color:white"></div><div id="budgetMenu_send" style="cursor:pointer;float:left;width:160px;height:20px;margin-top:6px; background-color:white"></div></div></div>');
					//
				break;
				//
				case 'show' :
					//
					var flap = $elmt('BF');
					//
					window.flappos = -350;
					window.flapgopos = -272;
					window.flapmiddle = document.body.scrollTop + (document.body.clientHeight/2);
					//
					flap.onmouseover = function()
					{
						window.flapgopos = 0;
						window.budgerflap ? clearTimeout(window.budgerflap) : null;
					};
					flap.onmouseout = function()
					{
						window.flapgopos = -272;
					};
					setInterval(function(){
						//
						window.flappos += (window.flapgopos - window.flappos) / 4;
						window.flapmiddle += ((document.body.scrollTop + (document.body.clientHeight/2)) - window.flapmiddle) / 5;
						//
						$style('BF','left',Math.floor(window.flappos) + 'px');
						$style('BF','top',Math.floor(window.flapmiddle) + 'px');
						//
					}, 10);
					//
				break;
				//
				case 'open':
					//
					window.flapgopos = 0; window.budgerflap ? clearTimeout(window.budgerflap) : null;
					//
					budgerflap = setTimeout(function(){ window.flapgopos = -272 },2000);
					//
				break;
			};
		}
	},
	BudgetCookie : {
		Get : function(method, id)
		{
			var value = this . Read('__BUDGETLIST');
			//
			switch(method)
			{
				case "splitlist": var arr = value.split('_'); arr = arr[1] ? arr : 0; return arr;
				case "readlist": var arr = value.split('_'); return arr[id];
				case "content": return value;
			};
		},
		Save : function(id, value)
		{
			var date = new Date();
			//
			date.setTime(date.getTime() + (30 * 24 * 60 * 60 *10000));
			//
			document.cookie = id + '=' + value + ';expires=' + date.toGMTString();
		},
		Read : function(id)
		{
			var i = 0;
			var value = '';
			var is1 = 0;
			var len = document . cookie . length;
			//
			while(i < len)
			{
				char = document . cookie . charAt(i);
				//
				if(char == ';')
				{
					if(!is1){
						value = '';
					} else {
						break;
					};
				} else if(char == '='){
					if(value == id){
						value = '';
						is1 = 1;
					};
				} else if(char != ' ' || is1)
					value = value + char;
					i = i + 1;
			};
			if(is1){
				return unescape(value);
			} else {
				return '';
			};
		}
	},
	GoTop : function()
	{
		var scrollPos;
		//
		setInterval(function()
		{
			if(window.gotop)
			{
				scrollPos = document.body.scrollTop -= 100;
				//
				if(scrollPos <= 10)
				{
					window.gotop = 0;
				};
			};
		}, 10);
	},
	LeadingZero : function(value)
	{
		var string = value.toString();
		string.length == 1 ? (string = '0' + string) : null;
		return string;
	},
	Data : {
		BudgetListID : null,
		SendSubmited : 0,
		BudgetList : new Array(),
		BudgetListLoaded : 0,
		BudgetListStarted : 0,
		BudgetListChanged : 0,
		BudgetSaveListDelete : new Array()
	},
	Paths : new Object(),
	Cache : new Object()

}; var $class = Midium_ProdGallery;
