//	WebHelp 5.10.004
var gsFileName="";
var gsDivName="";
var xmlDoc=null;
var sdocPath=null;
var gsInsertBeforeEndHTML="";
var sReplaceStringsSrc=new Array();
var gsDivName="dataDiv";
var gnLoadDivNum=0;
sReplaceStringsSrc[0]="&amp;";
sReplaceStringsSrc[1]="&gt;";
sReplaceStringsSrc[2]="&lt;";
sReplaceStringsSrc[3]="&quot;";
sReplaceStringsSrc[4]=String.fromCharCode(8364);
sReplaceStringsSrc[5]="&nbsp;";

var sReplaceStringsDst=new Array();
sReplaceStringsDst[0]="&";
sReplaceStringsDst[1]=">";
sReplaceStringsDst[2]="<";
sReplaceStringsDst[3]="\"";
sReplaceStringsDst[4]=String.fromCharCode(128);
sReplaceStringsDst[5]=" ";
var goHighLighted=null;

function _getRelativePath(strParentPath,strCurrentPath)
{
	if(_isAbsPath(strCurrentPath)) return _getPath(strCurrentPath);
	strParentPath=_replaceSlash(strParentPath);
	strParentPath=_getPath(strParentPath);
	strCurrentPath=_replaceSlash(strCurrentPath);
	strCurrentPath=_getPath(strCurrentPath);
	for(var i=0;i<strParentPath.length&&i<strCurrentPath.length;i++)
	{
		if(strParentPath.charAt(i)!=strCurrentPath.charAt(i))
			break;
	}
	
	strParentPath=strParentPath.substring(i);
	strCurrentPath=strCurrentPath.substring(i);	
	
	var nPathPos=0;
	while(nPathPos!=-1)
	{
		nPathPos=strParentPath.indexOf("/");
		if(nPathPos!=-1)
		{
			strParentPath=strParentPath.substring(nPathPos+1);
			strCurrentPath="../"+strCurrentPath;
		}
	}
	return strCurrentPath;
}

function _getRelativeFileName(strParentPath,strCurrentPath)
{
	strParentPath=_replaceSlash(strParentPath);
	strParentPath=_getPath(strParentPath);
	strCurrentPath=_replaceSlash(strCurrentPath);
	for(var i=0;i<strParentPath.length&&i<strCurrentPath.length;i++)
	{
		if(strParentPath.charAt(i)!=strCurrentPath.charAt(i))
			break;
	}
	
	strParentPath=strParentPath.substring(i);
	strCurrentPath=strCurrentPath.substring(i);	
	
	var nPathPos=0;
	while(nPathPos!=-1)
	{
		nPathPos=strParentPath.indexOf("/");
		if(nPathPos!=-1)
		{
			strParentPath=strParentPath.substring(nPathPos+1);
			strCurrentPath="../"+strCurrentPath;
		}
	}
	return strCurrentPath;
}

function _isAbsPathToHost(sPath)
{
	return (sPath.indexOf("/")==0);
}

function _getHost(sPath)
{
	var nPos=sPath.indexOf("//");
	if(nPos>0)
	{
		var nPosx=sPath.indexOf("/",nPos+2);
		if(nPosx>0)
			return sPath.substring(0,nPosx);
		else
			return sPath;
	}
	return sPath;
}

function _getFullPath(sPath,sRelPath)
{
	if(_isAbsPath(sRelPath))
		return sRelPath;
	else if(_isAbsPathToHost(sRelPath))
		return _getHost(sPath)+sRelPath;
	else
	{
		var sFullPath=sPath;
		var nPathPos=0;
		while(nPathPos!=-1)
		{
			var nPathPos=sRelPath.indexOf("../");
			if(nPathPos!=-1)
			{
				sRelPath=sRelPath.substring(nPathPos+3);
				sFullPath=sFullPath.substring(0,sFullPath.length-1);
				var nPos2=sFullPath.lastIndexOf("/");
				if(nPos2!=-1)
					sFullPath=sFullPath.substring(0,nPos2+1);
				else
					break;
			}
		}
		sFullPath+=sRelPath;
		return sFullPath;
	}	
}

