
function split(string,delimitador){
	vetor = new Array();
	atual = "";
	sequencia = 0;
	for(i=0;i<string.length;++i){
		if ( string.substr(i,1) == delimitador )
			{ vetor[sequencia] = atual;
			  atual = "";
			  ++sequencia; } 
		 else { atual += string.substr(i,1); }
	}
	if ( atual != "" ) { vetor[sequencia] = atual }
	return vetor;
}

//-------------------------------------------------------------------------------------------------

		function isValidDate (myDate,sep) 
		{
			if (myDate.length == 10) 
			{
				if (myDate.substring(2,3) == sep && myDate.substring(5,6) == sep)
				{
					dia = myDate.substring(0,2) ;
					ano = parseInt( myDate.substring(6,10));

					mes = parseInt( myDate.substring(3,5) );
					if ( myDate.substring(3,4) == '0' )
					{ mes = parseInt( myDate.substring(4,5) ); }

					var test = new Date(ano,mes-1,dia,0,0,0);

					adia = parseInt(test.getDate());
					ames = parseInt(test.getMonth());
					aano = parseInt(test.getFullYear());

					if ( aano < 1900 ) aano = aano + 1900;

					if ( aano.length == 2 ) { aano = aano + 1900; }

//					alert( "Ano : "+aano+"/"+ano+" Mes : "+ames+"/"+mes+" Dia : "+adia+"/"+dia+" - 03" );

					if ( (aano == ano ) && (ames == mes-1 ) && ( dia == adia ) ) {
						return 1;
					}
					else 
					{ return 0; }
				}
				else 
				{ return 0; }
			}
			else 
			{ return 0; }
		}

//----------------------------------------------------------------------------

	function checadata( form , campo ) {
		data = "document."+form+"."+campo+".value";
		campo = "document."+form+"."+campo+".focus()";
		data = eval(data);
		//alert("Data : "+data);
		if ( data != "" ) {
			data = isValidDate(data,"/");
			if ( data == 0 ) {
				alert("A data informada é inválida !!! ");
				eval(campo);
				return ;
			}
		}
		return true;
	}

//-----------------------------------------------------------------------------------------------------------
//
//	Formatação de Placa
//
	function inputplaca( info , field, event ){
		eeval = "";
		if ( event.keyCode == 8 ){
			if ( info.value.length == 2 ){
				eeval = field+".value = '"+info.value.substring(0,1)+"'";
			}
			else if ( info.value.length == 5 ){
				eeval = field+".value = '"+info.value.substring(0,4)+"'"; 
			}
		}
		else{
			var ajustar = (info.value.length == 2) || (info.value.length == 5);
			if (ajustar){
				//eeval = field+".value = '"+info.value + "/'";
				if (typeof(field) == "string"){ 
					eeval = field+".value = '"+info.value + "/'";
				}
				else{
					field.value = info.value + "/";
				}
			}
		}
		if ( eeval != "" ){
			eval(eeval); 
		}
	}

//-----------------------------------------------------------------------------------------------------------
//
//	Formatação de Data
//
	function inputdata( info , field, event ){
		eeval = "";
		if ( event.keyCode == 8 ){
			if ( info.value.length == 2 ){
				eeval = field+".value = '"+info.value.substring(0,1)+"'";
			}
			else if ( info.value.length == 5 ){
				eeval = field+".value = '"+info.value.substring(0,4)+"'"; 
			}
		}
		else{
			var ajustar = (info.value.length == 2) || (info.value.length == 5);
			if (ajustar){
				//eeval = field+".value = '"+info.value + "/'";
				if (typeof(field) == "string"){ 
					eeval = field+".value = '"+info.value + "/'";
				}
				else{
					field.value = info.value + "/";
				}
			}
		}
		if ( eeval != "" ){
			eval(eeval); 
		}
	}

