// JavaScript Document
$ = function (a) {
	return document.getElementById(a);
};



getDocSize = function () {
	return {x:document.body.offsetWidth, y:document.body.offsetHeight};
};
/* Fundo azul do site */
var bgSite = {
	'show': function() {
		setAlpha('bgSite', 60);
		$('bgSite').style.height = getDocSize().y+13+'px';
		$('bgSite').style.display = 'block';
		var obj = document.getElementsByTagName('SELECT');
		for (var i = 0; i < obj.length; i++) {
			if (obj[i].className != 'campoEditor') obj[i].style.display = "none";
		}
	},
	'hide': function() {
		$('bgSite').style.display = 'none';
		var obj = document.getElementsByTagName('SELECT');
		for (var i = 0; i < obj.length; i++) obj[i].style.display = "block";
	},
	'alinha': function(){
		$('bgSite').style.width = getDocSize().x+'px';
		$('bgSite').style.height = getDocSize().y+13+'px';
	}
};

// Aplica um valor alpha de 0 a 100
setAlpha = function (e, a) {
	a = Math.round(a);
	if (typeof e == 'string') e = $(e);
	with (e.style) {
		if (isIE) {
			filter = 'alpha(opacity='+a+')';
		} else {
			opacity = a/100;
		}
	}
};

/* Funo para carregar itens em objetos do tipo select */
selectLoader = function () {
	var xml = new xmlConnection();
	var thisObj = this;
	this.onLoad = function() {
	};
	this.load = function(strObj, strList, strValue, cache) {
		cache = cache || false;
		if (xml.create()) {
			xml.setURL(strList);
			xml.setMethod('GET');
			if (cache != false) {
				xml.add('nocache', nocache());
			}
			xml.onComplete = function() {
				this.setChildName('item');
				$(strObj).innerHTML = '';
				if (this.getCountItens()>1) {
					var linha = document.createElement("OPTION");
					$(strObj).appendChild(linha);
					linha.value = '';
					linha.text = 'Selecione...';
					linha.style.color = '#999999';
					var index = 0;
					for (var j = 0; j<this.getCountItens(); j++) {
						linha = document.createElement("OPTION");
						$(strObj).appendChild(linha);
						linha.value = this.getAttByName('id', j);
						linha.text = this.getAttByName('nome', j);
						if (strValue) {
							if (linha.value == strValue) {
								linha.selected = true;
								index = (j+1);
							}
						}
					}
					$(strObj).selectedIndex = index;
					$(strObj).disabled = false;
				} else if (this.getCountItens() == 1) {
					linha = document.createElement("OPTION");
					$(strObj).appendChild(linha);
					linha.value = this.getAttByName('id', 0);
					linha.text = this.getAttByName('nome', 0);
					linha.selected = true;
					$(strObj).disabled = true;
				} else {
					linha = document.createElement("OPTION");
					$(strObj).appendChild(linha);
					linha.value = '';
					linha.text = 'Sem dados';
					linha.selected = true;
					$(strObj).disabled = true;
				}
				thisObj.onLoad(($(strObj).disabled) ? false : true);
			};
			xml.execute();
		}
	};
};

/* TWEEN */ 

tween = function () {
	var obj = $(arguments[0]);
	obj.numStepTween = 10;
	obj.thisIntervalTween = null;
	obj.posXTween = 100;
	obj.posYTween = 100;
	obj.onEnterFrameTween = function() {
		obj.numTimeTween += obj.numStepTween;
		var posX = findTweenValue(obj.numInicioXTween, obj.numFinalXTween, 0, obj.numTimeTween, obj.numDurationTween, obj.strEasingTween);
		var posY = findTweenValue(obj.numInicioYTween, obj.numFinalYTween, 0, obj.numTimeTween, obj.numDurationTween, obj.strEasingTween);
		setPosition(obj, posX, posY);
		if (obj.numTimeTween>=obj.numDurationTween) {
			setPosition(obj, obj.numFinalXTween, obj.numFinalYTween);
			clearInterval(obj.thisIntervalTween);
			obj.callbackTween();
		}
	};
	obj.tweenTo = function() {
		var pos = getPos(obj);
		this.numTimeTween = 0;
		this.numInicioXTween = pos.y;
		this.numInicioYTween = pos.x;
		this.numFinalXTween = arguments[0];
		this.numFinalYTween = arguments[1];
		this.strEasingTween = (arguments[2]) ? arguments[2] : 'linear';
		this.numDurationTween = (arguments[3]) ? arguments[3]*1000 : 1000;
		this.callbackTween = arguments[4] || function () {
		};
		clearInterval(obj.thisIntervalTween);
		obj.thisIntervalTween = setInterval(obj.onEnterFrameTween, obj.numStepTween);
	};
	obj.stopTween = function() {
		clearInterval(obj.thisIntervalTween);
	};
};

