var http_request = false;
var timeoutID;



/**
 * Funcao para abrir a janela do player
 * @access public
 * @return void
 **/
function abre_player(){
/*
	var freq32 = $("freq32");
	var freq64 = $("freq64");

	var freq = "";

	if ( freq32.checked ) {
		freq = "32";
	}

	if ( freq64.checked ) {
		freq = "64";
	}
	janela("player.php","493","383");
*/

	//alert("Estamos enfrentando problemas técnicos alheios.\nDesculpe pelo transtorno gerado,em breve estaremos retornando com nosso serviço.\nObrigado.");
	janela("player.php","493","383");

}



/**
* Funcao para retirar espacos em branco de uma string
*/
function trim(str){
	return str.replace(/^\s+|\s+$/g,"");
}


/**
* Funcoes para tratamento de campos Input
*/
function mascara(o,f){
    v_obj=o
    v_fun=f
    setTimeout("execmascara()",1)
}

function execmascara(){
    v_obj.value=v_fun(v_obj.value)
}

function leech(v){
    v=v.replace(/o/gi,"0")
    v=v.replace(/i/gi,"1")
    v=v.replace(/z/gi,"2")
    v=v.replace(/e/gi,"3")
    v=v.replace(/a/gi,"4")
    v=v.replace(/s/gi,"5")
    v=v.replace(/t/gi,"7")
    return v
}

function soNumeros(v){
    return  v.replace(/\D/g,"")
}

function telefone(v){
    v=v.replace(/\D/g,"")                  
    v=v.replace(/^(\d\d)(\d)/g,"($1) $2") 
    v=v.replace(/(\d{4})(\d)/,"$1-$2")    
    return v
}
/*****************************************************/

/**
 *
 * @access public
 * @return void
 **/
function hideDestaque( canHide ){

	var destaque = document.getElementById('destaque');

	if ( destaque != null ) {
		if  ( canHide )  {
		destaque.style.display="none";
		
		} else {
			destaque.style.display="";
					
		}
	}
	var rBlog = document.getElementById('s6');
	if ( rBlog != null ) {
		if  ( canHide )  {
		rBlog.style.display="none";
		
		} else {
			rBlog.style.display="";
					
		}
	}

}

function hidePalco( canHide ){

	var palco = $('palco_jb');

	if ( palco != null ) {
		if  ( canHide )  {
		palco.style.display="none";
		} else {
			palco.style.display="";
		}
	}

}

function hideFilme( canHide ){

	var destaque = document.getElementById('filme');

	if ( destaque != null ) {
		if  ( canHide )  {
		destaque.style.display="none";
		} else {
			destaque.style.display="";
		}
	}

}

/**
 * Funcao para abrir uma janela popup
 * @access public
 * @return void
 **/
function janela(p_pag, p_width, p_heigth) {
	var desktop = window.open(p_pag,'pop','scrollbars=no,location=no,directories=no,status=no,resizable=no,copyhistory=yes,menubar=no,width='+p_width+',height='+p_heigth);
}



/**
 *
 * @access public
 * @return void
 **/
function abre_player32(){
	$("freq32").checked = true;
	abre_player();
}

function abre_player64(){
	$("freq64").checked = true;
	abre_player();
}


/**
 * Funcao para exibir um box de aguarde
 * @access public
 * @return void
 **/
function displayWaitBox( canShow )
{

	var box = document.getElementById("boxWait");
	if ( canShow ) {
		box.style.display = "";
		hideDestaque( false );
	} else {
		box.style.display = "none";

	}

}



/**
 * Funcao para colcoar mascara em campos de Data
 * @access public
 * @return void
 **/
function putDateMask( input )
{
	if  ( ( input.value.indexOf("/") <= 0 ) && (input.value.length == 8) ) {
		var dia = input.value.substring(0,2);
		var mes = input.value.substring(2,4);
		var ano = input.value.substring(4,8);

		var data = dia + "/" + mes + "/" + ano;
		input.value = data;
	}

}

