// JavaScript Document

var message = new Array();
// Set your messages you want typed into the title bar below.
// To add more messages, just add more elements to the array.
message[0] = "Metropolitana FM - 98.5 MHz -..";
message[1] = "Metropolitana...... YESSSSSSS! -..";

// Set the number of repetitions (how many times a given message is typed out
// before moving onto the next message).
var reps = 1;
var speed = 155;// Set the overall typing speed (larger number = slower action).
var hold = 10 // set the length of time to display the whole phrase before retyping (larger number = longer)

// DO NOT EDIT BELOW THIS LINE.
var p = message.length;
var q = 0;
var r = 0;
var C = 0;
var mC = 0;
var s = 0;
var sT = null;

if (reps < 1) {
reps = 1;
}
function setMessage() {
typing = message[mC];
q = typing.length;
r = q + hold;
typeMessage();
}
function typeMessage() {
if (s > r) {
s = 0;
}
if (s > q) {
document.title = '..- '+ typing +' - - -';
}
else {
document.title = '..- '+ typing.substr(0,s)+' - - -';
}
if (C < (r * reps)) {
sT = setTimeout("typeMessage()", speed);
C++;
s++;
}
else {
C = 0;
s = 0;
mC++;
if(mC > p - 1) {mC = 0;}
sT = null;
setMessage();
   }
}
//setMessage();

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

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_setTextOfTextfield(objName,x,newText) { //v3.0
  var obj = MM_findObj(objName); if (obj) obj.value = newText;
}

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_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_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];}
}

function validar(){
	var nome_form=arguments[0];
	for(var i=1;i<arguments.length;i++){
		if(document[nome_form][arguments[i]].value == ""){
			alert("Por favor, preencha o formulário corretamente.");
			document[nome_form][arguments[i]].focus();
			return false;
		}
	}
	return true;
}

function validaSenha () {
	if (document[arguments[0]][arguments[1]].value != "") {
		if (document[arguments[0]][arguments[1]].value != document[arguments[0]][arguments[2]].value) {
			alert("A confirmação de sua senha está incorreta");
			document[arguments[0]][arguments[1]].focus();
			return false;
		}
	}
}