// Retorna o scroll da pgina
getScroll = function () {
	if (self.pageXOffset) {
		sX = self.pageXOffset;
	} else if (document.documentElement && document.documentElement.scrollLeft) {
		sX = document.documentElement.scrollLeft;
	} else if (document.body) {
		sX = document.body.scrollLeft;
	}
	if (self.pageYOffset) {
		sY = self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop) {
		sY = document.documentElement.scrollTop;
	} else if (document.body) {
		sY = document.body.scrollTop;
	}
	return {x:sX, y:sY};
};

// Retorna o tamanho da rea visivel
getDocVisibleSize = function () {
	var _x, _y;
	if (window.innerWidth) {
		_x = window.innerWidth;
	} else if (document.documentElement && document.documentElement.clientWidth) {
		_x = document.documentElement.clientWidth;
	} else if (document.body) {
		_x = document.body.clientWidth;
	}
	if (window.innerHeight) {
		_y = window.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) {
		_y = document.documentElement.clientHeight;
	} else if (document.body) {
		_y = document.body.clientHeight;
	}
	return {x:_x, y:_y};
};

// Retorna o tamanho de um objeto
getSize = function (e) {
	if (typeof e == 'string') e = $(e);
	return {x:e.offsetWidth, y:e.offsetHeight};
};
// Retorna a posio de um objeto
getPos = function (e) {
	if (typeof e == 'string') e = $(e);
	var left = 0;
	var top = 0;
	while (e.offsetParent) {
		left += e.offsetLeft;
		top += e.offsetTop;
		e = e.offsetParent;
	}
	left += e.offsetLeft;
	top += e.offsetTop;
	return {x:left, y:top};
};
/* Funo de easing */
findTweenValue = function (PS, PD, TS, TN, TD, AT, E1, E2) {
	var t = TN-TS, b = PS, c = PD-PS, d = TD-TS, a = E1, p = E2, s = E1;
	switch (AT.toLowerCase()) {
	case "linear" :
		return c*t/d+b;
	case "easeinexpo" :
		return (t == 0) ? b : c*Math.pow(2, 10*(t/d-1))+b;
	case "easeoutexpo" :
		return (t == d) ? b+c : c*(-Math.pow(2, -10*t/d)+1)+b;
	case "easeoutelastic" :
		if (t == 0) {
			return b;
		}
		if ((t /= d) == 1) {
			return b+c;
		}
		if (!p) {
			p = d*.3;
		}
		if (!a || a<Math.abs(c)) {
			a = c;
			var s = p/4;
		} else {
			var s = p/(2*Math.PI)*Math.asin(c/a);
		}
		return (a*Math.pow(2, -10*t)*Math.sin((t*d-s)*(2*Math.PI)/p)+c+b);
	}
};

// Aplica a posio x e y a um objeto
setPosition = function (obj, x, y) {
	with (obj.style) {
		top = x+'px';
		left = y+'px';
	}
};

/* Flash Sound Player */
var FS = {
	'active': true,
	'created': false,
	'enable': false,
	'enabled': function() {
		this.enable = true;
	},
	'create': function(){
		if (this.created == false) {
			$('SWFLoader').innerHTML += '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http:/'+'/download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,22,0" id="flahSound" width="0" height="0"><param name="movie" value="som.swf" /><param name="wmode" value="transparent" /><param name="allowscriptaccess" value="always" /><embed type="application/x-shockwave-flash" pluginspage="http:/'+'/www.macromedia.com/go/getflashplayer" name="flahSound" width="0" height="0" src="som.swf" bgcolor="#FFFFFF" swliveconnect="true" allowscriptaccess="always"></embed></object>';
			this.created = true;
		}
	},
	'play': function(som) {
		if (this.enable == true && this.active == true) getFlashObject('flahSound')._play(som);
	}
};

