// solicitação de alualização de navegador

function $_freedom_(b)
{
	var i, a,c;
	if(arguments.length > 1){c = new Array(); for(i=0; i<arguments.length; i++) c.push(arguments[i]);}
	if(b instanceof Array){ c = b; }
	if(c instanceof Array){ a = new Array(); for(i=0; i<c.length; i++) a[i] = document.getElementById(c[i]);}
	else a = document.getElementById(b);
	return a;
}
function $_freedom_remove(a) { if(a && a.parentNode) a.parentNode.removeChild(a); }
function _freedom_addEvent(a, b, c, d, e)
{
	if(!a) return false;
	var f;
	if(typeof e != "undefined")
	{	
		if ( typeof(e) != 'string' ){ var g = []; for ( var i = 0; i < e.length; i++ ) g.push(e[i]); f = function(e) { c.apply(a,[e].concat(g)); };}
		else f = function(e) { c.apply(a, [e].concat(e)); };
	}
	else f = c;
	if (a.addEventListener){ addEventListener(b, f, d); return true; }
	else{ if (a.attachEvent) return a.attachEvent('on' + b, f); else a['on' + b] = f; }
};
function _freedom_getObjPosition(a)
{
	var b, c; a = $_freedom_(a); b = a.offsetLeft; c = a.offsetTop; var body = document.getElementsByTagName('body')[0];
	while (a.offsetParent && a!=body){ b += a.offsetParent.offsetLeft; c += a.offsetParent.offsetTop; a = a.offsetParent;}
	return {x: b, y:c};
}


var crossbrowser_BrowserDetect = {
	init: function () {
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		this.version = this.searchVersion(navigator.userAgent) || this.searchVersion(navigator.appVersion) || "an unknown version";
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
	},
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) { if (dataString.indexOf(data[i].subString) != -1) return data[i].identity; }
			else if (dataProp) return data[i].identity;
		}
	},
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataBrowser: [
		{ string: navigator.userAgent, subString: "Chrome", identity: "Chrome" },
		{  string: navigator.userAgent, subString: "OmniWeb", versionSearch: "OmniWeb/", identity: "OmniWeb" },
		{ string: navigator.vendor, subString: "Apple", identity: "Safari", versionSearch: "Version" },
		{ prop: window.opera, identity: "Opera" },
		{ string: navigator.vendor, subString: "iCab", identity: "iCab" },
		{ string: navigator.vendor, subString: "KDE", identity: "Konqueror" },
		{ string: navigator.userAgent, subString: "Firefox", identity: "Firefox" },
		{ string: navigator.vendor, subString: "Camino", identity: "Camino" },
		{ string: navigator.userAgent, subString: "Netscape", identity: "Netscape" },
		{ string: navigator.userAgent, subString: "MSIE", identity: "Explorer", versionSearch: "MSIE" },
		{ string: navigator.userAgent, subString: "Gecko", identity: "Mozilla", versionSearch: "rv" },
		{ string: navigator.userAgent, subString: "Mozilla", identity: "Netscape", versionSearch: "Mozilla" }
	],
	dataOS : [
		{ string: navigator.platform, subString: "Win", identity: "Windows" },
		{ string: navigator.platform, subString: "Mac", identity: "Mac" },
		{ string: navigator.platform, subString: "Linux", identity: "Linux" }
	]

};

crossbrowser_BrowserDetect.init();
function crossbrowser_down()
{
	var step = 1;
	var timeStep = 20;
	if(_freedom_getObjPosition("crossbrowser").y+step < 0) 
	{
		$_freedom_("crossbrowser").style.top = (_freedom_getObjPosition("crossbrowser").y+step)+"px";
		setTimeout("crossbrowser_down()", timeStep);
	}
}

crossbrowser_showed = false;

