/*============================================*/
/* SCROLL ANIMADA RETIRADA DO SITE: http://www.revolucao.etc.br */
/*============================================*/
	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 = 50;
		scrTime = 0;
		scrInt = 1;
		
		// 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;
	}
/*============================================*/
/* // SCROLL ANIMADA
/*============================================*/	

//////////////////////////////////////////////////////////////////
// qTip - CSS Tool Tips - by Craig Erskine
// http://qrayg.com | http://solardreamstudios.com
//
// Inspired by code from Travis Beckham
// http://www.squidfingers.com | http://www.podlob.com
//////////////////////////////////////////////////////////////////

var qTipTag = "a"; //Which tag do you want to qTip-ize? Keep it lowercase!//
var qTipX = -30; //This is qTip's X offset//
var qTipY = 25; //This is qTip's Y offset//



//There's No need to edit anything below this line//
tooltip = {
  name : "qTip",
  offsetX : qTipX,
  offsetY : qTipY,
  tip : null
}

tooltip.init = function () {
	var tipNameSpaceURI = "http://www.w3.org/1999/xhtml";
	if(!tipContainerID){ var tipContainerID = "qTip";}
	var tipContainer = document.getElementById(tipContainerID);

	if(!tipContainer) {
	  tipContainer = document.createElementNS ? document.createElementNS(tipNameSpaceURI, "div") : document.createElement("div");
		tipContainer.setAttribute("id", tipContainerID);
	  document.getElementsByTagName("body").item(0).appendChild(tipContainer);
	}

	if (!document.getElementById) return;
	this.tip = document.getElementById (this.name);
	if (this.tip) document.onmousemove = function (evt) {tooltip.move (evt)};

	var a, sTitle;
	var anchors = document.getElementsByTagName (qTipTag);

	for (var i = 0; i < anchors.length; i ++) {
		a = anchors[i];
		sTitle = a.getAttribute("title");
		if(sTitle) {
			a.setAttribute("tiptitle", sTitle);
			a.removeAttribute("title");
			a.onmouseover = function() {tooltip.show(this.getAttribute('tiptitle'))};
			a.onmouseout = function() {tooltip.hide()};
		}
	}
}

tooltip.move = function (evt) {
	var x=0, y=0;
	if (document.all) {//IE
		x = (document.documentElement && document.documentElement.scrollLeft) ? document.documentElement.scrollLeft : document.body.scrollLeft;
		y = (document.documentElement && document.documentElement.scrollTop) ? document.documentElement.scrollTop : document.body.scrollTop;
		x += window.event.clientX;
		y += window.event.clientY;
		
	} else {//Good Browsers
		x = evt.pageX;
		y = evt.pageY;
	}
	this.tip.style.left = (x + this.offsetX) + "px";
	this.tip.style.top = (y + this.offsetY) + "px";
}

tooltip.show = function (text) {
	if (!this.tip) return;
	this.tip.innerHTML = text;
	this.tip.style.display = "block";
}

tooltip.hide = function () {
	if (!this.tip) return;
	this.tip.innerHTML = "";
	this.tip.style.display = "none";
}

// FIM TOOLTIP

// When the page loads: 
function flash(){ 
if (document.getElementsByTagName) { 
// Get all the tags of type object in the page. 
var objs = document.getElementsByTagName("object"); 
for (i=0; i<objs.length; i++) { 
// Get the HTML content of each object tag 
// and replace it with itself. 
objs[i].outerHTML = objs[i].outerHTML; 
} 
} 
} 
// When the page unloads: 
window.onunload = function() { 
if (document.getElementsByTagName) { 
//Get all the tags of type object in the page. 
var objs = document.getElementsByTagName("object"); 
for (i=0; i<objs.length; i++) { 
// Clear out the HTML content of each object tag 
// to prevent an IE memory leak issue. 
objs[i].outerHTML = ""; 
} 
} 
} 


// barra de status
function scroll(jumpSpaces,position) {
var msg = "Supra Soluções Interativas // Criação de Sites Estáticos e Gerenciáveis"
var out = ""
if (killScroll) {return false} 
for (var i=0; i<position; i++){
out += msg.charAt(i)}
for (i=1;i<jumpSpaces;i++) {
out += " "}
out += msg.charAt(position)
window.status = out
if (jumpSpaces <= 1) {
position++
if (msg.charAt(position) == ' ') {
position++ }
jumpSpaces = 100-position        
}
else if (jumpSpaces >  3) {
jumpSpaces *= .75}
else {
jumpSpaces--}
if (position != msg.length) {
var cmd = "scroll(" + jumpSpaces + "," + position + ")";
scrollID = window.setTimeout(cmd,1);
} 
else {
scrolling = false
return false}
return true;
}

function startScroller() {
if (scrolling)
if (!confirm('Re-initialize snapIn?'))
return false
killScroll = true
scrolling = true
var killID = window.setTimeout('killScroll=false',6)
scrollID = window.setTimeout('scroll(100,0)',10)
return true
}

var scrollID = Object
var scrolling = false
var killScroll = false

startScroller();
// *** fim barra de status

// mostra esconde div
function mostra_esconde(nome_div,nome_img){
div = document.getElementById(nome_div);
img = document.getElementById(nome_img);

if(div.style.display == 'none'){
	div.style.display = 'block';
	img.src = 'imagens/seta_mostra.gif';	
	}else{
		div.style.display = 'none';		
		img.src = 'imagens/seta_esconde.gif';			
		}

	
}

// *** fim mostra esconde div

function $A(obj, fnc){
    var array = new Array();
    var fnc = fnc || function(){};
    for(var i=0; i<obj.length; i++){
        array.push(obj[i]);
        fnc(obj[i]);
    }
    return array;
}

