

///////////////////////// AJAX CHECK LOGIN INICIO /////////////////////////
//Browser Support Code
function ajaxFunction(){
var ajaxRequest;  // The variable that makes Ajax possible!
try{
// Opera 8.0+, Firefox, Safari
ajaxRequest = new XMLHttpRequest();
} catch (e){
// Internet Explorer Browsers
try{
ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try{
ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e){
// Something went wrong
alert("Your browser broke!");
return false;
}
}
}
// Create a function that will receive data sent from the server
ajaxRequest.onreadystatechange = function(){
if(ajaxRequest.readyState == 4){
var ajaxDisplay = document.getElementById('ajaxDiv');
ajaxDisplay.innerHTML = ajaxRequest.responseText;
}
}
var login_cliente = document.getElementById('login_cliente').value;
var queryString = "?login_cliente=" + login_cliente ;
ajaxRequest.open("GET", "checa_login.asp" + queryString, true);
ajaxRequest.send(null); 
}
///////////////////////// AJAX CHECK LOGIN FIM /////////////////////////




///////////////////////// AVISA CAPS LOCK INICIO /////////////////////////
function checkCapsLock( e ) {
var myKeyCode=0;
var myShiftKey=false;
var myMsg='Caps Lock ligado.\n\nDesligue-o para evitar erros.';
// Internet Explorer 4+
if ( document.all ) {
myKeyCode=e.keyCode;
myShiftKey=e.shiftKey;
// Netscape 4
} else if ( document.layers ) {
myKeyCode=e.which;
myShiftKey=( myKeyCode == 16 ) ? true : false;
// Netscape 6
} else if ( document.getElementById ) {
myKeyCode=e.which;
myShiftKey=( myKeyCode == 16 ) ? true : false;
}
// Upper case letters are seen without depressing the Shift key, therefore Caps Lock is on
if ( ( myKeyCode >= 65 && myKeyCode <= 90 ) && !myShiftKey ) {
alert( myMsg );
// Lower case letters are seen while depressing the Shift key, therefore Caps Lock is on
} else if ( ( myKeyCode >= 97 && myKeyCode <= 122 ) && myShiftKey ) {
alert( myMsg );
}
}
///////////////////////// AVISA CAPS LOCK FIM /////////////////////////




