// funcao corrige flash no IE
function embeds(url,w,h){
document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="'+w+'" height="'+h+'">');
document.write('<param name="movie" value="'+url+'">');
document.write('<param name="quality" value="high">');
document.write('<param name="wmode" value="transparent">');
document.write('<param name="menu" value="false">');
document.write('<embed src="'+url+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+w+'" height="'+h+'" wmode="transparent"></embed>');
document.write('</object>');
}
//-->


// para o menu funcionar no IEca 6
over = function() {
	var sfEls = document.getElementById("menuprincipal").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" over";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" over\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", over);
//-->










//ir para o topo animado
var scrollInt;
	var scrTime, scrSt, scrDist, scrDur, scrInt;
	
	
	function replaceAnchorLinks()
	{
		var anchors, i, targ, targarr;
	
		if (!document.getElementById)
			return;

		// get all anchors
		anchors = document.getElementsByTagName("a");
		
		for (i=0;i<anchors.length;i++)
		{
		
			// check if href links to an anchor on this page
			if ( anchors[i].href.indexOf("#") != -1 && anchors[i].href.indexOf( document.URL ) != -1 )
			{
				// get name of target anchor
				targ = anchors[i].href.substring( anchors[i].href.indexOf("#")+1 );
				
				// find target anchor
				targarr = document.getElementsByName( targ );
				
				if (targarr.length)
				{
					anchors[i].className = (targarr[0].offsetTop < anchors[i].offsetTop) ? "up" : "down";
					anchors[i].id = "__" + targ;	// save target as id with prefix (used in onclick function below)
					anchors[i].onmousedown = function () { scrollToAnchor( this.id.substring( 2 ) ); return false; };
					anchors[i].href = "javascript:;";			// rewrite href
				}
			}
			
		}
	}
	
	
	/*	SCROLL FUNCTIONS  */
	
	function scrollPage()
	{
		scrTime += scrInt;
		if (scrTime < scrDur) {
			window.scrollTo( 0, easeInOut(scrTime,scrSt,scrDist,scrDur) );
		}else{
			window.scrollTo( 0, scrSt+scrDist );
			clearInterval(scrollInt);
		}
	}
	
	function scrollToAnchor(aname)
	{
		var anchors, i, ele;
	
		if (!document.getElementById)
			return;
		
		// get anchor
		anchors = document.getElementsByTagName("a");
		for (i=0;i<anchors.length;i++) {
			if (anchors[i].name == aname) {
				ele = anchors[i];
				i = anchors.length;
			}
		}
		
		// set scroll target
		if (window.scrollY)
			scrSt = window.scrollY;
		else if (document.documentElement.scrollTop)
			scrSt = document.documentElement.scrollTop;
		else
			scrSt = document.body.scrollTop;

		
		
		scrDist = ele.offsetTop - scrSt;
		scrDur = 500;
		scrTime = 0;
		scrInt = 10;
		
		// set interval
		clearInterval(scrollInt);
		scrollInt = setInterval( scrollPage, scrInt );
	}
	
	/* EASING FUNCTIONS	*/
	
	function easeInOut(t,b,c,d)
	{
		return c/2 * (1 - Math.cos(Math.PI*t/d)) + b;
	}
	
	if (window.attachEvent){
		window.attachEvent("onload", replaceAnchorLinks);
	}else{
		window.onload = replaceAnchorLinks;
	}var scrollInt;
	var scrTime, scrSt, scrDist, scrDur, scrInt;
	
	
	
	
	function replaceAnchorLinks()
	{
		var anchors, i, targ, targarr;
	
		if (!document.getElementById)
			return;

		// get all anchors
		anchors = document.getElementsByTagName("a");
		
		for (i=0;i<anchors.length;i++)
		{
		
			// check if href links to an anchor on this page
			if ( anchors[i].href.indexOf("#") != -1 && anchors[i].href.indexOf( document.URL ) != -1 )
			{
				// get name of target anchor
				targ = anchors[i].href.substring( anchors[i].href.indexOf("#")+1 );
				
				// find target anchor
				targarr = document.getElementsByName( targ );
				
				if (targarr.length)
				{
					anchors[i].className = (targarr[0].offsetTop < anchors[i].offsetTop) ? "up" : "down";
					anchors[i].id = "__" + targ;	// save target as id with prefix (used in onclick function below)
					anchors[i].onmousedown = function () { scrollToAnchor( this.id.substring( 2 ) ); return false; };
					anchors[i].href = "javascript:;";			// rewrite href
				}
			}
			
		}
	}
	
	
	/*	SCROLL FUNCTIONS  */
	
	function scrollPage()
	{
		scrTime += scrInt;
		if (scrTime < scrDur) {
			window.scrollTo( 0, easeInOut(scrTime,scrSt,scrDist,scrDur) );
		}else{
			window.scrollTo( 0, scrSt+scrDist );
			clearInterval(scrollInt);
		}
	}
	
	function scrollToAnchor(aname)
	{
		var anchors, i, ele;
	
		if (!document.getElementById)
			return;
		
		// get anchor
		anchors = document.getElementsByTagName("a");
		for (i=0;i<anchors.length;i++) {
			if (anchors[i].name == aname) {
				ele = anchors[i];
				i = anchors.length;
			}
		}
		
		// set scroll target
		if (window.scrollY)
			scrSt = window.scrollY;
		else if (document.documentElement.scrollTop)
			scrSt = document.documentElement.scrollTop;
		else
			scrSt = document.body.scrollTop;

		
		
		scrDist = ele.offsetTop - scrSt;
		scrDur = 500;
		scrTime = 0;
		scrInt = 10;
		
		// set interval
		clearInterval(scrollInt);
		scrollInt = setInterval( scrollPage, scrInt );
	}
	
	/* EASING FUNCTIONS	*/
	
	function easeInOut(t,b,c,d)
	{
		return c/2 * (1 - Math.cos(Math.PI*t/d)) + b;
	}
	
	if (window.attachEvent){
		window.attachEvent("onload", replaceAnchorLinks);
	}else{
		window.onload = replaceAnchorLinks;
	}
	