/**
* Classe para requisicoes GET via AJAX
* @access public
* @return void
*/
function AJAX(url, metodo, params, processa, modo)
{
    this.url                = url;
    this.metodo             = (metodo) ? metodo : 'GET';
    this.params             = (metodo='GET') ? null : params;
    this.processaresultado  = processa;
    this.modo               = (modo) ? modo : 'T';

    /* T = Text , X = XML */
    if( this.modo != 'T' && this.modo != 'X' ){
        this.modo = 'T';
    }

    this.conectar();
}

AJAX.prototype = {

       conectar: function(){

			/* Verifica se URL é válda */
			if( this.url == undefined || this.url == ''){
				return;
			}

			this.httprequest = null;


			if( window.XMLHttpRequest ){
				this.httprequest = new XMLHttpRequest();

			} else if( window.ActiveXObject ) {
				try{
					this.httprequest = new ActiveXObject("Msxml2.XMLHTTP");
				} catch (e){
					try{
						this.httprequest = new ActiveXObject("Microsoft.XMLHTTP");
					} catch (e) {}
				}
			}
			if ( this.httprequest != null && this.httprequest != undefined ) {
				var obj = this;

				this.httprequest.onreadystatechange = function(){
					obj.processaretorno.call(obj);
				}


				this.httprequest.open(this.metodo,this.url, true);
				this.httprequest.send(this.params);

			}

		},


		processaretorno: function(){
			if( this.httprequest.readyState == 4 ) {

				if( this.httprequest.status == 200 ) {

					var resp = ( this.modo == 'T' ) ? this.httprequest.responseText : this.httprequest.responseXML;

					if( this.processaresultado != null ){
						this.processaresultado(resp);
					}

				}

			} else {
				this.processaerro();
			}
		},


		processaerro:function(){

		}
}

/*************************************************************/





/**
 * Função para submições post via AJAX
 * @access public
 * @return void
 **/
function submitAjax( url, params, method )
{
  http_request = false;
  if (window.XMLHttpRequest) { // Mozilla, Safari,...
     http_request = new XMLHttpRequest();
     if (http_request.overrideMimeType) {

        http_request.overrideMimeType('text/html');
     }
  } else if (window.ActiveXObject) { // IE
     try {
        http_request = new ActiveXObject("Msxml2.XMLHTTP");
     } catch (e) {
        try {
           http_request = new ActiveXObject("Microsoft.XMLHTTP");
        } catch (e) {}
     }
  }
  if (!http_request) {
     alert('Cannot create XMLHTTP instance');
     return false;
  }


  http_request.onreadystatechange = method;
  http_request.open('POST', url, true);
  http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  http_request.setRequestHeader("Content-length", params.length);
  http_request.setRequestHeader("Connection", "close");
  http_request.send( params );


}

/**
* Recupera um elemento HTML por ID
* @access public
* @return void
*/
function $( id )
{
	return document.getElementById( id );
}

/**
* Retorna o Objeto BODY
* @access public
* @return void
*/
function getBodyDocument() {
	var body = document.getElementsByTagName( "body" );
	return body[0];
}


/**
* Função para exibir o box de noticia.
* @access public
* @return void
**/
function displayNoticia( idNoticia )
{

	displayWaitBox( true );
	hideDestaque( true );

	var url = "index.php?module=NoticiaController&action=RenderNoticiaXML&id=" + idNoticia;
	var ajx = new AJAX();

	ajx.url = url;
    ajx.modo = 'T';
    ajx.processaresultado = function(r){

		if ( r != null ) {


			var noticia = r.split( "|" );

			JBFM_Window( 510, 310, "JBFM - Notícia" , noticia[1] , "JBFM_Window_Noticia"  );

		}

		displayWaitBox( false );
    }
	ajx.conectar();

}
/*
 * JBFM Na Copa 
*/
function openCopa()
{
    window.open('http://www.jb.fm/jbfmnacopa/','janelaCopa2010','width=1024,height=728,scrollbars=yes');
}




/**
 * Renderiza o formulario para participar de uma promocao
 * @access public
 * @return void
 **/
