function Valida(){  
	
	var confere = 0;
	
	for(var i = 2; i < arguments.length; i++) {
		
		var campo = document.getElementById(arguments[i]);
		
		//alert(arguments[i]);
	
		if ((campo.value == "" ) ||  (campo.value == campo.name) || (campo.name=="E-MAIL" && (campo.value.indexOf("@")==-1 || campo.value.indexOf(".")==-1)) || ( campo.name=="senha" && (campo.value!=senha2.value))){
            campo.style.background = "#f5dddd";
			confere++;
		} else {
			campo.style.background = arguments[1];
		}
	}
	
	if(confere >=1){
		alert(arguments[0]);
    	return false;
	} else {
        return true;
	}
}

listaIdProdutos = new Array();
contadorProduto = 0;
totalProduto = 0;
link = 0;
sublink = 0;
pg = 0;
id = 0;

function navegarProdutos (acao){	
	if(acao == "mais"){
		contadorProduto++;
	} else if(acao == "menos"){
		contadorProduto--;
	}
	window.location = "?link="+link+"&sublink="+sublink+"&pg="+pg+"&id="+listaIdProdutos[contadorProduto];
}

function desabilitarSetas () {
	
	if(totalProduto <= 1){
		document.getElementById("setaEsq").style.visibility = "hidden";
		document.getElementById("setaDir").style.visibility = "hidden";
	} else {
		//alert(totalProduto+ " - "+contadorProduto);
		if(contadorProduto == 0){
			document.getElementById("setaEsq").style.visibility = "hidden";
			document.getElementById("setaDir").style.visibility = "visible";
		}
		
		if(contadorProduto >= 1 && contadorProduto < totalProduto){
			document.getElementById("setaEsq").style.visibility = "visible";
			document.getElementById("setaDir").style.visibility = "visible";
		}
		
		if(contadorProduto == totalProduto){
			document.getElementById("setaEsq").style.visibility = "visible";
			document.getElementById("setaDir").style.visibility = "hidden";
		}
	}
}


var req;

function loadXMLDoc(url,id){
    req = null;
    // Procura por um objeto nativo (Mozilla/Safari)
    if (window.XMLHttpRequest) {
        req = new XMLHttpRequest();
        req.onreadystatechange = processReqChangeCateg;
        req.open("GET", url+'?id='+id, true);
        req.send(null);
    // Procura por uma versao ActiveX (IE)
    } else if (window.ActiveXObject) {
        req = new ActiveXObject("Microsoft.XMLHTTP");
        if (req) {
            req.onreadystatechange = processReqChangeCateg;
            req.open("GET", url+'?id='+id, true);
            req.send();
        }
    }
}

function processReqChangeCateg(){
    // apenas quando o estado for "completado"
    if (req.readyState == 4) {
        // apenas se o servidor retornar "OK"
        if (req.status == 200) {
            // procura pela div id="atualiza" e insere o conteudo
            // retornado nela, como texto HTML
            document.getElementById('imagem').innerHTML = req.responseText;
        } else {
            alert("Houve um problema ao obter os dados:\n" + req.statusText);
        }
    }
}

function atualizarImagemSimulador(id, qual){
	loadXMLDoc("simuladorAtualizaImagem.php",id);
	alterarAlphaMiniaturas(qual);
}

function alterarAlphaMiniaturas(qual){
	for(i=1; i<=16; i++){		
		if(document.getElementById("alpha_"+i) != null){
			document.getElementById("alpha_"+i).style.visibility = "hidden";
		}
	}
	
	document.getElementById("alpha_"+qual).style.visibility = "visible";
	
}



