

if (document.images){
      preload_image_object = new Image();
      // set image url
      image_url = new Array();
     
}


function fondos_pestanias(div,tipo,seccion)  
 {  
 	if(seccion=="comentarios"){
		if(tipo=="over") {document.getElementById(div).style.backgroundImage="url(\""+"../sprites/css/css.gif"+"\")"; document.getElementById(div).style.backgroundPosition="0 -1593px";document.getElementById(div).className="sobre_login"; }
		else {document.getElementById(div).style.backgroundPosition="0 -438px";document.getElementById(div).className="boton_login";}
		 
	}
 	if((seccion=="ultimos")&&( document.getElementById(div).className!="selected")){
		if(tipo=="over") src="../imagen/fondo-p.gif";
		else src="../imagen/fondo-p2.gif";
		 document.getElementById(div).style.backgroundImage="url(\""+src+"\")";  
	}
	if(seccion=="principal"){
		if(tipo=="over") {document.getElementById(div).style.backgroundPosition="0 -1443px"; document.getElementById(div).className="sobre"; }
		else {document.getElementById(div).style.backgroundcolor="#4a6b9b";document.getElementById(div).style.backgroundPosition="0 -308px"; document.getElementById(div).className="normal";}
		 
	}
		if(seccion=="blanco"){
		if(tipo=="over") {document.getElementById(div).style.backgroundImage="url(\""+"../sprites/css/css.gif"+"\")";document.getElementById(div).style.backgroundPosition="0 -1700px"; }
		else {document.getElementById(div).style.backgroundPosition="0 -1780px";}
		 
	}
	if(seccion=="estilos"){
		if(tipo=="over") {src="../imagen/fondo-p6.gif"; document.getElementById(div).style.backgroundImage="url(\""+src+"\")"; }
		else {document.getElementById(div).style.backgroundcolor="#ffffff";document.getElementById(div).style.backgroundImage="";}
		 
	}
	if((seccion=="usuarios")&&( document.getElementById(div).className!="selected")){
		if(tipo=="over"){ document.getElementById(div).style.backgroundPosition="0 -1493px"; document.getElementById(div).className="sobre";}
		else { document.getElementById(div).style.backgroundPosition="0 -248px";document.getElementById(div).className="normal";}
		 //document.getElementById(div).style.backgroundImage="url(\""+src+"\")";  
	}
	if((seccion=="lomas")&&( document.getElementById(div).className!="selected")){
		if(tipo=="over"){ document.getElementById(div).style.backgroundPosition="0 -1493px"; document.getElementById(div).className="sobre";document.getElementById('mas').className="sobre";}
		else { document.getElementById(div).style.backgroundPosition="0 -248px";document.getElementById(div).className="normal";document.getElementById('mas').className="mas";}
		
		
	}
		if((seccion=="conciertos")&&( document.getElementById(div).className!="selected")){
		if(tipo=="over"){document.getElementById(div).style.backgroundPosition="0 -1493px";document.getElementById(div).className="sobre";}
		else {document.getElementById(div).style.backgroundPosition="0 -248px";document.getElementById(div).className="normal";}
		document.getElementById(div).style.backgroundImage="url(\""+src+"\")";  
	}
	
 }



function activar_pestania(div) {  
	if(div=="pestania_1"){
		document.getElementById(div).style.backgroundPosition="0 -188px";
		document.getElementById("pestania_0").style.backgroundPosition="0 -248px";
		document.getElementById(div).className="selected";
		document.getElementById("pestania_0").className="";
	}
	if(div=="pestania_0"){
		document.getElementById(div).style.backgroundPosition="0 -188px";
		document.getElementById("pestania_1").style.backgroundPosition="0 -248px";
		document.getElementById(div).className="selected";
		document.getElementById("pestania_1").className="";
	}
 	if(div=="pestania_lomas1"){
		document.getElementById(div).style.backgroundPosition="0 -188px";
		document.getElementById("pestania_lomas0").style.backgroundPosition="0 -248px";
		document.getElementById(div).className="selected";
		document.getElementById("pestania_lomas0").className="";
		
	}
 	if(div=="pestania_lomas0"){ 
		document.getElementById(div).style.backgroundPosition="0 -188px";
		document.getElementById("pestania_lomas1").style.backgroundPosition="0 -248px";
		document.getElementById(div).className="selected";
		document.getElementById("pestania_lomas1").className="";
	} 
		if(div=="pestania_u1"){ 
		document.getElementById(div).style.backgroundPosition="0 -188px";
		document.getElementById("pestania_u0").style.backgroundPosition="0 -248px";
		document.getElementById(div).className="selected";
		document.getElementById("pestania_u0").className="";
	} 
		if(div=="pestania_u0"){ 
		document.getElementById(div).style.backgroundPosition="0 -188px";
		document.getElementById("pestania_u1").style.backgroundPosition="0 -248px";
		document.getElementById(div).className="selected";
		document.getElementById("pestania_u1").className="";
	} 
 
 }