///////////////////////// INICIO MENU LISTA /////////////////////////
var isDOM=document.getElementById?1:0,isIE=document.all?1:0,isNS4=navigator.appName=='Netscape'&&!isDOM?1:0,isOp=self.opera?1:0,isDyn=isDOM||isIE||isNS4;function getRef(i,p){p=!p?document:p.navigator?p.document:p;return isIE?p.all[i]:isDOM?(p.getElementById?p:p.ownerDocument).getElementById(i):isNS4?p.layers[i]:null};function getSty(i,p){var r=getRef(i,p);return r?isNS4?r:r.style:null};if(!self.LayerObj)var LayerObj=new Function('i','p','this.ref=getRef(i,p);this.sty=getSty(i,p);return this');function getLyr(i,p){return new LayerObj(i,p)};function LyrFn(n,f){LayerObj.prototype[n]=new Function('var a=arguments,p=a[0],px=isNS4||isOp?0:"px";with(this){'+f+'}')};LyrFn('x','if(!isNaN(p))sty.left=p+px;else return parseInt(sty.left)');LyrFn('y','if(!isNaN(p))sty.top=p+px;else return parseInt(sty.top)');if(!self.page)var page={win:self,minW:0,minH:0,MS:isIE&&!isOp};page.elmPos=function(e,p){var x=0,y=0,w=p?p:this.win;e=e?(e.substr?(isNS4?w.document.anchors[e]:getRef(e,w)):e):p;if(isNS4){if(e&&(e!=p)){x=e.x;y=e.y};if(p){x+=p.pageX;y+=p.pageY}}else if(e&&e.focus&&e.href&&this.MS&&navigator.platform.indexOf('Mac')>-1){e.onfocus=new Function('with(event){self.tmpX=clientX-offsetX;self.tmpY=clientY-offsetY}');e.focus();x=tmpX;y=tmpY;e.blur()}else while(e){x+=e.offsetLeft;y+=e.offsetTop;e=e.offsetParent}return{x:x,y:y}};function FSMenu(myName,nested,cssProp,cssVis,cssHid){this.myName=myName;this.nested=nested;this.cssProp=cssProp;this.cssVis=cssVis;this.cssHid=cssHid;this.cssLitClass='';this.menus={root:new FSMenuNode('root',this)};this.menuToShow=[];this.mtsTimer=null;this.showDelay=0;this.hideDelay=500};FSMenu.prototype.show=function(mN){with(this){menuToShow=arguments;clearTimeout(mtsTimer);mtsTimer=setTimeout(myName+'.menus.root.over()',10)}};FSMenu.prototype.hide=function(mN){with(this){clearTimeout(mtsTimer);if(menus[mN])menus[mN].out()}};function FSMenuNode(id,obj){this.id=id;this.obj=obj;this.lyr=this.child=this.args=this.par=this.timer=null;var node=this;this.over=function(evt){with(node)with(obj){if(isNS4&&evt&&lyr.ref)lyr.ref.routeEvent(evt);clearTimeout(timer);if(menuToShow){clearTimeout(mtsTimer);var a=menuToShow,m=a[0];menuToShow=null;if(!menus[m]||!menus[m].lyr.ref)menus[m]=new FSMenuNode(m,obj);var c=menus[m];if(c==node)return;clearTimeout(c.timer);if(c!=child&&c.lyr.ref){c.args=a;c.par=node;if(showDelay)c.timer=setTimeout(myName+'.menus["'+c.id+'"].show()',showDelay);else c.show()}}if(!nested&&par)par.over()}};this.out=function(evt){with(node)with(obj){if(isNS4&&evt&&lyr&&lyr.ref)lyr.ref.routeEvent(evt);clearTimeout(timer);timer=setTimeout(myName+'.menus["'+id+'"].hide()',hideDelay);if(!nested&&par)par.out()}};if(id!='root')with(this)with(lyr=getLyr(id))if(ref){if(ref.addEventListener){ref.addEventListener('mouseover',this.over,false);ref.addEventListener('mouseout',this.out,false)}else{if(isNS4)ref.captureEvents(Event.MOUSEOVER|Event.MOUSEOUT);ref.onmouseover=this.over;ref.onmouseout=this.out}}};FSMenuNode.prototype.show=function(){with(this)with(obj){if(!par)return;if(par.child&&par.child!=this)par.child.hide();par.child=this;var offR=args[1],offX=args[2],offY=args[3],lX=0,lY=0,doX=''+offX!='undefined',doY=''+offY!='undefined';if(offR&&(doX||doY)){with(page.elmPos(offR,par.lyr?par.lyr.ref:0))lX=x,lY=y;if(doX)lyr.x(lX+eval(offX));if(doY)lyr.y(lY+eval(offY))}if(offR&&cssLitClass&&!isNS4)offR.className+=(offR.className?' ':'')+cssLitClass;lyrVis(1)}};FSMenuNode.prototype.hide=function(){with(this)with(obj){if(!par)return;if(isNS4&&self.isMouseIn&&isMouseIn(lyr.ref))return show();if(args[1]&&cssLitClass&&!isNS4)args[1].className=args[1].className.replace(new RegExp('\\s*'+cssLitClass+'$'),'');if(lyr)lyrVis(0);if(child)child.hide();if(par&&par.child==this)par.child=null;par=null}};FSMenuNode.prototype.lyrVis=function(sh){with(this)with(obj){lyr.sty[cssProp]=sh?cssVis:cssHid}};if(isNS4){var fsmMouseX,fsmMouseY,fsmOR=self.onresize,nsWinW=innerWidth,nsWinH=innerHeight;document.fsmMM=document.onmousemove;self.onresize=function(){if(fsmOR)fsmOR();if(nsWinW!=innerWidth||nsWinH!=innerHeight)location.reload()};document.captureEvents(Event.MOUSEMOVE);document.onmousemove=function(e){fsmMouseX=e.pageX;fsmMouseY=e.pageY;return document.fsmMM?document.fsmMM(e):document.routeEvent(e)};function isMouseIn(sty){with(sty)return((fsmMouseX>left)&&(fsmMouseX<left+clip.width)&&(fsmMouseY>top)&&(fsmMouseY<top+clip.height))}}

