
function get_last_video()
{
	var titulo_video = $('titulo_video2');
	var texto_video = $('texto_video');
	var codigo_video = $('codigo_video');

	var opciones=
	{
		method:'post',
		onSuccess:function(respuesta)
		{
			resp = respuesta.responseXML.documentElement;
			resp2 = resp.getElementsByTagName('respuesta')[0].childNodes;

			num=resp2.length;

			for(i=0;i < num;i++)
			{
				switch(resp2.item(i).nodeName)
				{
					case "titulo_video" : titulo_video.innerHTML = resp2.item(i).firstChild.data; break;
					case "texto_video" : texto_video.innerHTML = resp2.item(i).firstChild.data; break;
					case "codigo_video" : codigo_video.innerHTML = resp2.item(i).firstChild.data; break;
				}
			}
		}
	}
	new Ajax.Request('noticias2.php',opciones);
}

/* Para desplegar el div del horoscopo */
function abrir_flash()
{
	
	document.getElementById("contenido_horoscopo").style.height = 'auto';
	$('contenido_horoscopo').setStyle({height: '412px'});
	stat_horoscopo();
}

/* para cerrar el div del horoscopo */
function cerrar_flash()
{
	document.getElementById("contenido_horoscopo").style.height = '190px';
}


/* estadisticas de vistas del horoscopo */
function stat_horoscopo()
{
	//_uacct = "UA-863435-7";
    //urchinTracker();    
    
	var opciones =
	{
		method:'post',
		onSuccess:function(respuesta)
		{
			respuesta_php = respuesta.responseXML.documentElement;
			resp2 = respuesta_php.getElementsByTagName('respuesta')[0].childNodes;
			num=resp2.length;
						
			for(i=0;i < num;i++)
			{
				switch(resp2.item(i).nodeName)
				{
					case "stat" : votar.innerHTML = resp2.item(i).firstChild.data; break;
				}
			}
		}
	}
	new Ajax.Request('/Presentacion/Ajax/stat_horoscopo.php',opciones);
}

function favoritos(url, site) 
{
	if ( navigator.appName != 'Microsoft Internet Explorer' )
		window.sidebar.addPanel(site,url,""); 
	else window.external.AddFavorite(url,site); 
} 

function descargar()
{
	/*	var parametros=Form.serialize('descargar');
	var opciones=
	{
		method:'post',
		parameters:parametros,
		onSuccess:function()
		{
			resp=respuesta.responseText;
		}
	}
	new Ajax.Request('download.php',opciones);
	window.location.href = $('nombre').value;*/
}

function votar(id_juego, voto, pais)
{
	var votar = $('votar');
	var parametros = "id_juego=" + id_juego + "&voto=" + voto + "&pais=" + pais;
	var opciones =
	{
		method:'post',
		parameters:parametros,
		onSuccess:function(respuesta)
		{
			respuesta_php = respuesta.responseXML.documentElement;
			resp2 = respuesta_php.getElementsByTagName('respuesta')[0].childNodes;
			num=resp2.length;
						
			for(i=0;i < num;i++)
			{
				switch(resp2.item(i).nodeName)
				{
					case "voto" : votar.innerHTML = resp2.item(i).firstChild.data; break;
				}
			}
		}
	}
	new Ajax.Request('/Presentacion/Ajax/votar.php',opciones);
}


/* javascript para comptabilizar los votos sobre las noticias ( wallpapers y video) */
function votar_noticias(id_noticia, tipo_noticia, voto, pais, gracias, ha_votado)
{
	var div=tipo_noticia+'_'+id_noticia;
	var votar=$(div);
	
	var parametros="id_noticia="+id_noticia+"&tipo_noticia="+tipo_noticia+"&voto="+voto+"&pais="+pais +"&gracias="+gracias+"&ha_votado="+ha_votado;
	var opciones=
	{
		method:'post',
		parameters:parametros,
		onSuccess:function(respuesta)
		{
			respuesta_php=respuesta.responseXML.documentElement;
			resp2=respuesta_php.getElementsByTagName('respuesta')[0].childNodes;
			num=resp2.length;
						
			for(i=0;i<num;i++)
			{
				switch(resp2.item(i).nodeName)
				{
					case "voto" : votar.innerHTML=resp2.item(i).firstChild.data; break;
				}
			}
		}
	}
	new Ajax.Request('/Presentacion/Ajax/votar_noticias.php',opciones);
}