var tipo_actual="lomas_hoy";
function activar_pestania2(div) { // usada para la caja lo más 
	document.getElementById('lomas_hoy').style.color="#CC9900"
	document.getElementById('lomas_semana').style.color="#CC9900"
	document.getElementById('lomas_mes').style.color="#CC9900"
	document.getElementById('lomas_ano').style.color="#CC9900"
	document.getElementById(div).style.color="#CC6633";
 }


function estilos_activar(div,tipo) {  
	if(tipo=="mostrar"){
		document.getElementById(div).className="visible";
		document.getElementById('estilos_general').style.width=290;
		
	}
	else if(tipo=="ocultar"){
		document.getElementById(div).className="oculta";
		document.getElementById('estilos_general').style.width="";
	}
	
}
function estilos_activar2(div,div1,tipo) {  
	if(tipo=="mostrar"){
		document.getElementById('c_image1').className="img_conciertos_3";
		document.getElementById(div).className="visible";
		document.getElementById(div1).className="visible_estilos";
		
		
		
	
		
		
	}
	else if(tipo=="ocultar"){
		document.getElementById('c_image1').className="img_conciertos_1";
		document.getElementById(div).className="oculta";
		document.getElementById(div1).className="oculta_estilos";
		
		
		
		
	}
	
}

function obtenerXHR(){
	req=false;
	if(window.XMLHttpRequest){
		req=new XMLHttpRequest();
	}	else{
			if(ActiveXObject){
				//DEFINIMOS UN VECTOR CON LAS DISTINTAS POSIBILIDADES
				var vectorVersiones=["MSXML2.XMLhttp.5.0","MSXML2.XMLhttp.4.0","MSXML2.XMLhttp.3.0","MSXML2.XMLhttp","Microsoft.XMLHttp"];
				//LO RECORREMOS E INTENTAMOS VER EL QUE CORRESPONDE
				for(var i=0;i<vectorVersiones.length;i++){
					try{
						req=new ActiveXObject(vectorVersiones[i]);
						return req;
						} catch(e){}
				}
			}
		}
		return req;
}

var peticion;
var longevidad;
var contenido;
var pestania;
var tipo;
function actualizar_lomas(div,aux,tipo1,pestania1){ 
	//alert(div);
	pestania=pestania1;
	contenido= document.getElementById(div);
	tipo="tiempo";
	peticion=obtenerXHR();
	longevidad=aux;
	if(tipo1=="lomas_noticias"){
		peticion.open("POST","../includes/noticias/lo_mas/ajax-generar_lomas_noticias.php",true);
	}
	else if(tipo1=="lomas_comentado"){
		peticion.open("POST","../includes/noticias/lo_mas/ajax-generar_lomas_comentarios.php",true);
	}
	
	else if(tipo1=="lomas_visto_conciertos"){
		peticion.open("POST","../includes/conciertos/lo_mas/ajax-generar_lomas_visto_conciertos.php",true);
	}
	else if(tipo1=="lomas_comentado_conciertos"){
		peticion.open("POST","../includes/conciertos/lo_mas/ajax-generar_lomas_comentado_conciertos.php",true);
	}
	else if(tipo1=="lomas_visto_festivales"){
		peticion.open("POST","../includes/festivales/lo_mas/ajax-generar_lomas_visto.php",true);
	}
	else if(tipo1=="lomas_comentado_festivales"){
		peticion.open("POST","../includes/festivales/lo_mas/ajax-generar_lomas_comentado.php",true);
	}
	else if(tipo1=="lomas_visto_grupos"){
		peticion.open("POST","../includes/grupos/lo_mas/ajax-generar_lomas_visto.php",true);
	}
	else if(tipo1=="lomas_comentado_grupos"){
		peticion.open("POST","../includes/grupos/lo_mas/ajax-generar_lomas_comentado.php",true);
	}
	else if(tipo1=="lomas_visto_mas_secciones"){
		peticion.open("POST","../includes/mas_secciones/lo_mas/ajax-generar_lomas_visto.php",true);
	}
	else if(tipo1=="lomas_comentado_mas_secciones"){
		peticion.open("POST","../includes/mas_secciones/lo_mas/ajax-generar_lomas_comentado.php",true);
	}
	peticion.onreadystatechange=procesarPeticion;
	peticion.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	var parametros="longevidad="+aux;
	peticion.send(parametros);
}
function actualizar_lomas_general(div,aux){  
//alert(div);
	contenido= document.getElementById(div);
	tipo="general";
	peticion=obtenerXHR();
	longevidad=aux;
	if(aux=="lomas_noticias") peticion.open("POST","../includes/noticias/lo_mas/ajax-generar_lomas_general_noticias.php",true);
	else if(aux=="lomas_comentarios")peticion.open("POST","../includes/noticias/lo_mas/ajax-generar_lomas_general_comentarios.php",true);
	else if(aux=="lomas_visto_conciertos")peticion.open("POST","../includes/conciertos/lo_mas/ajax-generar_lomas_general_visto_conciertos.php",true);
	else if(aux=="lomas_comentado_conciertos")peticion.open("POST","../includes/conciertos/lo_mas/ajax-generar_lomas_general_comentado_conciertos.php",true);
	else if(aux=="lomas_visto_festivales")peticion.open("POST","../includes/festivales/lo_mas/ajax-generar_lomas_general_visto.php",true);
	else if(aux=="lomas_comentado_festivales")peticion.open("POST","../includes/festivales/lo_mas/ajax-generar_lomas_general_comentado.php",true);
	else if(aux=="lomas_visto_grupos")peticion.open("POST","../includes/grupos/lo_mas/ajax-generar_lomas_general_visto.php",true);
	else if(aux=="lomas_comentado_grupos")peticion.open("POST","../includes/grupos/lo_mas/ajax-generar_lomas_general_comentado.php",true);
	else if(aux=="lomas_visto_mas_secciones")peticion.open("POST","../includes/mas_secciones/lo_mas/ajax-generar_lomas_general_visto.php",true);
	else if(aux=="lomas_comentado_mas_secciones")peticion.open("POST","../includes/mas_secciones/lo_mas/ajax-generar_lomas_general_comentado.php",true);
	peticion.onreadystatechange=procesarPeticion;
	peticion.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	var parametros="longevidad="+aux;
	peticion.send(parametros);
}
function procesarPeticion(){
	if(peticion.readyState==4){
		if(peticion.status==200){
			//alert(pestania);
				document.getElementById('contenido_lomas_general').innerHTML=peticion.responseText;
			if(tipo!="general")	activar_pestania2(pestania);
				
		}
	}
}