/* fim de ir para o topo --> */














/* Abre link em nova janela popup - nao obstrusivo */
 
/* This handy addLoadEvent function from Simon Willison allows you to stack up 'window.onload' events 
without them stepping on each other's toes. It's explained here - http://www.sitepoint.com/blog-post-view.php?id=171578 */

function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}


/* This is our old popup function - parts of the site still use it, so I need to keep it */
function acpopup(strURL,strType,strHeight,strWidth) {
var strOptions="";
if (strType=="console") strOptions="resizable,height="+strHeight+",width="+strWidth;
window.open(strURL, '', strOptions);
}


/* new accessible, unobtrusive popup code */
function windowLinks() {
    if(!document.getElementsByTagName) {
         return;
    }
	
    var anchors = document.getElementsByTagName("a");
    for (var i = 0; i < anchors.length; i++) {
         var anchor = anchors[i];
         var relIndex = anchor.rel;
		 if (relIndex){
		 var relSplit = relIndex.split("|");    // Split our REL value into parts 
/* XHTML compliant target attribute */
		 if (relSplit[0] == "external") {       // If the REL=external...
            anchor.target = "_blank";           // set it's 'target' attribute to '_blank'
			anchor.className = "external";      // attach a CSS class to it to allow us to style it
			anchor.title = "Abre em nova janela: "+ anchor.href;  // Add a new title attribute to warn the users of a new window
			
/* XHTML compliant popup attribute */
   			} else if (relSplit[0] == "popup") { // If the REL=popup...
			//anchor.className = "popup";          // attach a CSS class to it to allow us to style it
			anchor.title = "Abre em nova janela"; // Add a new title attribute to warn the users of a new window
			anchor.popupWidth = relSplit[1]; 
			anchor.popupHeight = relSplit[2];
	        anchor.onclick = function() {acpopup(this.href,'console',this.popupWidth,this.popupHeight);return false;};
			}
		}
	   }
} 

addLoadEvent(function() {
	windowLinks();	
	//otherFunctions();
	//goHere();
});

// fim janela popup 