function getVars(){
	varArray = document.location.href.split('?')[1].split('&');

	for(var x=0; x<varArray.length; x++){
		var tmp = varArray[x].split('=');
		eval(unescape(tmp[0]) + '="' + unescape(tmp[1]) + '"');
	}
}
//getVars();

function getParameter(name){
	  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
	  var regexS = "[\\?&]"+name+"=([^&#]*)";
	  var regex = new RegExp( regexS );
	  var results = regex.exec( window.location.href );
	  if( results == null )
	    return "";
	  else
	    return results[1];
}

function getParameterMap(){
	var varArray = document.location.href.split('?')[1].split('&');

	var ret = {};
	for(var x=0; x<varArray.length; x++){
		var tmp = varArray[x].split('=');
		if( tmp != "" && tmp != undefined){
			ret[unescape(tmp[0])] = unescape(tmp[1]);
		}
	}
	
	return ret;
}

 // Inclusao de funcoes para strings
String.prototype.startsWith = function(str){
	return (str == this.toString().substring(0, str.length));
}

String.prototype.endsWith = function(str){
	var t = this.toString().length;
	var p = t - str.length;
	return (this.toString().substr( p, t ) == str);
}

function showHideDiv(nr){
	if (document.getElementById){
		vista = (document.getElementById(nr).style.display != 'block' && document.getElementById(nr).style.display !=  '') ? 'block' : 'none';
		document.getElementById(nr).style.display = vista;
	}
}

// Função para resolver problema de banners por cima do GreyBox
function escondeItens(){
	var bannersTop = document.getElementById('fullbanner');
	if (bannersTop.style.visibility != "hidden") {
		bannersTop.style.visibility = "hidden";
	}
	else {
		bannersTop.style.visibility = "visible";
	}
}

function escondeAds(){
	var adsTopo = document.getElementById("superbanner");
	var adsBannersOpt = document.getElementById("banners-opt");

	if(adsTopo){
		showHideDiv("superbanner");
	}if(adsBannersOpt){
		showHideDiv("banners-opt");
	}
}

function Trim(TRIM_VALUE){
	if(TRIM_VALUE.length < 1){
		return"";
	}
	TRIM_VALUE = RTrim(TRIM_VALUE);
	TRIM_VALUE = LTrim(TRIM_VALUE);
	if(TRIM_VALUE==""){
		return "";
	}
	else{
		return TRIM_VALUE;
	}
}
	
function RTrim(VALUE){
	var w_space = String.fromCharCode(32);
	var v_length = VALUE.length;
	var strTemp = "";
	if(v_length < 0){
		return "";
	}
	var iTemp = v_length -1;
	
	while(iTemp > -1){
		if(VALUE.charAt(iTemp) == w_space){
		}else{
			strTemp = VALUE.substring(0,iTemp +1);
			break;
		}
		iTemp = iTemp-1;
	}
	return strTemp;
	
}

function LTrim(VALUE){
	var w_space = String.fromCharCode(32);
	if(v_length < 1){
		return"";
	}
	var v_length = VALUE.length;
	var strTemp = "";
	
	var iTemp = 0;
	
	while(iTemp < v_length){
		if(VALUE.charAt(iTemp) == w_space){
		}else{
			strTemp = VALUE.substring(iTemp,v_length);
			break;
		}
		iTemp = iTemp + 1;
	}
	return strTemp;
}

function popUp(URL,name,W,H) {
	var NewPop = null;
	var x = (window.screen.width - W)/2;
	var y = (window.screen.height - H)/2;
	NewPop = window.open(URL,name,'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,left='+ x +',top='+ y +',width='+ W +',height='+ H + '');
	NewPop.focus();
}

// Função de Focus para campos de um formulário
function sf(inputId){
	document.getElementById(inputId).focus();	
}

// FUNÇÃO PARA VOLTAR
function voltar(vezes){
	window.history.go(vezes);
}

// FUNÇÃO PARA VOLTAR NA MESMA CONTROLLER
function voltarController(vezes){
	window.location=window.location;
}

// FUNÇÃO PARA REDIRECIONAR VIA JAVASCRIPT
function goToPage(local){
    window.location=local;
}

// FUNÇÃO PARA BOX FLUTUANTES
// USAGE: JSFX_FloatDiv("boxerros",  0,   10).floatIt();
var ns = (navigator.appName.indexOf("Netscape") != -1);
var d = document;
function JSFX_FloatDiv(id, sx, sy)
{
	var el=d.getElementById?d.getElementById(id):d.all?d.all[id]:d.layers[id];
	var px = document.layers ? "" : "px";
	window[id + "_obj"] = el;
	if(d.layers)el.style=el;
	el.cx = el.sx = sx;el.cy = el.sy = sy;
	el.sP=function(x,y){this.style.left=x+px;this.style.top=y+px;};

	el.floatIt=function()
	{
		var pX, pY;
		pX = (this.sx >= 0) ? 0 : ns ? innerWidth : 
		document.documentElement && document.documentElement.clientWidth ? 
		document.documentElement.clientWidth : document.body.clientWidth;
		pY = ns ? pageYOffset : document.documentElement && document.documentElement.scrollTop ? 
		document.documentElement.scrollTop : document.body.scrollTop;
		if(this.sy<0) 
		pY += ns ? innerHeight : document.documentElement && document.documentElement.clientHeight ? 
		document.documentElement.clientHeight : document.body.clientHeight;
		this.cx += (pX + this.sx - this.cx)/8;this.cy += (pY + this.sy - this.cy)/8;
		this.sP(this.cx, this.cy);
		setTimeout(this.id + "_obj.floatIt()", 40);
	}
	return el;
}