function foto_hover(div,tipo)  
 {  
 	
		
	var im=document.getElementById(div);  
	if(tipo=="over") opacity1=60; else opacity1=100;
	if (navigator.appName.indexOf("Netscape")!=-1&&parseInt(navigator.appVersion)>=5)
  	  im.style.MozOpacity=opacity1/100;
 	else if (navigator.appName.indexOf("Microsoft")!=-1&&parseInt(navigator.appVersion)>=4){
	  if(tipo=="over") im.style.filter="alpha(opacity=60)";
	  else im.style.filter="alpha(opacity=100)";
	}
 }
function foto_hover_menus(div,tipo)  
 {  
 	
		
	var im=document.getElementById(div+'_foto');  
	if(tipo=="over"){ opacity1=60;document.getElementById(div).className="fondo_menu_resaltado";} else{ opacity1=100;document.getElementById(div).className="fondo_menu_no_resaltado";}
	if (navigator.appName.indexOf("Netscape")!=-1&&parseInt(navigator.appVersion)>=5)
  	  im.style.MozOpacity=opacity1/100;
 	else if (navigator.appName.indexOf("Microsoft")!=-1&&parseInt(navigator.appVersion)>=4){
	  if(tipo=="over") im.style.filter="alpha(opacity=60)";
	  else im.style.filter="alpha(opacity=100)";
	}
 }

function resaltar(div,tipo,seccion)  
 {  
 	if((seccion=="provincias")&&( tipo=="over")){
		
		 src="../imagen/fondo-p.gif";
		 document.getElementById(div).className="conciertos_resaltada";  
	}
	else if((seccion=="provincias")&&( tipo=="out")){		 
		 document.getElementById(div).className="conciertos_normal";
	}	
	if((seccion=="estilos")&&( tipo=="over")){		
		 src="../imagen/fondo-p.gif";
		 document.getElementById(div).className="conciertos_resaltada";  
	}
	else if((seccion=="estilos")&&( tipo=="out")){		 
		 document.getElementById(div).className="conciertos_normal";
	}
	
	 if((seccion=="todas")&&( tipo=="over")){
		
		 src="../imagen/fondo-p.gif";
		 document.getElementById(div).className="conciertos_tit_normal";  
	}
	else if((seccion=="todas")&&( tipo=="out")){
		 
		 document.getElementById(div).className="conciertos_tit_normal";
	}
	
 }