function displayFormParticipaPromocao( idPromocao )
{
	window.scroll(0,0);

	displayWaitBox( true );
	
	if(idPromocao == 190){
		hideFilme( true );
	}

	var url = "index.php?module=PromocaoController&action=ViewFormParticipa&id=" + idPromocao;
	var ajx = new AJAX();

	ajx.url = url;
    ajx.modo = 'T';
    ajx.processaresultado = function(r){

		JBFM_Window( 510, 420, "JBFM - Promoção", r, "JBFM_Window_Promocao"  );
		displayWaitBox( false );


    }
	ajx.conectar();
}

function displayFormParticipaPromocaoCarinhas( idPromocao, idcara )
{
	window.scroll(0,0);

	displayWaitBox( true );

	if(idPromocao == 190){
		hideFilme( true );
	}
	hidePalco ( true );

	var url = "index.php?module=PromocaoController&action=ViewFormParticipaCarinha&id=" + idPromocao + "&promo_resposta=" + idcara;
	var ajx = new AJAX();

	ajx.url = url;
	ajx.modo = 'T';
	ajx.processaresultado = function(r){

		JBFM_Window( 510, 420, "JBFM - Promoção", r, "JBFM_Window_Promocao"  );
		displayWaitBox( false );


	}
	ajx.conectar();
}


function displayFormRegulamentoPromocao( idPromocao )
{

	window.scroll(0,0);
	displayWaitBox( true );


	var url = "index.php?module=PromocaoController&action=ViewFormRegulamento&id=" + idPromocao;
	var ajx = new AJAX();

	ajx.url = url;
    ajx.modo = 'T';
    ajx.processaresultado = function(r){

		JBFM_Window( 510, 420, "JBFM - Regulamento", r, "JBFM_Window_Regulamento_Promocao"  );
		displayWaitBox( false );


    }
	ajx.conectar();
}



/**
 * Renderiza o formulário para participar de uma promoção
 * @access public
 * @return void
 **/
function displayFormCadastro()
{

	displayWaitBox( true );


	var url = "index.php?module=CadastroController&action=ViewFormCadastroAJAX";
	var ajx = new AJAX();

	ajx.url = url;
    ajx.modo = 'T';
    ajx.processaresultado = function(r){

		JBFM_Window( 641, 541, "JBFM - Cadastro", r, "JBFM_Window_Cadastro"  );
		displayWaitBox( false );


    }
	ajx.conectar();
}


/**
* Abre uma div com respectivo layout, tamanho, titulo e conteudo
*/
function JBFM_Window( width, height, title, content, className )
{

	var nShadow = document.createElement( "div" );
	nShadow.className = "JBFM_Shadow";
	nShadow.zIndex = 1;


	var nWindow = document.createElement( "div" );

	var marginTop = height / 2;
	var marginLeft = width / 2;

	nWindow.className 		 = className
	nWindow.style.width 	 =  width + "px";
	nWindow.style.height 	 =  height + "px";
	nWindow.style.position   = "absolute";
	nWindow.style.top 		 = "60%";
	nWindow.style.left		 = "50%";
	nWindow.style.marginTop  = "-" + marginTop + "px";
	nWindow.style.marginLeft = "-" + marginLeft + "px";
	nWindow.zIndex = 10;

	var nWindowTitleWrapper = document.createElement( "div" );
	nWindowTitleWrapper.className = "JBFM_Window_Title";

	var nWindowTitleText = document.createElement( "div" );
	nWindowTitleText.className = "JBFM_Window_Title_Text";
	nWindowTitleText.innerHTML = title;


	var nWindowTitleClose = document.createElement( "div" );
	nWindowTitleClose.className = "JBFM_Window_Title_Close";
	nWindowTitleClose.id = className + "_Btn_Close";

	nWindowTitleClose.onclick = function() {

			getBodyDocument().removeChild( nWindow );
			getBodyDocument().removeChild( nShadow );
			hideDestaque( false );
			hideFilme( false );
			hidePalco( false );
	}

	var nWindowContent = document.createElement( "div" );
	nWindowContent.className = "JBFM_Window_Content";
	nWindowContent.innerHTML = content;

	width = width - 30;

	var h = height-80;
	var wi = width-10;

	nWindowContent.style.height = h + "px";
	nWindowContent.style.width = wi + "px";

	nWindowTitleWrapper.appendChild( nWindowTitleText );
	nWindowTitleWrapper.appendChild( nWindowTitleClose );


	nWindow.appendChild( nWindowTitleWrapper );
	nWindow.appendChild( nWindowContent );

	getBodyDocument().appendChild( nShadow );
	getBodyDocument().appendChild( nWindow );
}


