/* Função para abrir janela */
function PopUp(u,n,w,h,l,s) {
	window.open(u,n,'width='+w+',height='+h+',resizable=0,scrollbars='+s+',menubar=no,status=no,left='+l+',top=0');
}
	
/* Verifica se é um dígito válido */
function isdigit(c){if ((c >= '0') && (c <= '9')) return true; else return false;}

/* Verifica se é um númerico aceitável */
function ispunct(c)
{
 if ((c == '.') || (c == ',') || (c == '') || (c == '+') ||
     (c == '@') || (c == '_') || (c == '"') || 
	 (c == '$') || (c == '#') || (c == '!') ||
	 (c == '%') || (c == '&') || (c == '*') || (c == '(') ||
	 (c == ')') || (c == '=') || (c == '{') || (c == '}') ||
	 (c == '[') || (c == ']') || (c == '/') || (c == '\\') ||
	 (c == ':') || (c == ';') || (c == '>') || (c == '<') ||
	 (escape(c) == '%20') )
 	 return true;
 else
    return false;
}

/* Verifica se é um texto válido */
function isalpha(c)
{
 if (((c >= 'a') && (c <= 'z')) ||
     ((c >= 'A') && (c <= 'Z')))
 	 return true;
 else
 	 return false;
}

/* Válida apenas os numeros de acordo como o isdigit e ispunct*/
function SoNumero(s)
{
 for (var i=0;i<s.length;i++) { 
 	  c = s.substring(i,i+1); 
	  if (!isdigit(c) && !ispunct(c)) 
	  	  return false;	  
 }
 return true;
}


/* Função que válida apenas os e-mails */
function ValidaEmail(email) {
	var achou_ponto=false;
	var achou_arroba=false;
	var achou_caracter=false;
	for(var i=0; i<email.length; i++) {
		if (email.charAt(i)=="@") achou_arroba=true;
        else if (email.charAt(i)==".") achou_ponto=true;
        else if (email.charAt(i)!=" ") achou_caracter=true;
        }
        return (achou_ponto & achou_arroba & achou_caracter);
}

/* Função que valida as datas */
function ValidaData(s){
	var i, c, barras, data;
	var d = new Date();  
	n_barras = 0;					  
	if (s.length != 10) return false; 
	for(i=0; i<s.length; i++) {
	  c = s.substring(i,i+1);
	  if (c == "/") n_barras++;
	  if (n_barras > 2) return false;
	  if (!isdigit(c) && (c != "/")) return false;
	}
	if (n_barras != 2) return false;
	if ( (s.indexOf("/") != 2) || (s.lastIndexOf("/") != 5) )return false;
	d = s.substring(0, 2)// dia
	m = s.substring(3, 5)// mes
	a = s.substring(6, 11)// ano
	if (m<1 || m>12) return false;
	if (d<1 || d>31) return false;
	if (a<1900 || a>2050) return false;
	if (m==4 || m==6 || m==9 || m==11) { if (d==31) return false; }
	if (m==2 && d>28) {if (!(((a-2)%4 == 0) && d == 29)) return false;}
			 
	return true;
}

/* Função que valida o Cep*/
function ValidaCEP(s)
{
 var i;
 var c;
 var achou;

 if (s.length != 9) 
 	 return false;
 achou = false;
 for (i=0; i<s.length; i++) {
 	 c = s.substring(i,i+1); 
     if ( !isdigit(c) && (c != '-') ) 					
	  	  return false;
     if (c == '-') {
	   if (!achou) achou = true;
	   else 
			  return false;
	 }  	 	
 }
 if (s.indexOf("-")!=5) 
 	 return false;
 return true;
}
	

/* Função que válida CPF */
function ValidaCPF(s)
{
	var i;
	s = limpa_string(s);
	var c = s.substr(0,9);
	var dv = s.substr(9,2);
	var d1 = 0;
	for (i = 0; i < 9; i++)
	{
		d1 += c.charAt(i)*(10-i);
	}
        if (d1 == 0) return false;
	d1 = 11 - (d1 % 11);
	if (d1 > 9) d1 = 0;
	if (dv.charAt(0) != d1)
	{
		return false;
	}

	d1 *= 2;
	for (i = 0; i < 9; i++)
	{
		d1 += c.charAt(i)*(11-i);
	}
	d1 = 11 - (d1 % 11);
	if (d1 > 9) d1 = 0;
	if (dv.charAt(1) != d1)
	{
		return false;
	}
        return true;
}