/* Libreria Ajax*/
var $tipo={
		XML: 0,
		TEXTO: 1,
		JSON:2
}
var $metodo ={
		GET: "GET",
		POST: "POST"
}
function $Ajax(url, opciones){
	if(__$P(opciones, "cache", true)==false){
		var caracter="?";
		if(url.indexOf("?")>0) caracter ="&";
		url+=caracter + Math.random();
	}
	var metodo=__$P(opciones, "metodo", $metodo.GET);
	var parametros=__$P(opciones, "parametros");
	var protoOpc={
		method: metodo,
		onSuccess: __$AjaxRecibir.bind(this, opciones),
		onException: __$AjaxError.bind(this,opciones),
		onFailure: __$AjaxError.bind(this, opciones)
	}
	if(parametros!=undefined){
		protoOpc.parameters=parametros;
	}
	var peticion= new Ajax.Request(url, protoOpc);
	if(__$P(opciones, "avisoCargando")!=undefined){
		__$AjaxCargando(opciones.avisoCargando, true);
	}
	
}
function __$AjaxRecibir(opciones,xhr){
		if(__$P(opciones, "avisoCargando")!=undefined){
			__$AjaxCargando(opciones.avisoCargando, false);
		}
		var funcionRetorno=__$P(opciones, "onfinish");
		var id=__$P(opciones, "id");
		if(funcionRetorno!=undefined){
			var colour = "red";
			var tipoRespuesta = __$P(opciones, "tipoRespuesta",$tipo.TEXTO);
			switch(tipoRespuesta){
				case $tipo.TEXTO:
					funcionRetorno(xhr.responseText, id)
					break;
				case $tipo.XML:
					funcionRetorno(xhr.responseXML, id);
					break;
				case $tipo.JSON:
					var objeto;
					try{
						objeto=xhr.responseText.evalJSON();
					} catch(e){
						__$AjaxError(opciones, xhr, {code: -1, message: "JSON No Válido"});
						return;
					}
					   funcionRetorno(objeto,id);
			}
		}
}
function __$AjaxCargando(cartel,prender){
	if(prender){
		$(cartel).show();
	} else{
		$(cartel).hide();
	}
}

function __$AjaxError(opciones, xhr, excepcion){
	if(__$P(opciones, "avisoCargando")!=undefined){
			__$AjaxCargando(opciones.avisoCargando, false);
	}
	if(excepcion==undefined){
		excepcion={code : xhr.status, message : "Error del servidor"}
	}
	var funcionError=__$P(opciones, "onerror");
	if(funcionError!=undefined){
		funcionError(excepcion, __$P(opciones, "id"));
	}
}
function __$P(coleccion, parametro, defecto){
	if(coleccion==undefined){
		return defecto;
	} else{
		if(coleccion[parametro]==undefined){
			return defecto;
		}else{
			return coleccion[parametro];
		}
	}
}
	
		
		

var republicar;
function enviar_formulario(div,tipo){
	var valores=$(div).serialize();
//	alert(div + valores);
		$Ajax("../includes/comunes/comentarios/procesar_comentario_noticias.php",
		  {metodo:$metodo.POST,
		  parametros: valores,
		  cache: true,
		  onfinish: formularioEnviado});
	
}
function formularioEnviado(html){
	//alert(html);
	$("sustituir_comentarios").innerHTML=html;
	if(document.getElementById("comentario_no_registrado")) mostrar_login_register();
	else{
		$('cabecera_comentarios').show();
		
		
		if(document.getElementById("error_comentario")) mostrar_error_comentario();
		else mostrar_ok_comentario();
	}
}

function mostrar_login_register(){
	Dialog.info($('comentario_no_registrado').innerHTML, 
				 {
					 className:"alphacube", 
					 width:650, 
					 height:150, 
					 showProgress:true
					 
				}
	); 
	republicar=1;
	//setTimeout("Dialog.closeInfo();",4500);	
	//Jump();
	
}

function mostrar_error_comentario(){
	Dialog.info($('error_comentario').innerHTML, 
				 {
					 className:"alphacube", 
					 width:450, 
					 height:100, 
					 showProgress:true
					 
				}
	); 
//	Windows.closeAll();
	
//	Windows.overlayHideEffectOptions.duration=null;
	setTimeout("Dialog.closeInfo();",1500);	
	//setTimeout("ocultar_modal();",2500);	
	Jump();
	
}
function ocultar_modal(){
	var doc = content.document;
	var body = doc.body;
	var aElm=document.body.getElementsByTagName('*');
	for(var i=0; i<aElm.length; i++) {
    	if(aElm[i].className=="dialog") {
    		body.removeChild(aElm[i]);
  	      }
 	   }        

	
	
	//var div = doc.getElementById("overlay_modal");
	
}
function mostrar_ok_comentario(){
	
	
	Dialog.info($('ok_comentario').innerHTML, 
				 {
					 className:"alphacube", 
					 width:450, 
					 height:100, 
					 showProgress:true
					 
				}
	); 
	//alert("nova_ok");
	setTimeout("Dialog.closeInfo();",1500);	
	Jump();
	
}
function Jump() {
	
	var pagina=location.href;
	if(pagina.search('#')!=-1) location.href=location.href;
else location.href=location.href+"#cabecera_comentarios";
}
function Jump_comentar() {
	
	var pagina=location.href;
	if(pagina.search('#')!=-1) location.href=location.href;
else location.href=location.href+"#formulario_com";
}
function reiniciar_descripcion_comentario(){
	$("descripcion").value='';
}