function oucaagora() {
	document.write('<table width="214" height="80" border="0" cellpadding="0" cellspacing="0">');
    document.write('<tr>');
    document.write('<td width="10" height="22"></td>');
    document.write('<td></td>');
    document.write('<td width="70" rowspan="5"><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="70" height="70">');
    document.write('<param name="movie" value="/web2.0/flashes/altofalante01.swf">');
    document.write('<param name="quality" value="high">');
    document.write('<param name="menu" value="false">');
    document.write('<param name="wmode" value="transparent">');
    document.write('<embed src="/web2.0/flashes/altofalante01.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="70" height="70" menu="false" wmode="transparent"></embed>');
    document.write('</object></td>');
    document.write('</tr>');
    document.write('<tr>');
    document.write('<td height="5"></td>');
    document.write('<td align="center"><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="59" height="5">');
	document.write('<param name="movie" value="/web2.0/flashes/noar01.swf">');
	document.write('<param name="quality" value="high">');
	document.write('<param name="menu" value="false">');
	document.write('<param name="wmode" value="transparent">');
	document.write('<embed src="/web2.0/flashes/noar01.swf" wmode="transparent" width="59" height="5" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" menu="false"></embed>');
	document.write('</object></td>');
    document.write('</tr>');
    document.write('<tr>');
    document.write('<td height="29"></td>');
    document.write('<td class="exemplo_playlist01">');
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="134" height="25" accesskey="2" tabindex="2">');
	document.write('<param name="movie" value="http://74.53.137.50/web2.0/pulsar/ticker1.swf">');
	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="http://74.53.137.50/web2.0/pulsar/ticker1.swf" wmode="transparent" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="134" height="25" menu="false"></embed>');
	document.write('</object>');
	document.write('</td>');
    document.write('</tr>');
    document.write('<tr>');
    document.write('<td height="6"></td>');
    document.write('<td align="center"><img src="/web2.0/images/bot_oucaagora01.gif" width="65" height="6" border="0"></td>');
    document.write('</tr>');
    document.write('<tr>');
    document.write('<td height="18"></td>');
    document.write('<td></td>');
    document.write('</tr>');
    document.write('</table>');
}
function tabs (pagina) {
	ajax = ajaxInit();
	if (ajax) {
		document.getElementById('tabLoading').innerHTML = "<center><br><br><img src=\"/web2.0/images/ico_loading_pl01.gif\"><br><br>Aguarde, carregando...<br><br><center>";
		ajax.open("GET", "/web2.0/?dir=html&act="+pagina, true);
		ajax.onreadystatechange = function() {
			if (ajax.readyState == 4) {
				if (ajax.status == 200) {
					texto = ajax.responseText;
					texto = texto.replace(/\+/g," ");
					texto = unescape(texto);
					document.getElementById('tabs').innerHTML = texto;
				}
				else {
					tabs(pagina);
				}
			}
		}
		ajax.send(null);
	}
}
function mainFlash() {
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="340" height="225">');
	document.write('<param name="movie" value="/web2.0/flashes/banner_main2.swf">');
	document.write('<param name="quality" value="high">');
	document.write('<param name="menu" value="false">');
	document.write('<param name="wmode" value="transparent">');
	document.write('<embed src="/web2.0/flashes/banner_main2.swf" wmode="transparent" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="340" height="225" menu="false"></embed>');
	document.write('</object>');
}
function mainMenu() {
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="760" height="96">');
    document.write('<param name="movie" value="/web2.0/flashes/menu_completo01.swf">');
    document.write('<param name="quality" value="high">');
	document.write('<param name="menu" value="false">');
	document.write('<param name="wmode" value="transparent">');
	document.write('<embed src="/web2.0/flashes/menu_completo01.swf" wmode="transparent" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="760" height="96" menu="false"></embed>');
	document.write('</object>');
}

// **************************************************
// * CALENDARIO										*
// * Autor : Peter M Jordan - uranking@uranking.com *
// * página: www.uranking.com                       *
// **************************************************

