function ajaxInit() {
	var req;
	
	try {
		req = new ActiveXObject("Microsoft.XMLHTTP");
	} 
	catch(e) {
		try {
			req = new ActiveXObject("Msxml2.XMLHTTP");
		} 
		catch(ex) {
			try {
				req = new XMLHttpRequest();
			} 
			catch(exc) {
				alert("Esse browser nao tem recursos para uso do Ajax");
				req = null;
			}
		}
	}
	return req;
}

function TempoEsconder(id){
	tout = setTimeout('fadeOut("' + id + '", 0.1)', 7000);
}

function TempoErro(id){
	tout = setTimeout('EsconderErro(' + id + ')', 1000);
}

function EsconderErro(id){
//	document.getElementById("Mensagem").style.display = "none";
	document.getElementById("Newsletter").innerHTML = "";
}

function fadeOut(id, time) {
	target = document.getElementById(id);
	alpha = 100;
	timer = (time*100)/2;
	var i = setInterval(
			function() {
				if (alpha <= 0)
					clearInterval(i);
				setAlpha(target, alpha);
				alpha -= 2;
			}, timer);
		TempoErro();
}

function setAlpha(target, alpha) {
	target.style.filter = "alpha(opacity="+ alpha +")";
	target.style.opacity = alpha/100;
}

function TrocarMes(Mes)
{
	for(var i=1;i < 13;i++){
		document.getElementById(i).style.backgroundColor = "#FFFFFF";
	}
	document.getElementById(Mes).style.backgroundColor = "#f3073d";
}

function TrocarColecao(Numero, Total){
	for(var i=1;i <= Total;i++){
		document.getElementById("Paginacao" + Numero).style.borderColor = "#FFFFFF";
		document.getElementById("Paginacao" + i).style.backgroundColor = "#FFFFFF";
		document.getElementById("Paginacao" + i).style.color = "#666666";
		document.getElementById("Paginacao" + i).style.fontWeight = "";
	}
	document.getElementById("Paginacao" + Numero).style.borderColor = "#666666";
	document.getElementById("Paginacao" + Numero).style.backgroundColor = "#666666";
	document.getElementById("Paginacao" + Numero).style.color = "#FFFFFF";
	document.getElementById("Paginacao" + Numero).style.fontWeight = "bold";
	
	document.getElementById("Colecao_Botoes").style.display = "none";
}

function Paginar(Numero, Colecao){
		var div = document.getElementById("Conteudo_Colecao");
		var url = "ajax/VestidosColecao.asp?Pagina=" + Numero + "&Colecao=" + Colecao;

		ajax = ajaxInit();
		if(ajax) {
			ajax.open("GET", url, true);
			ajax.onreadystatechange = function() {

			if (ajax.readyState==1){
				div.innerHTML = div.innerHTML; 
			}
			if(ajax.readyState == 4) {
				div.innerHTML = ajax.responseText;
			}
		}
		ajax.send(null);
	}
}

function Cidades(CampoEstado) {
		var Estado = CampoEstado.value;
		var div = document.getElementById("Cidades");
		var url = "ajax/Cidades.asp?Estado=" + Estado;
	
		ajax = ajaxInit();
		if(ajax) {
			ajax.open("GET", url, true);
			ajax.onreadystatechange = function() {

			if (ajax.readyState == 1){
				div.innerHTML = "<img src='imagens/ajax-loader.gif' width='15'>"; 
			}
			if(ajax.readyState == 4) {
				div.innerHTML = ajax.responseText;
			}
		}
		ajax.send(null);
	}
}

function EmailNewsletter(Email, Codigo) {
		var NewsEmail = document.getElementById(Email).value;
		var div = document.getElementById("NewsletterEmail");
		var url = "ajax/EmailNews.asp?Codigo=" + Codigo + "&Email=" + NewsEmail;

		ajax = ajaxInit();
		if(ajax) {
			ajax.open("GET", url, true);
			ajax.onreadystatechange = function() {

			if (ajax.readyState==1){
				div.innerHTML = "<img src='imagens/ajax-loader.gif'>"; 
			}
			if(ajax.readyState == 4) {
				div.innerHTML = ajax.responseText;
			}
		}
		ajax.send(null);
	}
}

function Newsletter() {
		var Email = document.getElementById("Email").value;
		var div = document.getElementById("Newsletter");
		var url = "ajax/Cadastro_Newsletter.asp?Email=" + Email;

		ajax = ajaxInit();
		if(ajax) {
			ajax.open("GET", url, true);
			ajax.onreadystatechange = function() {

			if (ajax.readyState==1){
				div.innerHTML = "<img src='imagens/ajax-loader.gif' width='10' />";
			}
			if(ajax.readyState == 4) {
				div.innerHTML = ajax.responseText;
			}
		}
		ajax.send(null);
		//TempoEsconder('Newsletter');
	}
}