/* Simple Alert */
/*var SA = {
	'created': 0,
	'opened': 0,
	'size': null,
	'docSize': null,
	'scroll': null,
	'shakeEnabled': false,
	'open': function(txt, tipo) {
		this.create();
		tipo = tipo || 1;
		if (tipo == 1) {
			$('SAButtons').innerHTML = '<img src="/media/imgs/cadastro/alertaOK.gif" alt="" onclick="SA.click(\'OK\');" style="cursor:_pointer;" />';
		} else {
			$('SAButtons').innerHTML = '<img src="/media/imgs/cadastro/alertaSim.gif" alt="" onclick="SA.click(\'YES\');" style="cursor:_pointer;" /><img src="/media/imgs/cadastro/alertaNao.gif" alt="" onclick="SA.click(\'NO\');" style="cursor:_pointer;" />';
		}
		$('SAText').innerHTML = txt;
		if (this.opened == 0) {
			//FS.play('alert');
			shakeEnabled=false;
			this.reset();
			$('SA').style.top = (this.scroll.y-this.size.y)+'px';
			$('block').style.height = getDocSize().y+13+'px';
			$('block').style.display = 'block';
			var x = (this.docSize.x-this.size.x)/2+this.scroll.x;
			var y = (this.docSize.y-this.size.y)/2+this.scroll.y;
			//$('SA').tweenTo(y,x,'easeoutexpo',0.35,function(){shakeEnabled=true;});
			
			
			setPosition($('SA'),y,x);
			//this.refresh(true);
			this.opened = 1;
		} else {
			this.refresh(true);
			this.shake();
		}
	},
	'close': function() {
		if (this.opened == 1) {
			this.opened = 0;
			shakeEnabled=false;
			var x = (this.docSize.x-this.size.x)/2;
			//var y = this.docSize.y+this.size.y+this.scroll.y;
			var y = this.docSize.y+this.scroll.y;
			//$('SA').tweenTo(y,x,'easeinexpo',0.35,function(){
			   SA.reset();
			   SA.onClose();
			//});
			$('block').style.display = 'none';
		}
	},
	'reset': function() {
		this.size = getSize('SA');
		this.docSize = getDocVisibleSize();
		this.scroll = getScroll();
		var x = (this.docSize.x-this.size.x)/2;
		var y = (this.size.y)*(-1);
		if (this.opened == 0) {
			$('SA').style.top = y+'px';
			$('SA').style.left = x+'px';
		}
	},
	'refresh': function(type) {
		type = type || false;
		if (this.opened == 1) {
			shakeEnabled=false;
			this.size = getSize('SA');
			this.docSize = getDocVisibleSize();
			this.scroll = getScroll();
			var x = (this.docSize.x-this.size.x)/2+this.scroll.x;
			var y = (this.docSize.y-this.size.y)/2+this.scroll.y;
			if (type == false) {
				//$('SA').tweenTo(y,x,'easeoutexpo',0.25,function(){shakeEnabled=true;});
				setPosition($('SA'),y,x);
				
			} else {
				setPosition($('SA'),y,x);
			}
		}
	},
	'create': function() {
		if (this.created == 0) {
			new tween('SA');
			new shake('SA');
			$('SA').className = 'SA';
			this.created = 1;
		}
	},
	'shake': function() {
		if (this.opened == 1 && shakeEnabled == true) {
			//FS.play('nudge');
			shakeEnabled = false;
			$('SA').shakeNow(0.5,function(){shakeEnabled=true;});
		}
	},
	'click': function(a) {
		this.close();
		this.onClick(a);
	},
	'onClose': function(){},
	'onClick': function(){}
};
*/



