/***********************************************
* functions needed for menu
***********************************************/
var timeout    = 500;
var closetimer = 0;
var ddmenuitem = 0;
		
function navlist_open()
{  navlist_canceltimer();
   navlist_close();
   ddmenuitem = $(this).find('ul').css('visibility', 'visible');}
		
function navlist_close()
{  if(ddmenuitem) ddmenuitem.css('visibility', 'hidden');}
		
function navlist_timer()
{  closetimer = window.setTimeout(navlist_close, timeout);}
		
function navlist_canceltimer()
{  if(closetimer)
{  window.clearTimeout(closetimer);
closetimer = null;}}
		
$(document).ready(function()
{  $('#navlist > li').bind('mouseover', navlist_open)
$('#navlist > li').bind('mouseout',  navlist_timer)});
		
document.onclick = navlist_close;
		
/***********************************************
* functions needed for auto completion
***********************************************/
		
function lookupAjax(){
	var oSuggest = $("#SearchAjax")[0].autocompleter;
	oSuggest.findValue();
	return false;
}

function lookupAjax2(){
	var oSuggest = $("#SearchAjax2")[0].autocompleter;
	oSuggest.findValue();
	return false;
}

function selectItem(li) {	
	findValue(li);
}


/***********************************************
* Functions needed for animated text
* Fading Scroller- � Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/
		

/*Rafael Raposo edited function*/
//function to change content
function changecontent(){
  if (index>=fcontent.length)
	index=0
  if (DOM2){
	document.getElementById("fscroller").style.color="rgb("+startcolor[0]+", "+startcolor[1]+", "+startcolor[2]+")"
	document.getElementById("fscroller").innerHTML=begintag+fcontent[index]+closetag
	if (fadelinks)
	  linkcolorchange(1);
	colorfade(1, 15);
  }
  else if (ie4)
	document.all.fscroller.innerHTML=begintag+fcontent[index]+closetag;
  index++
}

// colorfade() partially by Marcio Galli for Netscape Communications.  ////////////
// Modified by Dynamicdrive.com

function linkcolorchange(step){
  var obj=document.getElementById("fscroller").getElementsByTagName("A");
  if (obj.length>0){
	for (i=0;i<obj.length;i++)
	  obj[i].style.color=getstepcolor(step);
  }
}

/*Rafael Raposo edited function*/
var fadecounter;
function colorfade(step) {
  if(step<=maxsteps) {	
	document.getElementById("fscroller").style.color=getstepcolor(step);
	if (fadelinks)
	  linkcolorchange(step);
	step++;
	fadecounter=setTimeout("colorfade("+step+")",stepdelay);
  }else{
	clearTimeout(fadecounter);
	document.getElementById("fscroller").style.color="rgb("+endcolor[0]+", "+endcolor[1]+", "+endcolor[2]+")";
	setTimeout("changecontent()", delay);
	
  }   
}

/*Rafael Raposo's new function*/
function getstepcolor(step) {
  var diff
  var newcolor=new Array(3);
  for(var i=0;i<3;i++) {
	diff = (startcolor[i]-endcolor[i]);
	if(diff > 0) {
	  newcolor[i] = startcolor[i]-(Math.round((diff/maxsteps))*step);
	} else {
	  newcolor[i] = startcolor[i]+(Math.round((Math.abs(diff)/maxsteps))*step);
	}
  }
  return ("rgb(" + newcolor[0] + ", " + newcolor[1] + ", " + newcolor[2] + ")");
}

function go(x) {
	window.location.href = x;
	return false;
}

/***********************************************
* functions needed for dropdowns
***********************************************/
var req;

function invokeURL(url, processReqChange) 
{
  	 
  // branch for native XMLHttpRequest object
  if (window.XMLHttpRequest) {
    req = new XMLHttpRequest();
    req.onreadystatechange = eval(processReqChange);
    req.open("GET", url, true);
    req.send(null);
    // branch for IE/Windows ActiveX version
  } else if (window.ActiveXObject) {
    req = new ActiveXObject("Microsoft.XMLHTTP");
    if (req) {
      req.onreadystatechange = eval(processReqChange);
      req.open("GET", url, true);
      req.send();
    }
  }
  
 
}


function select_innerHTML(objeto,innerHTML){
/******
* select_innerHTML - corrige o bug do InnerHTML em selects no IE
* Veja o problema em: http://support.microsoft.com/default.aspx?scid=kb;en-us;276228
* Vers�o: 2.1 - 04/09/2007
* Autor: Micox - N�iron Jos� C. Guimar�es - micoxjcg@yahoo.com.br
* @objeto(tipo HTMLobject): o select a ser alterado
* @innerHTML(tipo string): o novo valor do innerHTML
*******/
    objeto.innerHTML = ""
    var selTemp = document.createElement("micoxselect")
    var opt;
    selTemp.id="micoxselect1"
    document.body.appendChild(selTemp)
    selTemp = document.getElementById("micoxselect1")
    selTemp.style.display="none"
    if(innerHTML.toLowerCase().indexOf("<option")<0){//se n�o � option eu converto
        innerHTML = "<option>" + innerHTML + "</option>"
    }
    innerHTML = innerHTML.replace(/<option/g,"<span").replace(/<\/option/g,"</span")
    selTemp.innerHTML = innerHTML
      
    
    for(var i=0;i<selTemp.childNodes.length;i++){
  var spantemp = selTemp.childNodes[i];
  
        if(spantemp.tagName){     
            opt = document.createElement("OPTION")
    
   if(document.all){ //IE
    objeto.add(opt)
   }else{
    objeto.appendChild(opt)
   }       
    
   //getting attributes
   for(var j=0; j<spantemp.attributes.length ; j++){
    var attrName = spantemp.attributes[j].nodeName;
    var attrVal = spantemp.attributes[j].nodeValue;
    if(attrVal){
     try{
      opt.setAttribute(attrName,attrVal);
      opt.setAttributeNode(spantemp.attributes[j].cloneNode(true));
     }catch(e){}
    }
   }
   //getting styles
   if(spantemp.style){
    for(var y in spantemp.style){
     try{opt.style[y] = spantemp.style[y];}catch(e){}
    }
   }
   //value and text
   opt.value = spantemp.getAttribute("value")
   opt.text = spantemp.innerHTML
   //IE
   opt.selected = spantemp.getAttribute('selected');
   opt.className = spantemp.className;
  } 
 }    
 document.body.removeChild(selTemp)
 selTemp = null
}