function tracker(referer, page, ip)
{
	if(navigator.browserLanguage)
		idioma = navigator.browserLanguage;
	else
		idioma = navigator.language;
		
	var parametros = "referer=" + referer + "&page=" + page + "&ip=" + ip + "&idioma=" + idioma; 
	var opciones=
	{
		method:'post',
		parameters:parametros,
		onSuccess:function(respuesta)
		{
			respuesta_php = respuesta.responseXML.documentElement;
			resp2 = respuesta_php.getElementsByTagName('respuesta')[0].childNodes;
			num=resp2.length;
								
			for(i=0;i < num;i++)
			{
				switch(resp2.item(i).nodeName)
				{
					case "track" :  /*$('titulo_recomendamos').innerHTML = resp2.item(i).firstChild.data;*/ break;
				}
			}
		}
	}
	new Ajax.Request('tracker2.php',opciones);
}

function SetVisita(wallpaper, pais)
{
	var parametros = "id_wallpapers=" + wallpaper + "&id_paises=" + pais; 
	var opciones=
	{
		method:'post',
		parameters:parametros,
		onSuccess:function(respuesta)
		{
			respuesta_php = respuesta.responseXML.documentElement;
			resp2 = respuesta_php.getElementsByTagName('respuesta')[0].childNodes;
			num=resp2.length;
								
			for(i=0;i < num;i++)
			{
				switch(resp2.item(i).nodeName)
				{
					case "visita" :  /*$('titulo_recomendamos').innerHTML = resp2.item(i).firstChild.data;*/ break;
				}
			}
		}
	}
	new Ajax.Request('visitas_wallpaper.php',opciones);
}

/**
 * permite de cambiar la idioma del sitio wambie
 * Borra el cookie y lo escribe de nuevo con la nueva valor
 */
/*function pais(id_pais)
{
	delCook('wambieIdioma');
	setCook('wambieIdioma', id_pais);
	location.reload();	
	//setTimeout("location.reload()",1000);
}*/

/**
 * Permite de escribir un cookie
 */
function setCook(nom,valeur)
{
	var expDate = new Date(2010,1,1,0,0,0);	
	document.cookie = nom + "=" + escape(valeur) + ";expires=" + expDate.toGMTString();
}

/**
 * Permite de borrar un cookie
 */
function delCook(nom) { 
	document.cookie = nom + "=;expires=-1";
}

function GetCookie ()
{
	var cookValue = "" ;
	var cookName = "wambieIdioma" ;
	 
	//position de "=" dans le cookie
	var egal = document.cookie.indexOf( "=" ) ;
	 
	//on prend la sous-chaine comprise entre le d�but du cookie et le "="
	cookName = document.cookie.substring ( 0, egal ) ;
	 
	//on prend la sous-chaine comprise entre le "=" et le ";" donc sa valeur
	cookValue = document.cookie.substring ( egal + 1 ) ;
	 
	//affiche le nom du cookie
	alert( "<br>cookName vaut: <b>" + cookName + "</b>" ) ;
	 
	//affiche la valeur du cookie
	alert ( "<br>cookValue vaut: <b>" + cookValue + "</b>" ) ;
}

function ReturnIdioma()
{
	if(navigator.browserLanguage)
		return navigator.browserLanguage;
	else
		return navigator.language;
}

function OpacityOn(element)
{
	new Effect.Opacity(element, {to: 0.7, from: 1.0, duration: 0.2});
}

function OpacityOut(element)
{
	new Effect.Opacity(element, { to: 1.0, from: 0.7, duration: 0.8});
}

function pagina_noticias(pagina)
{
	
	$('contenido_noticia').innerHTML=''; 
	$('loading_noticias').style.display="block";
	
	//Recargamos la publi
	recargar_divs_publi("noticias_home_siguientes");
	var opciones=
	{
		method:'post',
		parameters: {cat: 'listado_noticia', pagina: pagina },
		onSuccess:function(respuesta)
		{
			$('loading_noticias').style.display='none';
			$('contenido_noticia').innerHTML = respuesta.responseText;
			
//			var f = document.getElementById('recomendamos_frame1');
//			f.src=f.src;
		}
	}
	new Ajax.Updater($('contenido_noticia'), "/Presentacion/Ajax/paginas_portada.php", opciones );
	
}


function pagina_noticias_categoria(pagina, categoria)
{
	
	$('contenido_noticia').innerHTML=''; 
	$('loading_noticias').style.display="block";
	
	//Recargamos la publi
	recargar_divs_publi("noticias_home_siguientes");
	var opciones=
	{
		method:'post',
		parameters: {cat: 'listado_noticia_categoria', pagina: pagina , categoria:categoria},
		onSuccess:function(respuesta)
		{
			$('loading_noticias').style.display='none';
			$('contenido_noticia').innerHTML = respuesta.responseText;
			
//			var f = document.getElementById('recomendamos_frame1');
//			f.src=f.src;
		}
	}
	new Ajax.Updater($('contenido_noticia'), "/Presentacion/Ajax/paginas_portada.php", opciones );
	
}

function desplegaridiomas()
{
	$('listado_paises').style.display='block';
	
}

function cerraridiomas()
{
	Effect.BlindUp('listado_paises', { duration: 0.7 }); 
	return false;
}