function _isAbsPath(strPath)
{
	var strUpper=strPath.toUpperCase();
	return (strUpper.indexOf(":")!=-1||strUpper.indexOf("\\\\")==0);
}

function _replaceSlash(strURL)
{	
	var re=new RegExp("\\\\","g");
	var strReplacedURL=strURL.replace(re,"/");
	return strReplacedURL;
}

function _getPath(strURL)
{
	pathpos=strURL.lastIndexOf("/");
	if(pathpos>0)
		return strURL.substring(0,pathpos+1);
	else
		return "";
}

function removeItemFromArray(oArray,i)
{
	if(oArray.length&&i>=0&&i<oArray.length)
	{
		var len=oArray.length;
		for(var s=i;s<len-1;s++)
			oArray[s]=oArray[s+1];
		oArray.length=len-1;
	}
}

function insertItemIntoArray(oArray,i,obj)
{
	if(oArray.length&&i>=0&&i<=oArray.length)
	{
		var len=oArray.length;
		for(var s=len;s>i;s--)
			oArray[s]=oArray[s-1];
		oArray[i]=obj;		
	}
}

function loadData(sFileName)
{
	var i=gnLoadDivNum;
	var sName=gsDivName+gnLoadDivNum++;
	loadData_2(sFileName,sName);
}

function loadData_2(sFileName,sDivName)
{
	if(!getElement(sDivName))
	{
		if(!insertDataDiv(sDivName))
		{
			gsFileName=sFileName;
			gsDivName=sDivName;
			return;
		}
	}
	var sHTML="";
	if(gbMac)
		sHTML+="<iframe src=\""+sFileName+"\"></iframe>";
	else
		sHTML+="<iframe style=\"visibility:hidden;width:0;height:0\" src=\""+sFileName+"\"></iframe>";
	
	var oDivCon=getElement(sDivName);
	if(oDivCon)
	{
		if(gbNav6)
		{
			if(oDivCon.getElementsByTagName&&oDivCon.getElementsByTagName("iFrame").length>0)
			{
				oDivCon.getElementsByTagName("iFrame")[0].src=sFileName;
			}
			else
				oDivCon.innerHTML=sHTML;
		}
		else
			oDivCon.innerHTML=sHTML;
	}
}

function loadDataXML(sFileName)
{
	var sCurrentDocPath=_getPath(document.location.href);
	sdocPath=_getFullPath(sCurrentDocPath,sFileName);
	if(gbIE5)
	{
		xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
		xmlDoc.async=true;
		xmlDoc.onreadystatechange=checkState;
		if(document.body!=null)
			xmlDoc.load(sdocPath);
	}
	else if(gbNav6)
	{
		xmlDoc=document.implementation.createDocument("","",null);
		xmlDoc.addEventListener("load",initializeData,false);
		xmlDoc.load(sdocPath,"text/xml");
	}
}

function initializeData()
{
	if(xmlDoc!=null)
		putDataXML(xmlDoc,sdocPath);
}

function checkState()
{
	if(xmlDoc!=null)
	{
		var state=xmlDoc.readyState;
		if(state==4)
		{
			var err=xmlDoc.parseError;
			if(err.errorCode==0)
				putDataXML(xmlDoc,sdocPath);
			else
				onLoadXMLError();
		}
	}
}

function insertDataDiv(sName)
{
	var sHTML="";
	if(gbMac)
		sHTML+="<div id="+sName+" style=\"display:none;\"></div>";
	else
		sHTML+="<div id="+sName+" style=\"visibility:hidden\"></div>";
	if((gbIE5||gbNav6)&&document.body)
		document.body.insertAdjacentHTML("beforeEnd",sHTML);
	else
	{
		gsInsertBeforeEndHTML=sHTML;
		setTimeout("insertWhenBodyReady();",100);
		return false;
	}
	return true;
}

function insertWhenBodyReady()
{
	if(gsInsertBeforeEndHTML=="") return;
	if(document.body)
	{
		document.body.insertAdjacentHTML("beforeEnd",gsInsertBeforeEndHTML);
		gsInsertBeforeEndHTML="";
		loadData_2(gsFileName,gsDivName);
	}
	else
	{
		setTimeout("insertWhenBodyReady();",100);
	}
}