var divMenu = new FSMenu('divMenu', false, 'visibility', 'visible', 'hidden');
divMenu.cssLitClass = 'h_highlighted';
///////////////////////// FIM MENU LISTA /////////////////////////




///////////////////////// INICIO MASCARAS /////////////////////////
function mascara(o,f){
v_obj=o;
v_fun=f;
setTimeout("execmascara()",1);
}

function execmascara(){
v_obj.value=v_fun(v_obj.value);
}

function leech(v){
v=v.replace(/o/gi,"0");
v=v.replace(/i/gi,"1");
v=v.replace(/z/gi,"2");
v=v.replace(/e/gi,"3");
v=v.replace(/a/gi,"4");
v=v.replace(/s/gi,"5");
v=v.replace(/t/gi,"7");
return v
}

function soNumeros(v){
return v.replace(/\D/g,"");
}
	
function telefone(v){
v=v.replace(/\D/g,"");
v=v.replace(/^(\d\d)(\d)/g,"($1) $2");
v=v.replace(/(\d{4})(\d)/,"$1-$2");
return v
}
	
function cpf(v){
v=v.replace(/\D/g,"");
v=v.replace(/(\d{3})(\d)/,"$1.$2");
v=v.replace(/(\d{3})(\d)/,"$1.$2");
v=v.replace(/(\d{3})(\d{1,2})$/,"$1-$2");
return v
}

function cnpj(v){
v=v.replace(/\D/g,"");
v=v.replace(/^(\d{2})(\d)/,"$1.$2");
v=v.replace(/^(\d{2})\.(\d{3})(\d)/,"$1.$2.$3");
v=v.replace(/\.(\d{3})(\d)/,".$1/$2");
v=v.replace(/(\d{4})(\d)/,"$1-$2");
return v
}
///////////////////////// FIM MASCARAS /////////////////////////




///////////////////////// INICIO CADASTRO /////////////////////////
function formCadastro(frm){
if($('TipoPessoa_2').checked==true){
		
if($('razaosocial_cliente').value==''){
alert('Informe a Razão Social');	
$('razaosocial_cliente').focus();
return false;
}
			
if($('cnpj_cliente').value==''){
alert('Informe o Cnpj');	
$('cnpj_cliente').focus();
return false;
}

}
if($('nome_cliente').value==''){
alert('Informe o Nome');	
$('nome_cliente').focus();
return false;
}
		
if($('cpf_cliente').value==''){
alert('Informe o Cpf');	
$('cpf_cliente').focus();
return false;
}
		
if($('endereco_cliente').value==''){
alert('Informe o Endereço');	
$('endereco_cliente').focus();
return false;
}
	
if($('numero_cliente').value==''){
alert('Informe o Número');	
$('numero_cliente').focus();
return false;
}
		
if($('bairro_cliente').value==''){
alert('Informe o Bairro');	
$('bairro_cliente').focus();
return false;
}
		
if($('cidade_cliente').value==''){
alert('Informe a Cidade');	
$('cidade_cliente').focus();
return false;
}
		
if($('telefone_cliente').value=='' && $('celular_cliente').value==''){
alert('Informe um Telefone');	
$('telefone_cliente').focus();
return false;
}
		
if($('email_cliente').value=='' || $('email_cliente').value.match(/(\w+)@(.+)\.(\w+)$/)==null){
alert('Informe um E-mail válido');	
$('email_cliente').focus();
return false;
}
		
if($('login_cliente').value==''){
alert('Informe o Usuário');	
$('login_cliente').focus();
return false;
}
	
if($('senha_cliente').value==''){
alert('Informe a Senha');	
$('senha_cliente').focus();
return false;
}
}
///////////////////////// INICIO CADASTRO /////////////////////////