/* Shake */
shake = function () {
	var obj = $(arguments[0]);
	var dist = 4;
	var moving = false;
	obj.numStepShake = 25;
	obj.thisIntervalShake = null;
	obj.onEnterFrameShake = function() {
		obj.numTimeShake += obj.numStepShake;
		var posX = Math.round((Math.random()*dist*2-dist)+obj.numInicioXShake);
		var posY = Math.round((Math.random()*dist*2-dist)+obj.numInicioYShake);
		setPosition(obj, posX, posY);
		if (obj.numTimeShake>=obj.numDurationShake) {
			setPosition(obj, obj.numInicioXShake, obj.numInicioYShake);
			clearInterval(obj.thisIntervalShake);
			obj.callbackShake();
			moving = false;
		}
	};
	obj.shakeNow = function() {
		if (moving == true) {
			obj.stopShake();
		}
		var pos = getPos(obj);
		this.numTimeShake = 0;
		this.numInicioXShake = pos.y;
		this.numInicioYShake = pos.x;
		this.numDurationShake = (arguments[0]) ? arguments[0]*1000 : 1000;
		this.callbackShake = arguments[1] || function () {
		};
		obj.thisIntervalShake = setInterval(obj.onEnterFrameShake, obj.numStepShake);
		moving = true;
	};
	obj.stopShake = function() {
		clearInterval(obj.thisIntervalShake);
		setPosition(obj, obj.numInicioXShake, obj.numInicioYShake);
	};
};
/* Evento window.onstopscroll */
window.intervalstopscroll = null;
window.onscroll = function() {
	clearTimeout(window.intervalstopscroll);
	window.intervalstopscroll = setTimeout('window.onstopscroll2();', 50);
};
window.onstopscroll2 = function() {
	SA.refresh();
};

/* Font Size */
var fontSize = {
	'atual': 12,
	'minimo': 10,
	'maximo': 16,
	'local': 'conteudoPrint',
	'change': function(a) {
		this.atual += a;
		if (this.atual < this.minimo) this.atual = this.minimo;
		if (this.atual > this.maximo) this.atual = this.maximo;
		$(this.local).style.fontSize = this.atual+'px';
		//CK.w('fontSize',this.atual,7);
		//alert(this.atual);
	},
	'init': function() {
		var novo;				
		//if (novo = CK.r('fontSize')*1) 
		//{
			//this.atual = novo;
			//this.change(0);
		//}
	}
};

window.onload = function() {

	// Inicia o tamanho da fonte
	//fontSize.init();
	
};

function VCPF(pForm, pCampo)
 {
	var wVr, wVrCPF, wVrSEQ, wTam, wSoma, wSoma2, i, j, wDig1, wDig2,aux,
	    wVETOR_CC = new Array(11),
	    wVETOR_PESO = new Array(11);
 	var Erro = false;
	wVrCPF = pForm[pCampo].value;
	aux = pForm[pCampo].value;
	wVr = aux;
  
	//jrrrr   wVr= aux.toString().substring(0,3) + aux.toString().substring(4,7) + aux.toString().substring(8,11) + aux.toString().substring(12,14) ;     

//	wVr = wVr.toString().replace(".","");
//	wVr = wVr.toString().replace(".","");
//	wVr = wVr.toString().replace(".","");
//	wVr = wVr.toString().replace("-","");
	wTam = wVr.length + 1;

    if (wTam < 11) {
	  //alert("N de dgitos do CPF menor que o normal. Redigite !!!");
	  pForm[pCampo].value = "";
	  pForm[pCampo].focus();
	  return false;
	}
    
	for (i = 0; i < wVr.length; i++) {
	   if (isNaN(parseInt(wVr.charAt(i))) ) {
  	     //alert("O CPF contm dgitos invlidos. Corrija-o !!!");
	     pForm[pCampo].value = "";
	     pForm[pCampo].focus();
	     return false;
	   }
	}
	
	//comentado abaixo por claudio para testes
	//if (wVr == '11111111111' || wVr == '22222222222' || wVr == '33333333333' || wVr == '44444444444' || wVr == '55555555555' || 
	//    wVr == '66666666666' || wVr == '77777777777' || wVr == '88888888888' || wVr == '99999999999') {
  	//     alert("CPF Invlido. Redigite-o !!!");
	//     pForm[pCampo].value = "";
	//     pForm[pCampo].focus();
	//     return false;
    //	}
    
    wSoma = 0;
	wSoma2 = 0;
    j = 2;
    for (i = 0; i < 11; i++) {
	   wVETOR_CC[i] = wVr.charAt(i);
	   wVETOR_PESO[i] = j;
	   j++; 
	} 
    i = 0;	  
    while (i < 9)  {
	   i++;
	   if (i < 10) {
          wSoma += wVETOR_CC[9 - i] * wVETOR_PESO[i - 1]; }
	   wSoma2 += wVETOR_CC[10 - i] * wVETOR_PESO[i - 1];
	}
	wDig1 = (wSoma * 10) % 11;
	wDig2 = (wSoma2 * 10) % 11;
	if (wDig1 == 10) { 
	    wDig1 = 0;
	}	
	if (wDig2 == 10) { 
	    wDig2 = 0;
	}		
    if (parseInt(wVr.charAt(9)) != wDig1 || parseInt(wVr.charAt(10)) != wDig2) {
  	     //alert("CPF com Dgito Verificador invlido. Redigite-o !!!");
//	     pForm[pCampo].value = "";
	     pForm[pCampo].focus();
	     return false;
    }	
    pForm[pCampo].value = wVrCPF;
//    pForm[pCampo + 1].value = wVrSEQ;

	return true;  // VerificaChaveAcesso(pForm, 1, 2, 3);
}