function window_BUnload()
{
	for(var i=0;i<gnLoadDivNum;i++)
	{
		var oDivCon=getElement(gsDivName+i);
		if(oDivCon)
			oDivCon.innerHTML="";
	}
}

function removeThis(obj)
{
	if(obj.parentNode)
		obj.parentNode.removeChild(obj);
	else
		obj.outerHTML="";
}

function getParentNode(obj)
{
	if(obj.parentNode)
		return obj.parentNode;
	else if(obj.parentElement)
		return obj.parentElement;
	return null;
}

function getElement(sID)
{
	if(document.getElementById)
		return document.getElementById(sID);
	else if(document.all)
		return document.all(sID);
	return null;
}

function getChildrenByTag(obj,sTagName)
{
	if(obj.getElementsByTagName)
	{
		var aChildren=new Array();
		var aElements=getElementsByTag(obj,sTagName);
		if(aElements!=null)
		{
			for(var i=0;i<aElements.length;i++)
			{
				if(aElements[i].parentNode==obj)
					aChildren[aChildren.length]=aElements[i];
			}
			return aChildren;
		}
		else
			return new Array();
	}
	else if(obj.children)
		return obj.children.tags(sTagName);
}

function getElementsByTag(obj,sTagName)
{
	if(obj.getElementsByTagName)
		return obj.getElementsByTagName(sTagName);
	else if(obj.all)
		return obj.all.tags(sTagName);
	return null;
}

function _htmlToText(sHTML)
{
	if(sHTML==null) return null;
	var sText=sHTML;
	for(var i=0;i<sReplaceStringsSrc.length;i++)
	{
		var re=new RegExp(sReplaceStringsSrc[i],"g");
		sText=sText.replace(re,sReplaceStringsDst[i]);
	}	
	return sText;
}

function _textToHtml_nonbsp(sText)
{
	if(sText==null) return null;
	var sHTML=sText;
	for(var i=0;i<sReplaceStringsSrc.length-1;i++)
	{
		var re=new RegExp(sReplaceStringsDst[i],"g");
		sHTML=sHTML.replace(re,sReplaceStringsSrc[i]);
	}	
	return sHTML;
}

function _textToHtml(sText)
{
	if(sText==null) return null;
	var sHTML=sText;
	for(var i=0;i<sReplaceStringsSrc.length;i++)
	{
		var re=new RegExp(sReplaceStringsDst[i],"g");
		sHTML=sHTML.replace(re,sReplaceStringsSrc[i]);
	}	
	return sHTML;
}


function getInnerText(obj)
{
	var renbsp2sp=new RegExp("\xa0","g");
	if(obj.innerText)
	{
		var sText=obj.innerText;
		sText=sText.replace(renbsp2sp," ");
		return sText;
	}
	else
	{
		if(obj.nodeValue)
		{
			var sValue=obj.nodeValue;
			sValue=sValue.replace(renbsp2sp," ");
			return sValue;
		}
		else
		{
			var sText="";
			var oChild=obj.firstChild;
			while(oChild!=null)
			{
				sText+=getInnerText(oChild);
				oChild=oChild.nextSibling;
			}
			return sText;
		}
	}
		
}

function HighLightElement(obj,sHighLightColor,sNormalColor)
{
	if(obj!=null)
	{
		resetHighLight(sNormalColor);
		if (obj.style)
			obj.style.backgroundColor=sHighLightColor;
		goHighLighted=obj;
	}
}

function resetHighLight(sNormalColor)
{
	if(goHighLighted!=null)
	{
		if (goHighLighted.style)
			goHighLighted.style.backgroundColor=sNormalColor;
		goHighLighted=null;
	}
}

function whFont(sName,sSize,sColor,sStyle,sWeight,sDecoration)
{
	this.sName=sName;
	this.sSize=sSize;
	this.sColor=sColor;
	this.sStyle=sStyle;
	this.sWeight=sWeight;
	this.sDecoration=sDecoration;
}