// JavaScript Document
var idglobal;
var provinciaglobal;
var tipoglobal;
function seguimientos(id,provincia,tipo){
	idglobal=id;
	provinciaglobal=provincia;
	tipoglobal=tipo;
	var valores;
	$Ajax("../includes/aniadir/validar_usuario.php",
		  {metodo:$metodo.POST,
		  parametros: valores,
		  cache: true,
		  onfinish: validar_seguimientos});	
	
}
function validar_seguimientos(html){
	var logueado=0;
	var valores="?id="+idglobal+"&provincia="+provinciaglobal+"&tipo="+tipoglobal;
	var longitud=html.length;
	if(longitud==0)	$Ajax("../includes/comunes/seguimientos/comprobar_seguimientos.php",
		  			{metodo:$metodo.POST,
		  			parametros: valores,
		  			cache: true,
		  			onfinish: comprobar_duplicados});	
	else mostrar_registrarse_login();
}

function comprobar_duplicados(html){
	
	var longitud=html.length;
	var valores="?id="+idglobal+"&provincia="+provinciaglobal+"&tipo="+tipoglobal;
	if(longitud==0)	$Ajax("../includes/comunes/seguimientos/insertar.php",
		  			{metodo:$metodo.POST,
		  			parametros: valores,
		  			cache: true,
		  			onfinish: mostrar_seguimientos});
	else mostrar_seguimiento_duplicado()
}


function mostrar_seguimientos(html){
	
	Dialog.info($('seguimientos').innerHTML, 
				 {
					 className:"alphacube", 
					 width:400, 
					 okLabel: "seguimientos",
					 showProgress:true
				}
			);
	setTimeout("Dialog.closeInfo();",2500);
}

function mostrar_seguimiento_duplicado(){
	
	//alert(republicar);
	Dialog.info($('mostrar_seguimiento_duplicado').innerHTML, 
				 {
					 className:"alphacube", 
					 width:400, 
					 okLabel: "mostrar_seguimiento_duplicado",
					 showProgress:true
				}
			);
	setTimeout("Dialog.closeInfo();",2500);
}

function mostrar_registrarse_login(){
	Dialog.info($('no_registrado_seguimientos').innerHTML, 
				 {
					 className:"alphacube", 
					 width:650, 
					 height:150, 
					 showProgress:true
					 
				}
	);
}

  var win = null;
  var index = 1;
	function openDialog(id,size) {
	  Dialog.alert($(id).innerHTML, {className: "alphacube",  width:size, okLabel: "Actualizar", ok: closeAllModalWindows})
	  index++;
  }
  
 
  
  function closeAllModalWindows() {
    Windows.closeAllModalWindows();
    return true;
  }


var aux2;
function importar(rutaJS) {/* IMPORTO LAS LIBRERIAS EXTERNAS PROTOTYPE Y WINDOWS CUANDO SON NECESARIAS SOLO*/
    var scr=document.createElement("SCRIPT");
    scr.setAttribute("src", rutaJS);
    scr.setAttribute("type", "text/javascript");
    document.body.appendChild(scr);
} 
function cargar_login() {  
 	if(republicar==1){republicar=0;Dialog.closeInfo(); }
	setTimeout("mostrar_dialogo2();",500);
	

 }
function mostrar_dialogo2(){
	
	//alert(republicar);
	Dialog.confirm($('login').innerHTML, 
				 {
					 className:"alphacube", 
					 width:400, 
					 okLabel: "login", 
					 cancelLabel: "cancel", 
					 onOk:validar
				}
			);
	
}
function validar()
 { 
 	
 	var valores=$('login_variables').serialize();
 	$Ajax("../includes/comunes/login/procesar.php",
		  {metodo:$metodo.POST,
		  parametros: valores,
		  cache: true,
		  onfinish: verificar_login});
	
	
	
 }
 
 function verificar_login(html){
	var valores;
	var longitud=html.length;
	if(longitud==0){//SI SE HACE LOGIN CORRECTO
		Dialog.closeInfo();
		
		setTimeout("mostrar_dialogo4();",1000);
		$Ajax("../includes/comunes/login/actualizar_menuder.php",
		  {metodo:$metodo.POST,
		  parametros: valores+'?tipo2=si',
		  onfinish: actualizar_menuder});
		
		$('login').hide();
		$("login_ok_msg1").innerHTML="Login Correcto";
		$('login_ok_msg1').show();
		
		//Dialog.cancelCallback();
		
		
	}
	else{
		$("login_error_msg").innerHTML=html;
		$('login_error_msg').show();
		Windows.focusedWindow.updateHeight();
		 
		//new Effect.Shake(Windows.focusedWindow.getId()); 
		return false;
	}
	
}
function mostrar_dialogo4(){
	
	
	Dialog.info($('login_exito').innerHTML, 
				 {
					 className:"alphacube", 
					 width:400, 
					 height:100, 
					 showProgress:true
					 
				}
			); 	
	


//	if(aux2=='publicar') Windows.closeAll();
//	if(aux2=='publicar') $("overlay_modal").style.display="none";
	//Dialog.closeInfo();
}
function actualizar_menuder(html){	
		
	setTimeout("Dialog.closeInfo();",2500);
	$("contenedor_iuser").innerHTML=html;
	//if(aux2=='publicar'){aux2=''; enviar_formulario_republicar('formulario_com','');}
	
	if(document.getElementById("comentario_descripcion")) publicar_comentario_temporal();
	if(document.getElementById("comentarios")) actualizar_nombre_comentario();
	
	
	
	//if(document.getElementById("overlay_modal")) $("overlay_modal").style.display="none";
	
	
}
function actualizar_nombre_comentario(){	
	var valores;
	$Ajax("../includes/comunes/comentarios/actualizar_nuevo_comentario.php",
		  {metodo:$metodo.POST,
		  parametros: valores,
		  onfinish: actualizar_nombre_comentario2});
	
	
}
function actualizar_nombre_comentario2(html){	
	var valores;
	$("comentario_nombre").innerHTML=html;
	
	
}
function publicar_comentario_temporal(){
	
	var valores=$('formulario_com').serialize();
//	alert(div + valores);
		$Ajax("../includes/comunes/comentarios/procesar_comentario_noticias.php",
		  {metodo:$metodo.POST,
		  parametros: valores,
		  cache: true,
		  onfinish: publicar_comentario_temporal2});
	
}
function publicar_comentario_temporal2(html){
	$("sustituir_comentarios").innerHTML=html;
	setTimeout("mostrar_ok_comentario();",2500);
}
function no_disponible() {  
 	Dialog.info($('no_disponible').innerHTML, 
				 {
					 className:"alphacube", 
					 width:400, 					  
					 showProgress:true
					 
				}
			);
	setTimeout("Dialog.closeInfo();",2500);
	

 }