function crossbrowser_show(){
	if(!crossbrowser_showed &&  (crossbrowser_BrowserDetect.browser == "Internet Explorer" || crossbrowser_BrowserDetect.browser == "Explorer") && crossbrowser_BrowserDetect.version <= "7")
	{
		var stats = document.createElement("img");
		stats.setAttribute("src",crossbrowser_stats);
		stats.style.display = "none";
		document.body.appendChild(stats);
		
		var iframe = document.createElement("iframe");
		iframe.setAttribute("frameBorder","0");
		iframe.setAttribute("id","crossbrowser");
		iframe.setAttribute("scrolling","no");
		iframe.style.height = "31px";
		iframe.style.position = "absolute";
		iframe.style.width = "100%";
		iframe.style.top = "-40px";
		iframe.style.left = "0px";
		iframe.style.border = "0px solid #000";
		
		document.body.appendChild(iframe);
		var doc = iframe.document;
		if(iframe.contentDocument) doc = iframe.contentDocument; // For NS6
		else if(iframe.contentWindow) doc = iframe.contentWindow.document; // For IE5.5 and IE6
	
		doc.open();
		doc.writeln(crossbrowser_iframe);
		doc.close();
		crossbrowser_down();
		crossbrowser_showed = true;
		
	}
}

function crossbrowser_hide(){
	$_freedom_remove($_freedom_("crossbrowser"));
}

_freedom_addEvent(window, "load", crossbrowser_show);
crossbrowser_iframe = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html><body style="margin:0px; padding:0px; overflow:hidden; height:30px;"><div id="crossbrowser" style="height:30px;background:#F5FAFF;position:absolute;width:100%;left:0px;text-align:left;border-bottom:1px solid #AAAEB2;"><ul style="width:800px; margin:0 auto;padding:1px 0;list-style:none;"><li style="margin:3px 0 0 0;float:left;font:bold 16px Arial, Helvetica, sans-serif;color:#666;" title="Atualize seu navegador">Atualize seu navegador</li><li style="margin:3px 100px 0 8px;float:left;font:9px Arial, Helvetica, sans-serif;" title="Seguran&ccedil;a para voc&ecirc;, liberdade aos desenvolvedores"></li><li style="float:right;margin: 0 0 0 10px;"><a href="javascript:window.parent.crossbrowser_hide();" style="margin:7px 0 0 0;display:block;width:14px;height:14px;background:url(http://imasters.uol.com.br/crossbrowser/sprBarratopo.png) 0px -41px no-repeat;text-indent:-9999px;" title="Fechar">Fechar</a></li><li style="float:left;padding:2px 0 0 0;font-weight:bold;color:#690"><small style="font:10px Arial, Helvetica, sans-serif;">Baixe agora!</small></li><li style="float:left;"><a target="_blank" href="http://www.mozilla.com/" title="Mozilla Firefox" style="margin:0 0 0 12px;display:block;width:26px;height:26px;background: url(http://imasters.uol.com.br/crossbrowser/img/sprBarratopo.png) -62px -5px no-repeat;text-indent:-9999px;">Mozilla Firefox</a></li><li style="float:left;margin-left:2px;"><a target="_blank" href="http://www.google.com/chrome" title="Google Chrome" style="margin:4px 0 0 4px;display:block;width:19px;height:19px;background:url(http://imasters.uol.com.br/crossbrowser/sprBarratopo.png) -125px -8px no-repeat;text-indent:-9999px;">Google Chrome</a></li><li style="float:left;margin-left:2px;"><a target="_blank" href="http://www.apple.com/safari/download/" title="Apple Safari" style="margin:4px 0 0 4px;display:block;width:19px;height:19px;background:url(http://imasters.uol.com.br/crossbrowser/sprBarratopo.png) -96px -9px no-repeat;text-indent:-9999px;">Safari</a></li><li style="float:left;margin-left:2px;"><a target="_blank" href="http://www.opera.com/download/" title="Opera" style="margin:4px 0 0 4px;display:block;width:22px;height:18px;background:url(http://imasters.uol.com.br/crossbrowser/sprBarratopo.png) -151px -8px no-repeat;text-indent:-9999px;">Opera</a></li><li style="float:left;margin-left:2px;"><a target="_blank" href="http://www.microsoft.com/windows/internet-explorer/" title="Internet Explorer 8" style="margin:4px 0 0 4px;display:block;width:21px;height:20px;background:url(http://imasters.uol.com.br/crossbrowser/sprBarratopo.png) -180px -7px no-repeat;text-indent:-9999px;">Internet Explorer</a></li></ul></div></body></html>';
crossbrowser_stats = 'http://imasters.uol.com.br/crossbrowser/stats.gif?l=pt-br&ua='+navigator.userAgent+'&ref='+window.location+'&p=1';



//--------------------------------------------------------------------------------------------------------------



// JavaScript Document

function trim(str)