function ValidaCGC(s)
{
	var i;
	s = limpa_string(s);
	var c = s.substr(0,12);
	var dv = s.substr(12,2);
	var d1 = 0;
	for (i = 0; i < 12; i++)
	{
		d1 += c.charAt(11-i)*(2+(i % 8));
	}
        if (d1 == 0) return false;
        d1 = 11 - (d1 % 11);
	if (d1 > 9) d1 = 0;
	if (dv.charAt(0) != d1)
	{
		return false;
	}

	d1 *= 2;
	for (i = 0; i < 12; i++)
	{
		d1 += c.charAt(11-i)*(2+((i+1) % 8));
	}
	d1 = 11 - (d1 % 11);
	if (d1 > 9) d1 = 0;
	if (dv.charAt(1) != d1)
	{
		return false;
	}
        return true;
}

/* menu */
function ME_Cbrowser() {
	var b=navigator.appName
	if (b=="Netscape") this.b="ns"
	else if (b=="Microsoft Internet Explorer") this.b="ie"
	else this.b=b
	this.version=navigator.appVersion
	this.v=parseInt(this.version)
	this.ns=(this.b=="ns" && this.v>=4)
	this.ns4=(this.b=="ns" && this.v==4)
	this.ns5=(this.b=="ns" && this.v==5)
	this.ie=(this.b=="ie" && this.v>=4)
	this.ie4=(this.version.indexOf('MSIE 4')>0)
	this.ie5=(this.version.indexOf('MSIE 5')>0)
	this.ie55=(this.version.indexOf('MSIE 5.5')>0)
	this.dom=((document.createRange&&(document.createRange().createContextualFragment))?true:false)
}

me=new ME_Cbrowser()

function abre(div) {
	if(me.ns5){obj=document.getElementById(div).style}
	else if(me.ie){obj=document.all[div].style}
	else if(me.ns4){obj=document.layers[div]}
	obj.visibility='visible'
}

function fecha(div) {
	if(me.ns5){obj=document.getElementById(div).style}
	else if(me.ie){obj=document.all[div].style}
	else if(me.ns4) {obj=document.layers[div]}
	obj.visibility='hidden'
}

/* troca-fundo */
function mOvr(src,clrOver) {
	 if (!src.contains(event.fromElement)) {
	 src.style.cursor = 'hand';
	 src.bgColor = clrOver;
	}
}

function mOut(src,clrIn) {
	if (!src.contains(event.toElement)) {
	src.style.cursor = 'default';
	src.bgColor = clrIn;
	}
}

//script scroll
function makeScrollObj(obj,nest) {
	nest = (!nest) ? '' : 'document.'+nest+'.'										
	this.css = (n) ? eval(nest+'document.'+obj) : eval('document.all.'+obj+'.style')							
	this.scrollHeight = (n) ? this.css.document.height : eval('document.all.'+obj+'.offsetHeight')							
	this.top = rtop
	return this
}

function rtop() {
	return (n) ? eval(this.css.top) : eval(this.css.pixelTop)
}

function scroll(speed) {
	var way=speed>0?1:0
	if ((!way && oScroll.top()>-oScroll.scrollHeight+contHeight) || (oScroll.top()<0 && way)) {
		oScroll.css.top=oScroll.top()+speed
		scrollTim=setTimeout("scroll("+speed+")",timSpeed)
	}
}

function scroller(speed) {
	var way=speed>0?1:0
	if ((!way && oScroller.top()>-oScroller.scrollHeight+contHeighter) || (oScroller.top()<0 && way)) {
		oScroller.css.top=oScroller.top()+speed
		scrollTim=setTimeout("scroller("+speed+")",timSpeed)
	}
}


function noScroll() {
	clearTimeout(scrollTim)
}

function scrollInit() {
    oScroll=new makeScrollObj('divScroll','divCont')
	oScroll.css.visibility=(n) ? 'show' : 'visible'
	
	oScroller=new makeScrollObj('divScroller','divConter')
	oScroller.css.visibility=(n) ? 'show' : 'visible'
}

// end functions

var n=document.layers?1:0
var scrspeed=3


var timSpeed=5,contHeight=0,contHeighter=0,scrollTim,active=0
var jScroll,oScroll, oScroller