function recordar_password() {  
	setTimeout("mostrar_dialogor();",500);
 }
function mostrar_dialogor(){
	//alert(republicar);
	Dialog.info($('reenvio_password').innerHTML, 
				 {
					 className:"alphacube", 
					 width:420, 
					 height:170, 
					 showProgress:false
				}
			);
}
function validarr()
 { 
 	var valores=$('reenvio_password_form').serialize();
 	$Ajax("../includes/comunes/login/procesar_reenviar_clave.php",
		  {metodo:$metodo.POST,
		  parametros: valores,
		  cache: true,
		  onfinish: verificar_reenvio_clave});
 }
 
 function verificar_reenvio_clave(html){
	
	var valores;
	var longitud=html.length;
	if(longitud==68){//SI SE HACE LOGIN CORRECTO
		
		$('reenvio_error_msg').hide();
		$("reenvio_ok_msg1").innerHTML="Se ha enviado un email con los datos de usuario al email introducido.";
		$('reenvio_ok_msg1').show();
		setTimeout("Dialog.closeInfo();",2500);
	}
	else{ 
		$("reenvio_error_msg").innerHTML=html;
		$('reenvio_error_msg').show();
		Windows.focusedWindow.updateHeight();
		return false;
	}
}


function logout()
{ 
 	var valores;
	Dialog.info($('saliendo').innerHTML, 
				 {
					 className:"alphacube", 
					 width:400, 
					 height:100, 
					 showProgress:true
					 
				}
			); 
	$("saliendo_msg").innerHTML="Cerrando Sesi&#243;n";
	$('saliendo_msg').show();
	
 	$Ajax("../includes/comunes/login/logout.php",
		  {metodo:$metodo.POST,
		  parametros: valores,
		  cache: true,
		  onfinish: recargar_menuder});
	
	
	
	
}
function recargar_menuder(html){
	
	var valores;	
	setTimeout("Dialog.closeInfo();",1500);
	//alert(document.cookie);

	//eraseCookie('portalmusic');
	$Ajax("../includes/comunes/login/actualizar_menuder.php",
		  {metodo:$metodo.POST,
		  parametros: valores,
		  cache: true,
		  onfinish: actualizar_menuder5});
	
}
function actualizar_menuder5(html){	
		
	
	$("contenedor_iuser").innerHTML=html;
	
	if(document.getElementById("comentarios")) actualizar_nombre_comentario();
	
	
	
	
	
}

function registrarse() {  
	
		
	 mostrar_dialogo1();

 }