function $(id){return document.getElementById(id);}


// PISCA FUNDO
function blink_background(){
    /* @author Bernardo Rufino <bermonruf@gmail.com>
     * @license Creative Commons Developing Nations: http://creativecommons.org/licenses/devnations/2.0/
     * @description Function to manipulate the actual selection
     * @parameters The first is the object and the others are the colors that will blink
     *             Ex.: blink_background($("color"), "#FF0000", "#00FF00", "#0000FF", "#FFFF00");
     *
     *       !Não retire essas informações!
     *       !Do not drop this information!
    */
    var colors = $A(arguments);
    var obj = colors.shift();
    var chcolor = function(color){obj.style["backgroundColor"] = color;}
    if(obj.blinking){
        clearInterval(obj.blinking);
        obj.blinking = null;
        chcolor(colors[0]);
    } else{
        var counter = 0;
        obj.blinking = setInterval(function(){
            counter += 1;
            var color = colors[counter]
            if(!color){counter = 0; color = colors[counter];}
            chcolor(color);
        }, 10);
    }
}

// *** PISCA FUNDO
//Publicado por Johnathan Cardoso
//djhonyy@hotmail.com
//www.cdsbrasil.com.br
/*************************************************/
// Aperfeiçoado por Adriano de Oliveira Gonçalves
// adriano@ison.com.br
// http://adriano.ison.com.br

fadeGradativaObjects = new Object();
fadeGradativaTimers = new Object();

function fadeGradativa(id, destOp, rate, delta){

    object = document.getElementById(id);

    /*if (object != "[object]"){
        setTimeout("fadeGradativa('"+id+"',"+destOp+","+rate+","+delta+")",0);
        return;
    } */

    clearTimeout(fadeGradativaTimers[object.sourceIndex]);

    bname=navigator.appName;

    if(bname.indexOf("Microsoft")!=-1)
    {
        opacidade = object. filters.alpha.opacity;
        
        diff = destOp-opacidade;
        direction = 1;
        if (opacidade > destOp){
            direction = -1;
        }
        
        delta=Math.min(direction*diff,delta);
        object.filters.alpha.opacity+=direction*delta;
        
        opacidade = object.filters.alpha.opacity;
    }
    else if(bname.indexOf("Netscape")!=-1)
    {
        opacidade = object.style.MozOpacity*100;

        diff = destOp-opacidade;
        direction = 1;
        if (opacidade > destOp){
            direction = -1;
        }

        delta=Math.min(direction*diff,delta);
        object.style.MozOpacity = (opacidade+(direction*delta))/100;

        opacidade = object.style.MozOpacity*100;
    }
    else
        return;
        
    if (opacidade != destOp){
        fadeGradativaObjects[object.sourceIndex]=object;
        fadeGradativaTimers[object.sourceIndex]=setTimeout("fadeGradativa('"+id+"', "+destOp+", "+rate+", "+delta+")",rate);
    }
}

/* FUNCAO TOPO FLASH */

function flash_transforma(){
			
	var h1 = document.getElementsByTagName('h1');
	var pagina = document.getElementById('nome_pagina');

	for(i=0;i<h1.length;i++){
		
		if(h1[i].id=='topo_flash_texto'){
			var pagina_url = pagina.innerHTML;
			var embed;
			embed  = '\n\n<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="750" height="115">\n';
			embed += '	<param name="movie" value="topo.swf?pagina='+pagina_url+'" />\n';
			embed += '	<param name="wmode" value="transparent" />\n';
			embed += '	<embed wmode="transparent" src="topo.swf?pagina='+pagina_url+'" width="750" height="115" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />\n';
			embed += '</object>\n\n';
			h1[i].innerHTML = embed;

		}
		
	}
}

/* // FUNCAO TOPO FLASH */


/* FORMULARIO */
var class_over = 'campo_over';
var class_out = 'campo_texto';

function input_style() {
var input = document.getElementsByTagName("input");
for(var x = 0; x < input.length; x++) {
if(input[x].type!='submit'){
setEvento(input[x],'focus',Focus);
setEvento(input[x],'blur',Blur);
}
}
}

function textarea_style() {
var textarea = document.getElementsByTagName('textarea');
for(var x = 0; x < textarea.length; x++) {
setEvento(textarea[x],'focus',Focus);
setEvento(textarea[x],'blur',Blur);
}
}

function select_style() {
var selects = document.getElementsByTagName('select');
for(var x = 0; x < selects.length; x++) {
setEvento(selects[x],'focus',Focus);
setEvento(selects[x],'blur',Blur);
}
}

function setEvento(elemento, evento, funcao){
if (elemento.addEventListener)elemento.addEventListener(evento, funcao, false);        
if (elemento.attachEvent)elemento.attachEvent("on"+evento, funcao);
}

function Focus(e){
try{var element = e.target}catch(er){};
try{var element = event.srcElement}catch(er){};

if (element.className == class_out)
element.className = class_over;
else
element.className = class_out;
}


function Blur(e){
try{var element = e.target}catch(er){};
try{var element = event.srcElement}catch(er){};

if (element.className == class_over)
element.className = class_out;
else
element.className = class_over;
}
/* // FORMULARIO */


function teste(){
a = document.getElementsByTagName('body');
for(i=0;i<a.length;i++){
if(a[i].TextNode=='a'){
a[i].TextNode = a[i].TextNode.replace('a','<u>a</u>');
}
}
}

window.onload=function(){

flash_transforma();
tooltip.init ();
flash();
input_style();
textarea_style();
select_style();
replaceAnchorLinks();

};