function getPageContent( url )
{
	window.location=url;
}


/**
* Requisição ajax para retornar uma localidade
* de acordo com o cep informado
*/
function verificaLocalidade( campo )
{

	if ( campo != "" ) {
		var url = "index.php?module=CadastroController&action=RenderLocalidadeAJAX&cep=" + campo.value;
		var ajx = new AJAX();

		displayWaitBox( true );

		ajx.url = url;
		ajx.modo = 'T';
		ajx.processaresultado = function(r){

			var localidade 		  = r.split(";");

			if ( localidade != "" ) {
				$('cep').value 		  = trim( localidade[0] );
				$('logradouro').value = localidade[1];
				$('bairro').value 	  = localidade[2];
				$('cidade').value 	  = localidade[3];
				$('estado').value 	  = localidade[4];

			}

			displayWaitBox( false );

		}
		ajx.conectar();

	}
}


function setResp(op) 
{
	
	if(op == 0){ var r = "Chocotone"; }
	if(op == 1){ var r = "Panetone"; }
		
	$("promo_resposta").value = r;
	
	
}

function reloadPage(){
	window.location.href="http://www.jb.fm";
}
/**
 * Função ajax para efetuar a participação do usuário
 * @access public
 * @return void
 **/
function participaPromocao( idPromocao, btn )
{


	displayWaitBox( true );

	btn.value    = "Aguarde...";
	btn.disabled = true;

	var email 	 = $("promo_email").value;
	var senha 	 = $("promo_senha").value;
	var resposta = $("promo_resposta").value;
	
	
	var msg = "O Usuário não foi encontrado!\n\n Para participar das promoções é necessário estar cadastrado no site.\n Deseja cadastrar-se agora ?";

	var params = "email=" + encodeURI(email) + "&senha=" + encodeURI(senha) + "&resposta=" + encodeURI(resposta) + "&id=" + idPromocao;
	var url    = "index.php?module=PromocaoController&action=ConfirmaParticipacao";

	submitAjax( url, params, function( resposta ) {

	      if (http_request.readyState == 4) {
	         if (http_request.status == 200) {
		
				var resp = http_request.responseText;
		
		
				//alert( resp );
		
				displayWaitBox( false );


				if ( resp.indexOf("USUARIO_NOT_FOUND") >= 0 ) {
					if ( confirm( msg ) ) {
						//displayFormCadastro();
						window.location.href='http://www.jb.fm/index.php?module=CadastroController';
					} else {
						btn.value    = "Participar";
						btn.disabled = false;
					}
				}

				if ( resp.indexOf("OK") >= 0 ) {
					//alert(idPromocao);
					alert("Parabens! Você agora ja está concorrendo a esta promoção. Boa Sorte !!!");
					$("JBFM_Window_Promocao_Btn_Close").onclick();
					if(idPromocao == 256){
						window.location.href='http://www.jb.fm';
					}
				}

				if ( resp.indexOf("USUARIO_PARTICIPANTE") >= 0 ) {
					alert("Você já esta concorrendo a esta promoção");
					$("JBFM_Window_Promocao_Btn_Close").onclick();
				}


	         } else {
				//alert("Debug :" + http_request.responseText);
				displayWaitBox( false );
	         }
	      }
	} );
}