///////////////////////// INICIO JANELA /////////////////////////
function AbreJanela(link,x,y,s,u) {
var t = (screen.height - y) / 2;
var e = (screen.width - x) / 2;
window.open(link,x+y+s,'width=' + x + ',height=' + y + ',scrollbars=' + s + ',toolbar=0,location=0,status=0,menubar=0,resizable=0,left=' + e + ',top=' + t + '');
if(u==1){
window.focus();
}
}
///////////////////////// FIM JANELA /////////////////////////




///////////////////////// INICIO JANELA DOWNLOAD /////////////////////////
function faz_download(link,x,y,s,u) {
var t = (screen.height - y) / 2;
var e = (screen.width - x) / 2;
window.open(link,x+y+s,'width=' + x + ',height=' + y + ',scrollbars=' + s + ',toolbar=1,location=1,status=1,menubar=1,resizable=1,left=' + e + ',top=' + t + '');
if(u==1){
window.focus();
}
}
///////////////////////// FIM JANELA DOWNLOAD /////////////////////////




///////////////////////// INICIO LOGIN /////////////////////////
function check_login(frm){
if($('login_cliente').value==''){
alert('Informe o Usuário');	
$('login_cliente').focus();
return false;
}
if($('senha_cliente').value==''){
alert('Informe a Senha');	
$('senha_cliente').focus();
return false;
}
}
///////////////////////// FIM LOGIN /////////////////////////




///////////////////////// INICIO DOWNLOAD /////////////////////////
function check_busca_download(frm){
if($('form_nome_download').value==''){
alert('Digite o nome do arquivo que deseja encontrar.');	
$('form_nome_download').focus();
return false;
}
}
///////////////////////// FIM DOWNLOAD /////////////////////////




///////////////////////// INICIO AVISO /////////////////////////
function Aviso () {
alert ("Desculpe, esta área encontra-se indisponível.");
}
///////////////////////// FIM AVISO /////////////////////////




///////////////////////// INICIO FLASH /////////////////////////
function flash(arquivo, largura, altura){
  document.writeln('<object type="application/x-shockwave-flash" data="' + arquivo + '" width="' + largura + '" height="' + altura + '">');
  document.writeln('<param name="allowScriptAccess" value="sameDomain" />');
  document.writeln('<param name="movie" value="' + arquivo + '" />');
  document.writeln('<param name="menu" value="true" />');
  document.writeln('<param name="quality" value="high" />');
  document.writeln('<param name="wmode" value="transparent" />');
  document.writeln('<param name="bgcolor" value="#ffffff" />');
  document.writeln('</object>');
}
///////////////////////// FIM FLASH /////////////////////////



function verifica_form(form) {
var passed = false;
var ok = false
var campo
for (i = 0; i < form.length; i++) {
campo = form[i].name;
if (form[i].df_verificar == "sim") {
if (form[i].type == "text"  | form[i].type == "textarea" | form[i].type == "select-one") {
if (form[i].value == "" | form[i].value == "http://") {
form[campo].className='campo_alerta'
form[campo].focus();
alert("Preencha corretamente o campo");
return passed;
stop;
}
}
else if (form[i].type == "radio") {
for (x = 0; x < form[campo].length; x++) {
ok = false;
if (form[campo][x].checked) {
ok = true;
break;
}
}
if (ok == false) {
form[campo][0].focus();
form[campo][0].select();
alert("Informe uma das opcões");
return passed;
stop;
}
}
var msg = ""
if (form[campo].df_validar == "cpf") msg = checa_cpf(form[campo].value);
if (form[campo].df_validar == "cnpj") msg = checa_cnpj(form[campo].value);
if (form[campo].df_validar == "cpf_cnpj") {
msg = checa_cpf(form[campo].value);
if (msg != "") msg = checa_cnpj(form[campo].value);
}
if (form[campo].df_validar == "email") msg = checa_email(form[campo].value);
if (msg != "") {
form[campo].className='campo_alerta'
form[campo].focus();
form[campo].select();
alert(msg);
return passed;
stop;
}
}
}
passed = true;
return passed;
}
function desabilita_cor(campo) {
campo.className='campo_form'
}
function checa_email(campo) {
var mensagem = "Informe corretamente o email"
var msg = "";
var email = campo.match(/(\w+)@(.+)\.(\w+)$/);
if (email == null){
msg = mensagem;
}
return msg;
}