// JavaScript Document
String.prototype.trim = function()
{
	return this.replace(/^\s*/, "").replace(/\s*$/, "");
}
function campoEmail(obj)
{
	if(obj.value.trim() == '')
		obj.value = 'E-mail';
	else if(obj.value == 'E-mail')
		obj.value = '';
}
function lightUp(imageobject, opacity){
 if (navigator.appName.indexOf("Netscape")!=-1
  &&parseInt(navigator.appVersion)>=5)
    imageobject.style.MozOpacity=opacity/100
 else if (navigator.appName.indexOf("Microsoft")!= -1 
  &&parseInt(navigator.appVersion)>=4)
    imageobject.filters.alpha.opacity=opacity
}
function changeImg(flag, productName, width)
{
	var imgAtual = parseInt(document.getElementById('imagePreview').value);
	var qtdeImages = parseInt(image.length);
	
	if(flag == 0)
	{
		if(imgAtual == 0)
			return;
		
		imgAtual--;
	}
	else
	{
		if((imgAtual + 1) == qtdeImages)
			return;
		
		imgAtual++;
	}
	
	document.getElementById('imagePreview').value = imgAtual;
	document.getElementById('image').innerHTML = '<a href="' + image[imgAtual] + '" title="' + productName + '"><img src="inc/thumb.php?img=../' + image[imgAtual] + '&x=' + width + '&y=' + width + '" class="image"></a>';
	document.getElementById('enlarge').innerHTML = '<a href="' + image[imgAtual] + '" title="' + productName + '"><img src="image/ico_find.gif" border="0" />Clique p/ ampliar</a>';
	document.getElementById('counter').innerHTML = 'exibindo ' + (imgAtual + 1) + ' de ' + qtdeImages;
	
	    $(function() {
        $('#enlarge a').lightBox();
		$('#image a').lightBox();
    });

}
function buscaRastreamentoHome()
 	{
		if(document.rastreamentohome.tipo[0].checked) {
			//nacional
			var theurl = "http://websro.correios.com.br/sro_bin/txect01$.QueryList" + "?" + "P_LINGUA=" + document.rastreamentohome.P_LINGUA.value + "&P_TIPO=" + document.rastreamentohome.P_TIPO.value + "&P_COD_UNI=" + document.rastreamentohome.P_COD_UNI.value ;
			//alert(theurl);
			//alert(document.rastreamentohome.tipo[0].checked)
			window.open(theurl);
			//document.rastreamentohome.submit();
			return (false);
		}
				
		if(document.rastreamentohome.P_COD_UNI.value.substr(0,2)=='XM' || document.rastreamentohome.P_COD_UNI.value.substr(0,2)=='VC'){
  				window.open("http://websro.correios.com.br/sro_bin/txect01$.QueryList?P_COD_UNI="+document.rastreamentohome.P_COD_UNI.value.substr(0,13)+"&P_TIPO=001&P_LINGUA=001","SRO","width=550,height=400,scrollbars=yes,resizable=no,toolbar=no");
  				document.rastreamentohome.P_COD_UNI.value = "";
				return (false);
  		}
		
		if(document.rastreamentohome.tipo[1].checked) {
			//internacional
			var theurl = "http://www.correios.com.br/servicos/rastreamento/internacional/resultado.cfm" 
			//alert(theurl);
			document.rastreamentohome.method = "post";
			document.rastreamentohome.action = theurl;
			var pname = document.createElement("input");
			pname.type="hidden";
			pname.value="P";
			pname.name = "Idioma";
			document.rastreamentohome.appendChild(pname);
			
			pname = document.createElement("input");
			pname.type="hidden";
			pname.value="Pesquisar"
			pname.name = "Consultar";
			document.rastreamentohome.appendChild(pname);
			
			pname = document.createElement("input");
			pname.type="hidden";
			pname.value= document.rastreamentohome.P_COD_UNI.value
			pname.name = "Consulta";
			document.rastreamentohome.appendChild(pname);
			
			//alert(document.rastreamentohome.Consulta.value);
			//alert(document.rastreamentohome.tipo[1].checked)
			
			//document.rastreamentohome.submit();
			return (true);
		}
		
 	}
