// JavaScript Document

// toltips
function toltips()
  {
	var as = [];
	$S('a').each(function(a){
		if (a.getAttribute('title')) as.push(a);
	});
	new Tips(as, {maxOpacity: 0.9, maxTitleChars: 25});
  }
  
/*Carregando*/
function esconde(){ 
document.getElementById("carregando").style.display="none"; 
}

function mostra(){ 
document.getElementById("carregando").style.display="block"; 
}

//previa
function mostra_previa(){ 
document.getElementById("footer_previa").style.display="block"; 
}

function mostra_carega_previa(id){
bt = 'botao_previa_'+id;
btn = document.getElementById(bt);
btn.src="http://www.buscamp3.org/img1/carregando_previa.gif";
window.setTimeout("btn.src='http://www.buscamp3.org/img1/ouvir.png';", 3000);
}

function fecha_previa(){ 
document.getElementById("footer_previa").style.display="none"; 
}

//Verifica form vazio
function verifica_vazio(){ 
	if(document.searchform.txtSearch.value=='Digite o nome do artista ou da musica desejada.'){
	return false;
	alert('Ta vasio!');	
	} else {
	document.getElementById("cmdSearch").style.display="none";
	document.getElementById("trabalhando").style.display="block"; 
	}
}

// Twiter
var tfb={};tfb.allowedLabels=["follow-me","follow-us","follow","my-twitter"];tfb.defaultTop=78;tfb.defaultColor="#35ccff";tfb.isInArray=function(str,ar){if(ar.length<1)return;for(var i=0;i<ar.length;i++){if(ar[i]==str){return true;break;}}
return false;}
tfb.showbadge=function(){if(!window.XMLHttpRequest){return;}
if(document.getElementById('twitterFollowBadge')){document.body.removeChild(document.getElementById('twitterFollowBadge'));}
if(tfb.top<0||tfb.top>1000||isNaN(tfb.top)){tfb.top=tfb.defaultTop;}
if(!tfb.isInArray(tfb.label,tfb.allowedLabels)){tfb.label=tfb.allowedLabels[0];}
var validColorPattern=/^#([a-f]|[A-F]|[0-9]){3}(([a-f]|[A-F]|[0-9]){3})?$/;if(!validColorPattern.test(tfb.color)||(tfb.color.length!=4&&tfb.color.length!=7)){tfb.color=tfb.defaultColor;};if(tfb.side!='l'){tfb.side='r';}
tfb.tabStyleCode='position:fixed;'+'top:'+tfb.top+'px;'+'width:30px;'+'height:119px;'+'z-index:8765;'+'cursor:pointer;'+'background:'+tfb.color+' url(http://www.buscamp3.org/images/follow.png);'+'background-repeat:no-repeat;';{tfb.tabStyleCode+='right:0; background-position:left top;';tfb.aboutStyleCode+='right:0;';}
tfbMainDiv=document.createElement('div');tfbMainDiv.setAttribute('id','twitterFollowBadge');document.body.appendChild(tfbMainDiv);tfbMainDiv.innerHTML='<div id="tfbTab" style="'+tfb.tabStyleCode+'"></div>';document.getElementById('tfbTab').onclick=function(){window.open('http://twitter.com/'+tfb.account);}
}

tfb.account = 'buscamp3';
tfb.label = 'follow';
tfb.color = '#262626';
tfb.side = 'r';
tfb.top = 236;
tfb.showbadge();

//muda classe menu main.php
function anormal(){
mudado.className = 'nomeclasse';
}

//radio egrana
var ie=document.all
var dom=document.getElementById
var ns4=document.layers
var calunits=document.layers? "" : "px"

var bouncelimit=32 //(must be divisible by 8)
var direction="up"

function initbox(){

//Egrana
window.open("http://www.egrana.com.br/popunder.aspx?CD_Usuario=4236","popunder","toolbar=no,menubar=no,scrollbars=no,status=no,resisable=no,top=10,left=320");

}

function dropin(){
scroll_top=(ie)? truebody().scrollTop : window.pageYOffset
if (parseInt(crossobj.top)<100+scroll_top)
crossobj.top=parseInt(crossobj.top)+40+calunits
else{
clearInterval(dropstart)
bouncestart=setInterval("bouncein()",50)
}
}

function bouncein(){
crossobj.top=parseInt(crossobj.top)-bouncelimit+calunits
if (bouncelimit<0)
bouncelimit+=8
bouncelimit=bouncelimit*-1
if (bouncelimit==0){
clearInterval(bouncestart)
}
}

function dismissbox(){
if (window.bouncestart) clearInterval(bouncestart)
crossobj.visibility="hidden"
}

function truebody(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}


function get_cookie(Name) {
var search = Name + "="
var returnvalue = ""
if (document.cookie.length > 0) {
offset = document.cookie.indexOf(search)
if (offset != -1) {
offset += search.length
end = document.cookie.indexOf(";", offset)
if (end == -1)
end = document.cookie.length;
returnvalue=unescape(document.cookie.substring(offset, end))
}
}
return returnvalue;
}

function dropornot(){
if (get_cookie("droppedin")==""){
window.onload=initbox
document.cookie="droppedin=yes"
}
}
dropornot()

//Volta topo
function volta_topo() {
    var x1 = x2 = x3 = 0;
    var y1 = y2 = y3 = 0;

    if (document.documentElement) {
        x1 = document.documentElement.scrollLeft || 0;
        y1 = document.documentElement.scrollTop || 0;
    }

    if (document.body) {
        x2 = document.body.scrollLeft || 0;
        y2 = document.body.scrollTop || 0;
    }

    x3 = window.scrollX || 0;
    y3 = window.scrollY || 0;

    var x = Math.max(x1, Math.max(x2, x3));
    var y = Math.max(y1, Math.max(y2, y3));

    window.scrollTo(Math.floor(x / 2), Math.floor(y / 2));

    if (x > 0 || y > 0) {
        window.setTimeout("volta_topo()", 25);
    }
}

// Favoritos  OK em 16/02/10
function createRequestObject() {
	var ro;
	var browser = navigator.appName;
		if(browser == "Microsoft Internet Explorer"){
			ro = new ActiveXObject("Microsoft.XMLHTTP");
		}else{
			ro = new XMLHttpRequest();
		}
	return ro;
}

var http = createRequestObject();
function sndReq(action) {
	http.open('get', 'http://www.buscamp3.org/load.php?action='+action);
	http.onreadystatechange = handleResponse;
	http.send(null);
}

function handleResponse() {
	if(http.readyState == 4){
	var response = http.responseText;
	var update = new Array();
		if(response.indexOf('|' != -1)) {
			update = response.split('|');
			document.getElementById(update[0]).innerHTML = update[1];
		}
	}
}

// Sem erro
function silentErrorHandler() {return true;}
window.onerror=silentErrorHandler;

  