function participaPromocaoCarinha( idPromocao, btn )
{


	displayWaitBox( true );

	btn.value    = "Aguarde...";
	btn.disabled = true;

	var email 	 = $("promo_email").value;
	var senha 	 = $("promo_senha").value;
	var resposta = $("promo_resposta").value;


	var msg = "O Usuário não foi encontrado!\n\n Para participar das promoções é necessário estar cadastrado no site.\n Deseja cadastrar-se agora ?";

	var params = "email=" + encodeURI(email) + "&senha=" + encodeURI(senha) + "&resposta=" + encodeURI(resposta) + "&id=" + idPromocao;
	var url    = "index.php?module=PromocaoController&action=ConfirmaParticipacao";

	submitAjax( url, params, function( resposta ) {

		  if (http_request.readyState == 4) {
			 if (http_request.status == 200) {

				var resp = http_request.responseText;


				//alert( resp );

				displayWaitBox( false );


				if ( resp.indexOf("USUARIO_NOT_FOUND") >= 0 ) {
					if ( confirm( msg ) ) {
						window.location='index.php?module=CadastroController';
					} else {
						btn.value    = "Participar";
						btn.disabled = false;
					}
				}

				if ( resp.indexOf("OK") >= 0 ) {
					
					alert("Parabens! Você agora ja está concorrendo a esta promoção. Boa Sorte !!!");
					$("JBFM_Window_Promocao_Btn_Close").onclick();
					if(idPromocao == 256){
						reloadPage();
					}
					
				}

				if ( resp.indexOf("USUARIO_PARTICIPANTE") >= 0 ) {
					alert("Você já esta concorrendo a esta promoção");
					$("JBFM_Window_Promocao_Btn_Close").onclick();
				}


			 } else {
				//alert("Debug :" + http_request.responseText);
				displayWaitBox( false );
			 }
		  }
	} );
}


/**
 * Função para efetuar cadastro via AJAX
 * @access public
 * @return void
 **/
function efetuarCadastro( btn ) {

	displayWaitBox( true );

	btn.value 	 = "Aguarde...";
	btn.disabled = true;

	var url = "index.php?module=CadastroController&action=SalvarCadastroAJAX";

	var nome 			= encodeURI( $("nome").value );
	var dataNascimento  = encodeURI( $("dataNascimento").value );
	var sexo 			= encodeURI( $("sexo").value );
	var identidade 	 	= encodeURI( $("identidade").value );
	var cpf 			= encodeURI( $("cpf").value );
	var cep 			= encodeURI( $("cep").value );
	var logradouro 		= encodeURI( $("logradouro").value );
	var bairro 			= encodeURI( $("bairro").value );
	var cidade 			= encodeURI( $("cidade").value );
	var estado 			= encodeURI( $("estado").value );
	var email 			= encodeURI( $("email").value );
	var telefone 		= encodeURI( $("telefone").value );
	var celular 		= encodeURI( $("celular").value );
	var confirmaEmail 	= encodeURI( $("confirmaEmail").value );
	var senha 			= encodeURI( $("senha").value );
	var confirmaSenha 	= encodeURI( $("confirmaSenha").value );

	var queryString = "nome="+nome+"&dataNascimento="+dataNascimento+"&sexo=" + sexo;
		queryString += "&identidade="+identidade+"&cpf="+cpf+"&cep="+cep+"&logradouro="+logradouro;
		queryString += "&bairro="+bairro+"&cidade="+cidade+"&estado="+estado+"&email="+email;
		queryString += "&telefone="+telefone+"&celular="+celular+"&confirmaEmail="+confirmaEmail;
		queryString += "&senha="+senha+"&confirmaSenha="+confirmaSenha;


	submitAjax( url, queryString, function( resposta ) {

		 if (http_request.readyState == 4) {
	         if (http_request.status == 200) {

				displayWaitBox( false );

				if ( http_request.responseText.indexOf("OK") > 0 ) {

					alert("Parabens! Seu cadastro foi efetuado com sucesso\n Você agora poderá participar das promoções da JBFM");
					$("JBFM_Window_Cadastro_Btn_Close").onclick();

					$("btnParticipaPromo").disabled = false;
					$("btnParticipaPromo").value 	= "Participar";
					$("promo_email").value  		= email;

				} else {

					alert( http_request.responseText );
					btn.value 	 = "Cadastrar";
					btn.disabled = false;

				}

			 }
		 }

	} );

}