// construindo o calendário
function popdate(obj,div,tam,ddd)
{
    if (ddd) 
    {
        day = ""
        mmonth = ""
        ano = ""
        c = 1
        char = ""
        for (s=0;s<parseInt(ddd.length);s++)
        {
            char = ddd.substr(s,1)
            if (char == "/") 
            {
                c++; 
                s++; 
                char = ddd.substr(s,1);
            }
            if (c==1) day    += char
            if (c==2) mmonth += char
            if (c==3) ano    += char
        }
        ddd = mmonth + "/" + day + "/" + ano
    }
  
    if(!ddd) {today = new Date()} else {today = new Date(ddd)}
    date_Form = eval (obj)
    if (date_Form.value == "") { date_Form = new Date()} else {date_Form = new Date(date_Form.value)}
  
    ano = today.getFullYear();
    mmonth = today.getMonth ();
    day = today.toString ().substr (8,2)
  
    umonth = new Array ("Janeiro", "Fevereiro", "Março", "Abril", "Maio", "Junho", "Julho", "Agosto", "Setembro", "Outubro", "Novembro", "Dezembro")
    days_Feb = (!(ano % 4) ? 29 : 28)
    days = new Array (31, days_Feb, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31)

    if ((mmonth < 0) || (mmonth > 11))  alert(mmonth)
    if ((mmonth - 1) == -1) {month_prior = 11; year_prior = ano - 1} else {month_prior = mmonth - 1; year_prior = ano}
    if ((mmonth + 1) == 12) {month_next  = 0;  year_next  = ano + 1} else {month_next  = mmonth + 1; year_next  = ano}
    txt  = "<table bgcolor='#efefff' style='border:solid #330099; border-width:2' cellspacing='0' cellpadding='3' border='0' width='"+tam+"' height='"+tam*1.1 +"' class='calendario'>"
    txt += "<tr bgcolor='#FFFFFF'><td colspan='7' align='center'><table border='0' cellpadding='0' width='100%' bgcolor='#FFFFFF' class='calendario'><tr>"
    txt += "<td width=20% align=center><a href=javascript:popdate('"+obj+"','"+div+"','"+tam+"','"+((mmonth+1).toString() +"/01/"+(ano-1).toString())+"') class='Cabecalho_Calendario' title='Ano Anterior'><<</a></td>"
    txt += "<td width=20% align=center><a href=javascript:popdate('"+obj+"','"+div+"','"+tam+"','"+( "01/" + (month_prior+1).toString() + "/" + year_prior.toString())+"') class='Cabecalho_Calendario' title='Mês Anterior'><</a></td>"
    txt += "<td width=20% align=center><a href=javascript:popdate('"+obj+"','"+div+"','"+tam+"','"+( "01/" + (month_next+1).toString()  + "/" + year_next.toString())+"') class='Cabecalho_Calendario' title='Próximo Mês'>></a></td>"
    txt += "<td width=20% align=center><a href=javascript:popdate('"+obj+"','"+div+"','"+tam+"','"+((mmonth+1).toString() +"/01/"+(ano+1).toString())+"') class='Cabecalho_Calendario' title='Próximo Ano'>>></a></td>"
    txt += "<td width=20% align=right><a href=javascript:force_close('"+div+"') class='Cabecalho_Calendario' title='Fechar Calendário'><b>X</b></a></td></tr></table></td></tr>"
    txt += "<tr><td colspan='7' align='right' bgcolor='#ccccff' class='mes'><a href=javascript:pop_year('"+obj+"','"+div+"','"+tam+"','" + (mmonth+1) + "') class='mes'>" + ano.toString() + "</a>"
    txt += " <a href=javascript:pop_month('"+obj+"','"+div+"','"+tam+"','" + ano + "') class='mes'>" + umonth[mmonth] + "</a> <div id='popd' style='position:absolute'></div></td></tr>"
    txt += "<tr bgcolor='#330099'><td width='14%' class='dia' align=center><b>Dom</b></td><td width='14%' class='dia' align=center><b>Seg</b></td><td width='14%' class='dia' align=center><b>Ter</b></td><td width='14%' class='dia' align=center><b>Qua</b></td><td width='14%' class='dia' align=center><b>Qui</b></td><td width='14%' class='dia' align=center><b>Sex<b></td><td width='14%' class='dia' align=center><b>Sab</b></td></tr>"
    today1 = new Date((mmonth+1).toString() +"/01/"+ano.toString());
    diainicio = today1.getDay () + 1;
    week = d = 1
    start = false;

    for (n=1;n<= 42;n++) 
    {
        if (week == 1)  txt += "<tr bgcolor='#efefff' align=center>"
        if (week==diainicio) {start = true}
        if (d > days[mmonth]) {start=false}
        if (start) 
        {
            dat = new Date((mmonth+1).toString() + "/" + d + "/" + ano.toString())
            day_dat   = dat.toString().substr(0,10)
            day_today  = date_Form.toString().substr(0,10)
            year_dat  = dat.getFullYear ()
            year_today = date_Form.getFullYear ()
            colorcell = ((day_dat == day_today) && (year_dat == year_today) ? " bgcolor='#FFCC00' " : "" )
            txt += "<td"+colorcell+" style=\"border: 1px solid #efefff\" align=center onMouseOut=\"this.style.border='1px solid #efefff'\" onMouseOver=\"this.style.border='1px solid #5787B7'\" onClick=\"javascript:block('"+  d + "/" + (mmonth+1).toString() + "/" + ano.toString() +"','"+ obj +"','" + div +"')\" class='data' style=\"cursor: pointer\">"+ d.toString() + "</td>"
            d ++ 
        } 
        else 
        { 
            txt += "<td class='data' align=center> </td>"
        }
        week ++
        if (week == 8) 
        { 
            week = 1; txt += "</tr>"} 
        }
        txt += "</table>"
        div2 = eval (div)
        div2.innerHTML = txt 
}
  
