// Data
dia = new Date();
ano = dia.getYear();
mes = new Array("01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12")
dia_semana = new Array("domingo", "segunda", "terça", "quarta", "quinta", "sexta", "sábado");
hora = dia.getHours();minuto = dia.getMinutes();

// correçao para browsers que retornam 100 no ano 2000
if (ano < 2000) {ano = 1900 + dia.getYear();}
if (hora < 10) {hora = "0" + hora;}
if (minuto < 10) {minuto = "0" + minuto;}
// Data - Fim
function addEngine(name, ext, cat) {
	if ((typeof window.sidebar == "object") && (typeof window.sidebar.addSearchEngine == "function")){
		try{
		window.sidebar.addSearchEngine(
			"http://www.sacramusic.com/arquivos/" + name + ".src",
			"http://www.sacramusic.com/arquivos/" + name + "." + ext, name, cat);
		}
		catch(eX){
			alert("Falha ao adicionar mecanismo de pesquisa.\nVocê está usando o Mozilla FireFox?");
		}
	}
	else {
		errorMsg(name,ext,cat);
	}
}
function doIE7(){
	var strName = "Sacramusic.com";
	var strURI = "http://www.google.com/cse?cx=009531376702981607810%3Apxqqziyipyu&q={searchTerms}";
	var strEncoding = "UTF-8";
	var strQuery = "Encoding="+ encodeURIComponent(strEncoding) + "&Name=" + encodeURIComponent(strName) + "&URI="  + encodeURIComponent(strURI);
	var strAddURI = "http://www.microsoft.com/windows/ie/searchguide/spbuilder.mspx?" + strQuery;
	try{
	window.external.AddSearchProvider(strAddURI);
	}
	catch(eX){
		alert("Falha ao adicionar mecanismo de pesquisa.\nVocê está usando o IE7?\nTente usar o mouse para clicar no botão instalar.");
	}
}
// Returns array with x,y page scroll values.
// Core code from - quirksmode.org
function getPageScroll(){
	var yScroll;
	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
	} else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
	}
	arrayPageScroll = new Array("", yScroll) 
	return arrayPageScroll;
}
// Returns array with page width, height and window width, height
// Core code from - quirksmode.org
// Edit for Firefox by pHaez
function getPageSize(){
	var xScroll, yScroll;
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}
	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}
	arrayPageSize = new Array(pageWidth, pageHeight, windowWidth, windowHeight) 
	return arrayPageSize;
}
function showBlog(tabName, fechar){
	var arrayPageSize   = getPageSize();
	var arrayPageScroll = getPageScroll();
	
	if(tabName != "") {
		document.getElementById(tabName).style.display = "";
		document.getElementById(tabName).style.visibility = "visible";
	}
	if(fechar == 1) {
		document.getElementById(tabName).style.display = "none";
		document.getElementById(tabName).style.visibility = "hidden";
	}
	var varLeft = ((arrayPageSize[0] - 20 - 400) / 2);
	document.getElementById(tabName).style.left = varLeft;
}
// Determina o browser
NS6 = (document.getElementById&&!document.all);
IE = (document.all);
NS = (navigator.appName=="Netscape" && navigator.appVersion.charAt(0)=="4");
var objeto = null;
function PegaObject(nome){// Caça Objeto pelo nome (div, img etc)
	if (NS6){objeto = document.getElementById(nome);}
	else if (IE) {objeto = document.all(nome);}
	else if (NS) {objeto = document.layers[nome];}
	return objeto;
}
function desativa_obj(nome){// Desativa um layer pelo nome
	objeto = PegaObject(nome);
	if (IE||NS6) {objeto.style.visibility = "hidden";}
	if (NS) {objeto.style.visibility = "hide";}
	return true;
}
function ativa_obj(nome){// Ativa um layer pelo nome
	objeto = PegaObject(nome);
	if (IE||NS6) {objeto.style.visibility = "visible";}
	if (NS) {objeto.style.visibility = "show";}
	return true;
}
function NovaJanela(mypage,myname,w,h,scroll,resize,pos) {
	var win = null;
	if(pos=="random"){
		LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;
	}
	if(pos=="center"){
		LeftPosition=(screen.width)?(screen.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;
	}
	else if((pos!="center" && pos!="random") || pos==null){
		LeftPosition=0;TopPosition=20
	}
	settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=no,status=yes,menubar=no,toolbar=no,resizable='+resize+',copyhistory=no';
	win=window.open(mypage,myname,settings);
}
function PopUp(myname,w,h,scroll,resize,HTML) {
	var strResult = '<HTML>\n';
	strResult += '<HEAD>\n';
	strResult += '<TITLE>'+myname+'</TITLE>\n';
	strResult += '</HEAD>\n';
	strResult += '<BODY>\n';
	strResult += HTML
	strResult += '</BODY>\n';
	strResult += '</HTML>';
	newwindow=window.open('', myname, 'toolbar=0,scrollbars='+scroll+',location=0,statusbar=0,menubar=0,resizable=1,width='+w+',height='+h+'');
	newdocument=newwindow.document;
	newdocument.write(strResult);
	newdocument.close();
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
	var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
	if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
	d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}