function buscaproduto(id, tipo) {
	if(id != "") {
		if(tipo=="categoria"){
			window.location = 'prod.php?centro=vercategoria.php&'+tipo+'='+id.value;
		}
		else{
			window.location = 'prod.php?centro=resultadobusca.php&'+tipo+'='+id.value;
		}
	}
}
function addqtide(id, quantidade){
	if (!id){
		window.alert=('Não ta passando o id!');
	}
	if(quantidade){
		window.location = 'prod.php?centro=vercarrinho.php&ip='+id+'&qtde='+quantidade;
	}
}

//////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////
//  função q abre popup com o tamanho da foto
//  @largura -> largura da imagem a ser aberta
//  @altura -> altura da imagem a ser aberta
//  @foto -> caminho da foto desde a raiz
//
//////////////////////////////////////////////////////////////
function popup(largura, altura, foto) {
	var winl = (screen.width - largura) / 2;
    var wint = (screen.height - altura) / 2;
	winprops = 'height='+altura+',width='+largura+',top='+wint+',left='+winl+',scrollbars=yes,noresizable,status=no, location=no, toolbar=no, menubar=no'
	window.open ("popup/popup.php?foto="+foto, "Popup", winprops );
}

function abreformamigo(largura, altura, foto) {
	var winl = (screen.width - largura) / 2;
    var wint = (screen.height - altura) / 2;
	winprops = 'height='+altura+',width='+largura+',top='+wint+',left='+winl+',scrollbars=yes,noresizable,status=no, location=no, toolbar=no, menubar=no'
	window.open ("popup/abre.php?arquivo="+foto, "Popup", winprops );
}
////////////////////////////////////////////////////////////////////////////////////
// Função para fazer uma div aparecer e esconder a outra que está aberta
//
// @param divescondida (string) -> nome da div que vai aparecer
//
////////////////////////////////////////////////////////////////////////////////////
function showonehideothers(divescondida) {
	if(document.getElementById(divescondida).style.display == "none") {
		document.getElementById(divescondida).style.display = "block";
	}
	else{
		document.getElementById(divescondida).style.display = "none";
	}
}



function verificaNumeracao(campo){
	var checado=null;
	jQuery.each(jQuery('input[name=numeracao]'), function(){
	    if(this.checked==true){
	    	checado=true
	        window.location=campo.href+'&numero='+this.value;
	    	return true;
	    }
	});
	if(!checado){
		alert('Selecione a numeração desejada.');
	}
		
	return false;
}

function verificaTamanho(campo){
	var checado=null;
	jQuery.each(jQuery('input[name=tamanho]'), function(){
	    if(this.checked==true){
	    	checado=true
	        window.location=campo.href+'&tamanho='+this.value;
	    	return true;
	    }
	});
	if(!checado){
		alert('Selecione o tamanho desejado.');
	}
		
	return false;
}