// função para exibir a janela com os meses
function pop_month(obj, div, tam, ano)
{
  txt  = "<table bgcolor='#CCCCFF' border='0' width=80 class='calendario'>"
  for (n = 0; n < 12; n++) { txt += "<tr><td align=center><a href=javascript:popdate('"+obj+"','"+div+"','"+tam+"','"+("01/" + (n+1).toString() + "/" + ano.toString())+"')>" + umonth[n] +"</a></td></tr>" }
  txt += "</table>"
  popd.innerHTML = txt
}

// função para exibir a janela com os anos
function pop_year(obj, div, tam, umonth)
{
  txt  = "<table bgcolor='#CCCCFF' border='0' width=160 class='calendario'>"
  l = 1
  for (n=1991; n<2012; n++)
  {  if (l == 1) txt += "<tr>"
     txt += "<td align=center><a href=javascript:popdate('"+obj+"','"+div+"','"+tam+"','"+(umonth.toString () +"/01/" + n) +"')>" + n + "</a></td>"
     l++
     if (l == 4) 
        {txt += "</tr>"; l = 1 } 
  }
  txt += "</tr></table>"
  popd.innerHTML = txt 
}

// função para fechar o calendário
function force_close(div) 
    { 
	div2 = eval (div); div2.innerHTML = '';
	document.getElementById('hora').style.visibility='visible'
	}
    
// função para fechar o calendário e setar a data no campo de data associado
function block(data, obj, div)
{ 
    force_close (div)
    obj2 = eval(obj)
    obj2.value = data 
}