{

  return str.replace(/^\s+|\s+$/g,"");

}



function validaCPF(cpf)

{

  //cpf = document.validacao.cpfID.value;

  erro = new String;

  if (cpf.length < 11) erro += "Sao necessarios 11 digitos para verificacao do CPF! \n\n"; 

  var nonNumbers = /\D/;

  if (nonNumbers.test(cpf)) erro += "A verificacao de CPF suporta apenas numeros! \n\n"; 

  if (cpf == "00000000000" || cpf == "11111111111" || cpf == "22222222222" || cpf == "33333333333" || cpf == "44444444444" || cpf == "55555555555" || cpf == "66666666666" || cpf == "77777777777" || cpf == "88888888888" || cpf == "99999999999")

  {

    erro += "Numero de CPF invalido!"

  }

  var a = [];

  var b = new Number;

  var c = 11;

  for (i=0; i<11; i++)

  {

    a[i] = cpf.charAt(i);

    if (i < 9) b += (a[i] * --c);

  }

  if ((x = b % 11) < 2) { a[9] = 0 } else { a[9] = 11-x }

  b = 0;

  c = 11;

  for (y=0; y<10; y++) b += (a[y] * c--); 

  if ((x = b % 11) < 2) { a[10] = 0; } else { a[10] = 11-x; }

  if ((cpf.charAt(9) != a[9]) || (cpf.charAt(10) != a[10]))

  {

    erro +="Digito verificador com problema!";

  }

  if (erro.length > 0)

  {

    //alert(erro);

    return false;

  }

  return true;

}



function validaemail(field,alerttxt)

{

with (field)

{

apos=value.indexOf("@")

dotpos=value.lastIndexOf(".")

if (apos<1||dotpos-apos<2) 

  {alert(alerttxt);return false}

else {return true}

}

}function validate_form(thisform)

{

with (thisform)

{

if (validaemail(email,"endereço de e-mail inválido!")==false)

  {email.focus();return false}

}

}





function isNUMB(c) 

 { 

 if((cx=c.indexOf(","))!=-1) 

  { 

  c = c.substring(0,cx)+"."+c.substring(cx+1); 

  } 

 if((parseFloat(c) / c != 1)) 

  { 

  if(parseFloat(c) * c == 0) 

   { 

   return(1); 

   } 

  else 

   { 

   return(0); 

   } 

  } 

 else 

  { 

  return(1); 

  } 

 } 

function LIMP(c) 

 { 

 while((cx=c.indexOf("-"))!=-1) 

  { 

  c = c.substring(0,cx)+c.substring(cx+1); 

  } 

 while((cx=c.indexOf("/"))!=-1) 

  { 

  c = c.substring(0,cx)+c.substring(cx+1); 

  } 

 while((cx=c.indexOf(","))!=-1) 

  { 

  c = c.substring(0,cx)+c.substring(cx+1); 

  } 

 while((cx=c.indexOf("."))!=-1) 

  { 

  c = c.substring(0,cx)+c.substring(cx+1); 

  } 

 while((cx=c.indexOf("("))!=-1) 

  { 

  c = c.substring(0,cx)+c.substring(cx+1); 

  } 

 while((cx=c.indexOf(")"))!=-1) 

  { 

  c = c.substring(0,cx)+c.substring(cx+1); 

  } 

 while((cx=c.indexOf(" "))!=-1) 

  { 

  c = c.substring(0,cx)+c.substring(cx+1); 

  } 

 return(c); 

 } 



function VerifyCNPJ(CNPJ) 

 { 

 CNPJ = LIMP(CNPJ); 

 if(isNUMB(CNPJ) != 1) 

  { 

  return(0); 

  } 

 else 

  { 

  if(CNPJ == 0) 

   { 

   return(0); 

   } 

  else 

   { 

   g=CNPJ.length-2; 

   if(RealTestaCNPJ(CNPJ,g) == 1) 

    { 

    g=CNPJ.length-1; 

    if(RealTestaCNPJ(CNPJ,g) == 1) 

     { 

     return(1); 

     } 

    else 

     { 

     return(0); 

     } 

    } 

   else 

    { 

    return(0); 

    } 

   } 

  } 

 } 

