function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

function openWindow(pURL)
{
	myWindow = window.open(pURL, "myLittleCalendar", 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=170,height=200');
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function checkReturn(event){
   var key = event.keyCode;
   if(key == 13){
     document.formLogin.submit();
   } 
}

function getHTTPObject(){
  var xmlHttp = "";
  try{
    xmlHttp = new XMLHttpRequest();
  }catch(ee){
    try{
        xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
    }catch(e){
        try{
            xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
        }catch(E){
            xmlHttp = false;
        }
    }
  }
  return xmlHttp;
}



function getMetodo() {
	var metoto;
	// Mozilla, Firefox, Safari, e Netscape
	if (window.XMLHttpRequest){
		try {
			metodo = "GET";
		} catch(e) {
			metodo = false;
		}
		return metodo;
	}
	// Internet Explorer
	if (window.ActiveXObject) {
		try {
			metodo = "POST"; 
		} catch(e) {
			try {
				metodo = "POST"; 
			} catch(e) {
				try {
					metodo = "POST";
				} catch(e) {
					try {
						metodo = "POST"; 
					} catch(e) {
						metodo = false;
					}
				}
			}
		}
		return metodo;
	}
	alert("Objeto XMLHTTP nao e suportado pelo navegador.");
  }
  function verificaParceiro(){
  	vSel = document.getElementById('partner');
  	if (parseFloat(vSel.value) != ""){
    	var vRetorno = "";
  	  url = "ajax_consultas.php?partner="+vSel.value;
  	  ometodo = getMetodo();
  	  xmlhttp = getHTTPObject();
  	  xmlhttp.open(ometodo,url,true);
  	  xmlhttp.onreadystatechange=function(){
  	    if(xmlhttp.readyState == 1) {
  	       document.getElementById ( "parceiro"). innerHTML = "Carregando..." ; 
  	    }
    		if(xmlhttp.readyState == 4) {
    		  vRetorno = xmlhttp.responseText;
    		  MontaSelect(vRetorno,'parceiro');
    		}
  	  }
  	  xmlhttp.send(null);
  	}
  }
  
  
  function MontaSelect(vStr,vSel){
	  var vSelectItem = document.getElementById(vSel);
	  var msg = "";
	  
	  if(vStr != 0){
  	  msg = "Código aceito com sucesso!";
	  }else {
	    msg = "Código incorreto. Por favor verifique novamente o Código Promocional.";
	  }
	  vSelectItem.innerHTML = msg;
	  document.getElementById('msgErrorTable').style.display="block";
  	
  }
