// JavaScript Document
//Função Display Box ::::::::::::::::::::::::::::::::::::

var tooltip=function(){

	var id = 'tt';
	var top = 3;
	var left = 3;
	var maxw = 300;
	var speed = 10;
	var timer = 20;
	var endalpha = 95;
	var alpha = 0;
	var tt,t,c,b,h;
	var ie = document.all ? true : false;
	return{
		show:function(v,w){
			if(tt == null){
				tt = document.createElement('div');
				tt.setAttribute('id',id);
				t = document.createElement('div');
				t.setAttribute('id',id + 'top');
				c = document.createElement('div');
				c.setAttribute('id',id + 'cont');
				b = document.createElement('div');
				b.setAttribute('id',id + 'bot');
				tt.appendChild(t);
				tt.appendChild(c);
				tt.appendChild(b);
				document.body.appendChild(tt);
				tt.style.opacity = 0;
				tt.style.filter = 'alpha(opacity=0)';
				document.onmousemove = this.pos;
			}
			tt.style.display = 'block';
			c.innerHTML = v;
			tt.style.width = w ? w + 'px' : 'auto';
			if(!w && ie){
				t.style.display = 'none';
				b.style.display = 'none';
				tt.style.width = tt.offsetWidth;
				t.style.display = 'block';
				b.style.display = 'block';
			}
			if(tt.offsetWidth > maxw){tt.style.width = maxw + 'px'}
			h = parseInt(tt.offsetHeight) + top;
			clearInterval(tt.timer);
			tt.timer = setInterval(function(){tooltip.fade(1)},timer);
		},
		pos:function(e){
			var u = ie ? event.clientY + document.documentElement.scrollTop : e.pageY;
			var l = ie ? event.clientX + document.documentElement.scrollLeft : e.pageX;
			tt.style.top = (u - h) + 'px';
			tt.style.left = (l + left) + 'px';
		},
		fade:function(d){
			var a = alpha;
			if((a != endalpha && d == 1) || (a != 0 && d == -1)){
				var i = speed;
				if(endalpha - a < speed && d == 1){
					i = endalpha - a;
				}else if(alpha < speed && d == -1){
					i = a;
				}
				alpha = a + (i * d);
				tt.style.opacity = alpha * .01;
				tt.style.filter = 'alpha(opacity=' + alpha + ')';
			}else{
				clearInterval(tt.timer);
				if(d == -1){tt.style.display = 'none'}
			}
		},
		hide:function(){
			clearInterval(tt.timer);
			tt.timer = setInterval(function(){tooltip.fade(-1)},timer);
		}
	};
}();
//END
function topo(){
	scrollTo(0,0);	
}

//EFeito Gradativo
/*alt="Efeito gradativo" name="imgMuda" border=0 id="imgMuda" style="opacity:0.4;filter:alpha(opacity=40)"  onmouseover="fadeGradativa(this.id,100,40,10)" onmouseout="fadeGradativa(this.id,40,20,10)"*/

fadeGradativaObjects = new Object();
fadeGradativaTimers = new Object();

function fadeGradativa(id, destOp, rate, delta){

    object = document.getElementById(id);

    

    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);
    }
}

function getYTid($ytURL) {

    $ytvIDlen = 11; // This is the length of YouTube's video IDs

    // The ID string starts after "v=", which is usually right after 
    // "youtube.com/watch?" in the URL
    $idStarts = strpos($ytURL, "/v/");

    // In case the "v=" is NOT right after the "?" (not likely, but I like to keep my 
    // bases covered), it will be after an "&":
    if ($idStarts === FALSE)
        $idStarts = strpos($ytURL, "/v/");
    // If still FALSE, URL doesn't have a vid ID
    if ($idStarts === FALSE)
        die("YouTube video ID not found. Please double-check your URL.");

    // Offset the start location to match the beginning of the ID string
    $idStarts += 3;

    // Get the ID string and return it
    $ytvID = substr($ytURL, $idStarts, $ytvIDlen);

    document.write($ytvID);

}