function RealTestaCNPJ(CNPJ,g) 

 { 

 var VerCNPJ=0; 

 var ind=2; 

 var tam; 

 for(f=g;f>0;f--) 

  { 

  VerCNPJ+=parseInt(CNPJ.charAt(f-1))*ind; 

  if(ind>8) 

   { 

   ind=2; 

   } 

  else 

   { 

   ind++; 

   } 

  } 

  VerCNPJ%=11; 

  if(VerCNPJ==0 || VerCNPJ==1) 

   { 

   VerCNPJ=0; 

   } 

  else 

   { 

   VerCNPJ=11-VerCNPJ; 

   } 

 if(VerCNPJ!=parseInt(CNPJ.charAt(g))) 

  { 

  return(0); 

  } 

 else 

  { 

  return(1); 

  } 

 } 

  



  function FormataCGC(Formulario, Campo, TeclaPres) 

  { 

    var tecla = TeclaPres.keyCode; 

    var strCampo; 

    var vr; 

    var tam; 

    var TamanhoMaximo = 14; 

  

    eval("strCampo = document." + Formulario + "." + Campo); 

  

    vr = strCampo.value; 

    vr = vr.replace("/", ""); 

    vr = vr.replace("/", ""); 

    vr = vr.replace("/", ""); 

    vr = vr.replace(",", ""); 

    vr = vr.replace(".", ""); 

    vr = vr.replace(".", ""); 

    vr = vr.replace(".", ""); 

    vr = vr.replace(".", ""); 

    vr = vr.replace(".", ""); 

    vr = vr.replace(".", ""); 

    vr = vr.replace(".", ""); 

    vr = vr.replace("-", ""); 

    vr = vr.replace("-", ""); 

    vr = vr.replace("-", ""); 

    vr = vr.replace("-", ""); 

    vr = vr.replace("-", ""); 

    tam = vr.length; 



    if (tam < TamanhoMaximo && 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 <= 2) 

      { 

        strCampo.value = vr; 

      } 

       if ((tam > 2) && (tam <= 6)) 

       { 

         strCampo.value = vr.substr(0, tam - 2) + '-' + vr.substr(tam - 2, tam); 

       } 

       if ((tam >= 7) && (tam <= 9)) 

       { 

         strCampo.value = vr.substr(0, tam - 6) + '/' + vr.substr(tam - 6, 4) + '-' + vr.substr(tam - 2, tam); 

      } 

       if ((tam >= 10) && (tam <= 12)) 

       { 

         strCampo.value = vr.substr(0, tam - 9) + '.' + vr.substr(tam - 9, 3) + '/' + vr.substr(tam - 6, 4) + '-' + vr.substr(tam - 2, tam); 

      } 

       if ((tam >= 13) && (tam <= 14)) 

       { 

         strCampo.value = vr.substr(0, tam - 12) + '.' + vr.substr(tam - 12, 3) + '.' + vr.substr(tam - 9, 3) + '/' + vr.substr(tam - 6, 4) + '-' + vr.substr(tam - 2, tam); 

      } 

       if ((tam >= 15) && (tam <= 17)) 

       { 

         strCampo.value = vr.substr(0, tam - 14) + '.' + vr.substr(tam - 14, 3) + '.' + vr.substr(tam - 11, 3) + '.' + vr.substr(tam - 8, 3) + '.' + vr.substr(tam - 5, 3) + '-' + vr.substr(tam - 2, tam); 

      } 

    } 

  } 



function TESTA() 

 { 

 if(VerifyCNPJ(document.forms[0].CNPJ.value) == 1) 

  { 

  alert("CNPJ válido!"); 

  } 

 else 

  { 

  alert("CNPJ não é válido!"); 

  } 

 document.forms[0].CNPJ.focus(); 

 return; 

 } 



function MostraBoasVindas( ) 

{

{

 document.write("<font face=arial color=white size=5>")

hr = new Date().getHours()



if  ((hr == 0) || (hr == 1) || (hr == 2) || (hr == 3) || (hr == 4) || (hr == 5))

  document.write("Boa Madrugada Bem Vindos ao site da Printer Solutions")



if ((hr == 6) || (hr == 7) || (hr == 8) || (hr == 9) || (hr == 10) || (hr == 11))

  document.write("Bom Dia Bem Vindos ao site da Printer Solutions")



if ((hr == 12) || (hr == 13) || (hr == 14) || (hr == 15) || (hr == 16) || (hr == 17)) 

  document.write("Boa Tarde Bem Vindos ao site da Printer Solutions")



if ((hr == 18) || (hr == 19) || (hr == 20) || (hr == 21) || (hr == 22) || (hr == 23))

  document.write("Boa Noite Bem Vindos ao site da Printer Solutions") 

document.write("</font>")

}

}



