function trim(str){

    return str.replace(/^\s*/, "").replace(/\s*$/, "");

}



function verificaNf(){

    new Ajax.Request('/include/requestAjax.php',{
        method: 'get',
        parameters: "request=vernf&nnf=" + $('txtnf').value,
        onComplete: function(request){

            $('result').innerHTML = request.responseText;

        }
    });


}

function mascara(e,src,mask) {

    if(window.event) { _TXT = e.keyCode; } 

    else if(e.which) { _TXT = e.which; }

    if(_TXT > 47 && _TXT < 58) { 

 var i = src.value.length; var saida = mask.substring(0,1); var texto = mask.substring(i)

 if (texto.substring(0,1) != saida) { src.value += texto.substring(0,1); } 

    return true; } else { if (_TXT != 8) { return false; } 

 else { return true; }

    }

}




function logar(){

	

	var params = 'usuario='+$F('txtlogin')+'&senha=' + $F('txtsenha');

	

	new Ajax.Request('/include/requestAjax.php?request=login',{ method: 'get', parameters: params, onComplete: function(request){



		if(request.responseText == 0){



			alert('Login ou senha invalido!');



		}else{



//			$('logar').innerHTML = request.responseText;

			window.open('/','_parent');



		}



	}	



	});



}

//function abrirmapa(){
//
//	if (GBrowserIsCompatible()) {
//		var map = new GMap2(document.getElementById("divcontatodir"));
//		map.setCenter(new GLatLng(-22.233433,-49.972408), 15);
//	}
//
//}

String.prototype.trim=function(){
  nullo = this.replace(/^ +| +$/g,"")
  if(nullo == ""){
	  return true;
  }else{
	  return false;
  }
}

function validaForm(nomeform){

    var form = $(nomeform);
    var inputs = form.getElements();
    var result = true;
    var msg = '';
	var cont = 0;
	
    for (i in inputs) {

        if (inputs[i].className) {				
            if (inputs[i].className == 'obr-vazio') {
 		        if (inputs[i].value.trim()) {
					if(cont <= 11){		   
	                	msg = msg + " - "+ inputs[i].title + "<br />";
                    	result = false;
						cont = cont + 1;
					}
                }
				 
            }
			        
        }
    }


	 var msg = msg + '<br />';
	 
	if ($('imgerro')){
		if (trim($('imgerro').alt) == 'Nota Fiscal Errada'){

			showDialog("Erro",'Por favor digite corretamente o número da nota fiscal','warning');
			return false;
		}
	}		
	 
	if(!result){
		 showDialog('Campo abaixo s&atilde;o obrigat&oacute;rios:',msg,'warning');
		return result;
	}else{
	    return result;
	}
} 

function abrirmapa(){

	if (GBrowserIsCompatible()) {
		var map = new GMap2(document.getElementById("divmapa"));
//		map.setCenter(new GLatLng(-22.233433,-49.972408), 15);
		var point = new GLatLng(-22.233433,-49.972408);
        map.setCenter(point, 17);
        var mk = new GMarker(point);
        map.addOverlay(mk);
        GEvent.addListener(mk, 'click', function() {
            mk.openInfoWindowHtml("<b>PALG Produtos Médicos</b><br />Av. Maria Fernandes Cavallari, 655 - Sala 11<br />Cep: 17526-431<br />Jardim Cavallari - Marília/SP");
        });
        GEvent.trigger(mk,  'click');
		
	}
	runSlideShow();

}