//----------------------------------------------------------------------------
function checa_cgc(vcgc) { 

	if (vcgc.length < 14) { 
		alert("Número do CGC inválido !") ;
		return (0)
	} 

	var d = new Array(12);
	var i = 0;
	var df2 = 0;
	var df3 = 0;
	var resto1 = 0;
	var resto2 = 0;
	var temp = 0;
	for (i=0; i < 12; i++) {
		temp = vcgc.substr(i,1) ;
		temp = parseInt(temp, 10) ;
		d[i] = temp ;
	}

	df1 = 5 * d [0];
	df1 += 4 * d [1];
	df1 += 3 * d [2];
	df1 += 2 * d [3];
	df1 += 9 * d [4];
	df1 += 8 * d [5];
	df1 += 7 * d [6];
	df1 += 6 * d [7];
	df1 += 5 * d [8];
	df1 += 4 * d [9];
	df1 += 3 * d [10];
	df1 += 2 * d [11];

	df2 = df1 / 11 ;
	df2 = inteiro(df2) ;
	df3 = df2 * 11 ;
	resto1 = df1 - df3 ;

	if (resto1 == 1 || resto1 == 0)
		pridig = 0 ;
	else
		pridig = 11 - resto1;

	df1 = 6 * d [0];
	df1 += 5 * d [1];
	df1 += 4 * d [2];
	df1 += 3 * d [3];
	df1 += 2 * d [4];
	df1 += 9 * d [5];
	df1 += 8 * d [6];
	df1 += 7 * d [7];
	df1 += 6 * d [8];
	df1 += 5 * d [9];
	df1 += 4 * d [10];
	df1 += 3 * d [11];
	df1 += 2 * pridig ;

	df2 = df1 / 11 ;
	df2 = inteiro(df2) ;
	df3 = df2 * 11 ;
	resto2 = df1 - df3 ;

	if (resto2 == 0 || resto2 == 1)
		segdig = 0 ;
	else
		segdig = 11 - resto2 ;

	resto1 = parseInt(vcgc.substr(12,1));
	resto2 = parseInt(vcgc.substr(13,1));

	if (pridig == resto1 && segdig == resto2) {
		return true ;
	} else {
		alert("O número do CNPJ informado é inválido") ;
		return false ;
	}
}
//----------------------------------------------------------------------------

function inteiro(wValor) {
	wResult = "" ;
	wString = ""+wValor ;
	for (wfor = 0 ; wfor < wString.length ; ++wfor) {
		if (wString.substr(wfor,1) == ".")
			wfor = wString.length + 1;
		else
			wResult += wString.substr(wfor,1);
	}
	return parseInt(wResult, 10);
}

//----------------------------------------------------------------------------

function checa_cpf(vcpf) {

	if (vcpf.length < 10) {
		alert("Número do CPF inválido !");
		return (0)
	}

	var wSx1 = 0 ;
	var wCpfDigit = 0 ;
	var y = 0 ;
	var temp = 0 ;
	var temp2= 0 ;

	var wCpfCalc = vcpf.substr(0,9) ;
	var wSomaCpf = 0 ;

	for (wsx1 = 1; wsx1 < 10; wsx1++) {
		temp = vcpf.substr(wsx1-1,1);
		temp = parseInt(temp, 10) ;
		temp = temp * (11 - wsx1) ;
		wSomaCpf += temp ;
	}

	temp = wSomaCpf%11 ;
	wCpfDigit = 11 - temp ;

	if (wCpfDigit == 10 || wCpfDigit == 11)
		wCpfCalc += "0" ;
	else
		wCpfCalc += wCpfDigit ;

	wSomaCpf = 0 ;
	for (wsx1=1; wsx1 < 11; wsx1++) {
		temp = vcpf.substr(wsx1-1,1);
		temp = parseInt(temp, 10) ;
		temp = temp * (12-wsx1) ;
		wSomaCpf += temp ;
	}

	temp = wSomaCpf%11 ;
	wCpfDigit = 11 - temp ;

	if (wCpfDigit == 10 || wCpfDigit == 11)
		wCpfCalc += "0" ;
	else
		wCpfCalc += wCpfDigit ;

	if (vcpf != wCpfCalc) {
		alert("O número do cpf informado é inválido !");
		return false ;
	} else {
		return true;
	}
}

//-------------------------------------------------------------------------------------------
function validaemail(email) { 
	var er = /[A-Za-z0-9_.-]+@([A-Za-z0-9_]+\.)+[A-Za-z]{2,4}/;
	return er.test(email);
} 
//----------------------------------------------------------------------------