function mostrar_dialogo1(){
Dialog.confirm($('contenedor_registro').innerHTML, 
				 {
					 className:"alphacube", 
					 width:400, 
					 height:300,
					 okLabel: "Registrarse", 
					 cancelLabel: "Cancelar", 
					 onOk:validar_registrarse
				}
			); 
}
function validar_registrarse()
 { 
 	var valores=$('registrarse').serialize();
 	$Ajax("../includes/comunes/registrarse/procesar.php",
		  {metodo:$metodo.POST,
		  parametros: valores,
		  cache: true,
		  onfinish: verificar_registrarse});
	
	
	
 }

 function verificar_registrarse(html){
	var valores;
	var longitud=html.length;
	//alert(longitud);
	if(longitud==68){//SI SE HACE LOGIN CORRECTO
		//hago una consulta ajax para sacar el usuario y el password y email y mostrarlos
		Dialog.closeInfo();
		$Ajax("../includes/comunes/registrarse/fin_mostrar_datos.php",
		  {metodo:$metodo.POST,
		  parametros: valores,
		  cache: true,
		  onfinish: mostrar_info_fin});
		
		
	}
	else{
		$("registrar_error_msg").innerHTML=html;
		$('registrar_error_msg').show();
		Windows.focusedWindow.updateHeight();
		//new Effect.Shake(Windows.focusedWindow.getId());
		Windows.focusedWindow.updateHeight();
		return false;
	}
	
}
 function mostrar_info_fin(html){
	 var valores;
	 Dialog.info($('fin_registro_ok').innerHTML, 
				 {
					 className:"alphacube", 
					 width:450, 
					 height:240, 
					 showProgress:true
					 
				}
			); 
		
		$('login').hide();
		$("agrupador_registrarse").innerHTML=html;
		//$('agrupador_registrarse').show();
		
		setTimeout("Dialog.closeInfo();",7500);
		
		$Ajax("../includes/comunes/login/actualizar_menuder.php",
		  {metodo:$metodo.POST,
		  parametros: valores+"?tipo2=si",
		  cache: true,
		  onfinish: actualizar_menuder2});
		
 }
 
function actualizar_menuder2(html){	
	$("contenedor_iuser").innerHTML=html;
	if(document.getElementById("comentario_descripcion")) publicar_comentario_temporalx();
	if(document.getElementById("comentarios")) actualizar_nombre_comentario();
//	if(aux=='publicar'){aux=''; enviar_formulario_republicar('formulario_com','');}

	//setTimeout("Dialog.closeInfo();",7500);
	
	
}
function actualizar_nombre_comentario(){	
	var valores;
	$Ajax("../includes/comunes/comentarios/actualizar_nuevo_comentario.php",
		  {metodo:$metodo.POST,
		  parametros: valores,
		  onfinish: actualizar_nombre_comentario2});
	
	
}
function actualizar_nombre_comentario2(html){	
	var valores;
	$("comentario_nombre").innerHTML=html;
	
	
}
function publicar_comentario_temporalx(){
	
	var valores=$('formulario_com').serialize();
//	alert(div + valores);
		$Ajax("../includes/comunes/comentarios/procesar_comentario_noticias.php",
		  {metodo:$metodo.POST,
		  parametros: valores,
		  cache: true,
		  onfinish: publicar_comentario_temporal2x});
	
}
function publicar_comentario_temporal2x(html){
	$("sustituir_comentarios").innerHTML=html;
	
}

function cargar_formulario_contacto(){
		var valores;
		
		$Ajax("../includes/contacto/contacto.php",
		  {metodo:$metodo.POST,
		  parametros: valores,
		  cache: true,
		  onfinish: mostrar_contacto});
	
}
function mostrar_contacto(html){	
	$("cont_pie").innerHTML=html;
	Dialog.info($('contenedor_contacto').innerHTML, 
				 {
					 className:"alphacube", 
					 width:450, 
					 height:450,
					 showProgress:false
					 
				}
	); 
	
}
function procesar_consulta(){
	var valores=$('formulario_contacto').serialize();
		$Ajax("../includes/contacto/procesar_contacto.php",
		  {metodo:$metodo.POST,
		  parametros: valores,
		  cache: true,
		  onfinish: validar_consulta});
	
}
function validar_consulta(html){
var valores;
	var longitud=html.length;
	//alert(longitud);
	if(longitud==69){//SI SE HACE LOGIN CORRECTO
		Dialog.closeInfo();		
		setTimeout("mostrar_ok_consulta();",1000);		
	}
	else{
		$("contacto_error_msg").innerHTML=html;
		$('contacto_error_msg').show();
		Windows.focusedWindow.updateHeight();
		return false;
	}	
}
function mostrar_ok_consulta(){
	
	
	Dialog.info($('ok_consulta').innerHTML, 
				 {
					 className:"alphacube", 
					 width:450, 
					 height:100, 
					 showProgress:true
					 
				}
	); 
	//alert("nova_ok");
	setTimeout("Dialog.closeInfo();",2500);		
	
}

var WlWebsiteId = null;

function zbox_quoted(str) 
{
  return (str != "") ? '"' + str + '"' : '""';
}

function zbox_size(num) 
{
  return (num!="") && (num>0) ? '"' + num + '"' : '"0"';
}

function zbox_partner_code( id, checknumber, suba_id ) 
{
  if((id != "" ) && ( id > 0 ) &&  ( checknumber != "" ) && ( checknumber > 0 ))
  {
    return id + 'C' + checknumber + 'S' + suba_id;
  }
  return '';
}

function zbox_bg_param(adbox_color_bg)
{
	return('&ttbg=#' + adbox_color_bg);
}

