function GAddress( a, c ) {  var xmlhttp = false;  	try {   xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");  		} catch (e) {   	try {    xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");   } 	catch (E) {    xmlhttp = false;   }  }  if (!xmlhttp && typeof XMLHttpRequest!='undefined') {    xmlhttp = new XMLHttpRequest(); }  var l = new Array();  xmlhttp.open("GET", "gaddress.cgi?a=" + escape(a), true);  
  xmlhttp.onreadystatechange=function() 
  {   
    if (xmlhttp.readyState==4) 
    {    
        l = xmlhttp.responseText.split(',');    
        
        if ( l[0] == '' )      
            c( null, a );    
        else      
            c( new GPoint( l[0] - 0, l[1] - 0 ), a );   
    }  
  }  
  
  xmlhttp.send(null)
}

function LimpaCampo(variavel, valor)
{
	if(valor == 'E-mail')
        document.getElementById(variavel).value = "";
    
    if(valor == 'Senha' && variavel == 'ucLogin_txt_Senha')
    {
        document.getElementById('ucLogin_Senhas').style.display = 'none';
        document.getElementById(variavel).style.display = '';
        document.getElementById(variavel).focus();
    }
    
    if(valor == 'Senha' && variavel == 'ucLogin_txtSenha')
    {
        document.getElementById('ucLogin_Senha').style.display = 'none';
        document.getElementById(variavel).style.display = '';
        document.getElementById(variavel).focus();
    }
    
    if(valor == 'Senha' && variavel == 'txtSenha')
    {
        document.getElementById('Senha').style.display = 'none';
        document.getElementById(variavel).style.display = '';
        document.getElementById(variavel).focus();
    }
        
	if(valor == 'Nome do Restaurante')
	    document.getElementById(variavel).value = "";
}
		
		
function Botao_of(ident){
	imagem = "http://www.mesaexpress.com.br/Images/"+ident+".gif"
	document.getElementById(ident).background = imagem
}

function Botao_on(ident){
	imagem = "http://www.mesaexpress.com.br/Images/"+ident+"_on.gif"
	document.getElementById(ident).background = imagem
}

		
function mostraStarAmbiente(ident){

    imagem_off = "http://www.mesaexpress.com.br/images/star_off.gif"
	imagem_on = "http://www.mesaexpress.com.br/images/star_on.gif"
	
	imagem0_off = "http://www.mesaexpress.com.br/images/star_off.gif"
	imagem0_on = "http://www.mesaexpress.com.br/images/star0_on.gif"

    if(ident == '1_star0')
    {
	    document.getElementById('1_star0').background = imagem0_on
	    document.getElementById('1_star1').background = imagem_off
	    document.getElementById('1_star2').background = imagem_off
	    document.getElementById('1_star3').background = imagem_off
	    document.getElementById('1_star4').background = imagem_off
	    document.getElementById('1_star5').background = imagem_off
	    document.getElementById('varAmbiente').value = '0';
    }
    
    if(ident == '1_star1')
    {
	    document.getElementById('1_star0').background = imagem0_off
	    document.getElementById('1_star1').background = imagem_on
	    document.getElementById('1_star2').background = imagem_off
	    document.getElementById('1_star3').background = imagem_off
	    document.getElementById('1_star4').background = imagem_off
	    document.getElementById('1_star5').background = imagem_off
	    document.getElementById('varAmbiente').value = '1';
    }

    if(ident == '1_star2')
    {
	    document.getElementById('1_star0').background = imagem0_off
	    document.getElementById('1_star1').background = imagem_on
	    document.getElementById('1_star2').background = imagem_on
	    document.getElementById('1_star3').background = imagem_off
	    document.getElementById('1_star4').background = imagem_off
	    document.getElementById('1_star5').background = imagem_off
	    document.getElementById('varAmbiente').value = '2';
    }
    
    if(ident == '1_star3')
    {
	    document.getElementById('1_star0').background = imagem0_off
	    document.getElementById('1_star1').background = imagem_on
	    document.getElementById('1_star2').background = imagem_on
	    document.getElementById('1_star3').background = imagem_on
	    document.getElementById('1_star4').background = imagem_off
	    document.getElementById('1_star5').background = imagem_off
	    document.getElementById('varAmbiente').value = '3';
    }

    if(ident == '1_star4')
    {
	    document.getElementById('1_star0').background = imagem0_off
	    document.getElementById('1_star1').background = imagem_on
	    document.getElementById('1_star2').background = imagem_on
	    document.getElementById('1_star3').background = imagem_on
	    document.getElementById('1_star4').background = imagem_on
	    document.getElementById('1_star5').background = imagem_off
	    document.getElementById('varAmbiente').value = '4';
    }

    if(ident == '1_star5')
    {
	    document.getElementById('1_star0').background = imagem0_off
	    document.getElementById('1_star1').background = imagem_on
	    document.getElementById('1_star2').background = imagem_on
	    document.getElementById('1_star3').background = imagem_on
	    document.getElementById('1_star4').background = imagem_on
	    document.getElementById('1_star5').background = imagem_on
	    document.getElementById('varAmbiente').value = '5';
    }
}