/**
 * Função para exibir o box de musicalidades
 * @access public
 * @return void
 **/
function displayMusicalidade( id )
{

	displayWaitBox( true );
	hideDestaque( true );

	var url = "index.php?module=MusicalidadeController&id=" + id;
	var ajx = new AJAX();

	ajx.url = url;
    ajx.modo = 'T';
    ajx.processaresultado = function(r){

		JBFM_Window( 510, 420, "JBFM - Musicalidade", r, "JBFM_Window_Musicalidade"  );
		displayWaitBox( false );


    }
	ajx.conectar();
}


/**
 * Zoom na imagem clicada
 * @access public
 * @return void
 **/
function zoomImagem( img ) {

	var div = document.getElementById( "JBFM_Click_Picture" );
	div.innerHTML = "";

	var zoomImagem = document.createElement( "img" );

	zoomImagem.src = img.src;
	zoomImagem.style.width  = "500px";
	zoomImagem.style.height = "390px";
	zoomImagem.id = "zImagem";

	zoomImagem.style.filter = "alpha(opacity="+ 1 +")";
	zoomImagem.style.opacity = 1/100;

	div.appendChild( zoomImagem );

	fadeIn( "zImagem", 0.5 );

}

/**
 * Link para a página de Gadgets
 * @access public
 * @return void
 **/
function abre_gadget(){
	window.location='index.php?module=MainApplication&action=Gadget';
}

/**
 * Link para a página de RSS
 * @access public
 * @return void
 **/
function abre_rss(){
	window.location='index.php?module=MainApplication&action=Rss';
}

/**
 * Link para a página de Contato
 * @access public
 * @return void
 **/
function abre_fale_conosco(){
	window.location='index.php?module=ContatoController&action=ViewFormPedidoMusical'
}

/**
* Galeria de Fotos
*/
function fadeOut(id, time) {
	target = document.getElementById(id);
	alpha = 100;
	timer = (time*1000)/50;
	var i = setInterval(
			function() {
				if (alpha <= 0)
					clearInterval(i);
				setAlpha(target, alpha);
				alpha -= 2;
			}, timer);
}

function fadeIn(id, time) {
	target = document.getElementById(id);
	alpha = 0;
	timer = (time*1000)/50;
	var i = setInterval(
			function() {
				if (alpha >= 100)
					clearInterval(i);
				setAlpha(target, alpha);
				alpha += 2;
			}, timer);
}

function setAlpha(target, alpha) {
	target.style.filter = "alpha(opacity="+ alpha +")";
	target.style.opacity = alpha/100;
}

function stopScroll() {
	clearInterval(timeoutID);
}

function scrollUp() {
	document.getElementById("JBFM_Click_Pics").scrollLeft += 2
}

function scrollDown(){
	document.getElementById("JBFM_Click_Pics").scrollLeft -= 2
}

/**
 *
 * @access public
 * @return void
 **/
function abre_player_simples(){
	janela("player_simples.php","305","185");
	//alert("Serviço temporariamente indisponível!");
}

/**
 * Rolar para frente
 * @access public
 * @return void
 **/
function next() {
	var div = document.getElementById('JBFM_Click_Pics');

	if( div.scrollLeft >= 0 ) {
		timeoutID = setInterval('scrollUp()',8);
	}
}



/**
 * Rolar para traz
 * @access public
 * @return void
 **/
function prior() {
	var div = document.getElementById('JBFM_Click_Pics');

	if(div.scrollLeft > 0) {
		timeoutID = setInterval('scrollDown()',8);
	}

}


/**
 * @Função para enviar pedido musical via ajax
 * @access public
 * @return void
 **/
