//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Correctly handle PNG transparency in Win IE 5.5 or higher.
// http://homepage.ntlworld.com/bobosola. Updated 02-March-2004

function correctPNG() 
   {
   for(var i=0; i<document.images.length; i++)
      {
	  var img = document.images[i]
	  var imgName = img.src.toUpperCase()
	  if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
	     {
		 var imgID = (img.id) ? "id='" + img.id + "' " : ""
		 var imgClass = (img.className) ? "class='" + img.className + "' " : ""
		 var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
		 var imgStyle = "display:inline-block;" + img.style.cssText 
		 if (img.align == "left") imgStyle = "float:left;" + imgStyle
		 if (img.align == "right") imgStyle = "float:right;" + imgStyle
		 if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle		
		 var strNewHTML = "<span " + imgID + imgClass + imgTitle
		 + " style=\"margin-top: 4px;" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
	     + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
		 + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 
		 img.outerHTML = strNewHTML
		 i = i-1
	     }
      }
   }
   try{
	window.attachEvent("onload", correctPNG);
   }
   catch(e){}
   
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
   
function checa_mail() {
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.form.email.value)){
		return true
		}
		alert("E-mail inválido, verifique-o e tente novamente")
		document.form.email.focus();
		return false;
	}
	
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

function validacao(){
    if (document.form.nome.value == ""){
    alert("O campo Nome não foi preenchido");
    document.form.nome.focus();
    return false;
    }
    if (document.form.email.value == ""){
    alert("O campo Email não foi preenchido");
    document.form.email.focus();
    return false;
    }
    if (document.form.cidade.value == ""){
    alert("O campo Cidade não foi preenchido");
    document.form.cidade.focus();
    return false;
    }
	
	if (document.form.estado.value == "NULL"){
    alert("Selecione o estado que vive");
    document.form.estado.focus();
    return false;
    }

	
    if (document.form.pais.value == "NULL"){
    alert("Selecione o país que vive");
    document.form.pais.focus();
    return false;
    }
    if (document.form.pais.value == "1" && document.form.estado.value == "NULL"){
    alert("Selecione o estado que vive");
    document.form.pais.focus();
    return false;
    }
    if (document.form.mensagem.value == ""){
    alert("O campo Mensagem não foi preenchido");
    document.form.mensagem.focus();
    return false;
    }
	
return true;
}


//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function exibe(){
		if(document.form.pais.value==1){
			trestado.style.visibility='';
	}
		if(document.form.pais.value!=1){
			trestado.style.visibility='hidden';
	}
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

function max(txarea) 
	{
	total = 320;
	tam = txarea.value.length;
	str="";
	str=str+tam; 
	  
Digitado.innerHTML = str;   
Restante.innerHTML = total - str;   
  
if (tam > total){ 
	  aux = txarea.value; 
	  txarea.value = aux.substring(0,total); 
	  Digitado.innerHTML = total 
	  Restante.innerHTML = 0 
	} 
} 

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

function ajaxFunction(metodo, arquivo, divElem){
document.getElementById(divElem).innerHTML="<p align='center'><img src='_images/icone_carregando.gif'></p>";
var xmlHttp;
try{  // Firefox, Opera 8.0+, Safari  
	xmlHttp=new XMLHttpRequest();  
}
catch (e){  // Internet Explorer  
	try{
		xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");    
	}
	catch (e){
		try{
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch (e){
			alert("Your browser does not support AJAX!");
			return false;      
			}    
		}
	}
	xmlHttp.onreadystatechange=function(){
		if(xmlHttp.readyState==4){
//		document.myForm.time.value=xmlHttp.responseText;
		document.getElementById(divElem).innerHTML=xmlHttp.responseText;
		}
	}
	xmlHttp.open(metodo, arquivo, true);
	xmlHttp.send(null);  
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

function filtroAvaliacao(objA, objB, objC)
{

	ajaxFunction('GET','confirma_avaliacao.asp?n1=voto&apreco='+objA+'&codigo='+objB, objC);
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