function mostraStarComida(ident){

    imagem_off = "http://www.mesaexpress.com.br/images/star_off.gif"
	imagem_on = "http://www.mesaexpress.com.br/images/star_on.gif"
	
	imagem0_off = "http://www.mesaexpress.com.br/images/star_off.gif"
	imagem0_on = "http://www.mesaexpress.com.br/images/star0_on.gif"

    if(ident == '2_star0')
    {
	    document.getElementById('2_star0').background = imagem0_on
	    document.getElementById('2_star1').background = imagem_off
	    document.getElementById('2_star2').background = imagem_off
	    document.getElementById('2_star3').background = imagem_off
	    document.getElementById('2_star4').background = imagem_off
	    document.getElementById('2_star5').background = imagem_off
	    document.getElementById('varComida').value = '0';
    }
    
    if(ident == '2_star1')
    {
	    document.getElementById('2_star0').background = imagem0_off
	    document.getElementById('2_star1').background = imagem_on
	    document.getElementById('2_star2').background = imagem_off
	    document.getElementById('2_star3').background = imagem_off
	    document.getElementById('2_star4').background = imagem_off
	    document.getElementById('2_star5').background = imagem_off
	    document.getElementById('varComida').value = '1';
    }

    if(ident == '2_star2')
    {
	    document.getElementById('2_star0').background = imagem0_off
	    document.getElementById('2_star1').background = imagem_on
	    document.getElementById('2_star2').background = imagem_on
	    document.getElementById('2_star3').background = imagem_off
	    document.getElementById('2_star4').background = imagem_off
	    document.getElementById('2_star5').background = imagem_off
	    document.getElementById('varComida').value = '2';
    }
    
    if(ident == '2_star3')
    {
	    document.getElementById('2_star0').background = imagem0_off
	    document.getElementById('2_star1').background = imagem_on
	    document.getElementById('2_star2').background = imagem_on
	    document.getElementById('2_star3').background = imagem_on
	    document.getElementById('2_star4').background = imagem_off
	    document.getElementById('2_star5').background = imagem_off
	    document.getElementById('varComida').value = '3';
    }

    if(ident == '2_star4')
    {
	    document.getElementById('2_star0').background = imagem0_off
	    document.getElementById('2_star1').background = imagem_on
	    document.getElementById('2_star2').background = imagem_on
	    document.getElementById('2_star3').background = imagem_on
	    document.getElementById('2_star4').background = imagem_on
	    document.getElementById('2_star5').background = imagem_off
	    document.getElementById('varComida').value = '4';
    }

    if(ident == '2_star5')
    {
	    document.getElementById('2_star0').background = imagem0_off
	    document.getElementById('2_star1').background = imagem_on
	    document.getElementById('2_star2').background = imagem_on
	    document.getElementById('2_star3').background = imagem_on
	    document.getElementById('2_star4').background = imagem_on
	    document.getElementById('2_star5').background = imagem_on
	    document.getElementById('varComida').value = '5';
    }
}