function EscreveData( )

{

document.write("<font face=arial color=white size=3>") 

hoje = new Date ( ) ; dia = hoje.getDate( ) ; 

mes = hoje.getMonth( ) +1; ano = hoje.getYear( ) ; 

if (dia < 10) dia = "0" + dia ;

if (mes < 10) mes ="0" + mes ;

if (ano < 2000) ano = "19" + ano;

document.write (dia + "/" + mes + "/" + ano);

}





function EscreveHora( )

{

document.write("<font face=arial color= white size=3>")

agora = new Date( ) ; horas = agora.getHours( );

minutos = agora.getMinutes( ) ;

if (horas < 10) horas= "0" + horas;

if (minutos < 10) minutos = "0" + minutos ;

document.write(horas+":"+minutos+"h") ; 

}



function VerificaPlaca() {

	var rangeinvalido = /[^0-9a-zA-Z]/

	var rangenumeros = /[0-9]/

	var rangeletras = /[a-zA-Z]/

	pos=placa.value.length

	i=0

	while (i<pos) {

		placa.value=placa.value.substring(0,i)+placa.value.substring(i,i+1).replace(rangeinvalido,"")+placa.value.substring(i+1,pos)

		i++;

	}

	mascaraplaca=placa.value

	i=0

	while (i<3) {

		mascaraplaca=mascaraplaca.substring(0,i)+mascaraplaca.substring(i,i+1).replace(rangeletras,"X")+mascaraplaca.substring(i+1,7)

		i++

	}

	i=3

	while (i<7) {

		mascaraplaca=mascaraplaca.substring(0,i)+mascaraplaca.substring(i,i+1).replace(rangenumeros,"9")+mascaraplaca.substring(i+1,7)

		i++

	}

	if (! (mascaraplaca=="XXX9999")){

		return false;

	}

	

	return true;

}



// ===========================================================================================

// IMPLEMENTAÇÃO DE AJAX PARA ASP

// ===========================================================================================

function createXMLHTTP()

{

	var ajax;

	

	try

	{

		ajax = new ActiveXObject("Msxml2.XMLHTTP");

	}

	catch(e)

	{

		try

		{

			ajax = new ActiveXObject("Microsoft.XMLHTTP");

		}

		catch(ex)

		{

			try

			{

				ajax = new XMLHttpRequest();

			}

			catch(exc)

			{

				alert("Esse browser não tem recursos para uso do Ajax");

				ajax = null;

			}

		}

	}

	return ajax;

}



function goAjax(url, metodo, modo, tagRetorno, parametros)

{

	var xmlHttp = createXMLHTTP();

	

	var conteudoInner = "<div align='center' class='carregando'><img src='images/aguarde.gif'><br>Carregando ...</div>";

	document.getElementById(tagRetorno).innerHTML = conteudoInner;

	

	if (metodo == "GET")

	{

		xmlHttp.open ("GET", url, modo);

	}

	else

	{

		xmlHttp.open ("POST", url, modo);

		xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=iso-8859-1");

		xmlHttp.setRequestHeader("Cache-Control", "no-store, no-cache, must-revalidate");

		xmlHttp.setRequestHeader("Cache-Control", "post-check=0,pre-check=0");

		xmlHttp.setRequestHeader("Pragma", "no-cache");

	}

	

	xmlHttp.onreadystatechange = function()

	{

		if (xmlHttp.readyState == 4)

		{

			var retorno = xmlHttp.responseText;

			document.getElementById(tagRetorno).innerHTML = retorno;

		}

		

	}

	

	if (metodo == "GET")

	{

		xmlHttp.send(null);

	}

	else

	{

		xmlHttp.send(parametros);

	}

}



function enviaPage(url, metodo, modo, tagId, parametros)

{

	if (metodo == "GET")

	{

		goAjax(url + "?" + parametros + "&rnd=" + Math.random(), metodo, modo, tagId, parametros);

	}

	else

	{

		goAjax(url + "?rnd=" + Math.random(), metodo, modo, tagId, parametros);

	}

}

// ===========================================================================================




