	/*************************************************************************\
	CheckCardNumber(form)
	function called when users click the "check" button.
	\*************************************************************************/

	function validaCartao()
	{ 
		var retorno = true;
		
		var CCval = document.getElementById("CartaoNumero").value; 

		// check if credit card name has been entered 
		if (arguments.IsValid) 
		{               
			if (CCval == "") 
			{ 
				retorno = false;
			} 
		} 

		CCval = _strip_spaces(CCval); 

		// check if credit card number is actually a number 
		if (_isinteger(CCval) == false) 
		{ 
			retorno = false;
		} 
		if (retorno) 
		{ 
			// check for 4242 4242 4242 4242 
			if (CCval == "4242424242424242") 
			{ 
				retorno = false;
			} 
		} 

		if (retorno) 
		{ 
			//check that the credit card number is valid 
			if (!CC_Validate(CCval)) 
			{ 
				retorno = false;
			} 
		}

		return retorno;
	} 

	function _strip_spaces(_ipstr) 
	{ 
		var _opstr = ''; 
		var i; 
		for (i = 1; i <= _ipstr.length; i++) 
		{ 
			if(_ipstr.substring(i-1, i) != ' ') 
			{
				_opstr = _opstr + _ipstr.substring(i-1, i); 
			}
		} 
		return _opstr; 
	} 


	function _isinteger(test_string)
	{ 
		var i; 
		var non_nums = 0; 
		
		for (i = 1; i < test_string.length; i++)
		{ 
			if ((test_string.substring(i-1,i) < '0') || (test_string.substring(i-1,i) > '9')) 
			{
				non_nums++; 
			}
		} 

		if (non_nums == 0) 
			return true; 
		else 
			return false; 
	} 


	function CC_Validate(ccnumber)
	{ 
		var checksum = 0; 
		var i; 
		var digit; 
		var temp; 

		var cclength=ccnumber.length; 
		if (cclength % 2 != 0) 
		{ 
			cclength += 1; 
			ccnumber = "0" + ccnumber; 
		} 

		for (i = 0; i < cclength; i++)
		{ 
			digit = parseInt(ccnumber.charAt(i)); 
			if ((i % 2) == 0)
			{ 
				digit *= 2; 
				if (digit > 9) 
				{
					digit = parseInt(digit / 10) + parseInt(digit % 10); 
				} 
			}
			checksum += digit; 
		} 


		if (checksum % 10 == 0) 
			return true; 
		else 
			return false; 
	} 

	function AtualizaItem(ItemCodigo)
	{
		var prossegue = false;

		var Presente = document.getElementById("GiftTmp" + ItemCodigo).value;
		var MsgPresente = document.getElementById("MsgGift" + ItemCodigo).value;

		TrocaImagem("loading", "visible");

		if (Presente.length < 1)
		{
			if (confirm("Você deseja prosseguir sem preencher o campo de Mensagem?"))
			{
				prossegue = true;
			}
		}
		else
		{
			prossegue = true;
		}

		if (prossegue)
		{
			presente.AtualizaItem(ItemCodigo.toString(), Presente.toString(), MsgPresente, callback_AtualizaItem)
		}
	}

	function callback_AtualizaItem(res)
	{
		if (res.error)
		{
			alert(res.error.Message);
			TrocaImagem("loading", "hidden");
		}		

		if (res.value)
		{
			alert(res.value);
			TrocaImagem("loading", "hidden");
		}
	}

	function Gift(ItemCodigo, valor)
	{
		document.getElementById("GiftTmp" + ItemCodigo).value = valor;
	}


	function ArmazenaParcelamento(campo)
	{
		if (campo.type == "radio")
		{
			if (campo.checked)
			{
				document.getElementById("ParcelamentoSel").value = campo.id;
				document.getElementById("ParcelamentoSelCod").value = campo.value;
			}
		}
	}

	function ValidaMeioPagamento(MeioCodigo)
	{
		TrocaImagem("loading", "visible");
		
		try
		{
			if (MeioCodigo.checked)
			{			
				if (document.getElementById("OperadoraCodigo").value != MeioCodigo.value.substring(4))
				{
					if (document.getElementById(MeioCodigo.value.substring(0,3)))
					{
						ValidaPagamento(document.getElementById(MeioCodigo.value.substring(0,3)));
					}

					for (j=0; j<document.forms[0].elements.length; j++) 
					{
						campo = document.forms[0].elements[j];

						if (campo.type == "radio")
						{
							if (campo.value == MeioCodigo.value.substring(0,3))
							{
								campo.checked = true;
							}

							if (campo.value.indexOf(MeioCodigo.value.substring(0,3)) < 0)
							{
								campo.checked = false;
							}
						}
					}

					//window.location.href = "#p";

					document.getElementById("ParcelamentoSel").value = "";
					document.getElementById("ParcelamentoSelCod").value = "";
					document.getElementById("OperadoraCodigo").value = MeioCodigo.value.substring(4);
					document.getElementById("OperadoraTipo").value = MeioCodigo.value.substring(0,3);

					if (MeioCodigo.value.substring(0,3) == "CCR")
					{						
						fechamento.ValidaMeioPagamento(MeioCodigo.value.substring(4),"CCR", callback_ValidaMeioPagamento_CCR)
					}
					else if (MeioCodigo.value.substring(0,3) == "BOL")
					{
						document.getElementById("OperadoraTipo").value = "BOL";
						fechamento.ValidaMeioPagamento(MeioCodigo.value.substring(4),"BOL", callback_ValidaMeioPagamento_BOL)
					}
					else if (MeioCodigo.value.substring(0,3) == "DEP")
					{
						document.getElementById("OperadoraTipo").value = "DEP";
						fechamento.ValidaMeioPagamento(MeioCodigo.value.substring(4),"DEP", callback_ValidaMeioPagamento_DEP)
					}
					else if (MeioCodigo.value.substring(0,3) == "CHE")
					{
						document.getElementById("OperadoraTipo").value = "CHE";
						fechamento.ValidaMeioPagamento(MeioCodigo.value.substring(4),"CHE", callback_ValidaMeioPagamento_CHE)
					}
					else if (MeioCodigo.value.substring(0,3) == "DIN")
					{
						document.getElementById("OperadoraTipo").value = "DIN";
						fechamento.ValidaMeioPagamento(MeioCodigo.value.substring(4),"DIN", callback_ValidaMeioPagamento_DIN)
					}
					/*else if (MeioCodigo.value.substring(0,3) == "DEB")
					{
						fechamento.ValidaMeioPagamento(MeioCodigo.value.substring(4),"DEB", callback_ValidaMeioPagamento_DEB)
					}*/
				}
				else
				{
					TrocaImagem("loading", "hidden");
				}
			}
		} 
		catch(err)
		{
			alert(err.description);
			TrocaImagem("loading", "hidden");
		}
	}

	function callback_ValidaMeioPagamento_CCR(res)
	{
 		if (res.error)
		{
			alert(res.error.Message);
			window.location.href = window.location;
		}

		document.getElementById("spanPagamentoEscolhidoCCR").innerHTML = res.value[0];
		document.getElementById("spanPagamentoEscolhidoBOL").innerHTML = "";
		document.getElementById("spanPagamentoEscolhidoDEP").innerHTML = "";
		document.getElementById("spanPagamentoEscolhidoCHE").innerHTML = "";
		document.getElementById("spanPagamentoEscolhidoDIN").innerHTML = "";
		//document.getElementById("spanPagamentoEscolhidoDEB").innerHTML = "";

		if (res.value[1])
		{
			if (document.getElementById(res.value[1] + "_1"))
			{
				document.getElementById(res.value[1] + "_1").checked = true;
				ArmazenaParcelamento(document.getElementById(res.value[1] + "_1"));
			}
		}

		TrocaImagem("loading", "hidden");
	}

	function callback_ValidaMeioPagamento_BOL(res)
	{
 		if (res.error)
		{
			alert(res.error.Message);
			window.location.href = window.location;
		}

		document.getElementById("spanPagamentoEscolhidoCCR").innerHTML = "";
		document.getElementById("spanPagamentoEscolhidoBOL").innerHTML = res.value[0];
		document.getElementById("spanPagamentoEscolhidoDEP").innerHTML = "";
		document.getElementById("spanPagamentoEscolhidoCHE").innerHTML = "";
		document.getElementById("spanPagamentoEscolhidoDIN").innerHTML = "";
		//document.getElementById("spanPagamentoEscolhidoDEB").innerHTML = "";

		if (res.value[1])
		{
			if (document.getElementById(res.value[1] + "_1"))
			{
				document.getElementById(res.value[1] + "_1").checked = true;
				ArmazenaParcelamento(document.getElementById(res.value[1] + "_1"));
			}
		}

		TrocaImagem("loading", "hidden");
	}

	function callback_ValidaMeioPagamento_DEB(res)
	{
 		if (res.error)
		{
			alert(res.error.Message);
			window.location.href = window.location;
		}

		document.getElementById("spanPagamentoEscolhidoCCR").innerHTML = "";
		document.getElementById("spanPagamentoEscolhidoBOL").innerHTML = "";
		document.getElementById("spanPagamentoEscolhidoDEP").innerHTML = "";
		document.getElementById("spanPagamentoEscolhidoCHE").innerHTML = "";
		document.getElementById("spanPagamentoEscolhidoDIN").innerHTML = "";
		//document.getElementById("spanPagamentoEscolhidoDEB").innerHTML = res.value[0];

		if (res.value[1])
		{
			if (document.getElementById(res.value[1] + "_1"))
			{
				document.getElementById(res.value[1] + "_1").checked = true;
				ArmazenaParcelamento(document.getElementById(res.value[1] + "_1"));
			}
		}

		TrocaImagem("loading", "hidden");
	}
	
	function callback_ValidaMeioPagamento_DEP(res)
	{
 		if (res.error)
		{
			alert(res.error.Message);
			window.location.href = window.location;
		}

		document.getElementById("spanPagamentoEscolhidoCCR").innerHTML = "";
		document.getElementById("spanPagamentoEscolhidoBOL").innerHTML = "";
		document.getElementById("spanPagamentoEscolhidoDEP").innerHTML = res.value[0];
		document.getElementById("spanPagamentoEscolhidoCHE").innerHTML = "";
		document.getElementById("spanPagamentoEscolhidoDIN").innerHTML = "";
		//document.getElementById("spanPagamentoEscolhidoDEB").innerHTML = "";

		if (res.value[1])
		{
			if (document.getElementById(res.value[1] + "_1"))
			{
				document.getElementById(res.value[1] + "_1").checked = true;
				ArmazenaParcelamento(document.getElementById(res.value[1] + "_1"));
			}
		}

		TrocaImagem("loading", "hidden");
	}
	
	function callback_ValidaMeioPagamento_CHE(res)
	{
 		if (res.error)
		{
			alert(res.error.Message);
			window.location.href = window.location;
		}

		document.getElementById("spanPagamentoEscolhidoCCR").innerHTML = "";
		document.getElementById("spanPagamentoEscolhidoBOL").innerHTML = "";
		document.getElementById("spanPagamentoEscolhidoDEP").innerHTML = "";
		document.getElementById("spanPagamentoEscolhidoCHE").innerHTML = res.value[0];
		document.getElementById("spanPagamentoEscolhidoDIN").innerHTML = "";
		//document.getElementById("spanPagamentoEscolhidoDEB").innerHTML = "";

		if (res.value[1])
		{
			if (document.getElementById(res.value[1] + "_1"))
			{
				document.getElementById(res.value[1] + "_1").checked = true;
				ArmazenaParcelamento(document.getElementById(res.value[1] + "_1"));
			}
		}

		TrocaImagem("loading", "hidden");
	}
	
	function callback_ValidaMeioPagamento_DIN(res)
	{
 		if (res.error)
		{
			alert(res.error.Message);
			window.location.href = window.location;
		}

		document.getElementById("spanPagamentoEscolhidoCCR").innerHTML = "";
		document.getElementById("spanPagamentoEscolhidoBOL").innerHTML = "";
		document.getElementById("spanPagamentoEscolhidoDEP").innerHTML = "";
		document.getElementById("spanPagamentoEscolhidoCHE").innerHTML = "";
		document.getElementById("spanPagamentoEscolhidoDIN").innerHTML = res.value[0];
		//document.getElementById("spanPagamentoEscolhidoDEB").innerHTML = "";

		if (res.value[1])
		{
			if (document.getElementById(res.value[1] + "_1"))
			{
				document.getElementById(res.value[1] + "_1").checked = true;
				ArmazenaParcelamento(document.getElementById(res.value[1] + "_1"));
			}
		}

		TrocaImagem("loading", "hidden");
	}


	function ValidaPagamento(FormaCodigo)
	{
		if (FormaCodigo.checked)
		{
			var carrega = false;
			var MeioCodigo = 0;

			for (j=0; j<document.forms[0].elements.length; j++) 
			{
				campo = document.forms[0].elements[j];

				if (campo.type == "radio")
				{
					if (campo.value.indexOf(FormaCodigo.value) < 0)
					{
						campo.checked = false;
					}
				}
			}

			if (FormaCodigo.value == "CCR")
			{
				document.getElementById("spanPagamentoEscolhidoBOL").innerHTML = "";
				document.getElementById("spanPagamentoEscolhidoDEP").innerHTML = "";
				document.getElementById("spanPagamentoEscolhidoCHE").innerHTML = "";
				document.getElementById("spanPagamentoEscolhidoDIN").innerHTML = "";
				//document.getElementById("spanPagamentoEscolhidoDEB").innerHTML = "";
			}
			else if (FormaCodigo.value == "BOL")
			{
				document.getElementById("spanPagamentoEscolhidoCCR").innerHTML = "";
				document.getElementById("spanPagamentoEscolhidoDEP").innerHTML = "";
				document.getElementById("spanPagamentoEscolhidoCHE").innerHTML = "";
				document.getElementById("spanPagamentoEscolhidoDIN").innerHTML = "";
				//document.getElementById("spanPagamentoEscolhidoDEB").innerHTML = "";
			}
			else if (FormaCodigo.value == "DEB")
			{
				document.getElementById("spanPagamentoEscolhidoCCR").innerHTML = "";
				document.getElementById("spanPagamentoEscolhidoBOL").innerHTML = "";
				document.getElementById("spanPagamentoEscolhidoDEP").innerHTML = "";
				document.getElementById("spanPagamentoEscolhidoCHE").innerHTML = "";
				document.getElementById("spanPagamentoEscolhidoDIN").innerHTML = "";
			}
			else if (FormaCodigo.value == "DEP")
			{
				document.getElementById("spanPagamentoEscolhidoCCR").innerHTML = "";
				document.getElementById("spanPagamentoEscolhidoBOL").innerHTML = "";
				document.getElementById("spanPagamentoEscolhidoCHE").innerHTML = "";
				document.getElementById("spanPagamentoEscolhidoDIN").innerHTML = "";
				//document.getElementById("spanPagamentoEscolhidoDEB").innerHTML = "";
			}
			else if (FormaCodigo.value == "CHE")
			{
				document.getElementById("spanPagamentoEscolhidoCCR").innerHTML = "";
				document.getElementById("spanPagamentoEscolhidoBOL").innerHTML = "";
				document.getElementById("spanPagamentoEscolhidoDEP").innerHTML = "";
				document.getElementById("spanPagamentoEscolhidoDIN").innerHTML = "";
				//document.getElementById("spanPagamentoEscolhidoDEB").innerHTML = "";
			}
			else if (FormaCodigo.value == "DIN")
			{
				document.getElementById("spanPagamentoEscolhidoCCR").innerHTML = "";
				document.getElementById("spanPagamentoEscolhidoBOL").innerHTML = "";
				document.getElementById("spanPagamentoEscolhidoCHE").innerHTML = "";
				document.getElementById("spanPagamentoEscolhidoDEP").innerHTML = "";
				//document.getElementById("spanPagamentoEscolhidoDEB").innerHTML = "";
			}

			document.getElementById("ParcelamentoSel").value = "";
			document.getElementById("ParcelamentoSelCod").value = "";
			document.getElementById("OperadoraTipo").value = FormaCodigo.value;
			document.getElementById("OperadoraCodigo").value = "";

			TrocaImagem("loading", "hidden");

			//window.location.href = "#p";
		}
	}

	function positionit()
	{
		var ie=document.all&&navigator.userAgent.indexOf("Opera")==-1;
		var loading_obj=ie? document.all.loading : document.getElementById? document.getElementById("loading_div") : document.loading;

		var Hoffset=82 //Enter logo's offset from right edge of window (edit only if you don't like the default offset)
		var Voffset=-4 //Enter logo's offset from top edge of window (edit only if you don't like the default offset)

		var dsocleft=ie? document.body.scrollLeft : pageXOffset;
		var dsoctop=ie? document.body.scrollTop : pageYOffset;
		var window_width=ie? document.body.clientWidth : window.innerWidth-20;

		if (ie||document.getElementById)
		{
			if(document.getElementById(loading_obj))
			{
				loading_obj.style.left=parseInt(dsocleft)+parseInt(window_width)-Hoffset;
				loading_obj.style.top=parseInt(dsoctop)+5+Voffset;
			}
		}
		else if (document.layers)
		{
			if(document.getElementById(loading_obj))
			{
				loading_obj.left=dsocleft+window_width-Hoffset;
				loading_obj.top=dsoctop+window_height+5+Voffset;
			}
		}
	}

	function positionitOpiniao()
	{
		var ie=document.all&&navigator.userAgent.indexOf("Opera")==-1;
		var opiniao_obj=ie? document.all.opiniao : document.getElementById? document.getElementById("opiniao_div") : document.opiniao;

		var Voffset=196 //Enter logo's offset from top edge of window (edit only if you don't like the default offset)
		var Hoffset=9 //Enter logo's offset from top edge of window (edit only if you don't like the default offset)

		var dsocleft=ie? document.body.scrollLeft : pageXOffset;
		var dsoctop=ie? document.body.scrollTop : pageYOffset;
		var window_width=ie? document.body.clientWidth : window.innerWidth-20;

		if (ie||document.getElementById)
		{
			opiniao_obj.style.left=Hoffset;
			opiniao_obj.style.top=parseInt(dsoctop)+Voffset+2;
		}
		else if (document.layers)
		{
			opiniao_obj.left=Hoffset;
			opiniao_obj.top=dsoctop+Voffset;
		}
	}

	function beingloading()
	{
		loadinginterval = setInterval("positionit()",50);
	}

	function beingOpiniao()
	{
		Opiniaointerval = setInterval("positionitOpiniao()",50);
	}

	function ColocaFocus(NomeBtn, e) 
	{ 
		try
		{
			var key; 

			if(window.event) 
			{ 
				key = window.event.keyCode; 
			}
			else
			{ 
				key = e.which; 
			}
			if(key == 13)
			{
				document.getElementById(NomeBtn).focus();

				if(window.event) 
				{ 
					window.event.keyCode = 0;
				}
			}
		} 
		catch(err)
		{
			alert(err.description);
		}
		
		return false;
	} 

	/**
	 * SWFObject v1.5: Flash Player detection and embed - http://blog.deconcept.com/swfobject/
	 *
	 * SWFObject is (c) 2007 Geoff Stearns and is released under the MIT License:
	 * http://www.opensource.org/licenses/mit-license.php
	 *
	 */

	if(typeof deconcept=="undefined"){var deconcept=new Object();}if(typeof deconcept.util=="undefined"){deconcept.util=new Object();}if(typeof deconcept.SWFObjectUtil=="undefined"){deconcept.SWFObjectUtil=new Object();}deconcept.SWFObject=function(_1,id,w,h,_5,c,_7,_8,_9,_a){if(!document.getElementById){return;}this.DETECT_KEY=_a?_a:"detectflash";this.skipDetect=deconcept.util.getRequestParameter(this.DETECT_KEY);this.params=new Object();this.variables=new Object();this.attributes=new Array();if(_1){this.setAttribute("swf",_1);}if(id){this.setAttribute("id",id);}if(w){this.setAttribute("width",w);}if(h){this.setAttribute("height",h);}if(_5){this.setAttribute("version",new deconcept.PlayerVersion(_5.toString().split(".")));}this.installedVer=deconcept.SWFObjectUtil.getPlayerVersion();if(!window.opera&&document.all&&this.installedVer.major>7){deconcept.SWFObject.doPrepUnload=true;}if(c){this.addParam("bgcolor",c);}var q=_7?_7:"high";this.addParam("quality",q);this.setAttribute("useExpressInstall",false);this.setAttribute("doExpressInstall",false);var _c=(_8)?_8:window.location;this.setAttribute("xiRedirectUrl",_c);this.setAttribute("redirectUrl","");if(_9){this.setAttribute("redirectUrl",_9);}};deconcept.SWFObject.prototype={useExpressInstall:function(_d){this.xiSWFPath=!_d?"expressinstall.swf":_d;this.setAttribute("useExpressInstall",true);},setAttribute:function(_e,_f){this.attributes[_e]=_f;},getAttribute:function(_10){return this.attributes[_10];},addParam:function(_11,_12){this.params[_11]=_12;},getParams:function(){return this.params;},addVariable:function(_13,_14){this.variables[_13]=_14;},getVariable:function(_15){return this.variables[_15];},getVariables:function(){return this.variables;},getVariablePairs:function(){var _16=new Array();var key;var _18=this.getVariables();for(key in _18){_16[_16.length]=key+"="+_18[key];}return _16;},getSWFHTML:function(){var _19="";if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length){if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","PlugIn");this.setAttribute("swf",this.xiSWFPath);}_19="<embed type=\"application/x-shockwave-flash\" src=\""+this.getAttribute("swf")+"\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\" style=\""+this.getAttribute("style")+"\"";_19+=" id=\""+this.getAttribute("id")+"\" name=\""+this.getAttribute("id")+"\" ";var _1a=this.getParams();for(var key in _1a){_19+=[key]+"=\""+_1a[key]+"\" ";}var _1c=this.getVariablePairs().join("&");if(_1c.length>0){_19+="flashvars=\""+_1c+"\"";}_19+="/>";}else{if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","ActiveX");this.setAttribute("swf",this.xiSWFPath);}_19="<object id=\""+this.getAttribute("id")+"\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\" style=\""+this.getAttribute("style")+"\">";_19+="<param name=\"movie\" value=\""+this.getAttribute("swf")+"\" />";var _1d=this.getParams();for(var key in _1d){_19+="<param name=\""+key+"\" value=\""+_1d[key]+"\" />";}var _1f=this.getVariablePairs().join("&");if(_1f.length>0){_19+="<param name=\"flashvars\" value=\""+_1f+"\" />";}_19+="</object>";}return _19;},write:function(_20){if(this.getAttribute("useExpressInstall")){var _21=new deconcept.PlayerVersion([6,0,65]);if(this.installedVer.versionIsValid(_21)&&!this.installedVer.versionIsValid(this.getAttribute("version"))){this.setAttribute("doExpressInstall",true);this.addVariable("MMredirectURL",escape(this.getAttribute("xiRedirectUrl")));document.title=document.title.slice(0,47)+" - Flash Player Installation";this.addVariable("MMdoctitle",document.title);}}if(this.skipDetect||this.getAttribute("doExpressInstall")||this.installedVer.versionIsValid(this.getAttribute("version"))){var n=(typeof _20=="string")?document.getElementById(_20):_20;n.innerHTML=this.getSWFHTML();return true;}else{if(this.getAttribute("redirectUrl")!=""){document.location.replace(this.getAttribute("redirectUrl"));}}return false;}};deconcept.SWFObjectUtil.getPlayerVersion=function(){var _23=new deconcept.PlayerVersion([0,0,0]);if(navigator.plugins&&navigator.mimeTypes.length){var x=navigator.plugins["Shockwave Flash"];if(x&&x.description){_23=new deconcept.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/,"").replace(/(\s+r|\s+b[0-9]+)/,".").split("."));}}else{if(navigator.userAgent&&navigator.userAgent.indexOf("Windows CE")>=0){var axo=1;var _26=3;while(axo){try{_26++;axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+_26);_23=new deconcept.PlayerVersion([_26,0,0]);}catch(e){axo=null;}}}else{try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");}catch(e){try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");_23=new deconcept.PlayerVersion([6,0,21]);axo.AllowScriptAccess="always";}catch(e){if(_23.major==6){return _23;}}try{axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");}catch(e){}}if(axo!=null){_23=new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));}}}return _23;};deconcept.PlayerVersion=function(_29){this.major=_29[0]!=null?parseInt(_29[0]):0;this.minor=_29[1]!=null?parseInt(_29[1]):0;this.rev=_29[2]!=null?parseInt(_29[2]):0;};deconcept.PlayerVersion.prototype.versionIsValid=function(fv){if(this.major<fv.major){return false;}if(this.major>fv.major){return true;}if(this.minor<fv.minor){return false;}if(this.minor>fv.minor){return true;}if(this.rev<fv.rev){return false;}return true;};deconcept.util={getRequestParameter:function(_2b){var q=document.location.search||document.location.hash;if(_2b==null){return q;}if(q){var _2d=q.substring(1).split("&");for(var i=0;i<_2d.length;i++){if(_2d[i].substring(0,_2d[i].indexOf("="))==_2b){return _2d[i].substring((_2d[i].indexOf("=")+1));}}}return "";}};deconcept.SWFObjectUtil.cleanupSWFs=function(){var _2f=document.getElementsByTagName("OBJECT");for(var i=_2f.length-1;i>=0;i--){_2f[i].style.display="none";for(var x in _2f[i]){if(typeof _2f[i][x]=="function"){_2f[i][x]=function(){};}}}};if(deconcept.SWFObject.doPrepUnload){if(!deconcept.unloadSet){deconcept.SWFObjectUtil.prepUnload=function(){__flash_unloadHandler=function(){};__flash_savedUnloadHandler=function(){};window.attachEvent("onunload",deconcept.SWFObjectUtil.cleanupSWFs);};window.attachEvent("onbeforeunload",deconcept.SWFObjectUtil.prepUnload);deconcept.unloadSet=true;}}if(!document.getElementById&&document.all){document.getElementById=function(id){return document.all[id];};}var getQueryParamValue=deconcept.util.getRequestParameter;var FlashObject=deconcept.SWFObject;var SWFObject=deconcept.SWFObject;
	
	function RecuperaAguarda(name, base)
	{
		try
		{
			if (document.getElementById(base))
			{
				if (document.getElementById(base).innerHTML != "")
				{
					document.getElementById(name).innerHTML = document.getElementById(base).innerHTML;
					document.getElementById(base).innerHTML = "";
				}
			}
		}
		catch(err)
		{
			alert(err.description);
		}
	}	
	
	function MsgAguarda(name, base, msg)
	{
		try
		{
			if (document.getElementById(base))
			{
				document.getElementById(base).innerHTML = document.getElementById(name).innerHTML;
			}
		
			document.getElementById(name).innerHTML = (msg != "" ? msg : "Aguarde!");
		}
		catch(err)
		{
			if (document.getElementById(base))
			{
				if (document.getElementById(base).innerHTML != "")
				{
					document.getElementById(name).innerHTML = document.getElementById(base).innerHTML;
				}
			}
			
			alert(err.description);
		}
	}	

	function TrocaImagem(name, visibilidade)
	{
		try
		{
			document.getElementById(name).style.visibility = visibilidade;
		}
		catch(err)
		{
		}
	}	

	function MostraImagemAmpliada()
	{
		var CarValCod1 = 0;
		var CarValCod2 = 0;
		var CarValCod3 = 0;
		var CarValCod4 = 0;
		var CarValCod5 = 0;

		try
		{
			if (document.getElementById("ImagemAmpliada"))
			{
				if (document.getElementById("ImagemAmpliada").style.visibility == "visible")
				{
					document.getElementById("ImagemAmpliada").style.visibility = "hidden";

					(document.getElementById("DRP_SKU_1") ? document.getElementById("DRP_SKU_1").style.visibility = "visible" : void(0));
					(document.getElementById("DRP_SKU_2") ? document.getElementById("DRP_SKU_2").style.visibility = "visible" : void(0));
					(document.getElementById("DRP_SKU_3") ? document.getElementById("DRP_SKU_3").style.visibility = "visible" : void(0));
					(document.getElementById("DRP_SKU_4") ? document.getElementById("DRP_SKU_4").style.visibility = "visible" : void(0));
					(document.getElementById("DRP_SKU_5") ? document.getElementById("DRP_SKU_5").style.visibility = "visible" : void(0));
				}
				else
				{
					document.getElementById("ImagemAmpliada").style.visibility = "visible";

					(document.getElementById("DRP_SKU_1") ? document.getElementById("DRP_SKU_1").style.visibility = "hidden" : void(0));
					(document.getElementById("DRP_SKU_2") ? document.getElementById("DRP_SKU_2").style.visibility = "hidden" : void(0));
					(document.getElementById("DRP_SKU_3") ? document.getElementById("DRP_SKU_3").style.visibility = "hidden" : void(0));
					(document.getElementById("DRP_SKU_4") ? document.getElementById("DRP_SKU_4").style.visibility = "hidden" : void(0));
					(document.getElementById("DRP_SKU_5") ? document.getElementById("DRP_SKU_5").style.visibility = "hidden" : void(0));
				}			
			}
		}
		catch(err)
		{
		}
	}	

	function CarregaSKU(ProdutoCodigo)
	{
		try
		{
			TrocaImagem("loading", "visible");
			detalhes.CarregaSKU(ProdutoCodigo.toString(), callback_CarregaSKU)
		} 
		catch(err)
		{
			alert(err.description);
			TrocaImagem("loading", "hidden");
		}
	}

	function CarregaSKUCross(ProdutoCodigo, ordem)
	{
		try
		{
			TrocaImagem("loading", "visible");
			detalhes.CarregaSKUCross(ProdutoCodigo.toString(), ordem.toString(), callback_CarregaSKUCross);
		} 
		catch(err)
		{
			alert(err.description);
			TrocaImagem("loading", "hidden");
		}
	}


	function CarregaSKUGenericos(ProdutoCodigo)
	{
		try
		{
			TrocaImagem("loading", "visible");
			genericos.CarregaSKU(ProdutoCodigo.toString(), callback_CarregaSKUGenericos)
		} 
		catch(err)
		{
			alert(err.description);
			TrocaImagem("loading", "hidden");
		}
	}




	function CarregaSKUBusca(ProdutoCodigo)
	{
		try
		{
			TrocaImagem("loading", "visible");
			busca.CarregaSKUBusca(ProdutoCodigo.toString(), callback_CarregaSKUBusca);
		} 
		catch(err)
		{
			alert(err.description);
			TrocaImagem("loading", "hidden");
		}
	}

	function CarregaSKUCategoria(ProdutoCodigo)
	{
		try
		{
			TrocaImagem("loading", "visible");
			categoria.CarregaSKUCategoria(ProdutoCodigo.toString(), callback_CarregaSKUBusca);
		} 
		catch(err)
		{
			alert(err.description);
			TrocaImagem("loading", "hidden");
		}
	}

	function CarregaSKUComparador(ProdutoCodigo)
	{
		try
		{
			TrocaImagem("loading", "visible");
			comparar.CarregaSKUComparador(ProdutoCodigo.toString(), callback_CarregaSKUBusca);
		} 
		catch(err)
		{
			alert(err.description);
			TrocaImagem("loading", "hidden");
		}
	}

	function CarregaSKUFornecedor(ProdutoCodigo)
	{
		try
		{
			TrocaImagem("loading", "visible");
			fornecedor.CarregaSKUFornecedor(ProdutoCodigo.toString(), callback_CarregaSKUBusca);
		} 
		catch(err)
		{
			alert(err.description);
			TrocaImagem("loading", "hidden");
		}
	}

	function callback_CarregaSKUCross(res)
	{
		if (res.error)
		{
			alert(res.error.Message);
//			window.location.href = window.location;
		}	
		
		if (res.value)
		{
			document.getElementById("spanSKU_Cross_" + res.value[0] + "_" + res.value[2]).innerHTML = res.value[1];

			for (j=0; j<document.forms[0].elements.length; j++) 
			{
				campo = document.forms[0].elements[j];

				if (campo.name.indexOf("DRP_SKU_" + res.value[0] + "_") != -1)
				{
					campo.disabled = false;
				}
			}

			TrocaImagem("loading", "hidden");
		}
	}

	function callback_CarregaSKUBusca(res)
	{
		if (res.error)
		{
			alert(res.error.Message);
//			window.location.href = window.location;
		}			

		if (res.value)
		{
			document.getElementById("spanSKU_" + res.value[0]).innerHTML = res.value[1];

			for (j=0; j<document.forms[0].elements.length; j++) 
			{
				campo = document.forms[0].elements[j];
				
				if(document.getElementById(campo))
				{
					if (campo.name.indexOf("DRP_SKU_" + res.value[0] + "_") != -1)
					{
						campo.disabled = false;
					}
				}
			}

			TrocaImagem("loading", "hidden");
		}
	}


	function callback_CarregaSKU(res)
	{
 		if (res.error)
		{
			alert(res.error.Message);
//			window.location.href = window.location;
		}	

		if (res.value)
		{
			if (res.value[0])
			{
				document.getElementById("spanSKU").innerHTML = res.value[0];
			}

			for (j=0; j<document.forms[0].elements.length; j++) 
			{
				campo = document.forms[0].elements[j];
				
				if(document.getElementById(campo))
				{
					if (campo.name.indexOf("DRP_SKU") != -1)
					{
						campo.disabled = false;
					}
				}
			}

			TrocaImagem("loading", "hidden");
		}
	}



	function callback_CarregaSKUGenericos(res)
	{
 		if (res.error)
		{
			alert(res.error.Message);
//			window.location.href = window.location;
		}	

		if (res.value)
		{
			for (j=0; j<document.forms[0].elements.length; j++) 
			{
				campo = document.forms[0].elements[j];

				if (campo.name.indexOf("DRP_SKU") != -1)
				{
					campo.disabled = false;
				}
			}

			TrocaImagem("loading", "hidden");
		}
	}



	function DisponibilidadeSKU(campo, ProdutoCodigo, tipo)
	{
		var mensagem = "";
		var aux = "";
		var aux2 = "";
		var aux3 = "";
		var extensao = "";
		var endereco = "";

		var CarValCod1 = 0;
		var CarValCod2 = 0;
		var CarValCod3 = 0;
		var CarValCod4 = 0;
		var CarValCod5 = 0;

		TrocaImagem("loading", "visible");

		try
		{
			CarValCod1 = (document.getElementById("DRP_SKU_1") ? document.getElementById("DRP_SKU_1").options[document.getElementById("DRP_SKU_1").selectedIndex].value : 0);
			CarValCod2 = (document.getElementById("DRP_SKU_2") ? document.getElementById("DRP_SKU_2").options[document.getElementById("DRP_SKU_2").selectedIndex].value : 0);
			CarValCod3 = (document.getElementById("DRP_SKU_3") ? document.getElementById("DRP_SKU_3").options[document.getElementById("DRP_SKU_3").selectedIndex].value : 0);
			CarValCod4 = (document.getElementById("DRP_SKU_4") ? document.getElementById("DRP_SKU_4").options[document.getElementById("DRP_SKU_4").selectedIndex].value : 0);
			CarValCod5 = (document.getElementById("DRP_SKU_5") ? document.getElementById("DRP_SKU_5").options[document.getElementById("DRP_SKU_5").selectedIndex].value : 0);

			if (tipo == "F")
			{
				aux = document.getElementById("ProdutoImagem").src;

				campos = aux.split("_");

				if (campos.length > 0)
				{
					for (i=0; i<campos.length; i++)
					{
						if (i+2 < campos.length)
						{
							endereco = endereco + campos[i];

							if (i+3 < campos.length)
							{
								endereco = endereco + "_";
							}
						}
					}
				}

				extensao = aux.substring(aux.length-4);

				aux2 = 	endereco + '_' + campo.options[campo.selectedIndex].value + "_Detalhe" + extensao;
				aux3 = 	endereco + '_' + campo.options[campo.selectedIndex].value + "_Ampliada" + extensao;

				if (imageExists(aux2))
				{
					document.getElementById("ProdutoImagem").src = aux2;
				}			

				if (imageExists(aux3))
				{
					document.getElementById("ImagemAmpliadaFoto").src = aux3;
				}

				if (document.getElementById("ImagemAmpliada").style.visibility = "visible")
				{
					MostraImagemAmpliada();
				}
			}

			if(campo.options[campo.selectedIndex].value == "")
			{
				mensagem+="Opção inválida (vazio) !\n";
			}

			if(mensagem != "")
			{
				alert(mensagem);
				TrocaImagem("loading", "hidden");
			}
			else
			{
				detalhes.DisponibilidadeSKU(ProdutoCodigo.toString(), CarValCod1.toString(), CarValCod2.toString(), CarValCod3.toString(), CarValCod4.toString(), CarValCod5.toString(), callback_DisponibilidadeSKU)
			}		
		} 
		catch(err)
		{
			alert(err.description);
			TrocaImagem("loading", "hidden");
		}
	}


	
	function DisponibilidadeSKUGenericos(campo, ProdutoCodigo, tipo)
	{
		var mensagem = "";
		var aux = "";
		var aux2 = "";
		var aux3 = "";
		var extensao = "";
		var endereco = "";

		var CarValCod1 = 0;
		var CarValCod2 = 0;
		var CarValCod3 = 0;
		var CarValCod4 = 0;
		var CarValCod5 = 0;

		TrocaImagem("loading", "visible");

		try
		{
			CarValCod1 = (document.getElementById("DRP_SKU_1") ? document.getElementById("DRP_SKU_1").options[document.getElementById("DRP_SKU_1").selectedIndex].value : 0);
			CarValCod2 = (document.getElementById("DRP_SKU_2") ? document.getElementById("DRP_SKU_2").options[document.getElementById("DRP_SKU_2").selectedIndex].value : 0);
			CarValCod3 = (document.getElementById("DRP_SKU_3") ? document.getElementById("DRP_SKU_3").options[document.getElementById("DRP_SKU_3").selectedIndex].value : 0);
			CarValCod4 = (document.getElementById("DRP_SKU_4") ? document.getElementById("DRP_SKU_4").options[document.getElementById("DRP_SKU_4").selectedIndex].value : 0);
			CarValCod5 = (document.getElementById("DRP_SKU_5") ? document.getElementById("DRP_SKU_5").options[document.getElementById("DRP_SKU_5").selectedIndex].value : 0);

			if (tipo == "F")
			{
				aux = document.getElementById("ProdutoImagem").src;

				campos = aux.split("_");

				if (campos.length > 0)
				{
					for (i=0; i<campos.length; i++)
					{
						if (i+2 < campos.length)
						{
							endereco = endereco + campos[i];

							if (i+3 < campos.length)
							{
								endereco = endereco + "_";
							}
						}
					}
				}

				extensao = aux.substring(aux.length-4);

				aux2 = 	endereco + '_' + campo.options[campo.selectedIndex].value + "_Detalhe" + extensao;
				aux3 = 	endereco + '_' + campo.options[campo.selectedIndex].value + "_Ampliada" + extensao;

				if (imageExists(aux2))
				{
					document.getElementById("ProdutoImagem").src = aux2;
				}			

				if (imageExists(aux3))
				{
					document.getElementById("ImagemAmpliadaFoto").src = aux3;
				}

				if (document.getElementById("ImagemAmpliada").style.visibility = "visible")
				{
					MostraImagemAmpliada();
				}
			}

			if(campo.options[campo.selectedIndex].value == "")
			{
				mensagem+="Opção inválida (vazio) !\n";
			}

			if(mensagem != "")
			{
				alert(mensagem);
				TrocaImagem("loading", "hidden");
			}
			else
			{
				genericos.DisponibilidadeSKU(ProdutoCodigo.toString(), CarValCod1.toString(), CarValCod2.toString(), CarValCod3.toString(), CarValCod4.toString(), CarValCod5.toString(), callback_DisponibilidadeSKU)
			}		
		} 
		catch(err)
		{
			alert(err.description);
			TrocaImagem("loading", "hidden");
		}
	}
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	

	function callback_DisponibilidadeSKU(res)
	{
 		if (res.error)
		{
			alert(res.error.Message);
//			window.location.href = window.location;
		}	

		if (res.value)
		{
			if (res.value[0])
			{
				document.getElementById("spanDisponibilidade").innerHTML = res.value[0];
			}

			if (res.value[1])
			{
				document.getElementById("spanPreco").innerHTML = res.value[1];
			}

			if (res.value[2])
			{
				document.getElementById("spanPrecoPor").innerHTML = res.value[2];
			}

			if (res.value[3])
			{
				document.getElementById("spanParcelamento").innerHTML = res.value[3];
			}

			if (res.value[4])
			{
				document.getElementById("spanAVista").innerHTML = res.value[4];
			}

			TrocaImagem("loading", "hidden");
		}
	}

	function imageExists(url)
    {
		var tmp = new Image;
        tmp.src = url;
        if(tmp.height > 0 && tmp.height != 30)
		{
            return true;
        }
		else
		{
            return false;
		}
	}

	function RefinaSKUFoto(campo, tipo)
	{
		var aux = "";
		var aux2 = "";
		var aux3 = "";
		var extensao = "";
		var endereco = "";

		TrocaImagem("loading", "visible");

		if (tipo == "F")
		{
			aux = document.getElementById("ProdutoImagem").src;

			campos = aux.split("_");

			if (campos.length > 0)
			{
				for (i=0; i<campos.length; i++)
				{
					if (i+2 < campos.length)
					{
						endereco = endereco + campos[i];

						if (i+3 < campos.length)
						{
							endereco = endereco + "_";
						}
					}
				}
			}

			extensao = aux.substring(aux.length-4);

			if (campo.type == "hidden")
			{
				aux2 = 	endereco + '_' + campo.value + "_Detalhe" + extensao;
				aux3 = 	endereco + '_' + campo.value + "_Ampliada" + extensao;
			}
			else
			{
				aux2 = 	endereco + '_' + campo.options[campo.selectedIndex].value + "_Detalhe" + extensao;
				aux3 = 	endereco + '_' + campo.options[campo.selectedIndex].value + "_Ampliada" + extensao;
			}

			if (imageExists(aux2))
			{
				document.getElementById("ProdutoImagem").src = aux2;
			}

			if (imageExists(aux3))
			{
				document.getElementById("ImagemAmpliadaFoto").src = aux3;
			}

			if (document.getElementById("ImagemAmpliada").style.visibility = "visible")
			{
				MostraImagemAmpliada();
			}
		}

		TrocaImagem("loading", "hidden");
	}

	function Trim(inp)
	{ 
		var outp = "";

		for (i = 0; i <= inp.length; i++) 
		{ 
			if (inp.charAt (i) != " ")
			{
				outp = inp.charAt (i) + outp ;
			}
		} 

		return outp;
	} 

	function reverse(inp)
	{ 
		var outp = "";

		for (i = 0; i <= inp.length; i++) 
		{ 
			outp = inp.charAt (i) + outp ;
		} 

		return outp;
	} 

	function AdicionarItemCesta(ProdutoCodigo)
	{
		var enc = 0;
		var mensagem = "";

		var CarValCod1 = 0;
		var CarValCod2 = 0;
		var CarValCod3 = 0;
		var CarValCod4 = 0;
		var CarValCod5 = 0;

		TrocaImagem("loading", "visible");

		try
		{
			CarValCod1 = (document.getElementById("DRP_SKU_1") ? document.getElementById("DRP_SKU_1").value : 0);
			CarValCod2 = (document.getElementById("DRP_SKU_2") ? document.getElementById("DRP_SKU_2").value : 0);
			CarValCod3 = (document.getElementById("DRP_SKU_3") ? document.getElementById("DRP_SKU_3").value : 0);
			CarValCod4 = (document.getElementById("DRP_SKU_4") ? document.getElementById("DRP_SKU_4").value : 0);
			CarValCod5 = (document.getElementById("DRP_SKU_5") ? document.getElementById("DRP_SKU_5").value : 0);

			for (j=0; j<document.forms[0].elements.length; j++) 
			{
				campo = document.forms[0].elements[j];

				if(document.getElementById(campo))
				{
					if (campo.name.indexOf("DRP_SKU") != -1 && campo.name.length == 9)
					{
						if (campo.value == "0")
						{
							mensagem+="Escolha um valor para todas as Opções de Compra!\n";
							break;
						}
					}
				}
			}

			if(mensagem != "")
			{
				alert(mensagem);
				TrocaImagem("loading", "hidden");
			}
			else
			{
				detalhes.AdicionarItemCesta(ProdutoCodigo.toString(), CarValCod1.toString(), CarValCod2.toString(), CarValCod3.toString(), CarValCod4.toString(), CarValCod5.toString(), Redirect_callback)
			}		
		} 
		catch(err)
		{
			alert(err.description);
			TrocaImagem("loading", "hidden");
		}
	}

	function AdicionarItemCestaCrossDuplo(ProdutoCodigoVenda, ProdutoCodigoCross, OrdemVenda, OrdemCross)
	{
		var enc = 0;
		var mensagem = "";

		var Produto1_Op = true;
		var Produto2_Op = true;
		var Produto1_Di = true;
		var Produto2_Di = true;

		var CarValCodVenda1 = 0;
		var CarValCodVenda2 = 0;
		var CarValCodVenda3 = 0;
		var CarValCodVenda4 = 0;
		var CarValCodVenda5 = 0;

		var CarValCodCross1 = 0;
		var CarValCodCross2 = 0;
		var CarValCodCross3 = 0;
		var CarValCodCross4 = 0;
		var CarValCodCross5 = 0;

		TrocaImagem("loading", "visible");

		try
		{
			CarValCodVenda1 = (document.getElementById("DRP_SKU_" + ProdutoCodigoVenda + "_" + OrdemVenda + "_1") ? document.getElementById("DRP_SKU_" + ProdutoCodigoVenda + "_" + OrdemVenda + "_1").value : 0);
			CarValCodVenda2 = (document.getElementById("DRP_SKU_" + ProdutoCodigoVenda + "_" + OrdemVenda + "_2") ? document.getElementById("DRP_SKU_" + ProdutoCodigoVenda + "_" + OrdemVenda + "_2").value : 0);
			CarValCodVenda3 = (document.getElementById("DRP_SKU_" + ProdutoCodigoVenda + "_" + OrdemVenda + "_3") ? document.getElementById("DRP_SKU_" + ProdutoCodigoVenda + "_" + OrdemVenda + "_3").value : 0);
			CarValCodVenda4 = (document.getElementById("DRP_SKU_" + ProdutoCodigoVenda + "_" + OrdemVenda + "_4") ? document.getElementById("DRP_SKU_" + ProdutoCodigoVenda + "_" + OrdemVenda + "_4").value : 0);
			CarValCodVenda5 = (document.getElementById("DRP_SKU_" + ProdutoCodigoVenda + "_" + OrdemVenda + "_5") ? document.getElementById("DRP_SKU_" + ProdutoCodigoVenda + "_" + OrdemVenda + "_5").value : 0);

			CarValCodCross1 = (document.getElementById("DRP_SKU_" + ProdutoCodigoCross + "_" + OrdemCross + "_1") ? document.getElementById("DRP_SKU_" + ProdutoCodigoCross + "_" + OrdemCross + "_1").value : 0);
			CarValCodCross2 = (document.getElementById("DRP_SKU_" + ProdutoCodigoCross + "_" + OrdemCross + "_2") ? document.getElementById("DRP_SKU_" + ProdutoCodigoCross + "_" + OrdemCross + "_2").value : 0);
			CarValCodCross3 = (document.getElementById("DRP_SKU_" + ProdutoCodigoCross + "_" + OrdemCross + "_3") ? document.getElementById("DRP_SKU_" + ProdutoCodigoCross + "_" + OrdemCross + "_3").value : 0);
			CarValCodCross4 = (document.getElementById("DRP_SKU_" + ProdutoCodigoCross + "_" + OrdemCross + "_4") ? document.getElementById("DRP_SKU_" + ProdutoCodigoCross + "_" + OrdemCross + "_4").value : 0);
			CarValCodCross5 = (document.getElementById("DRP_SKU_" + ProdutoCodigoCross + "_" + OrdemCross + "_5") ? document.getElementById("DRP_SKU_" + ProdutoCodigoCross + "_" + OrdemCross + "_5").value : 0);

			for (j=0; j<document.forms[0].elements.length; j++) 
			{
				campo = document.forms[0].elements[j];

				if (Produto1_Op)
				{
					if (campo.name.indexOf("DRP_SKU_" + ProdutoCodigoVenda + "_" + OrdemVenda + "_") != -1)
					{
						if (campo.value == "0")
						{
							mensagem+="Escolha um valor para todas as Opções de Compra!\nProduto 1 da Venda Cruzada\n\n";
							Produto1_Op = false;
						}
					}
				}

				if (Produto2_Op)
				{
					if (campo.name.indexOf("DRP_SKU_" + ProdutoCodigoCross + "_" + OrdemCross + "_") != -1)
					{
						if (campo.value == "0")
						{
							mensagem+="Escolha um valor para todas as Opções de Compra!\nProduto 2 da Venda Cruzada\n\n";
							Produto2_Op = false;
						}
					}
				}
			}

			for (j=0; j<document.forms[0].elements.length; j++) 
			{
				campo = document.forms[0].elements[j];

				if (Produto1_Op)
				{
					if (Produto1_Di)
					{
						if (campo.name.indexOf("DRP_DISP_SKU_" + ProdutoCodigoVenda + "_" + OrdemVenda) != -1)
						{
							if (campo.value == "I")
							{
								mensagem+="Combinação Indisponível!\nProduto 1 da Venda Cruzada\n\n";
								Produto1_Di = false;
							}
						}
					}
				}

				if (Produto2_Op)
				{
					if (Produto2_Di)
					{
						if (campo.name.indexOf("DRP_DISP_SKU_" + ProdutoCodigoCross + "_" + OrdemCross) != -1)
						{
							if (campo.value == "I")
							{
								mensagem+="Combinação Indisponível!\nProduto 2 da Venda Cruzada\n\n";
								Produto2_Di = false;
							}
						}
					}
				}
			}

			if(mensagem != "")
			{
				alert(mensagem);
				TrocaImagem("loading", "hidden");
			}
			else
			{
				detalhes.AdicionarItemCestaCross(ProdutoCodigoVenda.toString(), CarValCodVenda1.toString(), CarValCodVenda2.toString(), CarValCodVenda3.toString(), CarValCodVenda4.toString(), CarValCodVenda5.toString(), ProdutoCodigoCross.toString(), CarValCodCross1.toString(), CarValCodCross2.toString(), CarValCodCross3.toString(), CarValCodCross4.toString(), CarValCodCross5.toString(), Redirect_callback)
			}	
		} 
		catch(err)
		{
			alert(err.description);
			TrocaImagem("loading", "hidden");
		}
	}

	function AdicionarItemCestaCross(ProdutoCodigo)
	{
		var enc = 0;
		var mensagem = "";

		var CarValCod1 = 0;
		var CarValCod2 = 0;
		var CarValCod3 = 0;
		var CarValCod4 = 0;
		var CarValCod5 = 0;

		TrocaImagem("loading", "visible");

		try
		{
			CarValCod1 = (document.getElementById("DRP_SKU_" + ProdutoCodigo + "_1") ? document.getElementById("DRP_SKU_" + ProdutoCodigo + "_1").value : 0);
			CarValCod2 = (document.getElementById("DRP_SKU_" + ProdutoCodigo + "_2") ? document.getElementById("DRP_SKU_" + ProdutoCodigo + "_2").value : 0);
			CarValCod3 = (document.getElementById("DRP_SKU_" + ProdutoCodigo + "_3") ? document.getElementById("DRP_SKU_" + ProdutoCodigo + "_3").value : 0);
			CarValCod4 = (document.getElementById("DRP_SKU_" + ProdutoCodigo + "_4") ? document.getElementById("DRP_SKU_" + ProdutoCodigo + "_4").value : 0);
			CarValCod5 = (document.getElementById("DRP_SKU_" + ProdutoCodigo + "_5") ? document.getElementById("DRP_SKU_" + ProdutoCodigo + "_5").value : 0);

			for (j=0; j<document.forms[0].elements.length; j++) 
			{
				campo = document.forms[0].elements[j];

				if (campo.name.indexOf("DRP_SKU_" + ProdutoCodigo + "_") != -1)
				{
					if (campo.value == "0")
					{
						mensagem+="Escolha um valor para todas as Opções de Compra!\n";
						break;
					}
				}
			}

			if(mensagem != "")
			{
				alert(mensagem);
				TrocaImagem("loading", "hidden");
			}
			else
			{
				detalhes.AdicionarItemCestaCross(ProdutoCodigo.toString(), CarValCod1.toString(), CarValCod2.toString(), CarValCod3.toString(), CarValCod4.toString(), CarValCod5.toString(), Redirect_callback)
			}		
		} 
		catch(err)
		{
			alert(err.description);
			TrocaImagem("loading", "hidden");
		}
	}

	function AdicionarItemCestaBusca(ProdutoCodigo)
	{
		var enc = 0;
		var mensagem = "";

		var CarValCod1 = 0;
		var CarValCod2 = 0;
		var CarValCod3 = 0;
		var CarValCod4 = 0;
		var CarValCod5 = 0;

		TrocaImagem("loading", "visible");

		try
		{
			CarValCod1 = (document.getElementById("DRP_SKU_" + ProdutoCodigo + "_1") ? document.getElementById("DRP_SKU_" + ProdutoCodigo + "_1").value : 0);
			CarValCod2 = (document.getElementById("DRP_SKU_" + ProdutoCodigo + "_2") ? document.getElementById("DRP_SKU_" + ProdutoCodigo + "_2").value : 0);
			CarValCod3 = (document.getElementById("DRP_SKU_" + ProdutoCodigo + "_3") ? document.getElementById("DRP_SKU_" + ProdutoCodigo + "_3").value : 0);
			CarValCod4 = (document.getElementById("DRP_SKU_" + ProdutoCodigo + "_4") ? document.getElementById("DRP_SKU_" + ProdutoCodigo + "_4").value : 0);
			CarValCod5 = (document.getElementById("DRP_SKU_" + ProdutoCodigo + "_5") ? document.getElementById("DRP_SKU_" + ProdutoCodigo + "_5").value : 0);

			for (j=0; j<document.forms[0].elements.length; j++) 
			{
				campo = document.forms[0].elements[j];
				
				if(document.getElementById(campo))
				{
					if (campo.name.indexOf("DRP_SKU_" + ProdutoCodigo + "_") != -1)
					{
						if (campo.value == "0")
						{
							mensagem+="Escolha um valor para todas as Opções de Compra!\n";
							break;
						}
					}
				}
			}

			if(mensagem != "")
			{
				alert(mensagem);
				TrocaImagem("loading", "hidden");
			}
			else
			{
				busca.AdicionarItemCestaBusca(ProdutoCodigo.toString(), CarValCod1.toString(), CarValCod2.toString(), CarValCod3.toString(), CarValCod4.toString(), CarValCod5.toString(), Redirect_callback)
			}		
		} 
		catch(err)
		{
			alert(err.description);
			TrocaImagem("loading", "hidden");
		}
	}
	
	function AdicionarItemCestaHome(ProdutoCodigo)
	{
		var enc = 0;
		var mensagem = "";

		var CarValCod1 = 0;
		var CarValCod2 = 0;
		var CarValCod3 = 0;
		var CarValCod4 = 0;
		var CarValCod5 = 0;

		TrocaImagem("loading", "visible");

		try
		{
			CarValCod1 = (document.getElementById("DRP_SKU_" + ProdutoCodigo + "_1") ? document.getElementById("DRP_SKU_" + ProdutoCodigo + "_1").value : 0);
			CarValCod2 = (document.getElementById("DRP_SKU_" + ProdutoCodigo + "_2") ? document.getElementById("DRP_SKU_" + ProdutoCodigo + "_2").value : 0);
			CarValCod3 = (document.getElementById("DRP_SKU_" + ProdutoCodigo + "_3") ? document.getElementById("DRP_SKU_" + ProdutoCodigo + "_3").value : 0);
			CarValCod4 = (document.getElementById("DRP_SKU_" + ProdutoCodigo + "_4") ? document.getElementById("DRP_SKU_" + ProdutoCodigo + "_4").value : 0);
			CarValCod5 = (document.getElementById("DRP_SKU_" + ProdutoCodigo + "_5") ? document.getElementById("DRP_SKU_" + ProdutoCodigo + "_5").value : 0);

			for (j=0; j<document.forms[0].elements.length; j++) 
			{
				campo = document.forms[0].elements[j];
				
				if(document.getElementById(campo))
				{
					if (campo.name.indexOf("DRP_SKU_" + ProdutoCodigo + "_") != -1)
					{
						if (campo.value == "0")
						{
							mensagem+="Escolha um valor para todas as Opções de Compra!\n";
							break;
						}
					}
				}
			}

			if(mensagem != "")
			{
				alert(mensagem);
				TrocaImagem("loading", "hidden");
			}
			else
			{
				WebForm1.AdicionarItemCestaHome(ProdutoCodigo.toString(), CarValCod1.toString(), CarValCod2.toString(), CarValCod3.toString(), CarValCod4.toString(), CarValCod5.toString(), Redirect_callback)
			}		
		} 
		catch(err)
		{
			alert(err.description);
			TrocaImagem("loading", "hidden");
		}
	}
	
	function AdicionarItemCestaVitrine(ProdutoCodigo)
	{
		var enc = 0;
		var mensagem = "";

		var CarValCod1 = 0;
		var CarValCod2 = 0;
		var CarValCod3 = 0;
		var CarValCod4 = 0;
		var CarValCod5 = 0;

		TrocaImagem("loading", "visible");

		try
		{
			CarValCod1 = (document.getElementById("DRP_SKU_" + ProdutoCodigo + "_1") ? document.getElementById("DRP_SKU_" + ProdutoCodigo + "_1").value : 0);
			CarValCod2 = (document.getElementById("DRP_SKU_" + ProdutoCodigo + "_2") ? document.getElementById("DRP_SKU_" + ProdutoCodigo + "_2").value : 0);
			CarValCod3 = (document.getElementById("DRP_SKU_" + ProdutoCodigo + "_3") ? document.getElementById("DRP_SKU_" + ProdutoCodigo + "_3").value : 0);
			CarValCod4 = (document.getElementById("DRP_SKU_" + ProdutoCodigo + "_4") ? document.getElementById("DRP_SKU_" + ProdutoCodigo + "_4").value : 0);
			CarValCod5 = (document.getElementById("DRP_SKU_" + ProdutoCodigo + "_5") ? document.getElementById("DRP_SKU_" + ProdutoCodigo + "_5").value : 0);

			for (j=0; j<document.forms[0].elements.length; j++) 
			{
				campo = document.forms[0].elements[j];
				
				if(document.getElementById(campo))
				{
					if (campo.name.indexOf("DRP_SKU_" + ProdutoCodigo + "_") != -1)
					{
						if (campo.value == "0")
						{
							mensagem+="Escolha um valor para todas as Opções de Compra!\n";
							break;
						}
					}
				}
			}

			if(mensagem != "")
			{
				alert(mensagem);
				TrocaImagem("loading", "hidden");
			}
			else
			{
				vitrine.AdicionarItemCestaVitrine(ProdutoCodigo.toString(), CarValCod1.toString(), CarValCod2.toString(), CarValCod3.toString(), CarValCod4.toString(), CarValCod5.toString(), Redirect_callback)
			}		
		} 
		catch(err)
		{
			alert(err.description);
			TrocaImagem("loading", "hidden");
		}
	}
	
	function AdicionarItemCestaCategoria(ProdutoCodigo)
	{
		var enc = 0;
		var mensagem = "";

		var CarValCod1 = 0;
		var CarValCod2 = 0;
		var CarValCod3 = 0;
		var CarValCod4 = 0;
		var CarValCod5 = 0;

		TrocaImagem("loading", "visible");

		try
		{
			CarValCod1 = (document.getElementById("DRP_SKU_" + ProdutoCodigo + "_1") ? document.getElementById("DRP_SKU_" + ProdutoCodigo + "_1").value : 0);
			CarValCod2 = (document.getElementById("DRP_SKU_" + ProdutoCodigo + "_2") ? document.getElementById("DRP_SKU_" + ProdutoCodigo + "_2").value : 0);
			CarValCod3 = (document.getElementById("DRP_SKU_" + ProdutoCodigo + "_3") ? document.getElementById("DRP_SKU_" + ProdutoCodigo + "_3").value : 0);
			CarValCod4 = (document.getElementById("DRP_SKU_" + ProdutoCodigo + "_4") ? document.getElementById("DRP_SKU_" + ProdutoCodigo + "_4").value : 0);
			CarValCod5 = (document.getElementById("DRP_SKU_" + ProdutoCodigo + "_5") ? document.getElementById("DRP_SKU_" + ProdutoCodigo + "_5").value : 0);

			for (j=0; j<document.forms[0].elements.length; j++) 
			{
				campo = document.forms[0].elements[j];
				
				if(document.getElementById(campo))
				{
					if (campo.name.indexOf("DRP_SKU_" + ProdutoCodigo + "_") != -1)
					{
						if (campo.value == "0")
						{
							mensagem+="Escolha um valor para todas as Opções de Compra!\n";
							break;
						}
					}
				}
			}

			if(mensagem != "")
			{
				alert(mensagem);
				TrocaImagem("loading", "hidden");
			}
			else
			{
				categoria.AdicionarItemCestaCategoria(ProdutoCodigo.toString(), CarValCod1.toString(), CarValCod2.toString(), CarValCod3.toString(), CarValCod4.toString(), CarValCod5.toString(), Redirect_callback)
			}		
		} 
		catch(err)
		{
			alert(err.description);
			TrocaImagem("loading", "hidden");
		}
	}

	function AdicionarItemCestaFornecedor(ProdutoCodigo)
	{
		var enc = 0;
		var mensagem = "";

		var CarValCod1 = 0;
		var CarValCod2 = 0;
		var CarValCod3 = 0;
		var CarValCod4 = 0;
		var CarValCod5 = 0;

		TrocaImagem("loading", "visible");

		try
		{
			CarValCod1 = (document.getElementById("DRP_SKU_" + ProdutoCodigo + "_1") ? document.getElementById("DRP_SKU_" + ProdutoCodigo + "_1").value : 0);
			CarValCod2 = (document.getElementById("DRP_SKU_" + ProdutoCodigo + "_2") ? document.getElementById("DRP_SKU_" + ProdutoCodigo + "_2").value : 0);
			CarValCod3 = (document.getElementById("DRP_SKU_" + ProdutoCodigo + "_3") ? document.getElementById("DRP_SKU_" + ProdutoCodigo + "_3").value : 0);
			CarValCod4 = (document.getElementById("DRP_SKU_" + ProdutoCodigo + "_4") ? document.getElementById("DRP_SKU_" + ProdutoCodigo + "_4").value : 0);
			CarValCod5 = (document.getElementById("DRP_SKU_" + ProdutoCodigo + "_5") ? document.getElementById("DRP_SKU_" + ProdutoCodigo + "_5").value : 0);

			for (j=0; j<document.forms[0].elements.length; j++) 
			{
				campo = document.forms[0].elements[j];

				if (campo.name.indexOf("DRP_SKU_" + ProdutoCodigo + "_") != -1)
				{
					if (campo.value == "0")
					{
						mensagem+="Escolha um valor para todas as Opções de Compra!\n";
						break;
					}
				}
			}

			if(mensagem != "")
			{
				alert(mensagem);
				TrocaImagem("loading", "hidden");
			}
			else
			{
				fornecedor.AdicionarItemCestaFornecedor(ProdutoCodigo.toString(), CarValCod1.toString(), CarValCod2.toString(), CarValCod3.toString(), CarValCod4.toString(), CarValCod5.toString(), Redirect_callback)
			}		
		} 
		catch(err)
		{
			alert(err.description);
			TrocaImagem("loading", "hidden");
		}
	}

	function AdicionarItemCestaComparador(ProdutoCodigo)
	{
		var enc = 0;
		var mensagem = "";

		var CarValCod1 = 0;
		var CarValCod2 = 0;
		var CarValCod3 = 0;
		var CarValCod4 = 0;
		var CarValCod5 = 0;

		TrocaImagem("loading", "visible");

		try
		{
			CarValCod1 = (document.getElementById("DRP_SKU_" + ProdutoCodigo + "_1") ? document.getElementById("DRP_SKU_" + ProdutoCodigo + "_1").value : 0);
			CarValCod2 = (document.getElementById("DRP_SKU_" + ProdutoCodigo + "_2") ? document.getElementById("DRP_SKU_" + ProdutoCodigo + "_2").value : 0);
			CarValCod3 = (document.getElementById("DRP_SKU_" + ProdutoCodigo + "_3") ? document.getElementById("DRP_SKU_" + ProdutoCodigo + "_3").value : 0);
			CarValCod4 = (document.getElementById("DRP_SKU_" + ProdutoCodigo + "_4") ? document.getElementById("DRP_SKU_" + ProdutoCodigo + "_4").value : 0);
			CarValCod5 = (document.getElementById("DRP_SKU_" + ProdutoCodigo + "_5") ? document.getElementById("DRP_SKU_" + ProdutoCodigo + "_5").value : 0);

			for (j=0; j<document.forms[0].elements.length; j++) 
			{
				campo = document.forms[0].elements[j];

				if (campo.name.indexOf("DRP_SKU_" + ProdutoCodigo + "_") != -1)
				{
					if (campo.value == "0")
					{
						mensagem+="Escolha um valor para todas as Opções de Compra!\n";
						break;
					}
				}
			}

			if(mensagem != "")
			{
				alert(mensagem);
				TrocaImagem("loading", "hidden");
			}
			else
			{
				comparar.AdicionarItemCestaComparador(ProdutoCodigo.toString(), CarValCod1.toString(), CarValCod2.toString(), CarValCod3.toString(), CarValCod4.toString(), CarValCod5.toString(), Redirect_callback);
			}		
		} 
		catch(err)
		{
			alert(err.description);
			TrocaImagem("loading", "hidden");
		}
	}

	function MudaPaginaBusca(pagina, bp, bfc, bcc, bcr, bprIni, bprFim, bo, bs, bq)
	{
		try
		{
			TrocaImagem("loading", "visible");
			busca.MudaPaginaBusca(pagina.toString(), bp, bfc, bcc, bcr, bprIni, bprFim, bo, bs, bq, Redirect_callback);
		} 
		catch(err)
		{
			alert(err.description);
			TrocaImagem("loading", "hidden");
		}
	}

	function MudaPaginaCategoria(pagina)
	{
		try
		{
			var Categoria = 0;
			var SubCategoria = 0;
			
			if(document.getElementById("CategoriaCodigo"))
				Categoria =document.getElementById("CategoriaCodigo").value;
			if(document.getElementById("SubCategoriaCodigo"))
				SubCategoria = document.getElementById("SubCategoriaCodigo").value;

			TrocaImagem("loading", "visible");
			categoria.MudaPaginaCategoria(pagina.toString(), Categoria.toString(), SubCategoria.toString(), Redirect_callback);
		} 
		catch(err)
		{
			alert(err.description);
			TrocaImagem("loading", "hidden");
		}
	}

	function MudaPaginaFornecedor(pagina)
	{
		try
		{
			var Fornecedor = 0;
			
			if(document.getElementById("FornecedorCodigo"))
				Fornecedor = document.getElementById("FornecedorCodigo").value;

			TrocaImagem("loading", "visible");
			fornecedor.MudaPaginaFornecedor(pagina.toString(), Fornecedor.toString(), Redirect_callback);
		} 
		catch(err)
		{
			alert(err.description);
			TrocaImagem("loading", "hidden");
		}
	}
	
	function Buscar(local)	
	{
		//local = cabecalho || rodape
		TrocaImagem("loading", "visible");

		try
		{
			var mensagem = "";
			var fabricante = "";
			var palavra = "";
			var categoria = "";

			if(local == 'cabecalho')
			{
				palavra= document.getElementById("txtBuscaHeader").value.replace("[", "").replace("]", "").replace("(", "").replace(")", "").replace("&", "").replace("%", "");
				//categoria= document.getElementById("cabecalho_DropLojas").options[document.getElementById("cabecalho_DropLojas").selectedIndex].value;
				//fabricante= document.getElementById("cabecalho_DropFabricantes") ? document.getElementById("cabecalho_DropFabricantes").options[document.getElementById("cabecalho_DropFabricantes").selectedIndex].value : 0;
			}
			else if(local == 'rodape')
			{
				palavra= document.getElementById("txtBuscaFooter").value.replace("[", "").replace("]", "").replace("(", "").replace(")", "").replace("&", "").replace("%", "");
				//categoria= document.getElementById("rodape_DropLojas").options[document.getElementById("rodape_DropLojas").selectedIndex].value;
				//fabricante= document.getElementById("rodape_DropFabricantes") ? document.getElementById("rodape_DropFabricantes").options[document.getElementById("rodape_DropFabricantes").selectedIndex].value : 0;
			}

			if(palavra == "" && (categoria == "" || categoria == "0") && (fabricante == "" || fabricante == "0"))
			{
				mensagem+="Valor inválido (todos os campos vazio ou inválidos) !\n";
			}

			if(mensagem != "")
			{
				alert(mensagem);
				TrocaImagem("loading", "hidden");
			}
			else
			{
				cabecalho.ArmazenaDadosBusca(palavra.toString(), categoria.toString(), fabricante.toString(), Redirect_callback);
			}
		} 
		catch(err)
		{
			alert(err.description);
			TrocaImagem("loading", "hidden");
		}
	}
	
	function BuscaNova(local)	
	{
		//local = cabecalho || rodape
		TrocaImagem("loading", "visible");

		try
		{
			var buscaPalavra = '';
			var buscaTipo = '';
		
			if(local == 'cabecalho')
			{
				buscaPalavra = document.getElementById('txtBuscaNovaHeader').value;
				buscaTipo = document.getElementById('ddl_busca_nova_header').value;
			}
			else if(local == 'rodape')
			{
				buscaPalavra = document.getElementById('txtBuscaNovaFooter').value;
				buscaTipo = document.getElementById('ddl_busca_nova_footer').value;
			}
			
			cabecalho.ArmazenaDadosBuscaNova(buscaPalavra, buscaTipo, Redirect_callback);
		} 
		catch(err)
		{
			alert(err.description);
			TrocaImagem("loading", "hidden");
		}
	}

	function ArmazenaValorAntigo(campo)
	{
		document.getElementById("ValorAntigo").value = campo.value;
	}

	function AtualizaQtdeItem(campo,itemId, qtdemax)
	{
		
		var mensagem = "";

		TrocaImagem("loading", "visible");

		try
		{
			if(Trim(campo.value) == "")
			{
				mensagem+="Valor inválido (vazio) !\n";
			}

			if(isNaN(campo.value))
			{
				mensagem+="Valor inválido (não numérico : " + campo.value + ") !\n";
			}
			else
			{
				if (campo.value > qtdemax)
				{
					mensagem+="Valor inválido  - excede máximo permitdo (" + qtdemax + ") !\n";
				}
			}

			if(mensagem != "")
			{
				alert(mensagem);
				campo.value = document.getElementById("ValorAntigo").value;
				TrocaImagem("loading", "hidden");
			}
			else
			{
				if (Trim(campo.value) != Trim(document.getElementById("ValorAntigo").value))
				{				
					index.AtualizaQtdeItem(itemId, campo.value, Redirect_callback);
					//index.AtualizaQtdeItem(campo.name, campo.value, Redirect_callback);
				}
				else
				{
					campo.value = Trim(document.getElementById("ValorAntigo").value);
					document.getElementById("ValorAntigo").value = "";
					TrocaImagem("loading", "hidden");
				}
			}
		} 
		catch(err)
		{
			alert(err.description);
			TrocaImagem("loading", "hidden");
		}
	}

	function LimparCesta()
	{
		TrocaImagem("loading", "visible");

		if (confirm('Você tem certeza que deseja LIMPAR sua Cesta de Compras?'))
		{
			index.LimparCesta(Redirect_callback);
		}
		else
		{
			TrocaImagem("loading", "hidden");
		}
	}

	function FecharPedido(CestaCodigo)
	{
		TrocaImagem("loading", "visible");

		try
		{
			index.FecharPedido(CestaCodigo.toString(),document.getElementById("txtCEP").value.toString(), callback_FecharPedido);
		} 
		catch(err)
		{
			alert(err.description);
			TrocaImagem("loading", "hidden");
		}		
	}

	function FecharPedidoGift(CestaCodigo)
	{
		TrocaImagem("loading", "visible");

		try
		{
			presente.FecharPedido(CestaCodigo.toString(), callback_FecharPedido);
		} 
		catch(err)
		{
			alert(err.description);
			TrocaImagem("loading", "hidden");
		}		
	}

	function callback_FecharPedido(res)
	{
		if (res.error)
		{
			alert(res.error.Message);
//			window.location.href = window.location;
			TrocaImagem("loading", "hidden");
		}		

		if (res.value)
		{
			window.location.href = res.value;
		}
	}

	function FinalizarPedido()
	{
		var mensagem = "";
		var minSeg = 3;

		var OperadoraCodigo = "";
		var OperadoraTipo = "";
		var ParcelamentoSel = "";
		var ParcelamentoSelCod = "";
		var CartaoNumero = "";
		var CartaoSeguranca = "";
		var CartaoTitular = "";
		var CartaoValMes = "";
		var CartaoValAno = "";
		//var NotaPaulista = "";
		
		
		MsgAguarda("FecharPedido", "FecharPedidoBase", "<b>Aguarde!</b><br>Pedido sendo processado!");
		TrocaImagem("loading", "visible");

		try
		{
			//NotaPaulista = (document.getElementById("cbNotaFiscal").checked)?"1":"0";
			var currentTime = new Date()

			if (document.getElementById("OperadoraTipo").value == "CCR")
			{
				if(document.getElementById("OperadoraCodigo").value == "")
				{
					mensagem+="Você precisa escolher uma Operadora de Cartão de Crédito !\n";
				}
				else
				{
					if (document.getElementById("OperadoraCodigo").value == "1")
					{
						minSeg = 4;
					}
					
					

					if(document.getElementById("CartaoNumero").value == "")
					{
						mensagem+="Número de cartão inválido (vazio) !\n";
						document.getElementById("CartaoNumero").className = "erro";
					}
					else
					{
					
						if (document.getElementById("OperadoraCodigo").value == "2")
						{
							if(!ValidaCartaoUltrafarma(document.getElementById("CartaoNumero").value))
							{
								mensagem+="Número de cartão inválido (incorreto) !\n";
								document.getElementById("CartaoNumero").className = "erro";
							}
							else
							{
								document.getElementById("CartaoNumero").className = "formulario_pagamento";
								CartaoNumero = document.getElementById("CartaoNumero").value;
							}
						}
						else if (document.getElementById("OperadoraCodigo").value == "7")
						{
							if(!ValidaCartaoHipercard(document.getElementById("CartaoNumero").value))
							{
								mensagem+="Número de cartão inválido (incorreto) !\n";
								document.getElementById("CartaoNumero").className = "erro";
							}
							else
							{
								document.getElementById("CartaoNumero").className = "formulario_pagamento";
								CartaoNumero = document.getElementById("CartaoNumero").value;
							}
						}
						else
						{					
							if (!validaCartao())
							{
								mensagem+="Número de cartão inválido (incorreto) !\n";
								document.getElementById("CartaoNumero").className = "erro";
							}
							else
							{
								document.getElementById("CartaoNumero").className = "formulario_pagamento";
								CartaoNumero = document.getElementById("CartaoNumero").value;
							}
						}						
					}
					
					if(document.getElementById("CartaoCodigo").value == "")
					{
						mensagem+="Código de segurança do cartão inválido (vazio) !\n";
						document.getElementById("CartaoCodigo").className = "erro";
					}
					else
					{
						if(document.getElementById("CartaoCodigo").value.length < minSeg)
						{
							mensagem+="Código de segurança do cartão inválido (incorreto) !\n";
							document.getElementById("CartaoCodigo").className = "erro";
						}
						else
						{
							document.getElementById("CartaoCodigo").className = "formulario_pagamento";
							CartaoSeguranca = document.getElementById("CartaoCodigo").value;
						}
					}

					if(document.getElementById("CartaoNome").value == "")
					{
						mensagem+="Nome no cartão inválido (vazio) !\n";
						document.getElementById("CartaoNome").className = "erro";
					}
					else
					{
						document.getElementById("CartaoNome").className = "formulario_pagamento";
						CartaoTitular = document.getElementById("CartaoNome").value;
					}

					if(document.getElementById("CartaoValMes").value == "")
					{
						mensagem+="Validade (mês) do cartão inválido (vazio) !\n";
						document.getElementById("CartaoValMes").className = "erro";
					}
					else
					{
						if(document.getElementById("CartaoValMes").value.length < 2 || parseInt(document.getElementById("CartaoValMes").value,10) > 12 || parseInt(document.getElementById("CartaoValMes").value,10) < 1)
						{
							mensagem+="Validade (mês) do cartão inválido (incorreto) !\n";
							document.getElementById("CartaoValMes").className = "erro";
						}
						else
						{
							document.getElementById("CartaoValMes").className = "formulario_pagamento";
							CartaoValMes = document.getElementById("CartaoValMes").value;
						}
					}
					
					

					if(document.getElementById("CartaoValAno").value == "")
					{
						mensagem+="Validade (ano) do cartão inválido (vazio) !\n";
						document.getElementById("CartaoValAno").className = "erro";
					}
					else
					{
						if(document.getElementById("CartaoValAno").value.length < 2)
						{
							mensagem+="Validade (ano) do cartão inválido (incorreto) !\n";
							document.getElementById("CartaoValAno").className = "erro";
						}
						else
						{
							if(Number("20" + document.getElementById("CartaoValAno").value) < currentTime.getFullYear())
							{
								mensagem+="Validade (ano) do cartão inválido (expirado) !\n";
								document.getElementById("CartaoValAno").className = "erro";
							}
							else
							{
								document.getElementById("CartaoValAno").className = "formulario_pagamento";
								CartaoValAno = document.getElementById("CartaoValAno").value;
							}
						}
					}

					if(document.getElementById("ParcelamentoSel").value == "" || document.getElementById("ParcelamentoSelCod").value == "")
					{
						mensagem+="Parcelamento inválido (vazio) !\n";
					}
				}
			}
			else if (document.getElementById("OperadoraTipo").value == "DEB")
			{
				if(document.getElementById("OperadoraCodigo").value == "")
				{
					mensagem+="Você precisa escolher um Banco de Cartão de Débito !\n";
				}

				if(document.getElementById("ParcelamentoSel").value == "" || document.getElementById("ParcelamentoSelCod").value == "")
				{
					mensagem+="Opção de Pagamento inválido (vazio) !\n";
				}
			}
			else if (document.getElementById("OperadoraTipo").value == "CHE")
			{
				if(document.getElementById("txtChequeNumBanco").value == "" || 
					document.getElementById("txtChequeNumero").value == "" ||
					document.getElementById("txtChequeNumeroDigito").value == ""
					)
				{
					mensagem+="Informe os dados do cheque corretamente !\n";
				}
			}
			
			if(mensagem != "")
			{
				alert(mensagem);
				TrocaImagem("loading", "hidden");
				RecuperaAguarda("FecharPedido", "FecharPedidoBase")
			}
			else
			{

				/*if (document.getElementById("OperadoraTipo").value == "BOL")
				{
					alert("Implementar Chamada para Gateway de Pagamento – Boleto");
				}*/
				OperadoraCodigo = document.getElementById("OperadoraCodigo").value;
				OperadoraTipo = document.getElementById("OperadoraTipo").value;
				ParcelamentoSel = document.getElementById("ParcelamentoSel").value;
				ParcelamentoSelCod = document.getElementById("ParcelamentoSelCod").value;
				
				var NumCheque		= document.getElementById("txtChequeNumero") ? document.getElementById("txtChequeNumero").value : '';
				var DigCheque		= document.getElementById("txtChequeNumeroDigito") ? document.getElementById("txtChequeNumeroDigito").value : '';
				var NumBancoCheque	= document.getElementById("txtChequeNumBanco") ? document.getElementById("txtChequeNumBanco").value : '';

				setTimeout(FechamentoSimples, 15000);
				fechamento.FinalizarPedido(OperadoraCodigo.toString(), OperadoraTipo.toString(), ParcelamentoSel.toString(), ParcelamentoSelCod.toString(), CartaoNumero.toString(), CartaoSeguranca.toString(), CartaoTitular.toString(), CartaoValMes.toString(), CartaoValAno.toString(), NumCheque.toString(),DigCheque.toString(),NumBancoCheque.toString() /*,NotaPaulista.toString()*/, callback_FinalizarPedido);
			}
		} 
		catch(err)
		{
			alert(err.description);
			TrocaImagem("loading", "hidden");
			RecuperaAguarda("FecharPedido", "FecharPedidoBase")
		}		
	}
	
	function FechamentoSimples()
	{
		//window.location.href = "confirmacao_simples.aspx";
	}

	function callback_FinalizarPedido(res)
	{
		if (res.error)
		{
			alert(res.error.Message.replace("[RECARREGA]", ""));
			
			if (res.error.Message.indexOf("[RECARREGA]") >= 0)
			{
				window.location.href = window.location;
			}
			else
			{
				//teste
				if(res.error.Message.indexOf("Valor Mínimo") >= 0)
				{					
					array = location.href.split("/");
				
					if(location.href.indexOf("www") >=0)//producao
					{
						window.location = array[0].replace("https","http") + "//" + array[2]+"/basket/index.aspx";
					}
					else//local
					{	
						window.location = array[0] + "//" + array[2] + "/" + array[3] + "/basket/index.aspx";
					}
				}
				else
				{
					RecuperaAguarda("FecharPedido", "FecharPedidoBase")
					TrocaImagem("loading", "hidden");				
				}
			}

		}		

		if (res.value)
		{
			window.location.href = res.value;
		}
	}

	function FiltrarFornecedor()
	{
		TrocaImagem("loading", "visible");

		try
		{
			var Ordem = document.getElementById("drpOrdem").value;
			var OrdemSentido = document.getElementById("drpOrdemSentido").value;
			var QtdePagina = document.getElementById("drpQtdePagina").value;
			var Fornecedor = document.getElementById("FornecedorCodigo").value;

			fornecedor.FiltrarFornecedor(Ordem.toString(), OrdemSentido.toString(), QtdePagina.toString(), Fornecedor.toString(), Redirect_callback);
		} 
		catch(err)
		{
			alert(err.description);
			TrocaImagem("loading", "hidden");
		}
	}

	function FiltrarCategoria()
	{
		TrocaImagem("loading", "visible");

		try
		{
			var Ordem = document.getElementById("drpOrdem").value;
			var OrdemSentido = document.getElementById("drpOrdemSentido").value;
			var QtdePagina = document.getElementById("drpQtdePagina").value;
			var Categoria = document.getElementById("CategoriaCodigo").value;
			var SubCategoria = document.getElementById("SubCategoriaCodigo").value;
			var BuscaPalavra = (document.getElementById("inputTextBusca")) ? document.getElementById("inputTextBusca").value : "";

			categoria.FiltrarCategoria(BuscaPalavra.toString(),Ordem.toString(), OrdemSentido.toString(), QtdePagina.toString(), Categoria.toString(), SubCategoria.toString(), Redirect_callback);
		} 
		catch(err)
		{
			alert(err.description);
			TrocaImagem("loading", "hidden");
		}
	}
	function FiltrarCategoriaBuscaEspecial()
	{
		TrocaImagem("loading", "visible");
		

		try
		{
			var Ordem = document.getElementById("drpOrdem").value;
			var OrdemSentido = document.getElementById("drpOrdemSentido").value;
			var QtdePagina = document.getElementById("drpQtdePagina").value;
			var Categoria = document.getElementById("CategoriaCodigo").value;
			var SubCategoria = document.getElementById("SubCategoriaCodigo").value;
			var BuscaPalavra = (document.getElementById("inputTextBusca")) ? document.getElementById("inputTextBusca").value : "";
			
			categoria.FiltrarCategoriaBuscaEspecial(BuscaPalavra.toString(),Ordem.toString(), OrdemSentido.toString(), QtdePagina.toString(), Categoria.toString(), SubCategoria.toString(), Redirect_callback);
		} 
		catch(err)
		{
			alert(err.description);
			TrocaImagem("loading", "hidden");
		}
	}

	function FiltrarBusca()
	{
		TrocaImagem("loading", "visible");

		try
		{

			var Ordem = document.getElementById("drpOrdem").value;
			var OrdemSentido = document.getElementById("drpOrdemSentido").value;
			var QtdePagina = document.getElementById("drpQtdePagina").value;

			busca.FiltrarBusca(Ordem.toString(), OrdemSentido.toString(), QtdePagina.toString(), Redirect_callback);

		} 
		catch(err)
		{
			alert(err.description);
			TrocaImagem("loading", "hidden");
		}
	}

	function DisponibilidadeSKUCross(campo, ProdutoCodigo, tipo, ordem)
	{
		var mensagem = "";
		var aux = "";
		var extensao = "";
		var endereco = "";

		var CarValCod1 = 0;
		var CarValCod2 = 0;
		var CarValCod3 = 0;
		var CarValCod4 = 0;
		var CarValCod5 = 0;

		TrocaImagem("loading", "visible");

		try
		{
			CarValCod1 = (document.getElementById("DRP_SKU_" + ProdutoCodigo + "_" + ordem + "_1") ? document.getElementById("DRP_SKU_" + ProdutoCodigo + "_" + ordem + "_1").options[document.getElementById("DRP_SKU_" + ProdutoCodigo + "_" + ordem + "_1").selectedIndex].value : 0);
			CarValCod2 = (document.getElementById("DRP_SKU_" + ProdutoCodigo + "_" + ordem + "_2") ? document.getElementById("DRP_SKU_" + ProdutoCodigo + "_" + ordem + "_2").options[document.getElementById("DRP_SKU_" + ProdutoCodigo + "_" + ordem + "_2").selectedIndex].value : 0);
			CarValCod3 = (document.getElementById("DRP_SKU_" + ProdutoCodigo + "_" + ordem + "_3") ? document.getElementById("DRP_SKU_" + ProdutoCodigo + "_" + ordem + "_3").options[document.getElementById("DRP_SKU_" + ProdutoCodigo + "_" + ordem + "_3").selectedIndex].value : 0);
			CarValCod4 = (document.getElementById("DRP_SKU_" + ProdutoCodigo + "_" + ordem + "_4") ? document.getElementById("DRP_SKU_" + ProdutoCodigo + "_" + ordem + "_4").options[document.getElementById("DRP_SKU_" + ProdutoCodigo + "_" + ordem + "_4").selectedIndex].value : 0);
			CarValCod5 = (document.getElementById("DRP_SKU_" + ProdutoCodigo + "_" + ordem + "_5") ? document.getElementById("DRP_SKU_" + ProdutoCodigo + "_" + ordem + "_5").options[document.getElementById("DRP_SKU_" + ProdutoCodigo + "_" + ordem + "_5").selectedIndex].value : 0);

			if(campo.options[campo.selectedIndex].value == "")
			{
				mensagem+="Opção inválida (vazio) !\n";
			}

			if(mensagem != "")
			{
				alert(mensagem);
				TrocaImagem("loading", "hidden");
			}
			else
			{
				detalhes.DisponibilidadeSKUCross(ProdutoCodigo.toString(), CarValCod1.toString(), CarValCod2.toString(), CarValCod3.toString(), CarValCod4.toString(), CarValCod5.toString(), ordem.toString(), callback_DisponibilidadeSKUCross)
			}
		} 
		catch(err)
		{
			alert(err.description);
			TrocaImagem("loading", "hidden");
		}
	}

	function callback_DisponibilidadeSKUCross(res)
	{
		if (res.error)
		{
			alert(res.error.Message);
//			window.location.href = window.location;
		}	
		
		if (res.value)
		{
			document.getElementById("DRP_DISP_SKU_" + res.value[0] + "_" + res.value[2]).value = res.value[3];
			document.getElementById("spanDisponibilidade_Cross_" + res.value[0] + "_" + res.value[2]).innerHTML = res.value[1];
			TrocaImagem("loading", "hidden");
		}
	}

	function DisponibilidadeSKUBusca(campo, ProdutoCodigo, tipo)
	{
		var mensagem = "";
		var aux = "";
		var extensao = "";
		var endereco = "";

		var CarValCod1 = 0;
		var CarValCod2 = 0;
		var CarValCod3 = 0;
		var CarValCod4 = 0;
		var CarValCod5 = 0;

		TrocaImagem("loading", "visible");

		try
		{
			CarValCod1 = (document.getElementById("DRP_SKU_" + ProdutoCodigo + "_1") ? document.getElementById("DRP_SKU_" + ProdutoCodigo + "_1").options[document.getElementById("DRP_SKU_" + ProdutoCodigo + "_1").selectedIndex].value : 0);
			CarValCod2 = (document.getElementById("DRP_SKU_" + ProdutoCodigo + "_2") ? document.getElementById("DRP_SKU_" + ProdutoCodigo + "_2").options[document.getElementById("DRP_SKU_" + ProdutoCodigo + "_2").selectedIndex].value : 0);
			CarValCod3 = (document.getElementById("DRP_SKU_" + ProdutoCodigo + "_3") ? document.getElementById("DRP_SKU_" + ProdutoCodigo + "_3").options[document.getElementById("DRP_SKU_" + ProdutoCodigo + "_3").selectedIndex].value : 0);
			CarValCod4 = (document.getElementById("DRP_SKU_" + ProdutoCodigo + "_4") ? document.getElementById("DRP_SKU_" + ProdutoCodigo + "_4").options[document.getElementById("DRP_SKU_" + ProdutoCodigo + "_4").selectedIndex].value : 0);
			CarValCod5 = (document.getElementById("DRP_SKU_" + ProdutoCodigo + "_5") ? document.getElementById("DRP_SKU_" + ProdutoCodigo + "_5").options[document.getElementById("DRP_SKU_" + ProdutoCodigo + "_5").selectedIndex].value : 0);

			if(campo.options[campo.selectedIndex].value == "")
			{
				mensagem+="Opção inválida (vazio) !\n";
			}

			if(mensagem != "")
			{
				alert(mensagem);
				TrocaImagem("loading", "hidden");
			}
			else
			{
				busca.DisponibilidadeSKUBusca(ProdutoCodigo.toString(), CarValCod1.toString(), CarValCod2.toString(), CarValCod3.toString(), CarValCod4.toString(), CarValCod5.toString(), callback_DisponibilidadeSKUBusca)
			}		
		} 
		catch(err)
		{
			alert(err.description);
			TrocaImagem("loading", "hidden");
		}
	}

	function callback_DisponibilidadeSKUBusca(res)
	{
		if (res.error)
		{
			alert(res.error.Message);
//			window.location.href = window.location;
		}	
		
		if (res.value[0])
		{
			if (res.value[1])
			{
				document.getElementById("spanDisponibilidade_" + res.value[0]).innerHTML = res.value[1];
			}

			if (res.value[2])
			{
				document.getElementById("spanPreco_" + res.value[0]).innerHTML = res.value[2];
			}

			if (res.value[3])
			{
				document.getElementById("spanPrecoPor_" + res.value[0]).innerHTML = res.value[3];
			}

			if (res.value[4])
			{
				document.getElementById("spanParcelamento_" + res.value[0]).innerHTML = res.value[4];
			}

			TrocaImagem("loading", "hidden");
		}
	}

	function DisponibilidadeSKUCategoria(campo, ProdutoCodigo, tipo)
	{
		var mensagem = "";
		var aux = "";
		var extensao = "";
		var endereco = "";

		var CarValCod1 = 0;
		var CarValCod2 = 0;
		var CarValCod3 = 0;
		var CarValCod4 = 0;
		var CarValCod5 = 0;

		TrocaImagem("loading", "visible");

		try
		{
			CarValCod1 = (document.getElementById("DRP_SKU_" + ProdutoCodigo + "_1") ? document.getElementById("DRP_SKU_" + ProdutoCodigo + "_1").options[document.getElementById("DRP_SKU_" + ProdutoCodigo + "_1").selectedIndex].value : 0);
			CarValCod2 = (document.getElementById("DRP_SKU_" + ProdutoCodigo + "_2") ? document.getElementById("DRP_SKU_" + ProdutoCodigo + "_2").options[document.getElementById("DRP_SKU_" + ProdutoCodigo + "_2").selectedIndex].value : 0);
			CarValCod3 = (document.getElementById("DRP_SKU_" + ProdutoCodigo + "_3") ? document.getElementById("DRP_SKU_" + ProdutoCodigo + "_3").options[document.getElementById("DRP_SKU_" + ProdutoCodigo + "_3").selectedIndex].value : 0);
			CarValCod4 = (document.getElementById("DRP_SKU_" + ProdutoCodigo + "_4") ? document.getElementById("DRP_SKU_" + ProdutoCodigo + "_4").options[document.getElementById("DRP_SKU_" + ProdutoCodigo + "_4").selectedIndex].value : 0);
			CarValCod5 = (document.getElementById("DRP_SKU_" + ProdutoCodigo + "_5") ? document.getElementById("DRP_SKU_" + ProdutoCodigo + "_5").options[document.getElementById("DRP_SKU_" + ProdutoCodigo + "_5").selectedIndex].value : 0);

			if(campo.options[campo.selectedIndex].value == "")
			{
				mensagem+="Opção inválida (vazio) !\n";
			}

			if(mensagem != "")
			{
				alert(mensagem);
				TrocaImagem("loading", "hidden");
			}
			else
			{
				categoria.DisponibilidadeSKUCategoria(ProdutoCodigo.toString(), CarValCod1.toString(), CarValCod2.toString(), CarValCod3.toString(), CarValCod4.toString(), CarValCod5.toString(), callback_DisponibilidadeSKUCategoria)
			}		
		} 
		catch(err)
		{
			alert(err.description);
			TrocaImagem("loading", "hidden");
		}
	}

	function callback_DisponibilidadeSKUCategoria(res)
	{
		if (res.error)
		{
			alert(res.error.Message);
//			window.location.href = window.location;
		}	
		
		if (res.value[0])
		{
			if (res.value[1])
			{
				document.getElementById("spanDisponibilidade_" + res.value[0]).innerHTML = res.value[1];
			}

			if (res.value[2])
			{
				document.getElementById("spanPreco_" + res.value[0]).innerHTML = res.value[2];
			}

			if (res.value[3])
			{
				document.getElementById("spanPrecoPor_" + res.value[0]).innerHTML = res.value[3];
			}

			if (res.value[4])
			{
				document.getElementById("spanParcelamento_" + res.value[0]).innerHTML = res.value[4];
			}

			TrocaImagem("loading", "hidden");
		}
	}

	function DisponibilidadeSKUComparador(campo, ProdutoCodigo, tipo)
	{
		var mensagem = "";
		var aux = "";
		var extensao = "";
		var endereco = "";

		var CarValCod1 = 0;
		var CarValCod2 = 0;
		var CarValCod3 = 0;
		var CarValCod4 = 0;
		var CarValCod5 = 0;

		TrocaImagem("loading", "visible");

		try
		{
			CarValCod1 = (document.getElementById("DRP_SKU_" + ProdutoCodigo + "_1") ? document.getElementById("DRP_SKU_" + ProdutoCodigo + "_1").options[document.getElementById("DRP_SKU_" + ProdutoCodigo + "_1").selectedIndex].value : 0);
			CarValCod2 = (document.getElementById("DRP_SKU_" + ProdutoCodigo + "_2") ? document.getElementById("DRP_SKU_" + ProdutoCodigo + "_2").options[document.getElementById("DRP_SKU_" + ProdutoCodigo + "_2").selectedIndex].value : 0);
			CarValCod3 = (document.getElementById("DRP_SKU_" + ProdutoCodigo + "_3") ? document.getElementById("DRP_SKU_" + ProdutoCodigo + "_3").options[document.getElementById("DRP_SKU_" + ProdutoCodigo + "_3").selectedIndex].value : 0);
			CarValCod4 = (document.getElementById("DRP_SKU_" + ProdutoCodigo + "_4") ? document.getElementById("DRP_SKU_" + ProdutoCodigo + "_4").options[document.getElementById("DRP_SKU_" + ProdutoCodigo + "_4").selectedIndex].value : 0);
			CarValCod5 = (document.getElementById("DRP_SKU_" + ProdutoCodigo + "_5") ? document.getElementById("DRP_SKU_" + ProdutoCodigo + "_5").options[document.getElementById("DRP_SKU_" + ProdutoCodigo + "_5").selectedIndex].value : 0);

			if(campo.options[campo.selectedIndex].value == "")
			{
				mensagem+="Opção inválida (vazio) !\n";
			}

			if(mensagem != "")
			{
				alert(mensagem);
				TrocaImagem("loading", "hidden");
			}
			else
			{
				comparar.DisponibilidadeSKUComparador(ProdutoCodigo.toString(), CarValCod1.toString(), CarValCod2.toString(), CarValCod3.toString(), CarValCod4.toString(), CarValCod5.toString(), callback_DisponibilidadeSKUComparador)
			}		
		} 
		catch(err)
		{
			alert(err.description);
			TrocaImagem("loading", "hidden");
		}
	}

	function callback_DisponibilidadeSKUComparador(res)
	{
		if (res.error)
		{
			alert(res.error.Message);
//			window.location.href = window.location;
		}	
		
		if (res.value[0])
		{
			if (res.value[1])
			{
				document.getElementById("spanDisponibilidade_" + res.value[0]).innerHTML = res.value[1];
			}

			if (res.value[2])
			{
				document.getElementById("spanPreco_" + res.value[0]).innerHTML = res.value[2];
			}

			if (res.value[3])
			{
				document.getElementById("spanPrecoPor_" + res.value[0]).innerHTML = res.value[3];
			}

			if (res.value[4])
			{
				document.getElementById("spanParcelamento_" + res.value[0]).innerHTML = res.value[4];
			}

			TrocaImagem("loading", "hidden");
		}
	}

	function DisponibilidadeSKUFornecedor(campo, ProdutoCodigo, tipo)
	{
		var mensagem = "";
		var aux = "";
		var extensao = "";
		var endereco = "";

		var CarValCod1 = 0;
		var CarValCod2 = 0;
		var CarValCod3 = 0;
		var CarValCod4 = 0;
		var CarValCod5 = 0;

		TrocaImagem("loading", "visible");

		try
		{
			CarValCod1 = (document.getElementById("DRP_SKU_" + ProdutoCodigo + "_1") ? document.getElementById("DRP_SKU_" + ProdutoCodigo + "_1").options[document.getElementById("DRP_SKU_" + ProdutoCodigo + "_1").selectedIndex].value : 0);
			CarValCod2 = (document.getElementById("DRP_SKU_" + ProdutoCodigo + "_2") ? document.getElementById("DRP_SKU_" + ProdutoCodigo + "_2").options[document.getElementById("DRP_SKU_" + ProdutoCodigo + "_2").selectedIndex].value : 0);
			CarValCod3 = (document.getElementById("DRP_SKU_" + ProdutoCodigo + "_3") ? document.getElementById("DRP_SKU_" + ProdutoCodigo + "_3").options[document.getElementById("DRP_SKU_" + ProdutoCodigo + "_3").selectedIndex].value : 0);
			CarValCod4 = (document.getElementById("DRP_SKU_" + ProdutoCodigo + "_4") ? document.getElementById("DRP_SKU_" + ProdutoCodigo + "_4").options[document.getElementById("DRP_SKU_" + ProdutoCodigo + "_4").selectedIndex].value : 0);
			CarValCod5 = (document.getElementById("DRP_SKU_" + ProdutoCodigo + "_5") ? document.getElementById("DRP_SKU_" + ProdutoCodigo + "_5").options[document.getElementById("DRP_SKU_" + ProdutoCodigo + "_5").selectedIndex].value : 0);

			if(campo.options[campo.selectedIndex].value == "")
			{
				mensagem+="Opção inválida (vazio) !\n";
			}

			if(mensagem != "")
			{
				alert(mensagem);
				TrocaImagem("loading", "hidden");
			}
			else
			{
				fornecedor.DisponibilidadeSKUFornecedor(ProdutoCodigo.toString(), CarValCod1.toString(), CarValCod2.toString(), CarValCod3.toString(), CarValCod4.toString(), CarValCod5.toString(), callback_DisponibilidadeSKUFornecedor)
			}		
		} 
		catch(err)
		{
			alert(err.description);
			TrocaImagem("loading", "hidden");
		}
	}

	function callback_DisponibilidadeSKUFornecedor(res)
	{
		if (res.error)
		{
			alert(res.error.Message);
//			window.location.href = window.location;
		}	
		
		if (res.value[0])
		{
			if (res.value[1])
			{
				document.getElementById("spanDisponibilidade_" + res.value[0]).innerHTML = res.value[1];
			}

			if (res.value[2])
			{
				document.getElementById("spanPreco_" + res.value[0]).innerHTML = res.value[2];
			}

			if (res.value[3])
			{
				document.getElementById("spanPrecoPor_" + res.value[0]).innerHTML = res.value[3];
			}

			if (res.value[4])
			{
				document.getElementById("spanParcelamento_" + res.value[0]).innerHTML = res.value[4];
			}

			TrocaImagem("loading", "hidden");
		}
	}

	function MudaTab(tabNome, redirect)
	{
		var campos = document.getElementsByTagName("DIV");
		var tabs = document.getElementsByTagName("A");

		for (k=0; k<tabs.length; k++) 
		{
			link_atual = tabs[k];

			/*if (link_atual.id.indexOf("Tab_") != -1 )
			{
				link_atual.className = "Link_Tab_Inativa";			
			}*/
		}

		/*if (document.getElementById("Tab_" + tabNome))
		{
			document.getElementById("Tab_" + tabNome).className = "Link_Tab_Ativa";
		}*/

		for (j=0; j<campos.length; j++) 
		{
			campo_atual = campos[j];

			if (campo_atual.id.indexOf("Detalhe_Tab_") != -1 )
			{
				if (campo_atual.id == "Detalhe_Tab_" + tabNome)
				{
					campo_atual.className = "Detalhe_Tab_Ativa";
				}
				else
				{
					campo_atual.className = "Detalhe_Tab_Inativa";
				}
			}
		}

		if (redirect)
		{
			window.location.href = "#d";
		}
	}

	function MudaCheck(tipo)
	{
		if (tipo == "S")
		{
			document.getElementById('rdnSenha').checked = true;
			document.getElementById('rdnPrimeiraCompra').checked = false;
			document.getElementById('txtCep1').value = '';
		}	
		else
		{
			document.getElementById('rdnSenha').checked = false;
			document.getElementById('rdnPrimeiraCompra').checked = true;
			document.getElementById('txtSenha').value = '';
		}
	}

	function LoginAlternar()
	{
		if(document.getElementById('rdnSenha').checked)
		{
			document.getElementById('txtCep1').value = '';
			document.getElementById('txtCep1').disabled = true;
			
			document.getElementById('txtSenha').disabled = false;
		}
		else
		{
			document.getElementById('txtSenha').value = '';
			document.getElementById('txtSenha').disabled = true;
			
			document.getElementById('txtCep1').disabled = false;
		}
	}

	function SomenteNumero(e)
	{ 
		var key;

		if (window.event) 
		{
			key = event.keyCode;
		}
		else
		{ 
			key = e.which;
		}

		if(key > 47 && key < 58 || key == 8)
		{
			return; 
		}
		else
		{
			if(window.event)
			{
				window.event.returnValue = null; 
			}
			else 
			{
				e.preventDefault();
			}
		}
	} 

	function SomenteNumero2(e, src, mask)
	{
		SomenteNumero(e);
		
		var key;
		
		if (window.event) 
		{
			key = event.keyCode;
		}
		else
		{ 
			key = e.which;
		}

		
		if(	key != 8)
		{
			Mascara(src,mask);
		}	
	}
	
	function Mascara(src, mask) 
	{
		 var i = src.value.length;
		 var saida = mask.substring(0,1);
		 var texto = mask.substring(i)
		 if (texto.substring(0,1) != saida) 
		 {
			  src.value += texto.substring (0,1);
		 }
	}

	function Mascara2(e, src, mask) 
	{
		var key;

		if (window.event) 
		{
			key = event.keyCode;
		}
		else
		{ 
			key = e.which;
		}
		
		if (key != 8)
		{
			Mascara(src, mask);
		}
	}
	
	function Continuar()
	{
		TrocaImagem("loading", "visible");

		var mensagem = "";

		try
		{
			var username = document.getElementById("txtEmail").value;
			var password = document.getElementById("txtSenha").value;
			var cep = document.getElementById("txtCep1").value;
			var tipo = (document.getElementById("rdnSenha").checked ? "S" : "P");

			if (Trim(username) == "")
			{
				mensagem+="Email inválido (vazio) !\n";
			}

			if (tipo == "S")
			{
				if (Trim(password) == "")
				{
					mensagem+="Senha inválida (vazia) !\n";
				}
			}
			else if (tipo == "P")
			{
				if (Trim(cep) == "")
				{
					mensagem+="CEP inválido (vazio) !\n";
				}
			}

			if(mensagem != "")
			{
				alert(mensagem);
				TrocaImagem("loading", "hidden");
			}
			else
			{
				login.Continuar(username, password, cep, tipo, Redirect_callback)
			}		
		} 
		catch(err)
		{
			alert(err.description);
			TrocaImagem("loading", "hidden");
		}
	}
	
	
	function ContinuarPedCodigo()
	{
		TrocaImagem("loading", "visible");
		lblErroPedCodigo.style.display = 'none';

		try
		{
			var PedCodigo = document.getElementById("txtPedCodigo").value;
			
			if(PedCodigo != '')
			{
				loginpedido.ContinuarPedCodigo(PedCodigo.toString(), ContinuarPedCodigo_Callback)
			}
			else
			{
				alert('Preencha corretamente o Número do Pedido!');
				TrocaImagem("loading", "hidden");
			}		
		} 
		catch(err)
		{
			alert(err.message);
			TrocaImagem("loading", "hidden");
		}
	}


	function ContinuarPedCodigo_Callback(res)
	{
		try
		{
			var txtPedCodigo		= document.getElementById("txtPedCodigo");
			var lblErroPedCodigo	= document.getElementById("lblErroPedCodigo");
			
			if(res.value[0] != null)
			{
				if(res.value[0] == "true")
				{
					if(res.value[0] != '')
					{
						window.location = res.value[2];
					}
					else
					{
						lblErroPedCodigo.value = 'Pedido inválido!';	
					}
				}
				else
				{
					alert(res.value[1]);	
				}
			}
			
			txtPedCodigo.value = '';	
			TrocaImagem("loading", "hidden");
		} 
		catch(err)
		{
			alert(err.message);
		}	

		TrocaImagem("loading", "hidden");
	}

	function CarregaEnderecoEnderecos(cep)
	{
		TrocaImagem("loading", "visible");
		enderecos.CarregaEnderecoEnderecos(cep, callback_CarregaEnderecoEnderecos)
	}

	function callback_CarregaEnderecoEnderecos(res)
	{
		var retorno = "0";
	
		if (res.error)
		{
			alert(res.error.Message);
			TrocaImagem("loading", "hidden");
		}


		if (res.value)
		{
			if(document.getElementById("txtCep").value.replace('-','').length > 7)
			{
				if (res.value[0])
				{
					document.getElementById("txtEndereco").value = res.value[0];
					retorno = "1";
				}
				if (res.value[0])
				{
					document.getElementById("txtBairro").value = res.value[1];
					retorno = "1";
				}
				if (res.value[0])
				{
					document.getElementById("txtCidade").value = res.value[2];
					retorno = "1";
				}
				if (res.value[0])
				{
					document.getElementById("ddlEstado").value = res.value[3];
					retorno = "1";
				}

				TrocaImagem("loading", "hidden");
			
				if(retorno == "0")
				{
					alert("PREZADO CLIENTE\nVerifique se o CEP preenchido está correto.\nO preenchimento incorreto implicará em problemas na entrega do seu pedido.");
				}
			}else
			{
					TrocaImagem("loading", "hidden");
					alert("O CEP informado é inválido (incompleto)!");
			}
			
		
		}
	}

	function UsarEndereco(EnderecoCodigo)
	{
		TrocaImagem("loading", "visible");
		enderecos.UsarEndereco(EnderecoCodigo.toString(), Redirect_callback);
	}

	function EditarEndereco(EnderecoCodigo)
	{
		TrocaImagem("loading", "visible");
		enderecos.EditarEndereco(EnderecoCodigo.toString(), callback_EditarEndereco);
	}

	function callback_EditarEndereco(res)
	{
		if (res.error)
		{
			alert(res.error.Message);
			TrocaImagem("loading", "hidden");
		}

		if (res.value)
		{
			if (res.value[0])
			{
				document.getElementById("txtCep").value = res.value[0];
			}
			if (res.value[1])
			{
				document.getElementById("ddlEndereco").value = res.value[1];
			}
			if (res.value[2])
			{
				document.getElementById("txtEndereco").value = res.value[2];
			}
			if (res.value[3])
			{
				document.getElementById("txtNumero").value = res.value[3];
			}
			if (res.value[4])
			{
				document.getElementById("txtComplemento").value = res.value[4];
			}
			if (res.value[5])
			{
				document.getElementById("txtBairro").value = res.value[5];
			}
			if (res.value[6])
			{
				document.getElementById("txtCidade").value = res.value[6];
			}
			if (res.value[7])
			{
				document.getElementById("ddlEstado").value = res.value[7];
			}
			if (res.value[8])
			{
				document.getElementById("ddlPais").value = res.value[8];
			}			
			if (res.value[9])
			{
				document.getElementById("txtTel1Ddd").value = res.value[9];
			}
			if (res.value[10])
			{
				document.getElementById("txtTel1").value = res.value[10];
			}
			if (res.value[11])
			{
				document.getElementById("txtRamal1").value = res.value[11];
			}
			if (res.value[12])
			{
				document.getElementById("txtTel2Ddd").value = res.value[12];
			}
			if (res.value[13])
			{
				document.getElementById("txtTel2").value = res.value[13];
			}
			if (res.value[14])
			{
				document.getElementById("txtRamal2").value = res.value[14];
			}
			if (res.value[15])
			{
				document.getElementById("txtTel3Ddd").value = res.value[15];
			}
			if (res.value[16])
			{
				document.getElementById("txtTel3").value = res.value[16];
			}
			if (res.value[17])
			{
				document.getElementById("txtRamal3").value = res.value[17];
			}
			if (res.value[18])
			{
				document.getElementById("txtTelCelDdd").value = res.value[18];
			}
			if (res.value[19])
			{
				document.getElementById("txtTelCel").value = res.value[19];
			}
			if (res.value[20])
			{
				document.getElementById("txtTelFaxDdd").value = res.value[20];
			}
			if (res.value[21])
			{
				document.getElementById("txtTelFax").value = res.value[21];
			}
			if (res.value[22])
			{
				document.getElementById("txtRefEndereco").value = res.value[22];
			}
			if (res.value[23])
			{
				document.getElementById("ddlTipoLog").value = res.value[23];
			}
			if (res.value[24])
			{
				document.getElementById("txtNomeEndereco").value = res.value[24];
			}

			document.getElementById("EnderecoTexto").innerHTML = "<img src='imagens/bt_atualizar_end_escolhido.jpg' border='0'/>";

			TrocaImagem("loading", "hidden");
			window.location.href = "#e";
		}
	}

	function CancelarEndereco()
	{
		TrocaImagem("loading", "visible");
		enderecos.CancelarEndereco(callback_CancelarEndereco);
	}

	function callback_CancelarEndereco(res)
	{
		if (res.error)
		{
			alert(res.error.Message);
			TrocaImagem("loading", "hidden");
		}

		if (res.value)
		{
			document.getElementById("txtCep").value = "";
			document.getElementById("ddlEndereco").selectedIndex = 0;
			document.getElementById("txtEndereco").value = "";
			document.getElementById("txtNumero").value = "";
			document.getElementById("txtComplemento").value = "";
			document.getElementById("txtBairro").value = "";
			document.getElementById("txtCidade").value = "";
			document.getElementById("ddlEstado").value = "SP";
			document.getElementById("ddlPais").value = "31";
			document.getElementById("txtTel1Ddd").value = "";
			document.getElementById("txtTel1").value = "";
			document.getElementById("txtRamal1").value = "";
			document.getElementById("txtTel2Ddd").value = "";
			document.getElementById("txtTel2").value = "";
			document.getElementById("txtRamal2").value = "";
			document.getElementById("txtTel3Ddd").value = "";
			document.getElementById("txtTel3").value = "";
			document.getElementById("txtRamal3").value = "";
			document.getElementById("txtTelCelDdd").value = "";
			document.getElementById("txtTelCel").value = "";
			document.getElementById("txtTelFaxDdd").value = "";
			document.getElementById("txtTelFax").value = "";
			document.getElementById("txtRefEndereco").value = "";
			document.getElementById("ddlTipoLog").selectedIndex = 0;
			document.getElementById("txtNomeEndereco").value = "";

			TrocaImagem("loading", "hidden");

			document.getElementById("EnderecoTexto").innerHTML = "<img src='imagens/bt_salvar_endereco.jpg' width='153' height='21' border='0' />";
		}
	}

	function ExcluirEndereco(EnderecoCodigo)
	{
		TrocaImagem("loading", "visible");

		if (confirm("Tem certeza que deseja excluir o endereço escolhido?"))
		{
			enderecos.ExcluirEndereco(EnderecoCodigo.toString(), Redirect_callback);
		}
		else
		{
			TrocaImagem("loading", "hidden");
		}
	}

	function SalvarEndereco()
	{
		var mensagem = "";

		TrocaImagem("loading", "visible");

		try
		{
			if (document.getElementById("txtCep").value == "")
			{
				mensagem+="CEP inválido (vazio) !\n";
			}
			else
			{
				
				if (document.getElementById("txtCep").value.replace('-','').length < 8)
				{
					mensagem+="CEP inválido (incompleto) !\n";
				}
			}
			if(document.getElementById("ddlEndereco").value == "")
			{
				mensagem+="Tipo inválido (vazio) !\n";
			}
			if (document.getElementById("txtNomeEndereco").value == "")
			{
				mensagem+="Nome inválido (vazio) !\n";
			}
			if (document.getElementById("txtEndereco").value == "" || document.getElementById("ddlTipoLog").value == "")
			{
				mensagem+="Endereço inválido (vazio) !\n";
			}
			if (document.getElementById("txtNumero").value == "")
			{
				mensagem+="Número inválido (vazio) !\n";
			}
			if (document.getElementById("txtBairro").value == "")
			{
				mensagem+="Bairro inválido (vazio) !\n";
			}
			if (document.getElementById("txtCidade").value == "")
			{
				mensagem+="Cidade inválida (vazia) !\n";
			}
			if (document.getElementById("ddlEstado").value == "")
			{
				mensagem+="Estado inválido (vazio) !\n";
			}
			if (document.getElementById("ddlPais").value == "")
			{
				mensagem+="País inválido (vazio) !\n";
			}
			if (document.getElementById("txtTel1Ddd").value == "" || document.getElementById("txtTel1").value == "")
			{
				mensagem+="Telefone inválido (vazio) !\n";
			}

			if(mensagem != "")
			{
				alert(mensagem);
				TrocaImagem("loading", "hidden");
			}
			else
			{
				enderecos.SalvarEndereco(document.getElementById("txtCep").value, document.getElementById("ddlEndereco").value, document.getElementById("txtEndereco").value, document.getElementById("txtNumero").value, document.getElementById("txtComplemento").value, document.getElementById("txtBairro").value, document.getElementById("txtCidade").value, document.getElementById("ddlEstado").value, document.getElementById("ddlPais").value, document.getElementById("txtTel1Ddd").value, document.getElementById("txtTel1").value, document.getElementById("txtRamal1").value, document.getElementById("txtTel2Ddd").value, document.getElementById("txtTel2").value, document.getElementById("txtRamal2").value, document.getElementById("txtTel3Ddd").value, document.getElementById("txtTel3").value, document.getElementById("txtRamal3").value, document.getElementById("txtTelCelDdd").value, document.getElementById("txtTelCel").value, document.getElementById("txtTelFaxDdd").value, document.getElementById("txtTelFax").value, document.getElementById("txtRefEndereco").value, document.getElementById("ddlTipoLog").value, document.getElementById("txtNomeEndereco").value, Redirect_callback)
			}		
		} 
		catch(err)
		{
			alert(err.description);
			TrocaImagem("loading", "hidden");
		}
	}

	function Redirect_callback(res)
	{
		if (res.error)
		{
			alert(res.error.Message);
			
			if(res.error.Message.indexOf("Valor Mínimo") >= 0)
			{	
				array = location.href.split("/");
				
				if(location.href.indexOf("www") >=0)//producao
				{
					window.location = array[0].replace("https","http") + "//" + array[2]+"/basket/index.aspx";
				}
				else//local
				{	
					window.location = array[0] + "//" + array[2] + "/" + array[3] + "/basket/index.aspx";
				}
			}
			TrocaImagem("loading", "hidden");
		}		

		if (res.value)
		{
			window.location.href = res.value;
		}	
	}

	function CancelarCupom()
	{
		index.CancelarCupom(callback_CancelarCupom);
	}

	function callback_CancelarCupom(res)
	{
		if (res.error)
		{
			alert(res.error.Message);
		}			

		if (res.value)
		{
			window.location.href = res.value;
		}
	}

	function CalcularFrete()
	{	
		try
		{
			var mensagem = "";

			TrocaImagem("loading", "visible");
			
			if (document.getElementById("CEP"))
			{
				if (document.getElementById("CEP").value.length < 1)
				{
					mensagem+="CEP inválido (vazio) !\n";					
					document.getElementById("CEP").className = "formulario_carrinho_erro";
				}
				else
				{
					if (document.getElementById("CEP").value.replace('-','').length < 8)
					{
						mensagem+="CEP inválido (incompleto) !\n";
						document.getElementById("CEP").className = "formulario_carrinho_erro";
					}
					else
					{					
						document.getElementById("CEP").className = "formulario_carrinho";
					}
				}

				if(mensagem != "")
				{
					alert(mensagem);
					TrocaImagem("loading", "hidden");
				}
				else
				{
					index.CalcularFrete(document.getElementById("CEP").value.replace("-", ""), callback_CalcularFrete)
				}		
			}
		}
		catch(err)
		{
			alert(err.description);
			TrocaImagem("loading", "hidden");
		}
	}

	function callback_CalcularFrete(res)
	{
		if (res.error)
		{
			alert(res.error.Message);
			TrocaImagem("loading", "hidden");
			//document.getElementById("Cupom").value = "";
		}			

		if (res.value)
		{
			window.location.href = res.value;
		}
	}

	function CalcularCupom()
	{
		try
		{
			var mensagem = "";

			TrocaImagem("loading", "visible");
			
			if (document.getElementById("Cupom"))
			{
				if (document.getElementById("Cupom").value.length < 1)
				{
					mensagem+="Cupom inválido (vazio) !\n";
					document.getElementById("Cupom").className = "campo_cupom_erro";
				}
				else
				{
					if (document.getElementById("Cupom").value.length < 36)
					{
						mensagem+="Cupom inválido (incompleto) !\n";
						document.getElementById("Cupom").className = "campo_cupom_erro";
					}
					else
					{
						document.getElementById("Cupom").className = "campo_cupom";
					}
				}

				if(mensagem != "")
				{
					alert(mensagem);
					TrocaImagem("loading", "hidden");
				}
				else
				{
					index.CalcularCupom(document.getElementById("Cupom").value, callback_CalcularCupom)
				}		
			}
		}
		catch(err)
		{
			alert(err.description);
			TrocaImagem("loading", "hidden");
		}
	}

	function callback_CalcularCupom(res)
	{
		if (res.error)
		{
			alert(res.error.Message);
			TrocaImagem("loading", "hidden");
			document.getElementById("Cupom").value = "";
		}			

		if (res.value)
		{
			window.location.href = res.value;
		}
	}

	function Contagem(qtde, campotxt, campoqtde) 
	{
		field = document.getElementById(campotxt.name);
		if (field) 
		{
			if(field.value.length >= Number(qtde))
			{
				field.value = field.value.substring(0, qtde);
			}
		}
		txt_field = document.getElementById(campoqtde);
		if (txt_field) 
		{
			txt_field.innerHTML = campotxt.value.length;
		}
	}

	function Avaliar(nota)
	{
		for (i=1; i<=5; i++)
		{
			document.getElementById("star" + i).src = (i <= nota ? document.getElementById("star" + i).src.replace("off", "ok").replace("on", "ok") : document.getElementById("star" + i).src);
		}
		document.getElementById("txtNota").value = nota;
	}

	function Preview(nota)
	{
		for (i=1; i<=5; i++)
		{
			document.getElementById("star" + i).src = (i <= nota ? document.getElementById("star" + i).src.replace("off2", "on").replace("ok", "on") : document.getElementById("star" + i).src);
		}
	}

	function ResetPreview()
	{
		var nota = 0;

		if (document.getElementById("txtNota").value.length > 0)
		{
			nota = Number(document.getElementById("txtNota").value)

			for (i=1; i<=5; i++)
			{
				document.getElementById("star" + i).src = (i <= nota ? document.getElementById("star" + i).src.replace("off2", "ok").replace("on", "ok") : document.getElementById("star" + i).src.replace("on", "off2").replace("ok", "off2"));
			}
		}
		else
		{
			for (i=1; i<=5; i++)
			{
				document.getElementById("star" + i).src = document.getElementById("star" + i).src.replace("on", "off2").replace("ok", "off2");
			}
		}
	}

	function SalvarOpiniao()
	{
		var mensagem = "";
		TrocaImagem("loading", "visible");

		var Nota = "";
		var Nome = "";
		var Email = "";
		var Comentario = "";

		try
		{
			if(document.getElementById("txtNome").value == "")
			{
				mensagem+="Nome inválido (vazio) !\n";
			}

			if(document.getElementById("txtEmail").value == "")
			{
				mensagem+="Email inválido (vazio) !\n";
			}

			if(document.getElementById("txtDescricao").value == "")
			{
				mensagem+="Comentário inválido (vazio) !\n";
			}

			if(document.getElementById("txtNota").value == "")
			{
				mensagem+="Nota inválida (vazio) !\n";
			}

			if(mensagem != "")
			{
				alert(mensagem);
				TrocaImagem("loading", "hidden");
			}
			else
			{
				Nota = document.getElementById("txtNota").value;
				Nome = document.getElementById("txtNome").value;
				Email = document.getElementById("txtEmail").value;
				Comentario = document.getElementById("txtDescricao").value;

				detalhes.SalvarOpiniao(Nome, Email, Comentario, Nota.toString(), callback_SalvarOpiniao)
			}		
		} 
		catch(err)
		{
			alert(err.description);
			TrocaImagem("loading", "hidden");
		}
	}

	function callback_SalvarOpiniao(res)
	{
		if (res.error)
		{
			alert(res.error.Message);
			TrocaImagem("loading", "hidden");
		}		

		if (res.value)
		{
			Opinar();
			alert(res.value);

			document.getElementById("txtNota").value = "";
			document.getElementById("txtNome").value = "";
			document.getElementById("txtEmail").value = "";
			document.getElementById("txtDescricao").value = "";

			ResetPreview();

			TrocaImagem("loading", "hidden");
		}
	}

	function PublicaSelo(PromocaoGCodigo, PromocaoPCodigo, ProdutoCodigo, Path, PromoNome)
	{
		if (document.getElementById("Selo" + ProdutoCodigo))
		{
			if (PromocaoGCodigo > 0 || PromocaoPCodigo > 0)
			{
				if (imageExists(Path + "/promocao/" + (PromocaoGCodigo > 0 ? "G"+PromocaoGCodigo : "P"+PromocaoPCodigo) + ".gif"))
				{
					document.getElementById("Selo" + ProdutoCodigo).innerHTML = "<img src='" + Path + "/promocao/" + (PromocaoGCodigo > 0 ? "G"+PromocaoGCodigo : "P"+PromocaoPCodigo) + ".gif' alt='" + PromoNome + "' title='" + PromoNome + "'><br>";
				}
				else
				{
					document.getElementById("Selo" + ProdutoCodigo).innerHTML = "<img src='" + Path + "/casper.gif' width='1' height='1' border='0'><br>";
				}
			}		
		}
	}

	function Opinar()
	{
		try
		{
			if (document.getElementById("opiniao_div"))
			{
				if (document.getElementById("opiniao_div").style.display == "block")
				{
					document.getElementById("opiniao_div").style.display = "none";
				}
				else
				{
					document.getElementById("opiniao_div").style.display = "block";
					window.location.href = "#recados";
				}			
			}
		}
		catch(err)
		{
		}
	}

	function GuardarAviso()
	{
		var Email = "";
		var mensagem = "";

		TrocaImagem("loading", "visible");

		try
		{
			if(document.getElementById("txtEmailAviso").value == "")
			{
				mensagem+="Email inválido (vazio) !\n";
			}

			if(mensagem != "")
			{
				alert(mensagem);
				TrocaImagem("loading", "hidden");
			}
			else
			{
				Email = document.getElementById("txtEmailAviso").value;
				detalhes.GuardarAviso(Email, callback_GuardarAviso)
			}		
		} 
		catch(err)
		{
			alert(err.description);
			TrocaImagem("loading", "hidden");
		}
	}

	function callback_GuardarAviso(res)
	{
		if (res.error)
		{
			alert(res.error.Message);
			TrocaImagem("loading", "hidden");
		}		

		if (res.value)
		{
			alert(res.value);
			document.getElementById("txtEmailAviso").value = "";
			TrocaImagem("loading", "hidden");
		}
	}
	
	function janela(hp, width, height, texto)
	{
		var w = window.screen.width;
		var h = window.screen.height;
		var l = (w-width)/2;
		var t = (h-height)/2;

		wAbout = window.open(hp, texto, "fullscreen=0, toolbar=0, location=0, directories=0, status=0, menubar=0, scrollbars=1, resizable=0");

		wAbout.blur();
		window.focus();
		wAbout.resizeTo(width,height);
		wAbout.moveTo(l, t);
		wAbout.focus();
	}
	
	//FALE CONOSCO(AJAX)
	
	
	function Mostra(quem, tammax) 
	{
		VerifiqueTAB=true;
		
		if (quem.value.length == tammax && VerifiqueTAB)
		{
			var i=0,j=0, indice=-1;
			
			for (i=0; i<document.forms.length; i++) 
			{
				for (j=0; j<document.forms[i].elements.length; j++) 
				{
					if (document.forms[i].elements[j].name == quem.name) 
					{
						indice=i;
						break;
					}
				}
				if (indice != -1)
				{
					break;
				}
			}
			for (i=0; i<=document.forms[indice].elements.length; i++) 
			{
				if (document.forms[indice].elements[i].name == quem.name) 
				{
					try
					{
						while ((document.forms[indice].elements[(i+1)].type == "hidden") && (i < document.forms[indice].elements.length)) 
						{
							i++;
						}
						document.forms[indice].elements[(i+1)].focus();
					}
					catch(err)
					{
					}
					
					VerifiqueTAB=false;
					break;
				}
			}
		}
	}
	
	function ColocaFocoEm(NomeBtn, e) 
	{ 
		try
		{
			var key;  
				
			if (window.event) 
			{    
				key = event.keyCode;   
			}
			else
			{     
				key = e.which; 
			}

			if (key == 13)
			{
				document.getElementById(NomeBtn).focus();
				key = 13;
			}
		}     
		catch(err)
		{
			alert(err);
		}
	}
	
	function CamposPreenchidosFaleConosco()
	{
		retornoCamposPreenchidosFaleConosco = true;
	    
		try
		{
			var CorErro                 			= '#FF0000';
			var CorOk                   			= '#6C79A6';
	           
			var ddlAssunto		= document.getElementById('ddlAssunto');
			var txtNome			= document.getElementById('txtNome');
			var txtEmail		= document.getElementById('txtEmail');
			var txtDDD			= document.getElementById('txtDDD');
			var txtTelefone		= document.getElementById('txtTelefone');
			var txtMensagem		= document.getElementById('txtMensagem');
	       
	        
	        
			if(Trim(txtNome.value) == '')		{MudaCorBorda(txtNome, CorErro);			retornoCamposPreenchidosFaleConosco = false;} else MudaCorBorda(txtNome, CorOk);           
			if(Trim(txtEmail.value) == '')		{MudaCorBorda(txtEmail, CorErro);			retornoCamposPreenchidosFaleConosco = false;} else MudaCorBorda(txtEmail, CorOk);           
			if(Trim(txtDDD.value) == '')		{MudaCorBorda(txtDDD, CorErro);				retornoCamposPreenchidosFaleConosco = false;} else MudaCorBorda(txtDDD, CorOk);           
			if(Trim(txtTelefone.value) == '')	{MudaCorBorda(txtTelefone, CorErro);		retornoCamposPreenchidosFaleConosco = false;} else MudaCorBorda(txtTelefone, CorOk);           
			if(Trim(txtMensagem.value) == '')	{MudaCorBorda(txtMensagem, CorErro);		retornoCamposPreenchidosFaleConosco = false;} else MudaCorBorda(txtMensagem, CorOk);           
			if(Trim(ddlAssunto.value) == '0')	{MudaCorBorda(ddlAssunto, CorErro);			retornoCamposPreenchidosFaleConosco = false;} else MudaCorBorda(ddlAssunto, CorOk);           
	         
	        if(!retornoCamposPreenchidosFaleConosco)
			{
				alert('Preencha os campos corretamente!');
			}                                             
		}
		catch(err)
		{
			document.write("<!--" + err.description + "-->");
		}
    
		return retornoCamposPreenchidosFaleConosco;          
	}

	function MudaCorBorda(obj, cor)
	{
		try
		{        
			var Borda               = '1px';
			var BordaEstilo         = 'solid';
	        
			obj.style.border        = Borda;
			obj.style.borderStyle   = BordaEstilo;
			obj.style.borderColor   = cor;        
		}
		catch(err)
		{
			document.write(err.description);
		}    
	}
	
	
	function EnviarMensagem()
	{
		try
		{
			var ddlAssunto		= document.getElementById('ddlAssunto');
			var txtNome			= document.getElementById('txtNome');
			var txtSobrenome	= document.getElementById('txtSobrenome');
			var txtEmail		= document.getElementById('txtEmail');
			var txtDDD			= document.getElementById('txtDDD');
			var txtTelefone		= document.getElementById('txtTelefone');
			var txtMensagem		= document.getElementById('txtMensagem');
					
			if(CamposPreenchidosFaleConosco())
			{
				faleconosco.EnviarMensagem(txtNome.value,txtSobrenome.value,txtEmail.value,txtDDD.value,txtTelefone.value,ddlAssunto.options[ddlAssunto.selectedIndex].text,txtMensagem.value,EnviarMensagem_CallBack);
			}
			
		}
		catch(err)
		{
			alert(err.message);
		}
	}

	function EnviarMensagem_CallBack(resp)
	{
		try
		{
			var lblMsgErro = document.getElementById('lblMsgErro');
			if(resp.value[0] == "1")
			{
				lblMsgErro.innerHTML = resp.value[1];
				
			}
			else
			{
				lblMsgErro.innerHTML = resp.value[1];
			}
					
		}
		catch(err)
		{
			lblMsgErro.value = err.message;
		}
	}
	
	function AdicionarListaDesejo()
	{
		var ProdutoCodigo	= 0;
		var CategoriaCodigo = 0;
		var CarValCod1		= 0;
		var CarValCod2		= 0;
		var CarValCod3		= 0;
		var CarValCod4		= 0;
		var CarValCod5		= 0;

		try
		{
					
			ProdutoCodigo		= (document.getElementById("ProdutoCodigo") ? document.getElementById("ProdutoCodigo").value : 0);
			CategoriaCodigo		= (document.getElementById("CategoriaCodigo") ? document.getElementById("CategoriaCodigo").value : 0);
			CarValCod1			= (document.getElementById("DRP_SKU_1") ? ((document.getElementById("DRP_SKU_1").tagName.toLowerCase() == "select")?(document.getElementById("DRP_SKU_1").options[document.getElementById("DRP_SKU_1").selectedIndex].value):(0)): 0);
			CarValCod2			= (document.getElementById("DRP_SKU_2") ? ((document.getElementById("DRP_SKU_2").tagName.toLowerCase() == "select")?(document.getElementById("DRP_SKU_2").options[document.getElementById("DRP_SKU_2").selectedIndex].value):(0)): 0);
			CarValCod3			= (document.getElementById("DRP_SKU_3") ? ((document.getElementById("DRP_SKU_3").tagName.toLowerCase() == "select")?(document.getElementById("DRP_SKU_3").options[document.getElementById("DRP_SKU_3").selectedIndex].value):(0)): 0);
			CarValCod4			= (document.getElementById("DRP_SKU_4") ? ((document.getElementById("DRP_SKU_4").tagName.toLowerCase() == "select")?(document.getElementById("DRP_SKU_4").options[document.getElementById("DRP_SKU_4").selectedIndex].value):(0)): 0);
			CarValCod5			= (document.getElementById("DRP_SKU_5") ? ((document.getElementById("DRP_SKU_5").tagName.toLowerCase() == "select")?(document.getElementById("DRP_SKU_5").options[document.getElementById("DRP_SKU_5").selectedIndex].value):(0)): 0);
			
			detalhes.AdicionarListaDesejo(ProdutoCodigo.toString(), CategoriaCodigo.toString(), CarValCod1.toString(), CarValCod2.toString(), CarValCod3.toString(), CarValCod4.toString(), CarValCod5.toString(), AdicionarListaDesejo_CallBack);
		} 
		catch(err)
		{
			alert(err.description);
			
		}
	}

	function AdicionarListaDesejo_CallBack(res)
	{
		try
		{
			
			if(res.value[0] == "0")
			{
				if(res.value[2] != "")
				{
					alert(res.value[2]);
				}			
				if(res.value[3] != "")
				{
					 window.location = res.value[3];
				}
			}
			else
			{
				if(res.value[2] != "")
				{
					alert(res.value[2]);
				}			
				if(res.value[3] != "")
				{
					 window.location = res.value[3];
				}
		
			}
		
		}
		catch(err)
		{
			alert(err.description);
		}
	}


	function CompararTodos(campo)
	{
		divs=document.getElementsByTagName("input");
		for (i=0;i<divs.length;i++) 
		{
			if (divs[i].type == "checkbox")
			{
				if (divs[i].name.indexOf("CompProd_") >= 0)
				{
					divs[i].checked = campo.checked;
				}
			}
		}
	}

	function CompararProdutos()
	{
		var totalItens = 0;
		var ItensCod = "";

		divs=document.getElementsByTagName("input");
		
		for (i=0;i<divs.length;i++) 
		{
			if (divs[i].type == "checkbox")
			{
				if (divs[i].name.indexOf("CompProd_") >= 0)
				{
					if(divs[i].checked)
					{
						if (ItensCod == "")
						{
							ItensCod = divs[i].value;
						}
						else
						{
							ItensCod += "|" + divs[i].value;
						}

						totalItens++;
					}
				}
			}
		}

		if (totalItens > 1)
		{
			busca.CompararProdutos(ItensCod.toString(), callback_CompararProdutos);
		}
		else
		{
			alert("Você precisa selecionar mais de 1 produto pra poder fazer a comparação de produtos!");
		}
	}

	function callback_CompararProdutos(res)
	{
		if (res.error)
		{
			alert(res.error.Message);
			TrocaImagem("loading", "hidden");
		}		

		if (res.value)
		{
			window.location.href = res.value;
		}
	}

	function Saudacao()
	{
		var hoje = new Date();
		var hora = hoje.getHours();
		
		if(hora < 6) 
				return "Boa Madrugada!"; 
		else if (hora < 12) 
				return "Bom Dia!"; 
		else if (hora < 18) 
				return "Boa Tarde!"; 
		else
				return "Boa noite!"; 
	}
	
	
function AlterarSenha()
{			
	try
	{			
		Email        		= document.getElementById("txtEmail").value ;		
		SenhaAtual   		= document.getElementById("txtSenha").value ;
		NovaSenha	 		= document.getElementById("txtNovaSenha1").value ;
		NovaSenhaConfirm	= document.getElementById("txtNovaSenha2").value ;		
		
		TrocaImagem("loading", "visible");

		var mensagem = "";

		if (Trim(Email) == "")
		{
			mensagem+="Email inválido (vazio) !\n";
		}

		if (Trim(SenhaAtual) == "")
		{
			mensagem+="Senha inválida (vazia) !\n";
		}
		
		if (Trim(NovaSenha) == "")
		{
			mensagem+="Nova Senha inválida (vazia) !\n";
		}
		
		if (Trim(NovaSenhaConfirm) != Trim(NovaSenha))
		{
			mensagem+="Confirmação de senha inválida !\n";
		}

		if(mensagem != "")
		{
			alert(mensagem);
			TrocaImagem("loading", "hidden");
		}
		else
		{
			senhaalteracao.Continuar(Email,SenhaAtual,NovaSenha,NovaSenhaConfirm,callback_AlterarSenha);
		}		
	} 
	catch(err)
	{
		TrocaImagem("loading", "hidden");
		alert(err);
	}
}

function callback_AlterarSenha(res)
{			
	try
	{
		if(res.value == "ok")
		{
			document.getElementById("txtEmail").value = "";
			document.getElementById("txtSenha").value = "";
			document.getElementById("txtNovaSenha1").value = "";
			document.getElementById("txtNovaSenha2").value = "";
		
			alert("Senha alterada, um email foi enviado.");
		}
		else
		{
			alert(res.value);
		}
		
		TrocaImagem("loading","hidden");
	}	
	catch(err)
	{
		TrocaImagem("loading","hidden");
		alert(err);
	}
}









function GerarSenha()
{
	try
	{			
		Email = document.getElementById("txtEmail").value;
		
		TrocaImagem("loading", "visible");	

		if(Trim(Email) == "")
		{
			alert("Email inválido ! (vazio)");
			TrocaImagem("loading", "hidden");
		}
		else
		{
			senhageracao.Continuar(Email,callback_GerarSenha);
		}		
	} 
	catch(err)
	{
		TrocaImagem("loading", "hidden");
		alert(err);
	}
}

function callback_GerarSenha(res)
{
	try
	{
		if(res.value == "ok")
		{	
			alert("A solicitação de nova senha foi enviada com sucesso por email.");
		}
		else
		{
			alert(res.value);
		}
		
		TrocaImagem("loading","hidden");
		document.getElementById("txtEmail").value = "";	
	}	
	catch(err)
	{
		TrocaImagem("loading","hidden");
		alert(err);
	}
}

//funcoes para botoes de detalhes do produto
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


function EnviaEmailAlacarta(controle)
{
	TrocaImagem("loading", "visible");
	
	if(Trim(controle.value) == '')
	{
		alert('Informe seu email!');
		TrocaImagem("loading", "hidden");
	}
	else
	{
		cabecalho.EnviaEmailAlacarta(controle.value,callback_EnviaEmailAlacarta);
	}	
}
function callback_EnviaEmailAlacarta(res)
{
	if (res.error)
	{
		alert(res.error.Message);
	}
	else
	{		
		alert(res.value);
	}
	
	TrocaImagem("loading", "hidden");
}


function NomeClienteLogado()
{	
	cabecalho.NomeClienteLogado(callback_NomeClienteLogado);	
}
function callback_NomeClienteLogado(texto)
{
	if (texto.error)
	{
		alert(texto.error.Message);
	}
	else
	{
		document.getElementById("saudacao_user").innerHTML = '<span>' + Saudacao() + '</span> ' + texto.value;
	}
}


//meus pedidos - detalhes
function AvisoBoleto(pedCodigo, StatusAviso)
{	
	alert(pedCodigo +' - '+ StatusAviso);
	
	detalhes.AvisoBoleto(pedCodigo,StatusAviso);
}

//confirmacao
function AvisoBoletoConfirmacao(pedCodigo, StatusAviso)
{	
	confirmacao.AvisoBoletoConfirmacao(pedCodigo,StatusAviso,callBack_AvisoBoletoConfirmacao);
}

function callBack_AvisoBoletoConfirmacao(res)
{
		if (res.error)
		{
			alert(res.error.Message);
		}

		if (res.value)
		{
			if(res.value != "")
			{
				window.open(res.value,'Boleto','toolbar=yes,location=no,status=no,menubar=yes,scrollbars=yes,resizable=yes,copyhistory=no,width=800,height=600,left=0,top=0');
			}
		}		
}



function AbrePopUp(URL)	
{		
	window.open(URL,'text','fullscreen=0,toolbar=0,location=0,directories=0,status=0,menubar=0,statusbar=0,scrollbars=no,resizable=0,width=420,height=420')
}

function AbrePopUpAviso(URL)	
{		
	window.open(URL,'text','fullscreen=0,toolbar=0,location=0,directories=0,status=0,menubar=0,statusbar=0,scrollbars=no,resizable=0,width=500,height=400')
}


function ConsisteCep()
{
	
	var field = document.getElementById("txtCEP").value.replace('-','');
	var msg = "";
	
	if(field.length < 8)
	{
		msg = "Cep informado é inválido!";
	}

	if(msg != "")
	{
		alert(msg);
		return false;
	}else
	{
		return true;
	}
}



function AdicionarItemCestaGenericos(ProdutoCodigo)
{
	var enc = 0;
	var mensagem = "";

	var CarValCod1 = 0;
	var CarValCod2 = 0;
	var CarValCod3 = 0;
	var CarValCod4 = 0;
	var CarValCod5 = 0;

	TrocaImagem("loading", "visible");

	try
	{
		CarValCod1 = (document.getElementById("DRP_SKU_1") ? document.getElementById("DRP_SKU_1").value : 0);
		CarValCod2 = (document.getElementById("DRP_SKU_2") ? document.getElementById("DRP_SKU_2").value : 0);
		CarValCod3 = (document.getElementById("DRP_SKU_3") ? document.getElementById("DRP_SKU_3").value : 0);
		CarValCod4 = (document.getElementById("DRP_SKU_4") ? document.getElementById("DRP_SKU_4").value : 0);
		CarValCod5 = (document.getElementById("DRP_SKU_5") ? document.getElementById("DRP_SKU_5").value : 0);

		for (j=0; j<document.forms[0].elements.length; j++) 
		{
			campo = document.forms[0].elements[j];
			
			if(document.getElementById(campo))
			{
				if (campo.name.indexOf("DRP_SKU") != -1 && campo.name.length == 9)
				{
					if (campo.value == "0")
					{
						mensagem+="Escolha um valor para todas as Opções de Compra!\n";
						break;
					}
				}
			}
		}

		if(mensagem != "")
		{
			alert(mensagem);
			TrocaImagem("loading", "hidden");
		}
		else
		{
			genericos.AdicionarItemCesta(ProdutoCodigo.toString(), CarValCod1.toString(), CarValCod2.toString(), CarValCod3.toString(), CarValCod4.toString(), CarValCod5.toString(), Redirect_callback)
		}		
	} 
	catch(err)
	{
		alert(err.description);
		TrocaImagem("loading", "hidden");
	}
}



function flash(arqflash,largura,altura) {
document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="' + largura + '" height="' + altura + '">');
document.write('<param name="movie" value="' + arqflash + '" />');
document.write('<param name="quality" value="high" />');
document.write('<param name="wmode" value="transparent" />');
document.write('<param name="menu" value="false" />');
document.write('<embed src="' + arqflash + '" width="' + largura + '" height="' + altura + '" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" menu="false" wmode="transparent"></embed>');
document.write('</object>');
}

function AbreJanela(url) {
          window.open(url);
}

function Fecha()
{
	document.getElementById("DHTML").style.display="none";
}

function ValidaCartaoUltrafarma(numero)
{	
	if(numero.substring(0,6)=="520898" && numero.length == 16)
	{
		return true;
	}
	else
	{
		return false;
	}
}

function ValidaCartaoHipercard(numero)
{	
	if(numero.substring(0,6)=="384100" || numero.substring(0,6)=="384140" || numero.substring(0,6)=="384160")
	{
		return true;
	}
	else
	{
		return false;
	}
}

function AlteraPosicaoCartao()
{
	if (document.getElementById("OperadoraCodigo").value != "7")
	{
		if(document.getElementById("CartaoNumero").value.length == 16)
		{
			document.getElementById('CartaoCodigo').focus();
		}
	}
	else
	{
		if(document.getElementById("CartaoNumero").value.length == 19)
		{
			document.getElementById('CartaoCodigo').focus();
		}
	}
}

var correctos = new Array("a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","x","z","y","w","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","X","Z","Y","W","1","2","3","4","5","6","7","8","9","0","á","é","í","ó","ú","à","è","ì","ò","ù","Á","É","Í","Ó","Ú","À","È","Ì","Ò","Ù","â","ê","ô","Â","Ê","Ô"," ");
function NoSpecialCharacter(e) 
{

    estado=false;

    if(document.all)
    {
        codigoTecla = event.keyCode
        cadenaTecla = (String.fromCharCode(event.keyCode));
    }
    else if(document.layers)
    {
        codigoTecla = e.which
        cadenaTecla = String.fromCharCode(e.which);
    }
    else if(document.getElementById)
    {
        codigoTecla = (window.Event) ? e.which : e.keyCode;
        cadenaTecla=(String.fromCharCode(codigoTecla));
    }

    for(i=0;i<correctos.length;i++)
    {
        if(cadenaTecla==correctos[i])
            estado=true;
    }

    if(estado==false)
    {
        if(document.all)
        {
        event.returnValue = false;
		alert('Atenção: Não utilize caracteres especiais ao digitar!');
        }   
        else
            return false;
	
    }
}			
			
			

