function loadByCep(cep){
	$("Cidade_TXT1").value = "Buscando...";
	$("Estado_CMB1").value = "Buscando...";
	
	var a = new Ajax();
	a.onLoad = function() {
		arr_retorno = this.html.split("###");
		if($("Cidade_TXT1").value == "Buscando...")
			$("Cidade_TXT1").value = arr_retorno[0];
		if($("Estado_CMB1").value == "Buscando...")
			$("Estado_CMB1").value = arr_retorno[1];
		
		for(i = 0; i < $("Estado_CMB1").length; i++){
		
			if($("Estado_CMB1").options[i].id == arr_retorno[1]){
				$("Estado_CMB1").selectedIndex = i;
				return;
			}
		}	
	}
	a.get('site/inc/routines/routines.php?rotina=endereco&cep='+cep);
}
function dropMenu(m){
	if($("m"+m).style.display = "none")
		$("m"+m).style.display = "";
}
function dropMenuOut(m){
	if($("m"+m))
		$("m"+m).style.display = "none";
}
function popLocalizacao(who){
	//var popup = new Popup(635,545);
	var popup = new Popup(650,575);
	popup.open(who);
}

function popZoom(who){
	//var popup = new Popup(635,545);
	var popup = new Popup(600,490);
	popup.open(who);
}
function popZoom2(who){
	//var popup = new Popup(635,545);
	var popup = new Popup(573,430);
	popup.open(who);
}

function buscaTxt(obj, focus){
	if(focus){
		if(obj.value == "Digite aqui o produto desejado"){
			obj.value = "";
		}
	} else {
		if(obj.value == ""){
			obj.value = "Digite aqui o produto desejado";
		}
	}
}
function zoom(args, w, h){//w padrão, h é altura da imagem
	//var p = new Popup(510,h);
	if(h < 230)
		h = 230;
	var p = new Popup(520,h+10);
	p.template = 2;
	p.open("zoomProdutos.php"+args);
}
function aboutList(){
	//var p = new Popup(511,645);
	var p = new Popup(520,655);
	p.template = 2;
	p.position = "fixed";
	p.open("aboutList.php");
}
function enviarLista(){
	var p = new Popup(511,245);
	p.template = 2;
	p.position = "fixed";
	p.open("enviarEmail.php");
}
function addLista(id){
	var a = new Ajax();
	a.onLoad = function () {
		if(this.html != ""){
			if(this.html > 0){
				alert("Produto inseridos com sucesso na sua lista!");
				var img = parent.document.getElementById("IMGconfira_lista");
				if(img)
					img.style.display = "";
			} else {
				alert("Por alguma razão a lista está vazia. Contate os administradores do sistema.");
			}
		} else {
			alert("Desculpe, ocorreu um problema na hora de inserir na lista... por favor, contate os administradores do site.");
		}
	}
	a.get("site/inc/routines/routines.php?rotina=addItemList&item="+id);
}
function openList(){
	window.location = "lista_produto.php";
}
function refreshList(){
	var arrChecks = document.getElementsByName("chkLista");
	var news = "";
	var novo = false;
	for(x=0;x<arrChecks.length;x++){
		if(arrChecks[x].checked){
			if(novo){
				news += ",";
			}
			news += arrChecks[x].value;
			novo = true;
		}
	}
	if(news == ""){
		alert("Por favor, selecione ao menos um item para ser inserido na lista.");
	} else {
		var a = new Ajax();
		a.onLoad = function () {
			if(this.html != ""){
				if(this.html > 0){
					alert("Produto(s) inseridos com sucesso na sua lista!");
					var img = parent.document.getElementById("IMGconfira_lista");
					if(img)
						img.style.display = "";
				} else {
					alert("Por alguma razão a lista está vazia. Contate os administradores do sistema.");
				}
			} else {
				alert("Desculpe, ocorreu um problema na hora de inserir na lista... por favor, contate os administradores do site.");
			}
		}
		a.get("site/inc/routines/routines.php?rotina=addArrayList&listaPro="+news);
	}
}