var keyCodigo = 0;

function soNumeroPress(evento)
{

	if (keyCodigo == 0)
	{	
		keyCodigo = evento.keyCode;	
	}
	
	if ((keyCodigo == 8 || keyCodigo == 13 || keyCodigo == 9 || keyCodigo == 71 || keyCodigo == 46 || keyCodigo  == 37  || keyCodigo  == 39) || (keyCodigo >= 48 && keyCodigo <= 57) || (keyCodigo >= 96 && keyCodigo <= 105)) 
	{
		VerifiqueTAB=true; 
		return true;
	} 
	else
	{
		return false;
	}
}


function soNumeroDown(evento)
{
	keyCodigo = evento.keyCode;

	if ((keyCodigo == 8 || keyCodigo == 13 || keyCodigo == 9 || keyCodigo == 46) || (keyCodigo >= 48 && keyCodigo <= 57) || (keyCodigo >= 96 && keyCodigo <= 105))
	{
		VerifiqueTAB=true; 

		return true;
	} 
	else 
	{
		return false;
	}
}

VerifiqueTAB=true;
function Mostra(quem, tammax) {
	if ( (quem.value.length == tammax) && (VerifiqueTAB) ) {
		var i=0,j=0, indice=-1;
		for (i=0; i<document.forms.length; i++) {
			for (j=0; j<document.forms[i].elements.length; j++) {
				if (document.forms[i].elements[j].name == quem.name) {
					indice=i;
					break;
				}
			}
			if (indice != -1)
		         break;
		}
		for (i=0; i<=document.forms[indice].elements.length; i++) {
			if (document.forms[indice].elements[i].name == quem.name) {
				while ( (document.forms[indice].elements[(i+1)].type == "hidden") &&
						(i < document.forms[indice].elements.length) ) {
							i++;
				}
				document.forms[indice].elements[(i+1)].focus();
				VerifiqueTAB=false;
				break;
			}
		}
	}
}

/* Formulrios */
campoAtual = '';
formError = function(campo, mensagem) {
	campoAtual = campo;
	
	SA.onClose = function() 
	{
		if (!stageTest(campoAtual)) {
			SC.scroll(getPos(campoAtual).y-20,'easeoutexpo',0.5,function(){focusTo(campoAtual);});
		} else {
			focusTo(campoAtual);
		}
	};
	SA.open('Aten&ccedil;&atilde;o!', mensagem);
	
};

stageTest = function(o) {
	var DSC = getScroll().y;
	var DVS = getDocVisibleSize().y;
	var OP = getPos(o).y;
	var OS = getSize(o).y;
	return (DSC < OP && OP+OS < DVS+DSC);
};

focusTo = function(o) {
	try {
		$(o).focus();
		$(o).select();
	} catch(e) {}
};

function addFav(){
	var url = window.location.href;
	var title = "TRINOLEX.COM - o seu portal jurdico";

    if (window.sidebar) window.sidebar.addPanel(title, url,"");
    else if(window.opera && window.print){
        var mbm = document.createElement('a');
        mbm.setAttribute('rel','sidebar');
        mbm.setAttribute('href',url);
        mbm.setAttribute('title',title);
        mbm.click();
    }
    else if(document.all){window.external.AddFavorite(url, title);}
}