function getFontStyle(oFont)
{
	var sStyle="";
	if(oFont)
	{
		sStyle+="font-family:"+oFont.sName+";";
		if(gbMac)
		{
			var nSize=parseInt(oFont.sSize);
			if(gbIE5)
				nSize+=2;
			else
				nSize+=4;
			sStyle+="font-size:"+nSize+"pt;";
		}
		else
			sStyle+="font-size:"+oFont.sSize+";";
			
		sStyle+="font-style:"+oFont.sStyle+";";
		sStyle+="font-weight:"+oFont.sWeight+";";
		sStyle+="text-decoration:"+oFont.sDecoration+";";
		sStyle+="color:"+oFont.sColor+";";
	}
	return sStyle;
}

function _browserStringToText(sBStr)
{
	var sText="";
	// change %xxx back to the real char.
	var nPos=sBStr.indexOf('%');
	while(nPos!=-1)
	{
		sText+=sBStr.substring(0,nPos);
		sBStr=sBStr.substring(nPos+1);
		var sNum="";
		var i=0;
		while(sBStr.charAt(i)>='0'&&sBStr.charAt(i)<='9')
		{
			sNum+=sBStr.charAt(i++);	
		}
		if(sNum!=""){
			var nNum=parseInt(sNum,16);
			sText+=String.fromCharCode(nNum);
			sBStr=sBStr.substring(i);
		}
		nPos=sBStr.indexOf('%');
	}
	sText+=sBStr;
	return sText;
}

function excapeSingleQuotandSlash(str)
{
	if(str==null) return null;
	var nPos=0;
	var sRes="";
	var nPosNew=str.indexOf("\\",nPos);
	while(nPosNew!=-1){
		sRes+=str.substring(nPos,nPosNew+1)+"\\";
		nPos=nPosNew+1;
		nPosNew=str.indexOf("\\",nPos);
	}
	if(nPos<str.length)
		sRes+=str.substring(nPos);
	var re=new RegExp("'","g");
	sRes=sRes.replace(re,"\\'");
	return sRes;
}

var gbWhUtil=true;







//Funcoes acrescentadas para poder usar o highlight das palavras de busca
//Pega o valor do cookie esta função é requerida pela GetCookie 
function getCookieVal (offset) 
{
   var endstr = document.cookie.indexOf (";", offset);
   if (endstr == -1)
      endstr = document.cookie.length;
   return unescape(document.cookie.substring(offset, endstr));
}

//Esta função le um cookie com o nome passado como parametro
function GetCookie (name) 
{
   var arg = name + "=";
   var alen = arg.length;
   var clen = document.cookie.length;
   var i = 0;
   while (i < clen) 
      {
      var j = i + alen;
      if (document.cookie.substring(i, j) == arg)
         return getCookieVal (j);
      i = document.cookie.indexOf(" ", i) + 1;
      if (i == 0) break; 
      }
   return null;
}

//Seta o cookie com um nome e um valor
function SetCookie (name, value) 
{   
	 var argv = SetCookie.arguments;
   var argc = SetCookie.arguments.length;
   var expires = (argc > 2) ? argv[2] : null;
   var path = (argc > 3) ? argv[3] : null;
   var domain = (argc > 4) ? argv[4] : null;
   var secure = (argc > 5) ? argv[5] : false;
   document.cookie = name + "=" + escape (value) +
        ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
        ((path == null) ? "" : ("; path=" + path)) +
        ((domain == null) ? "" : ("; domain=" + domain)) +
        ((secure == true) ? "; secure" : "");
}

//Deleta um cookie
function DeleteCookie () 
{
   var exp = new Date();
   exp.setTime (exp.getTime() - 1000000000);
   var cval = GetCookie ('DemoName');
   document.cookie ='DemoName' + "=" + cval + "; expires=" + exp.toGMTString();
   //alert("O cookie foi deletado com sucesso!");
}