function zbox_page_param(adbox_width, adbox_height, adbox_show_images)
{
	var page = 25;
	if((adbox_width == 125) && (adbox_height == 125))
	{
		page = 20;
	}
	else if((adbox_width == 468) && (adbox_height == 60))
	{
		page = 25;
	}
	else if((adbox_width == 120) && (adbox_height == 240))
	{
		page = 30;
	}
	else if((adbox_width == 120) && (adbox_height == 600))
	{
		page = 35;
	}
	else if((adbox_width == 160) && (adbox_height == 600))
	{
		page = 40;
	}
	else if((adbox_width == 180) && (adbox_height == 150))
	{
		page = 45;
	}
	else if((adbox_width == 300) && (adbox_height == 250))
	{
		page = 50;
	}
	else if((adbox_width == 336) && (adbox_height == 280))
	{
		page = 55;
	}
	else if((adbox_width == 250) && (adbox_height == 250))
	{
		page = 60;
	}
	else if((adbox_width == 728) && (adbox_height == 90))
	{
		page = 65;
	}
	else if((adbox_width == 240) && (adbox_height == 400))
	{
		page = 100;
	}
	else if((adbox_width == 234) && (adbox_height == 60))
	{
		page = 105;
	}
	else if((adbox_width == 120) && (adbox_height == 90))
	{
		page = 110;
	}
	else if((adbox_width == 120) && (adbox_height == 60))
	{
		page = 115;
	}
	else if((adbox_width == 88) && (adbox_height == 31))
	{
		page = 120;
	}
	else if((adbox_width == 200) && (adbox_height == 200))
	{
		page = 125;
	}
	else if((adbox_width == 300) && (adbox_height == 600))
	{
		page = 130;
	}
	else if((adbox_width == 250) && (adbox_height == 600))
	{
		page = 135;
	}
	else if((adbox_width == 120) && (adbox_height == 468))
	{
		page = 140;
	}
	else if((adbox_width == 468) && (adbox_height == 400))
	{
		page = 145;
	}
	else if((adbox_width == 400) && (adbox_height == 468))
	{
		page = 150;
	}
	else if((adbox_width == 300) && (adbox_height == 400))
	{
		page = 155;
	}
	else if((adbox_width == 600) && (adbox_height == 400))
	{
		page = 160;
	}
	else if((adbox_width == 140) && (adbox_height == 350))
	{
		page = 165;
	}
	else if((adbox_width == 250) && (adbox_height == 240))
	{
		page = 170;
	}
	else if((adbox_width == 250) && (adbox_height == 120))
	{
		page = 175;
	}

	if((page == 25) || (page == 65) || (page == 115) || (page == 120))
	{
		return '&page='+page;
	}
	if(adbox_show_images == true)
	{
		page += 1;
		return ('&page=' + page);
	}
	return ('&page=' + page);
}

function zbox_master_param()
{
	return '&master=11';
};

function zbox_master_website_param()
{
	return '&ma_website_id=183924';
};

function zbox_img_default_param(adbox_img_default)
{
	return ('&DefaultURL='+adbox_img_default);
};

function CallAdBoxTracking(adbox_id, adbox_checknumber, adbox_subaffiliate, adbox_width, adbox_height, adbox_color_border, adbox_color_bg, adbox_color_link, adbox_color_url, adbox_color_text, adbox_frameborder, adbox_img_default, adbox_show_images)
{
	if((adbox_id != "") && (adbox_id > 0) && (adbox_checknumber != "") && (adbox_checknumber > 0)) 
	{
	 window.document.open();
//   WlWebsiteId = adbox_id;
//   if (typeof (wlrcmd) == "undefined") { var wlrcmd = ""; };
//	 var tmp=		'<scr' + 'ipt language="JavaScript" src="http://rc.wunderloop.zanox.com/Tag/zanox/JS/Gt.js"></scr' + 'ipt>';
	 		var tmp = '<ifr' + 'ame' + ' name="zanox_adbox_frame"';
      tmp+=' width=' + zbox_size(adbox_width) + ' height=' + zbox_size(adbox_height);
      tmp+=               ' frameborder=' + zbox_quoted(adbox_frameborder);
      tmp+=               ' src="http://zbox.zanox.com/ppb/?' + zbox_partner_code(adbox_id, adbox_checknumber, adbox_subaffiliate) + zbox_img_default_param(adbox_img_default) + zbox_master_param() + zbox_page_param(adbox_width, adbox_height, adbox_show_images) + zbox_master_website_param() + zbox_bg_param(adbox_color_bg) + '" marginwidth="0"';
      tmp+=               ' marginheight="0"';
      tmp+=               ' vspace="0"';
      tmp+=               ' hspace="0"';
      tmp+=               ' allowtransparency="true"';
      tmp+=               ' scrolling="no">';
	  tmp+=				 '</ifr' + 'ame>';
//	  alert(tmp);
	 window.document.write(tmp);
	 window.document.close();
	}
}