///////////////////////////////////////////////////////////////
// Objeto para trabalho com xml                              //
// Verso: 2.0                                               //
///////////////////////////////////////////////////////////////
//var URLdominio = "http://www.trinolex.com.br/novo/";
var URLdominio = "http://200.189.179.17/trinolex/";
xmlConnection = function() {

	// Variveis utilizadas no objeto
	var strNav = new String('');
	var objAjax = null;
	var strMethod = new String('GET');
	var strParams = new String('');
	var strURL = new String('');
	var strChildName = new String('');
	var arrParamName = new Array();
	var arrParamValue = new Array();
	var numTotalParams = new Number(0);
	var xmlReturn = null;
	var textReturn = new String('');
	var thisObj = this;
	
	// Evento executado quando o xml  lido comsucesso
	this.onComplete = function () { };
	// Evento executado quando o xml acabou de ser lido | Retorna o cdigo do resultado Ex.: 200, 401...
	this.onLoad = function () { };
	// Evento executado quando o xml troca de status | Retorna o status atual
	this.onStateChange = function () { };
	// Evento executado quando o xml no foi lido | Retorna o cdigo do erro
	this.onError = function() { alert('Erro ao ler o xml!'); }
	
	// Adiciona itens as array de parmetros (variveis que sero passadas)
	this.addParameters = function() {	
		arrParamName[numTotalParams] = arguments[0];
		arrParamValue[numTotalParams] = arguments[1];
		numTotalParams++;
	}
	this.add = function() {
		arrParamName[numTotalParams] = arguments[0];
		arrParamValue[numTotalParams] = arguments[1];
		numTotalParams++;
	};	


	// Limpa o array de parmetros
	this.emptyParameters = function() {
		numTotalParams = new Number(0);
		arrParamName = new Array();
		arrParamValue = new Array();
	}
	
	// Informa para o objeto a URL do xml
	this.setURL = function() {
		strURL = arguments[0];
	}

	// Informa para o objeto o mtodo utilizado para os envios dos dados
	this.setMethod = function() {
		if ((arguments[0].toUpperCase() == 'POST') || (arguments[0].toUpperCase() == 'GET')) {
			strMethod = arguments[0].toUpperCase();
		}
	}
	
	// Informa para o objeto o nome da tag padro para retorno dos dados
	this.setChildName = function() {
		strChildName = arguments[0];
	}

	// Retorna o status da leitura do xml
	this.getStatus = function() {
		return objAjax.statusText;
	}

	// Retorna o browser do usurio ('ie' ou 'ff')
	this.getBrowser = function() {
		return strNav;
	}

	// Retorna o XML recebido
	this.getXML = function() {
		return xmlReturn;
	}

	// Retorna o texto recebido
	this.getText = function() {
		return textReturn;
	}
	
	// Retorna a quantidade de itens da tag especificada pela funo setChildName
	this.getCountItens = function() {
		return xmlReturn.getElementsByTagName(strChildName).length;
	}
	
	// Retorna o atributo da tag especificada pela funo setChildName
	this.getAttByName = function() {
		try { return xmlReturn.getElementsByTagName(strChildName)[arguments[1]].getAttribute(arguments[0]); } catch(e) { return null; }
	}
	
	// Retorna o CDATA da tag especificada pela funo setChildName
	this.getDataByName = function() {
		try { return xmlReturn.getElementsByTagName(strChildName)[arguments[0]].firstChild.data; } catch(e) { return null; }
	}
	
	// Faz o envio de dados e aguarda o retorno
	this.execute = function() {
		strParams = '';
		for (var i = 0; i < arrParamName.length; i++) {
			if (i > 0) strParams += '&';
			strParams += arrParamName[i]+'='+arrParamValue[i];
		}
		if (strMethod == 'GET') {
			objAjax.open(strMethod, strURL+'?'+strParams, true);
		} else {
			objAjax.open(strMethod, strURL, true);
		}
		objAjax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");//; iso-8859-1
		objAjax.setRequestHeader("CharSet", "UTF-8");
		objAjax.setRequestHeader("Cache-Control","no-store, no-cache, must-revalidate");
		objAjax.setRequestHeader("Cache-Control","post-check=0, pre-check=0");
		objAjax.setRequestHeader("Pragma", "no-cache");
		objAjax.onreadystatechange = function() {
			thisObj.onStateChange(objAjax.readyState);
			if (objAjax.readyState == 4){
				thisObj.onLoad(objAjax.status);
				if (objAjax.status == 200){
					xmlReturn = objAjax.responseXML;
					textReturn = objAjax.responseText;
					thisObj.onComplete();
				} else {
					thisObj.onError(objAjax.statusText, objAjax.status);
				}
			}
		}
		if (strMethod == 'GET') {
			objAjax.send(null);
		} else {
			objAjax.send(strParams);
		}
	}

	// Cria o objeto AJAX (utilizado para envio e recebimento dos dados)
	this.create = function() {
		if (window.ActiveXObject) {
			strNav = 'ie';
			try {
				objAjax = new ActiveXObject("Msxml2.XMLHTTP.4.0");
			} catch(e) {
				try {
					objAjax = new ActiveXObject("Msxml2.XMLHTTP.3.0");
				} catch(e) {
					try {
						objAjax = new ActiveXObject("Msxml2.XMLHTTP");
					} catch(e) {
						try {
							objAjax = new ActiveXObject("Microsoft.XMLHTTP");
						} catch(e) {
							objAjax = null;
							return false;
						}
					}
				}
			}
		} else if (window.XMLHttpRequest) {
			objAjax = new XMLHttpRequest();
			strNav = 'ff';
		}
		return true;
	}

}