function mostraStarServico(ident){

    imagem_off = "http://www.mesaexpress.com.br/images/star_off.gif"
	imagem_on = "http://www.mesaexpress.com.br/images/star_on.gif"
	
	imagem0_off = "http://www.mesaexpress.com.br/images/star_off.gif"
	imagem0_on = "http://www.mesaexpress.com.br/images/star0_on.gif"

    if(ident == '3_star0')
    {
	    document.getElementById('3_star0').background = imagem0_on
	    document.getElementById('3_star1').background = imagem_off
	    document.getElementById('3_star2').background = imagem_off
	    document.getElementById('3_star3').background = imagem_off
	    document.getElementById('3_star4').background = imagem_off
	    document.getElementById('3_star5').background = imagem_off
	    document.getElementById('varServico').value = '0';
    }
    
    if(ident == '3_star1')
    {
	    document.getElementById('3_star0').background = imagem0_off
	    document.getElementById('3_star1').background = imagem_on
	    document.getElementById('3_star2').background = imagem_off
	    document.getElementById('3_star3').background = imagem_off
	    document.getElementById('3_star4').background = imagem_off
	    document.getElementById('3_star5').background = imagem_off
	    document.getElementById('varServico').value = '1';
    }

    if(ident == '3_star2')
    {
	    document.getElementById('3_star0').background = imagem0_off
	    document.getElementById('3_star1').background = imagem_on
	    document.getElementById('3_star2').background = imagem_on
	    document.getElementById('3_star3').background = imagem_off
	    document.getElementById('3_star4').background = imagem_off
	    document.getElementById('3_star5').background = imagem_off
	    document.getElementById('varServico').value = '2';
    }
    
    if(ident == '3_star3')
    {
	    document.getElementById('3_star0').background = imagem0_off
	    document.getElementById('3_star1').background = imagem_on
	    document.getElementById('3_star2').background = imagem_on
	    document.getElementById('3_star3').background = imagem_on
	    document.getElementById('3_star4').background = imagem_off
	    document.getElementById('3_star5').background = imagem_off
	    document.getElementById('varServico').value = '3';
    }

    if(ident == '3_star4')
    {
	    document.getElementById('3_star0').background = imagem0_off
	    document.getElementById('3_star1').background = imagem_on
	    document.getElementById('3_star2').background = imagem_on
	    document.getElementById('3_star3').background = imagem_on
	    document.getElementById('3_star4').background = imagem_on
	    document.getElementById('3_star5').background = imagem_off
	    document.getElementById('varServico').value = '4';
    }

    if(ident == '3_star5')
    {
	    document.getElementById('3_star0').background = imagem0_off
	    document.getElementById('3_star1').background = imagem_on
	    document.getElementById('3_star2').background = imagem_on
	    document.getElementById('3_star3').background = imagem_on
	    document.getElementById('3_star4').background = imagem_on
	    document.getElementById('3_star5').background = imagem_on
	    document.getElementById('varServico').value = '5';
    }
}

function CheckAllDataGridCheckBoxes(aspCheckBoxID, checkVal) 
{
    re = new RegExp(':' + aspCheckBoxID + '$');  // generated control name starts with a colon
    
    for(i = 0; i < document.Form1.elements.length; i++) {

        elm = document.forms[0].elements[i];           

        if (elm.type == 'checkbox') {

            if (re.test(elm.name)) {

                elm.checked = checkVal;
            }
        }
    }
}

function Numero(d_len, d_pt, t_pt)
{
  var d_len = d_len || 0;
  var d_pt = d_pt || ".";
  var t_pt = t_pt || ",";
  if ((typeof d_len != "number")
    || (typeof d_pt != "string")
    || (typeof t_pt != "string")) {
    throw new Error("wrong parameters for method 'String.pad()'.");
  }
  var integer = "", decimal = "";
  var n = new String(this).split(/\./), i_len = n[0].length, i = 0;
  if (d_len > 0) {
    n[1] = (typeof n[1] != "undefined") ? n[1].substr(0, d_len) : "";
    decimal = d_pt.concat(n[1].pad(d_len, "0", String.PAD_RIGHT));
  }
  while (i_len > 0) {
    if ((++i % 3 == 1) && (i_len != n[0].length)) {
      integer = t_pt.concat(integer);
    }
    integer = n[0].substr(--i_len, 1).concat(integer);
  }
  return (integer + decimal);
}

function Limpar(valor, validos) 
{
	// retira caracteres invalidos da string
	var result = "";
	var aux;
	
	for (var i=0; i < valor.length; i++) {
		aux = validos.indexOf(valor.substring(i, i+1));
		
		if (aux>=0) {
			result += aux;
		}
	}
	return result;
}

