function Submeter(action){
  document.form1.action = action;	
  document.form1.submit();
}

function AssistenteMarca(){
	var xmlhttp = getXmlHttpRequest();
	
	var strData = "CodMarca=" + document.getElementById("CodMarca").value;
	
	xmlhttp.open("POST", "../../adm/Produto/AssistenteMarca.php", true);
	
	xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlhttp.setRequestHeader('Content-length', strData.length);  	
	
	xmlhttp.onreadystatechange = function(){
		if (xmlhttp.readyState==4){	
			document.getElementById("CodModelo").innerHTML = "";
			document.getElementById("CodModelo").innerHTML = xmlhttp.responseText;					
		}
	}		
	
	xmlhttp.send(strData); 	
}

function getXmlHttpRequest() {
	if (window.XMLHttpRequest) {
		return new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		return new ActiveXObject("Microsoft.XMLHTTP");
	}
}

function popup(url,	width, height, baixo, direita)
{
	nova=window.open(url,"","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width="	+	width	+	",height=" + height +	",screenY=" + baixo +	",screenX=" + direita);			
}

function Passo( n, max )
{
	var maximo = max;
	var disp;
	var cla;
	
	for ( i=1; i<=maximo; i++ ) {
		if ( i == n ) {
			disp = '';
			cla = 'ligado';
		} else {
			disp = 'none';
			cla = 'desligado';
		}
		document.getElementById('passo'+i).style.display = disp;
		document.getElementById('passo'+i).className = cla;
		document.getElementById('tab'+i).className = 'tab_'+cla;
	}
}

function confirmacao(){
	var senha = document.getElementById("senha");
	var senhac = document.getElementById("senhac");
	
	if(senha.value != senhac.value){
		showError("Mensagem de Erro", "A senha de confirmação está incorreta!");
		senhac.value = '';
		senha.focus();
	}
}

function addCidade(){
	if(document.getElementById("cidade").value == 'o'){
		document.getElementById("ocidade").style.display = '';
	}else{
		document.getElementById("outracidade").value = '';
		document.getElementById("ocidade").style.display = "none";
	}
}

function putImage(path_origem,img_destino)
{
	obj = document.getElementById(img_destino);
	obj.src = path_origem;
	if(obj.width > 300) {
		obj.width = 300;
	}
	if(obj.height > 150) {
		obj.height = 150;
	}
}

 // Popup Imagens
function popUpImg(url) {
	var largura=550;
	var altura=450;
	var e=(screen.width - largura)/2;
	var t=(screen.height - altura)/2;
	
	pp = window.open(url,"popup","top="+t+",left="+e+",width="+largura+",height="+altura+",scrollbars=0");
	if (window.focus) {pp.focus()}
	//	return false;
}


function AssistenteModelo(){
	var xmlhttp = getXmlHttpRequest();
	
	var strData = "Modelo=" + document.getElementById("Modelo").value;
	
	xmlhttp.open("POST", "../../adm/Pastilha/AssistenteModelo.php", true);
	
	xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlhttp.setRequestHeader('Content-length', strData.length);  	
	
	xmlhttp.onreadystatechange = function(){
		if (xmlhttp.readyState==4){	
			document.getElementById("divano").innerHTML = "";
			document.getElementById("divano").innerHTML = xmlhttp.responseText;					
		}
	}		
	
	xmlhttp.send(strData); 	
}

function AssistenteMarca(nome){
	var xmlhttp = getXmlHttpRequest();
	
	var strData = "CodMarca=" + document.getElementById("CodMarca").value;
	
	xmlhttp.open("POST", "../../adm/"+nome+"/AssistenteMarca"+nome+".php", true);
	
	xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlhttp.setRequestHeader('Content-length', strData.length);  	
	
	xmlhttp.onreadystatechange = function(){
		if (xmlhttp.readyState==4){	
			document.getElementById("divmodelo").innerHTML = "";
			document.getElementById("divmodelo").innerHTML = xmlhttp.responseText;					
		}
	}		
	
	xmlhttp.send(strData); 	
}