function doHighlight(bodyText, searchTerm, highlightStartTag, highlightEndTag) 
{
  // the highlightStartTag and highlightEndTag parameters are optional
  if ((!highlightStartTag) || (!highlightEndTag)) {
    highlightStartTag = "<font style='color:white; background-color:red;'>";
    highlightEndTag = "</font>";
  }
  
  // find all occurences of the search term in the given text,
  // and add some "highlight" tags to them (we're not using a
  // regular expression search, because we want to filter out
  // matches that occur within HTML tags and script blocks, so
  // we have to do a little extra validation)
  var newText = "";
  var i = -1;
  var lcSearchTerm = searchTerm.toLowerCase();
	//var lcSearchTerm = searchTerm;
  var lcBodyText = bodyText.toLowerCase();
	//var lcBodyText = bodyText;      
	
	while (bodyText.length > 0)
	{
    i = lcBodyText.indexOf(lcSearchTerm, i+1);    		
		//alert(lcBodyText);
		//alert(i);
		//alert(lcSearchTerm);		
		//Se não achou o termo para colorir no corpo de html				
		if (i < 0)
		{
      newText += bodyText;
      bodyText = "";
    }
		//Se achou o termo para colorir no corpo de html
		else
		{
      //Não mostra nada que esta dentro de uma tag html
      if (bodyText.lastIndexOf(">", i) >= bodyText.lastIndexOf("<", i))
			{
        //Não pega tudo que estiver entre a tag <script></script>        
				if ( (lcBodyText.lastIndexOf("/script>", i) >= lcBodyText.lastIndexOf("<script", i))&&(lcBodyText.lastIndexOf("/textarea>", i) >= lcBodyText.lastIndexOf("<textarea", i)) )
				{
          newText += bodyText.substring(0, i) + highlightStartTag + bodyText.substr(i, searchTerm.length) + highlightEndTag;
          bodyText = bodyText.substr(i + searchTerm.length);
          lcBodyText = bodyText.toLowerCase();
          i = -1;
        }
      }
    }
  }
  
  return newText;
}


/*
 * This is sort of a wrapper function to the doHighlight function.
 * It takes the searchText that you pass, optionally splits it into
 * separate words, and transforms the text on the current web page.
 * Only the "searchText" parameter is required; all other parameters
 * are optional and can be omitted.
 */
function highlightSearchTerms(searchText, treatAsPhrase, warnOnFailure, highlightStartTag, highlightEndTag)
{  
  // if the treatAsPhrase parameter is true, then we should search for 
  // the entire phrase that was entered; otherwise, we will split the
  // search string so that each word is searched for and highlighted
  // individually
  
	if (treatAsPhrase) {
    searchArray = [searchText];
  } else {
    searchArray = searchText.split(" ");
  }  			

	//alert(searchArray.length);
	
  if (!document.body || typeof(document.body.innerHTML) == "undefined") {
    if (warnOnFailure) {
      alert("Sorry, for some reason the text of this page is unavailable. Searching will not work.");
    }
    return false;
  }
  
  var bodyText = document.body.innerHTML;
  for (var i = 0; i < searchArray.length; i++)
	{    
		if( (searchArray[i] != 'e')&&(searchArray[i] != 'E')&&(searchArray[i] != 'de')&& (searchArray[i] != 'DE')&&				(searchArray[i] != 'D0')&&(searchArray[i] != 'DA')&&(searchArray[i] != 'DOS')&&(searchArray[i] != 'DAS')&&(searchArray[i] != 'do')&&(searchArray[i] != 'da')&&(searchArray[i] != 'dos')&&(searchArray[i] != 'das')&&(searchArray[i] != 'por')&&(searchArray[i] != 'POR')&&(searchArray[i] != 'que')&&(searchArray[i] != 'QUE')&&(searchArray[i] != 'nos')&&(searchArray[i] != 'NOS')&&(searchArray[i] != 'nas')&&(searchArray[i] != 'NAS')&&(searchArray[i] != 'com')&&(searchArray[i] != 'ou')&&(searchArray[i] != 'OU')&&(searchArray[i] != 'COM')&&(searchArray[i] != 'á')&&(searchArray[i] != 'Á')&&(searchArray[i] != 'é')&&(searchArray[i] != 'É')&&(searchArray[i] != 'art.')&&(searchArray[i] != 'art')&&(searchArray[i] != 'ART.')&&(searchArray[i] != 'ART')&&(searchArray[i] != 'em')&&(searchArray[i] != 'EM') )
    {
			//alert(searchArray[i]);
			//Passando a palavra como parametro para a função que colore para que a mesma somente colora
			//exatamente a palavra e pare de coloria um pedaço dela =)
		  bodyText = doHighlight(bodyText, ' '+searchArray[i], highlightStartTag, highlightEndTag);			 
    }
  }
  
  document.body.innerHTML = bodyText;
  return true;
}

