// JavaScript Document
var sitepath = "/";

function serveractual(){
	/*
	var the_url = document.location.href;
	
	var lead_slashes = the_url.indexOf("//");
	
	var domain_start = lead_slashes + 2;
	
	var without_resource = the_url.substring(domain_start, the_url.length);
	
	var next_slash = without_resource.indexOf("/");
	
	var domain = without_resource.substring(0, next_slash);
	
	var conta=0;
	var strRelativePath='./';
	for(i=domain_start; i<=the_url.length; i++){
		var without_resource = the_url.substring(domain_start, the_url.length);
		var next_slash = without_resource.indexOf("/");
		if(next_slash>-1){
			conta++;
			domain_start+=next_slash +1 ;
		}	
	}
	
	for(j=1; j<conta;j++){
		strRelativePath=strRelativePath + '../';
	}
	
	return strRelativePath;
	*/
	
	return "/";
}

function last_isCurrentMenu(url){
	var the_url = document.location.href;
	
	var lead_slashes = the_url.indexOf("//");
	
	var domain_start = lead_slashes + 2;
	
	var without_resource = the_url.substring(domain_start, the_url.length);
	
	var next_slash = without_resource.indexOf("/");
	
	var domain = without_resource.substring(0, next_slash);

	var initPath = domain_start + without_resource.indexOf("/");

	var endPath = next_slash; //the_url.lastIndexOf('/') + 1;
	var menuPath = the_url.substring(initPath, endPath);


	if(url==menuPath){
		return true;
	}else{
		return false;	
	}
	
}

function isCurrentMenu(url){
	var the_url = document.location.href;
	
	var lead_slashes = the_url.indexOf("//");
	
	var domain_start = lead_slashes + 2;
	
	var without_resource = the_url.substring(domain_start, the_url.length);
	
	var next_slash = without_resource.indexOf("/");
	
	var domain = without_resource.substring(0, next_slash);

	var initPath = domain_start + without_resource.indexOf("/");

	//Conta 3 slashes a seguir ao hostheader
	var conta=0;
	var inicio=initPath;
	for(i=initPath; i<=the_url.length; i++){
		var without_resource = the_url.substring(initPath, the_url.length);
		var next_slash = without_resource.indexOf("/");
		if(next_slash>-1){
			conta++;
			initPath+=next_slash +1 ;
		}
		if(conta==3){var fim=initPath};
	}
	
	
	var menuPath = the_url.substring(inicio, fim);
	
	//alert(menuPath)

	if(url==menuPath){
		return true;
	}else{
		return false;	
	}
	
}

//alert(isCurrentMenu("/particulares/solucoes_investimento/"))

function currentPage(){
var sPath = window.location.pathname;
var sPage = sPath.substring(sPath.lastIndexOf('/') + 1);
}

function isCurrentPage(Page){
var sPath = window.location.pathname;
var sPage = sPath.substring(sPath.lastIndexOf('/') + 1);	

	if(Page==sPage){
		return true;
	}else{
		return false;	
	}
}

function gup( name )
{
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var tmpURL = window.location.href;
  var results = regex.exec( tmpURL );
  if( results == null )
    return "";
  else
    return results[1];
}

function gparam(str, name)
{
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var tmpURL = str;
  var results = regex.exec( tmpURL );
  if( results == null )
    return "";
  else
    return results[1];
}
//------------------------------------------------------------------------------------------
function setCookie(name, value)
{
  document.cookie = name+"="+value;
}
function myGetCookie(name)
{
  if (document.cookie)
  {
    var cookies=document.cookie.split(";");
    for (var i=0; i<cookies.length; i++)
    {
      var varName=(cookies[i].split("=")[0]);
      var varValue=(cookies[i].split("=")[1]);

      while (varName.charAt(0)==" ")
        varName=varName.substr(1,varName.length);

      // the escape() function will url encode the value				
      if (varName==name)
        return escape(varValue);
    }
  }
  return " ";
}


function Set_Cookie( name, value, expires, path, domain, secure ) 
{
// set time, it's in milliseconds
var today = new Date();
today.setTime( today.getTime() );

/*
if the expires variable is set, make the correct 
expires time, the current script below will set 
it for x number of days, to make it for hours, 
delete * 24, for minutes, delete * 60 * 24
*/
if ( expires )
{
expires = expires * 1000 * 60 * 60 * 24;
}
var expires_date = new Date( today.getTime() + (expires) );

document.cookie = name + "=" +escape( value ) +
( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) + 
( ( path ) ? ";path=" + path : "" ) + 
( ( domain ) ? ";domain=" + domain : "" ) +
( ( secure ) ? ";secure" : "" );
}
	
	
function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}
//---------------------------------------------------------------------------------


function topo(){
document.write("<div align='right'><a href=\"#\"><img src=\"" + serveractual() + "images/comum/bot_topo.gif\"  height=\"15\"  align=\"absmiddle\" border=0></a></div> ");
}