// Controla a posio do scroll
var SC = {
	'interval': null,
	'initPos': 0,
	'finalPos': 0,
	'timeNow': 0,
	'timeTotal': 0,
	'effect': '',
	'step': 20,
	'fn': 20,
	'scroll': function(pos,effect,time,fn) {
		var sc = getScroll();
		SC.fn = fn || function(){};
		SC.timeTotal = (time)?time*1000:1000;
		SC.timeNow = 0;
		SC.initPos = sc.y;
		SC.finalPos = pos;
		SC.effect = effect;
		clearInterval(SC.interval);
		SC.interval = setInterval(SC.enterFrame,SC.step);
	},
	'enterFrame': function() {
		var sc = findTweenValue(SC.initPos, SC.finalPos, 0, SC.timeNow, SC.timeTotal, SC.effect);
		window.scrollTo(0,sc);
		SC.timeNow += SC.step;
		if (SC.timeNow >= SC.timeTotal) {
			clearInterval(SC.interval);
			SC.fn();
		}
	}
};



String.prototype.isWhite = function() {
  if (!isVoid(this)) {
	var value = this.replace(/^\s+/m,'').replace(/\s+$/m,'');
    return (value == '');
  }
  return true;
}
function validateEmail(email) {
  return (/^[A-Za-z0-9]+(([\.\_\-]{1}[A-Za-z0-9]+)+)?@[A-Za-z0-9]+(([\.\_\-]{1}[A-Za-z0-9]+)+)?\.[A-Za-z]{2,4}$/.test(email));
}
function isVoid(obj) {
	if (obj != null && typeof obj != 'undefined' && obj != "") return false;
	return true;
}
validaCpf = function(cpf) {
	var rrValida = new Array(00000000000,11111111111,22222222222,33333333333,44444444444,55555555555,66666666666,77777777777,88888888888,99999999999);
	for(i=0;i<11;i++){
		if(cpf == rrValida[i]){
			return false;	
		}
	}
    var i;
    var c = cpf.substr(0,9);
    var dv = cpf.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;
}

mask = function(strMask, ev, objData) {
	ev = ev || event;
	var key = getKey(ev);
	if (isNum(key, '%\'#$.') == true) {
		return true;
	}
	if (!(key>=37 && key<=40)) {
		var valor = filter2(objData.value, '0123456789');
		var tam = valor.length;
		var tamMask = strMask.length;
		var strOut = '';
		var intCont = 0;
		for (var a = 0; a<tamMask && intCont<=tam; a++) {
			if (strMask.substr(a, 1) == '#') {
				strOut += valor.substr(intCont++, 1);
			} else {
				strOut += strMask.substr(a, 1);
			}
		}
		objData.value = strOut;
		return true;
	}
};

validaCnpj = function(cnpj) {
    var i;
    var c = cnpj.substr(0,12);
    var dv = cnpj.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;
}

radio = function(object) {
	if(typeof object == 'object'){
		var strChek = object.name;
	}else{
		var strChek = object;
	}
	obj = document.getElementsByTagName('input');
	for (var i = 0; i< obj.length; i++){
	    if (obj[i].type == 'radio' && obj[i].name == strChek  && obj[i].checked){
			return obj[i].value;
		}
	}
	return null
}