function onlyNumbers(type, evt) {
	var key_code = evt.keyCode  ? evt.keyCode  :
				   evt.charCode ? evt.charCode :
				   evt.which    ? evt.which    : void 0;
	if (key_code == 8  ||  key_code == 9  ||  key_code == 13  ||  key_code == 27)
	{
		return true;
	}
	else if ((key_code >= 35)  &&  (key_code <= 40))
	{
		return true
	}
	if (type == "rg") {
		if ((key_code != 120 && key_code != 88) && (key_code < 48 || key_code > 57)) return false;
		else return true;
	}
	else {
		if ((key_code >= 48)  &&  (key_code <= 57)) return true;
		else return false;
	}
}
function permiteFlash (id) {
	document.getElementById(id).innerHTML = document.getElementById(id).innerHTML;
}
function abreVideo (str, nome) {
	floater('divClipes', 435, 380);
	echo = '<table border=0 cellspacing=0 cellpadding=5 width="100%" height="100%" bgcolor="#FFFFFF">';
	echo += '<tr><td class="internas_texto_medio01" align="center" width="100%" height="100%">';
	echo += nome +'<br>';
	echo += '<object width="425" height="350"><param name="movie" value="http://www.youtube.com/v/'+str+'"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/'+str+'" type="application/x-shockwave-flash" wmode="transparent" width="425" height="350"></embed></object>';
	echo += '</td></tr>';
	echo += '<tr><td class="internas_texto_medio01" align="center">';
	echo += '[ <a class="internas_texto_promos01" href="javascript:void(0)" onClick="document.getElementById(\'divBackground\').style.display=\'none\';document.getElementById(\'divClipes\').style.display=\'none\'; document.getElementById(\'divClipes\').innerHTML=\'\'; ">fechar</a> ]';
	echo += '</td></tr>';
	echo += '</table>';
	document.getElementById('divClipes').innerHTML = echo;
}
function floater (nome, width, height) {
	if (!document.getElementById('divBackground')) {
		var div = document.createElement('div');
		div.setAttribute('id', 'divBackground');
		document.body.appendChild(div);
		var divBack = document.getElementById('divBackground');
		divBack.style.display = "block";
		divBack.style.width = document.body.clientWidth;
		divBack.style.height = document.body.scrollHeight;
		var div = document.createElement('div');
		div.setAttribute('id', nome);
		document.body.appendChild(div);
		var divMain = document.getElementById(nome);
		divMain.style.border = "1px solid #666";
		divMain.style.width = width+"px";
		divMain.style.height = height+"px";
		divMain.style.position = 'absolute';
		divMain.style.zIndex = 500;
		divMain.style.top = document.body.scrollTop + (document.body.clientHeight / 2) - (divMain.clientHeight / 2);
		divMain.style.left = (document.body.clientWidth / 2) - (divMain.clientWidth / 2);
	}
	else {
		document.getElementById('divBackground').style.display = "block";
		document.getElementById(nome).style.display = "block";
	}
}
function addPlaylist (id) {
	floater('addPlaylist', 200, 130);
	document.getElementById('addPlaylist').innerHTML = '<div style="background:#FFF; width:100%; height:100%" align="center" class="internas_texto_medio01"><br><br><img src="/web2.0/images/ico_loading_ajax.gif" border="0"><br>Adicionando música na playlist.</div>';
	xajax_addPlaylist('addPlaylist', id);
}
function rodaClipes (x) {
	if (!x) {
		if (clipe_x == 3) { clipe_x = 1; }
		else { clipe_x = clipe_x + 1; }
	}
	else {
		clipe_x = x;
		clearInterval(intervaloClipes);
		intervaloClipes = window.setInterval('rodaClipes(x)', 10000);
	}
	if (!imgAntigo) { 
		imgAntigo = 'destaque_1';
		idAntigo = 1;
		w3Opacity.set('imgDestaque2', 0);
		w3Opacity.set('imgDestaque3', 0);
	}
	else {
		document.getElementById(imgAntigo).style.background = '#FFFFFF';
		document.getElementById('destaque_'+clipe_x).style.background = '#d9e8f2';
		document.getElementById('imgDestaque'+clipe_x).style.zIndex = 3;
		document.getElementById('imgDestaque'+idAntigo).style.zIndex = 1;
		idAntigo2 = idAntigo;
		idAntigo = clipe_x;
		imgAntigo = 'destaque_'+clipe_x;
		w3Opacity.toggle('imgDestaque'+clipe_x, 400);
		w3Opacity.toggle('imgDestaque'+idAntigo2, 400);
	}
	return true;
}
function startClipes () {
	clipe_x = 0;
	rodaClipes();
	intervaloClipes = window.setInterval('rodaClipes(x)', 10000);
}
function mostraVideo (youtube, file) {
	if (youtube) {
		document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="342" height="282"><param name="movie" value="http://www.youtube.com/v/'+file+'"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/'+file+'" type="application/x-shockwave-flash" wmode="transparent" width="342" height="282"></object>');
	}
	else {
		file = "http://p.download.uol.com.br/metropolitanafm/videos/"+file;
		document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="342" height="291" id="FLVPlayer">');
		document.write('<param name="movie" value="/web2.0/flashes/flvplayer.swf?file='+file+'" />');
		document.write('<param name="salign" value="lt" />');
		document.write('<param name="quality" value="high" />');
		document.write('<param name="scale" value="noscale" />');
		document.write('<param name="allowfullscreen" value="true" />');
		document.write('<embed src="/web2.0/flashes/flvplayer.swf?file='+file+'" quality="high" scale="noscale" width="342" height="291" name="FLVPlayer" salign="LT" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
		document.write('</object>');
	}
}
function abre_player (id) {
		window.open('/player/?id='+id,'aovivo','status=yes,resizable=no,width=480,height=295,top=111,left=10');
}