function enviarPedidoMusical( btn )
{
	var nome  =  $("pm_nome").value;
	var email =  $("pm_email").value;
	var texto =  $("pm_texto").value;


	btn.value 	 = "Aguarde...";
	btn.disabled = true;

	var url = "index.php?module=ContatoController&action=EnviarPedidoMusicalAJAX";
	var queryString = "nome="+nome+"&email="+email+"&texto=" + texto;

	submitAjax( url, queryString, function( resposta ) {

		 if (http_request.readyState == 4) {
	         if (http_request.status == 200) {


				if ( http_request.responseText.indexOf("OK") > 0 ) {

					alert("Seu pedido foi enviado com sucesso");

					$("pm_nome").value  = "";
					$("pm_email").value = "";
					$("pm_texto").value = "";

					btn.disabled = false;
					btn.value = "Enviar Pedido";

				} else {
					alert("Não foi possível enviar seu pedido. Tente novamente");
					btn.disabled = false;
					btn.value = "Enviar Pedido";

				}

			 }
		 }

	} );



}

/**
 *
 * @access public
 * @return void
 **/
function abre_home(){
	window.location='index.php';
}

function abreCelebrationPlayer() {
		window.open("http://www.jb.fm/ondemand/player_ondemand.php","Celebration","toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=no,resizable=yes,top=0,left=0,width=450,height=300")
	}

function smooth_jazz(){
	janela('http://www.jb.fm/smooth/player.php', '640', '470');

}

/**
 *
 * @access public
 * @return void
 **/
function getGanhadores( combo ){
	if ( combo.value == "reibacalhau" ) {
		window.location='index.php?module=PromocaoController&action=ViewResultadoReiBacalhau';
	}else	
		if ( combo.value == "carioca" ) {
		window.location='index.php?module=PromocaoController&action=ViewResultadoCarioca';
	} 
	else
		if ( combo.value == 256 ) {
		window.location='index.php?module=PromocaoController&action=ViewEsconderijo';
	}
    else
        if ( combo.value == "lrc" ) {
        window.location='index.php?module=PromocaoController&action=ViewGanhadorCelebration';
    }
	else
		if ( combo.value == 276 ) {
		window.location='index.php?module=PromocaoController&action=GanhadoresAnaCarolina';
	}
	
	else
		if ( combo.value == 286 ) {
		window.location='index.php?module=PromocaoController&action=GanhadoresAnaCarolinaVIP';
	}
	
	else
		if ( combo.value == 310 ) {
		window.location='index.php?module=PromocaoController&action=ViewGanhadoresViolao';
	}
	else
		if ( combo.value == 333 ) {
		window.location='index.php?module=PromocaoController&action=ViewGanhadoresMorgan';
	}
	
	else
		if ( combo.value == 289 ) {
		window.location='index.php?module=PromocaoController&action=GanhadoresCirqueduSoleil';
	}
	
	else {
		window.location='index.php?module=PromocaoController&action=ViewGanhadoresPromocao&idPromocao=' + combo.value;
	}



}

function getGaleria( combo ){

	window.location='index.php?module=GaleriaController&id=' + combo.value;

}

function showRegulamento( combo ){

	window.location='index.php?module=MainApplication&action=RegulamentoSms&id=' + combo;

}

/**
 *
 * @access public
 * @return void
 **/
function showBoxLogin(){
	var box = document.getElementById("boxLogin");
	if (box.style.display == "none") {
		box.style.display = "";
	} else {
		box.style.display = "none"
	}
}

/**
 *
 * @access public
 * @return void
 **/