function inputnumber( info , mascara , t ){

//	alert(t.charCode);

	if (window.event) { // Internet Explorer
		var tecla = event.keyCode;
	} else { //if(document.layers) { // Nestcape
		var tecla = t.which; 
	}

	var chr= String.fromCharCode(tecla);

	pontoinfo	= info.value;
	preinfo		= pontoinfo.indexOf(".");

	pontomascara= mascara.indexOf('.');

	tamantesponto = mascara.substr(0,pontomascara);
	tamantesponto = tamantesponto.length;

	posinfo = pontoinfo.substr(preinfo+1);
	posinfo = posinfo.length;

	tamdepoisponto = mascara.substr(pontomascara+1);
	tamdepoisponto = tamdepoisponto.length;

	if ( ( pontomascara == -1 ) && ( tecla == 46 ) ){
//		alert("Aqui 01");
		return true ;
	}

			if ( (tecla > 47 && tecla < 58) || (tecla == 46) ){ // numeros de 0 a 9
				if ( (preinfo == -1) && ( tamantesponto > 0 ) && ( pontoinfo.length >= tamantesponto ) && (tecla != 46 ) ){
						if (document.all) // Internet Explorer
							event.keyCode = 0;
						else if(document.layers) // Nestcape
							t.charCode = 0;
						return false;

				} else { 
					if ( (pontomascara > 0) && (tecla == 46) ) { 
						//
						//	Existe ponto na máscara
						//
						if ( preinfo > 0 ) { 

							if (document.all) // Internet Explorer
								event.keyCode = 0;
							else if(document.layers) // Nestcape
								t.charCode = 0;
						} 
					} // mascara com ponto 
					if ( (pontomascara > 0) && (tecla != 46) && ( posinfo > 0 ) && ( preinfo != -1 ) && ( posinfo >= tamdepoisponto ) ){ // && ( posinfo >= tamantesponto ) ) { 
						if (document.all) // Internet Explorer
							event.keyCode = 0;
						else if(document.layers) // Nestcape
							t.charCode = 0;
					} 
					return false ; 
				} 
			} 
			else { 
				if (tecla != 8) { // backspace
					if (document.all) // Internet Explorer
						event.keyCode = 0;
					else if(document.layers) // Nestcape
						t.charCode = 0;
					return false;
				} else {
					return true;
				}
			}

	return true;
}

//----------------------------------------------------------------------------

function trim(str) { 
    str.replace(/^\s*/, '').replace(/\s*$/, ''); 
   return str;
} 


//----------------------------------------------------------------------------
// scroll

function verifyCompatibleBrowser(){ 
	this.ver=navigator.appVersion 
	this.dom=document.getElementById?1:0 
	this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom)?1:0; 
	this.ie4=(document.all && !this.dom)?1:0; 
	this.ns5=(this.dom && parseInt(this.ver) >= 5) ?1:0; 
	this.ns4=(document.layers && !this.dom)?1:0; 
	this.bw=(this.ie5 || this.ie4 || this.ns4 || this.ns5) 
	return this 
} 

function ConstructObject(obj,nest){ 

	nest=(!nest) ? '':'document.'+nest+'.' ;
	this.el = 0;
	if ( bw.dom ) {
		this.el=document.getElementById(obj);
	} else { 
		if ( bw.ie4 ) {
			this.el=document.all[obj] ;
		} else {
			if ( bw.ie4 ) {
				this.el=eval(nest+'document.'+obj);
			} else { 
				this.el=0; 
			}
		}
	}
//	this.el=bw.dom?document.getElementById(obj):bw.ie4?document.all[obj]:bw.ns4?eval(nest+'document.'+obj):0; 

	if ( bw.dom ) {
		this.css=document.getElementById(obj);
	} else {
		if ( bw.ie4 ) {
			this.css=document.all[obj].style;
		} else {
			if ( bw.ns4 ) {
				this.css=eval(nest+'document.'+obj);
			} else {
				this.css=0;
			}
		}
	}
//	this.css=bw.dom?document.getElementById(obj).style:bw.ie4?document.all[obj].style:bw.ns4?eval(nest+'document.'+obj):0; 

	this.scrollHeight=bw.ns4?this.css.document.height:this.el.offsetHeight ;
	this.clipHeight=bw.ns4?this.css.clip.height:this.el.offsetHeight ;
	this.up=MoveAreaUp;this.down=MoveAreaDown; 
	this.MoveArea=MoveArea; this.x; this.y; 
	this.obj = obj + "Object" ;
	eval(this.obj + "=this") ;
	return this ;
} 

function MoveArea(x,y){ 
	this.x=x;this.y=y 
	this.css.left=this.x 
	this.css.top=this.y 
} 

function MoveAreaDown(move){ 
	if(this.y>-this.scrollHeight+objContainer.clipHeight){ 
		this.MoveArea(0,this.y-move) 
		if(loop) setTimeout(this.obj+".down("+move+")",speed) 
	} 
} 

function MoveAreaUp(move){ 
	if(this.y<0) { 
		this.MoveArea(0,this.y-move) 
		if(loop) setTimeout(this.obj+".up("+move+")",speed) 
	} 
} 

function PerformScroll(speed){ 
	if(initialised){ 
		loop=true; 
//		alert(objScroller.down);
		if(speed>0) objScroller.down(speed) 
		else objScroller.up(speed) 
	} 
} 

function CeaseScroll(){ 
	loop=false 
	if(timer) clearTimeout(timer) 
} 

function InitialiseScrollableArea(){ 
	objContainer=new ConstructObject('divContainer') 
	objScroller=new ConstructObject('divContent','divContainer') 
	objScroller.MoveArea(0,0) 
	objContainer.css.visibility='visible' 
	initialised=true; 
} 
// end absolutely positioned scrollable area object scripts


