// JavaScript Document

/* Autor: Mario Costa */
function formatar_moeda(campo, separador_milhar, separador_decimal, tecla) {
	var sep = 0;
	var key = '';
	var i = j = 0;
	var len = len2 = 0;
	var strCheck = '0123456789';
	var aux = aux2 = '';
	var whichCode = (window.Event) ? tecla.which : tecla.keyCode;

	if (whichCode == 13) return true; // Tecla Enter
	if (whichCode == 8) return true; // Tecla Delete
	key = String.fromCharCode(whichCode); // Pegando o valor digitado
	if (strCheck.indexOf(key) == -1) return false; // Valor inválido (não inteiro)
	len = campo.value.length;
	for(i = 0; i < len; i++)
	if ((campo.value.charAt(i) != '0') && (campo.value.charAt(i) != separador_decimal)) break;
	aux = '';
	for(; i < len; i++)
	if (strCheck.indexOf(campo.value.charAt(i))!=-1) aux += campo.value.charAt(i);
	aux += key;
	len = aux.length;
	if (len == 0) campo.value = '';
	if (len == 1) campo.value = '0'+ separador_decimal + '0' + aux;
	if (len == 2) campo.value = '0'+ separador_decimal + aux;

	if (len > 2) {
		aux2 = '';

		for (j = 0, i = len - 3; i >= 0; i--) {
			if (j == 3) {
				aux2 += separador_milhar;
				j = 0;
			}
			aux2 += aux.charAt(i);
			j++;
		}

		campo.value = '';
		len2 = aux2.length;
		for (i = len2 - 1; i >= 0; i--)
		campo.value += aux2.charAt(i);
		campo.value += separador_decimal + aux.substr(len - 2, len);
	}

	return false;
}
//add favoritos
function add_bookmark() { 
var browsName = navigator.appName; 
if (browsName == "Microsoft Internet Explorer") { 
window.external.AddFavorite('url do seu blog','nome do seu blog' );
} else if (browsName == "Netscape") { 
alert ("nPara adicionar meu blog ao seu BookMark aperte CTRL+D"); 
}
}

// POPUP
function pedido(){
	window.open("pedido.php","POPUP","toolbar=0,location=0,directories=0,scrollbars=0,width=223,height=300,left=10,top=5");
}
function popUp(PG,W,H){
	window.open(PG,"POPUP","toolbar=0,location=0,directories=0,scrollbars=0,width="+W+",height="+H+",left=10,top=5");
}
function aovivo(){
	window.open("player.php","POPUP","toolbar=0,location=0,directories=0,scrollbars=0,width=318,height=148,left=10,top=5");
}
function viewFoto(F,W,H){
	window.open("zoom.php?id="+F,"POPUP","toolbar=0,location=0,directories=0,scrollbars=0,width="+W+",height="+H+",left=60,top=10");
}
function viewFoto2(F,W,H){
	window.open("fotoview2.php?id="+F,"POPUP","toolbar=0,location=0,directories=0,scrollbars=0,width="+W+",height="+H+",left=60,top=10");
}

//	RADIO
<!--
function RegisterEventObservers(){ 
    var plugin = document.WMPlay;
    document.appObs.setByProxyDSNewStreamObserver(plugin, true); 
    troca();
    numero = numero - 1;
}

function OnDSNewStreamEvt(oldstate, newstate){
    setTimeout('troca();',1000);
}
         
function PlayClick(){
    document.WMPlay.Play();
}

function StopClick(){
    numero = 1;
    document.WMPlay.Stop();
    if (navigator.appName.indexOf('Netscape') != -1) {
        document.WMPlay.SetCurrentPosition(0);
    } else {
        document.WMPlay.CurrentPosition = 0;
    }
}

function PauseClick(){
    if (navigator.appName.indexOf('Netscape') != -1) {
        estado=document.WMPlay.GetPlayState();
    } else {
        estado=document.WMPlay.PlayState;
    }

    if (estado==1) {
        document.WMPlay.Play();
    } else if (estado==2) {
        document.WMPlay.Pause();
    }
}

function FowardClick(){
    document.WMPlay.Next();
}

function BackClick(){
    numero = numero - 2;
    document.WMPlay.Previous();
}

function UpVolumeClick(){
    if (document.WMPlay.Volume <= -300) {
        document.WMPlay.Volume = document.WMPlay.Volume + 300;
    }
}

function DownVolumeClick(){
    if (document.WMPlay.Volume >= -8000) {
        document.WMPlay.Volume = document.WMPlay.Volume - 300;
    }
}
//-->

//	STATUS PROGRAMAÇÃO
var progNow;
function ajaxProgNow(){
progNow = null;
	if(window.XMLHttpRequest){
		progNow = new XMLHttpRequest();
		progNow.onreadystatechange = progressoProgNow; 
        progNow.open("GET","prognow.php"); 
        progNow.send(null);
	} else if(window.ActiveXObject){
		progNow = new ActiveXObject("Microsoft.XMLHTTP"); 
		progNow.onreadystatechange = progressoProgNow; 
        progNow.open("GET","prognow.php"); 
        progNow.send(null);
	} else {
		alert('Seu navegado está desatualizado!');
	}
}

function progressoProgNow(){
	if(progNow.readyState == 4){
		if(progNow.status == 200){
			document.getElementById('marqueeProgNow').innerHTML = progNow.responseText;
		} else {
			alert ("Falha\n" + progNow.statusText);
		}
	}
}


/* Autor: Mario Costa */
function formatar_moeda(campo, separador_milhar, separador_decimal, tecla) {
	var sep = 0;
	var key = '';
	var i = j = 0;
	var len = len2 = 0;
	var strCheck = '0123456789';
	var aux = aux2 = '';
	var whichCode = (window.Event) ?  tecla.which : tecla.keyCode;

	if (whichCode == 13) return true; // Tecla Enter
	if (whichCode == 8) return true; // Tecla Delete
	key = String.fromCharCode(whichCode); // Pegando o valor digitado
	if (strCheck.indexOf(key) == -1) return false; // Valor inválido (não inteiro)
	len = campo.value.length;
	for(i = 0; i < len; i++)
	if ((campo.value.charAt(i) != '0') && (campo.value.charAt(i) != separador_decimal)) break;
	aux = '';
	for(; i < len; i++)
	if (strCheck.indexOf(campo.value.charAt(i))!=-1) aux += campo.value.charAt(i);
	aux += key;
	len = aux.length;
	if (len == 0) campo.value = '';
	if (len == 1) campo.value = '0'+ separador_decimal + '0' + aux;
	if (len == 2) campo.value = '0'+ separador_decimal + aux;

	if (len > 2) {
		aux2 = '';

		for (j = 0, i = len - 3; i >= 0; i--) {
			if (j == 3) {
				aux2 += separador_milhar;
				j = 0;
			}
			aux2 += aux.charAt(i);
			j++;
		}

		campo.value = '';
		len2 = aux2.length;
		for (i = len2 - 1; i >= 0; i--)
		campo.value += aux2.charAt(i);
		campo.value += separador_decimal + aux. substr(len - 2, len);
	}

	return false;
}
//	status programação