function carregaCadastro(){

	var email = encodeURI ( $("emailLogin").value );
	var senha = encodeURI ( $("senhaLogin").value );

	var url = "index.php?module=CadastroController&action=CarregaCadastro";
	var queryString = "email="+email+"&senha="+senha;

	url += "&" + queryString;


	var ajx = new AJAX();

	//displayWaitBox( true );

	ajx.url = url;
	ajx.modo = 'T';
	ajx.processaresultado = function(r){

		if ( r.indexOf("NOT_FOUND_USER") > 0 ) {
			alert("Usuário ou Senha inválidos");
		} else {

            document.getElementById("boxLogin").style.display="none";
			$("emailLogin").value = "";
			$("senhaLogin").value = "";

			var values = r.split(";");

			$("idCadastro").value 	  = values[0];
			$("nome").value 		  = values[1];

			$("email").value 		  = values[2];
			$("confirmaEmail").value 		  = values[2];

			//$("dataNascimento").value = values[3];

			var dataNasc = values[3].split("-");
			$("dataNascimento").value = dataNasc[2].substring(0,2) + "/" + dataNasc[1].substring(0,2) + "/" + dataNasc[0].substring(0,4);

			$("identidade").value     = values[4];
			$("cpf").value            = values[5];
			$("cep").value			  = values[6];

			$("senha").value		  = values[9];
			$("confirmaSenha").value  = values[9];

			$("celular").value		  = values[8];
			$("telefone").value		  = values[7];

			$("logradouro").value 	  = values[12];
			$("bairro").value 	  	  = values[13];
			$("estado").value 	  	  = values[14];
			$("cidade").value 	  	  = values[15];

			$("sexo").value = values[10];

			//showBoxLogin();


		}

		//displayWaitBox( false );

	}
	ajx.conectar();


}

function printFoto( id )
{
	var url = "index.php?module=FotoAniversarioController&action=PrintFoto&f="+id;
	janela( url,"620","580");
}

function showBox(){
document.getElementById('dark').style.display='';
document.getElementById('showBox').style.display='';
document.getElementById('texto_showBox').style.display='';
}

function closeBox(){
document.getElementById('dark').style.display='none';
document.getElementById('showBox').style.display='none';
document.getElementById('texto_showBox').style.display='none';

}

function displayDestaqueIndex( )
{
	/*hideDestaque(true);*/

	var url = "showaniversario.php";
	var ajx = new AJAX();

	ajx.url = url;
    	ajx.modo = 'T';
    	ajx.processaresultado = function(r){

		if ( r != null ) {

			JBFM_Window( 720, 820, "" , r , "JBFM_Destaque_Flash"  );

		}

    }
	ajx.conectar();

}
function fecharDestaqueIndex(){
	var btn = document.getElementById("JBFM_Destaque_Flash_Btn_Close");
	if(btn != null){
		btn.onclick();
	}
}

function showSenha(){

		window.open("http://www.jb.fm/esenha.php", "mywindow",
    "location=1,status=1,scrollbars=1,width=280,height=190");

}

function abre_iphone(){
	window.location='http://www.jb.fm/index.php?module=MainApplication&action=Iphone';
}


/**
 * @Função para enviar pedido musical via ajax
 * @access public
 * @return void
 **/
function enviarPedidoMusicalajx( btn )
{
	var nome  =  escape(document.getElementById("pm_nome").value);
	var email =  document.getElementById("pm_email").value;
	var texto =  escape(document.getElementById("pm_texto").value);
	
	
	btn.value 	 = "Aguarde...";
	btn.disabled = true;
	
	var url = "index.php?module=ContatoController&action=EnviarPedidoMusicalajx";
	var queryString = "nome="+nome+"&email="+email+"&texto="+texto;

	submitAjax( url, queryString, function( resposta ) {

		 if (http_request.readyState == 4) {
			 if (http_request.status == 200) {


				//alert(http_request.responseText);
				alert("Seu pedido foi enviado com sucesso");

					$("pm_nome").value  = "";
					$("pm_email").value = "";
					$("pm_texto").value = "";

					btn.disabled = false;
					btn.value = "Enviar Pedido";

			 }
		 }

	} );



}

function CloseIphone()
{
        document.getElementById("divIphone").style.display='none';    
		hideDestaque(false);
}
function showIphone()
{
        document.getElementById("divIphone").style.display='';    
         
}
   
window.setTimeout(function() { CloseIphone(); hideDestaque(false); }, 25000);
window.setTimeout(function() { showIphone(); hideDestaque(true); }, 1500);