//Formata número tipo moeda usando o evento onKeyDown
function FormataMoeda(campo,tammax,teclapres,decimal) 
{
	var tecla = teclapres.keyCode;
	vr = Limpar(campo.value,"0123456789");
	tam = vr.length;
	dec=decimal

	if (tam < tammax && tecla != 8){ tam = vr.length + 1 ; }

	if (tecla == 8 ) {
		tam = tam - 1 ; 
	}

	if ( tecla == 8 || tecla >= 48 && tecla <= 57 || tecla >= 96 && tecla <= 105 )
	{
		if ( tam <= dec ) { 
			campo.value = vr ; 
		}

		if ( (tam > dec) && (tam <= 8) ) {
			campo.value = vr.substr( 0, tam - 5 ) + "." + vr.substr( tam - dec, tam ) ; 
		}

		if ( (tam >= 8) && (tam <= 11) ) {
			campo.value = vr.substr( 0, tam - 11 ) + "," + vr.substr( tam - 8, 3 ) + "." + vr.substr( tam - dec, tam ) ; 
		}

		if ( (tam >= 11) && (tam <= 14) ) {
			campo.value = vr.substr( 0, tam - 14 ) + "," + vr.substr( tam - 11, 3 ) + "," + vr.substr( tam - 8, 3 ) + "." + vr.substr( tam - dec, tam ) ; 
		}

		if ( (tam >= 14) && (tam <= 17) ) 
		{
			campo.value = vr.substr( 0, tam - 17 ) + "," + vr.substr( tam - 14, 3 ) + "," + vr.substr( tam - 11, 3 ) + "," + vr.substr( tam - 8, 3 ) + "." + vr.substr( tam - dec, tam ) ; 
		}

		if ( (tam >= 17) && (tam <= 20) ) 
		{
			campo.value = vr.substr( 0, tam - 20 ) + "," + vr.substr( tam - 17, 3 ) + "," + vr.substr( tam - 14, 3 ) + "," + vr.substr( tam - 11, 3 ) + "," + vr.substr( tam - 8, 3 ) + "." + vr.substr( tam - 5, tam ) ;
		}
	} 
}


//Formata número usando o evento onKeyDown
function FormataNumero(campo,tammax,teclapres,decimal) 
{
	var tecla = teclapres.keyCode;
	vr = Limpar(campo.value,"0123456789");
	tam = vr.length;
	dec=decimal

	if (tam < tammax && tecla != 8){ tam = vr.length + 1 ; }

	if (tecla == 8 ) {
		tam = tam - 1 ; 
	}

	if ( tecla == 8 || tecla >= 48 && tecla <= 57 || tecla >= 96 && tecla <= 105 )
	{
		if ( tam <= dec ) { 
			campo.value = vr ; 
		}

		if ( (tam > dec) && (tam <= 6) ) {
			campo.value = vr.substr( 0, tam - 3 ) + "," + vr.substr( tam - dec, tam ) ; 
		}

		if ( (tam >= 7) && (tam <= 9) ) {
			campo.value = vr.substr( 0, tam - 6 ) + "," + vr.substr( tam - 6, 3 ) + "," + vr.substr( tam - dec, tam ) ; 
		}

		if ( (tam >= 10) && (tam <= 12) ) {
			campo.value = vr.substr( 0, tam - 9 ) + "," + vr.substr( tam - 9, 3 ) + "," + vr.substr( tam - 6, 3 ) + "," + vr.substr( tam - dec, tam ) ; 
		}

		if ( (tam >= 13) && (tam <= 15) ) 
		{
			campo.value = vr.substr( 0, tam - 12 ) + "," + vr.substr( tam - 12, 3 ) + "," + vr.substr( tam - 9, 3 ) + "," + vr.substr( tam - 6, 3 ) + "," + vr.substr( tam - dec, tam ) ; 
		}

		if ( (tam >= 16) && (tam <= 18) ) 
		{
			campo.value = vr.substr( 0, tam - 15 ) + "," + vr.substr( tam - 15, 3 ) + "," + vr.substr( tam - 12, 3 ) + "," + vr.substr( tam - 9, 3 ) + "," + vr.substr( tam - 6, 3 ) + "," + vr.substr( tam - 3, tam ) ;
		}
	} 
}