/*
 * This displays a dialog box that allows a user to enter their own
 * search terms to highlight on the page, and then passes the search
 * text or phrase to the highlightSearchTerms function. All parameters
 * are optional.
 */
function searchPrompt(defaultText, treatAsPhrase, textColor, bgColor)
{
  // This function prompts the user for any words that should
  // be highlighted on this web page
  if (!defaultText) {
    defaultText = "";
  }
  
  // we can optionally use our own highlight tag values
  if ((!textColor) || (!bgColor)) {
    highlightStartTag = "";
    highlightEndTag = "";
  } else {
    highlightStartTag = "<font style='color:" + textColor + "; background-color:" + bgColor + ";'>";
    highlightEndTag = "</font>";
  }
  
  if (treatAsPhrase) {
    promptText = "Please enter the phrase you'd like to search for:";
  } else {
    promptText = "Please enter the words you'd like to search for, separated by spaces:";
  }
  
  searchText = prompt(promptText, defaultText);

  if (!searchText)  {
    alert("No search terms were entered. Exiting function.");
    return false;
  }
  
  return highlightSearchTerms(searchText, treatAsPhrase, true, highlightStartTag, highlightEndTag);
}

/*
 * This function takes a referer/referrer string and parses it
 * to determine if it contains any search terms. If it does, the
 * search terms are passed to the highlightSearchTerms function
 * so they can be highlighted on the current page.
 */