function FormataNumero2(valor) 
{
	var vMilhar, vAux, vDivMil, vDec;
	vAux = "";
	vDivMil = 1;
	valor = f_sPassaFloat(valor);
	valor = valor.toString();

	if (valor.indexOf(".")==-1)
	{
		vMilhar = valor.length;
		vDec = "00";
	}
	else 
	{
		vMilhar = valor.indexOf(".");
		vDec = valor.substr(vMilhar+1,2);
		
		if (vDec.length==1)
		{
			vDec = vDec+"0";
		}
	}

    vMilhar = valor.substr(0,vMilhar);

	if (vMilhar.length>3)
	{
		for (var i = vMilhar.length-1; i >=0; i--)
		{
			vAux = vMilhar.charAt(i) + vAux;

			if (vDivMil==3)
			{
				vAux = "." + vAux;
				vDivMil = 0;
			}
			vDivMil = vDivMil + 1;
		}
	
		if (vAux.charAt(0)=="-")
		{
			if (vAux.charAt(1)==".")
			{
				vAux =  "-" + vAux.substr(2,vAux.length);
			}
		}

		if (vAux.charAt(0)==".")
		{
			vAux =  vAux.substr(1,vAux.length);
		}
	} 
    else 
    {
	    vAux = vMilhar;
	}

    valor = vAux + "," + vDec;
	return valor;                                        
}

function openCombobox() {
    cmbAtivo.open();
}

function getWordDescription() {            
    var sWord = cmbAtivo.getText();
    ob_post.AddParam("sWord", sWord);
    ob_post.post(null, "GetWordDescription", loadWordDescription);                
}

function loadWordDescription(sWordDescription) {
	
    // document.getElementById("divWordInformation").innerHTML = "<span class='tdText' style='white-space: wrap;width:325px;'><b>" + cbo1.getText() + "</b><br /><br /><br />" + sWordDescription.replace(/\n/g, "<br />").replace(/\r\n/g, "<br />") + "</span>";
}            

function mascara_data(data)
{
 
	var mydata = ''; 
	mydata = mydata + data; 
	
	if (mydata.length == 2)
	{
		mydata = mydata + '/';
	}
	
	if (mydata.length == 5){ 
		mydata = mydata + '/'; 
	}
	
	return mydata; 
}

function verifica_data(data) 
{
	if (data.value != "") 
	{
		dia = (data.value.substring(0,2));
		mes = (data.value.substring(3,5)); 
		ano = (data.value.substring(6,10)); 
		situacao = ""; 
			if ((dia < 01)||(dia < 01 || dia > 30) && (  mes == 04 || mes == 06 || mes == 09 || mes == 11 ) || dia > 31) 
			{ 
				situacao = "falsa"; 
			} 
		if (mes < 01 || mes > 12 ) { 
			situacao = "falsa"; 
		}
		if (mes == 2 && ( dia < 01 || dia > 29 || ( dia > 28 && (parseInt(ano / 4) != ano / 4)))) 
		{
			situacao = "falsa"; 
		}
		
		if (situacao == "falsa") 
		{
			data.focus();
			data.select();
			alert("Data inválida!"); 
		}
	} 
}

counter = 0;

function slideIt()
{
    if (document.all)
    {
        banner.style.clip = "rect(0," + counter + ",640,0)"; 
    }
        
    if (document.layers)
    { 
        document.banner.clip.top = 0;
        document.banner.clip.right = counter;
        document.banner.clip.bottom = 480;
        document.banner.clip.left = 0; 
    }
    
    counter += 10;
    time_out = setTimeout("slideIt()", 80);

    if (counter >= 640)
    { 
        clearTimeout(time_out); 
    }
}

function slideIt2()
{
alert('oi');
    if (document.all)
    {
        banner.style.clip = "rect(0," + counter + ", 640,0)"; 
    }
        
    if (document.layers)
    { 
        document.banner.clip.top = 0;
        document.banner.clip.right = counter;
        document.banner.clip.bottom = 100;
        document.banner.clip.left = 0; 

    }
    
    counter += 10;
    time_out = setTimeout("slideIt()", 60);
    
    if (counter >= 800)
    { 
        clearTimeout(time_out);

    }
}