function highlightGoogleSearchTerms(referrer)
{
  // This function has only been very lightly tested against
  // typical Google search URLs. If you wanted the Google search
  // terms to be automatically highlighted on a page, you could
  // call the function in the onload event of your <body> tag, 
  // like this:
  //   <body onload='highlightGoogleSearchTerms(document.referrer);'>
  
  //var referrer = document.referrer;
  if (!referrer) {
    return false;
  }
  
  var queryPrefix = "q=";
  var startPos = referrer.toLowerCase().indexOf(queryPrefix);
  if ((startPos < 0) || (startPos + queryPrefix.length == referrer.length)) {
    return false;
  }
  
  var endPos = referrer.indexOf("&", startPos);
  if (endPos < 0) {
    endPos = referrer.length;
  }
  
  var queryString = referrer.substring(startPos + queryPrefix.length, endPos);
  // fix the space characters
  queryString = queryString.replace(/%20/gi, " ");
  queryString = queryString.replace(/\+/gi, " ");
  // remove the quotes (if you're really creative, you could search for the
  // terms within the quotes as phrases, and everything else as single terms)
  queryString = queryString.replace(/%22/gi, "");
  queryString = queryString.replace(/\"/gi, "");
  
  return highlightSearchTerms(queryString, false);
}


/*
 * This function is just an easy way to test the highlightGoogleSearchTerms
 * function.
 */
function testHighlightGoogleSearchTerms()
{
  var referrerString = "http://www.google.com/search?q=javascript%20highlight&start=0";
  referrerString = prompt("Test the following referrer string:", referrerString);
  return highlightGoogleSearchTerms(referrerString);
}

function highlight()
{    	    
	var string_busca = GetCookie('string_busca');	
  var string_busca_inteira = GetCookie('string_busca_inteira');		
	var bol = false;				
	
	//alert("1) "+string_busca);
	
	if( string_busca_inteira != null )
	{  	  	
  	if( string_busca_inteira.length > 0 )
  	{	
  	  string_busca = string_busca_inteira;
  		bol = true;
  	}
	}		
		
	//alert("2) "+string_busca);
	if( string_busca != null )
	{
  	if( string_busca.length > 0 )
  	{
  	  highlightSearchTerms(string_busca, bol);
  	}
	}					
}

function SetCookie_infinito(name, value) 
{   
	 var argv = SetCookie_infinito.arguments;
   var argc = SetCookie_infinito.arguments.length;
	 //Seta um cookie com uma data de 1 ano de duração
	 var _d = new Date();
	 var y = _d.getYear();	 
	 var m = _d.getMonth();
	 var d = _d.getDate();	 
	 var hoje_ano = new Date(2050,m,d);
	 var expires = hoje_ano;	 	 
   var path = (argc > 3) ? argv[3] : null;
   var domain = (argc > 4) ? argv[4] : null;
   var secure = (argc > 5) ? argv[5] : false;
   //Tira as tags html do cookie das anotações	 	 
	 document.cookie = name + "=" + escape (value) +
        ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
        ((path == null) ? "" : ("; path=" + path)) +
        ((domain == null) ? "" : ("; domain=" + domain)) +
        ((secure == true) ? "; secure" : "");
}

function pega_nome_anotacao()
{
  /*
	Nesta função eu gravo o nome do cookie concatenado com a palavra robo_ para 
	depois quando for ler todos os cookies que existem na pagina eu poder destinguir
	o que é titulo o que é conteudo.
	Neste conteudo uso o caracter separado para gravar conteudo§nome_arquivo, sendo que este
	nome_arquivo vai servir na função list_cookie() para pegar todos os cookies a mostra-los
	linkando para seus respectivos URLS para que o usuario possa ver os documentos aos quais 
	ele colocou alguma anotação.
	*/
	return "robo_"+document.title+"§"+document.location;	
}

function save_note( nome,id )
{
  //Pega o textarea passado como ID e grava o value dele
	var obj = document.getElementById(id);		
	SetCookie_infinito(nome,obj.value);	
	alert("Informações gravadas com sucesso!");
}

function list_cookie()
{   
	var todos = document.cookie; 	
  var tmp = todos.split("=");
	var arquivo = '';
	document.write("<table border=\"1\" cellpadding=\"5\" cellspacing=\"0\" style=\"font-family: verdana; font-size: 11px\">");
	for (var i=0;i<tmp.length;i++)
	{	  	  				
		var linha = tmp[i];		
		if( linha.indexOf("robo_") != -1 )
		{		 	  			 
			var titulo = tmp[i];
			
			//Este bloco serve para limpar o conteudo das anotações do titulo da mesmas
			var ktmp2 = titulo.split("; ");
			if( ktmp2.length > 1 )
			{
			  titulo = ktmp2[1];
			}
			
			//Este bloco é para separar o titulo propriamente dito do arquivo ao qual 
			//este titulo será linkado logo abaixo			
			ktmp = titulo.split("§");
			if( ktmp.length > 1 )
			{
			  titulo = ktmp[0];
				arquivo = ktmp[1];				 
			}
			
			//Tirando a string robo_ do titulo que será mostrado mas o que fica gravado
			//continua o mesmo sem alterações
			titulo = titulo.replace("robo_","");
			
			//Escrevendo as linhas da tabela na qual mostrarão os titulos das anotações com
			//seus respectivos links						
			document.write("<tr>");
			document.write("<td>");
			document.write(titulo);
			document.write("</td>");
			document.write("<td>");
			document.write("<a href='");
			document.write(arquivo);
			document.write("'><img src=\"../chr_search.gif\" border=\"0\"></a>");
			document.write("</td>");			
			document.write("</tr>");
		}		
	}
	document.write("</table>");	
}

function muda_texto( _id )
{
  var obj = document.getElementById(_id);
	var tmp_anotacao = GetCookie(nome);
	if( tmp_anotacao != null )
  {
    var _texto = "Ver Anotações";
  }
  else
  {
    var _texto = "Inserir Anotações";
  }
	obj.innerHTML = _texto;
}

function pega_nome_arquivo()
{
  var tr = window.location.pathname;
  var tmp = ''; 
  len = tr.length; 
  rs = 0;
  for (i = len; i > 0; i--)
  { 
    vb = tr.substring(i,i+1); 
    //Se nao achar com \\ que eh o caminho local
		if (vb == '\\' && rs == 0)
    { 
      tmp = tr.substring(i+1,len); 
      rs = 1 ;
    }				 
  }
	return tmp;
}

function completa_zero_esquerda( numero )
{
  //Transformando um inteiro em string para colocar os zeros depois retornar 
	//string com zero do lado para concatenar com htm e mostrar o anterior/proximo 
	//arquivo na navegação linear	
	var numero_string = numero + '';		
	if( numero_string.length == 1 )
	{
	  return '0' + numero_string;		  
	}	
	else
	{
	  return numero_string;
	}
}
