/*CSS Browser Selector v0.4.0 (Nov 02, 2010)*/
function css_browser_selector(u){var ua=u.toLowerCase(),is=function(t){return ua.indexOf(t)>-1},g='gecko',w='webkit',s='safari',o='opera',m='mobile',h=document.documentElement,b=[(!(/opera|webtv/i.test(ua))&&/msie\s(\d)/.test(ua))?('ie ie'+RegExp.$1):is('firefox/2')?g+' ff2':is('firefox/3.5')?g+' ff3 ff3_5':is('firefox/3.6')?g+' ff3 ff3_6':is('firefox/3')?g+' ff3':is('gecko/')?g:is('opera')?o+(/version\/(\d+)/.test(ua)?' '+o+RegExp.$1:(/opera(\s|\/)(\d+)/.test(ua)?' '+o+RegExp.$2:'')):is('konqueror')?'konqueror':is('blackberry')?m+' blackberry':is('android')?m+' android':is('chrome')?w+' chrome':is('iron')?w+' iron':is('applewebkit/')?w+' '+s+(/version\/(\d+)/.test(ua)?' '+s+RegExp.$1:''):is('mozilla/')?g:'',is('j2me')?m+' j2me':is('iphone')?m+' iphone':is('ipod')?m+' ipod':is('ipad')?m+' ipad':is('mac')?'mac':is('darwin')?'mac':is('webtv')?'webtv':is('win')?'win'+(is('windows nt 6.0')?' vista':''):is('freebsd')?'freebsd':(is('x11')||is('linux'))?'linux':'','js']; c = b.join(' '); h.className += ' '+c; return c;}; css_browser_selector(navigator.userAgent);
/****************/
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
/****************/
function toggler(obj) {
	var el = document.getElementById(obj);
	if ( el.style.display != 'none' ) {
		el.style.display = 'none';
	}
	else {
		el.style.display = '';
	}
}
/****************/
function ShowHide(LayerName,TotalLayers){//v1.0
	var temp = new Array();
	temp = LayerName.split('_');
	ReLayerName = temp[0];
	
		for (i=1;i<=TotalLayers;i++){
		document.getElementById(ReLayerName+'_'+i).style.display = 'none';
		}
	document.getElementById(LayerName).style.display = 'block';
}
/****************/
function LinkClasses(IDlink,TotalLinks,OFF,ON){//v1.0
	var temp = new Array();
	temp = IDlink.split('_');
	ReIDlink = temp[0];

		for (i=1;i<=TotalLinks;i++){
		document.getElementById(ReIDlink+'_'+i).className = OFF;
		}
	document.getElementById(IDlink).className = ON;
}
/****************/
/* Modified to support Opera */
function bookmarksite(title,url){
if (window.sidebar) // firefox
	window.sidebar.addPanel(title, url, "");
else if(window.opera && window.print){ // opera
	var elem = document.createElement('a');
	elem.setAttribute('href',url);
	elem.setAttribute('title',title);
	elem.setAttribute('rel','sidebar');
	elem.click();
} 
else if(document.all)// ie
	window.external.AddFavorite(url, title);
}
/********ANTI IE6 BUG***********/
if (document.all && !window.opera && !window.XMLHttpRequest) {
	document.execCommand("BackgroundImageCache",false,true);
}
/*****jQUERY*****/
function equalHeight(group) {
	tallest = 0;
	group.each(function() {
		thisHeight = $(this).height();
		if(thisHeight > tallest) {
			tallest = thisHeight;
		}
	});
	group.height(tallest);
}
/*SKYPE*/
$(document).ready(function() {
		window.setTimeout(function() {
			$('.skype_pnh_container').html('');
			$('.skype_pnh_print_container').removeClass('skype_pnh_print_container');
		}, 800);
	});

/****W3C HIDDEN STYLES****/
document.write('<style type="text/css">');
document.write('HTML {overflow:-moz-scrollbars-vertical}');
document.write('TEXTAREA {resize: none}');
document.write('.ie6 HEADER HGROUP H1 A, .ie6 HEADER #Panel, .ie6 HEADER #Panel FIELDSET #User LABEL, .ie6 HEADER #Panel FIELDSET #Password LABEL, .ie6 HEADER #Panel FIELDSET INPUT#BtnEntrar, .ie6 HEADER #Panel H4 A, .ie6 HEADER #Panel #Logued #Time H3, .ie6 HEADER #Panel #Logued #Credits H3, .ie6 #PincodeOk #Panel #Time H3, .ie6 #PincodeOk #Panel #Credits H3, .ie6 #MiCuenta #Panel #Time H3, .ie6 #MiCuenta #Panel #Credits H3, .ie6 #Contenedor HEADER H1 {behavior: url("css/iepngfix.htc");}');
document.write('</style>');
/********* jQuery ***********/

// Abre la pantalla recibida por parametro con el efecto lightwindow
function openLightBox(url, alto)
{
	$('.LightBox .iFrame').html('<iframe src="' + url +'" name="IframeBox" width="779" marginwidth="0" height="'+ alto +'" marginheight="0" scrolling="no" frameborder="0" allowtransparency="true"></iframe>');
	$('.Mask').show();
	$('.LightBox').show();
}

$(document).ready(function() {
	$(".OpcionesTop10Escuchado .Share").tooltip({position: "bottom right",offset: [2, -15], relative: true});
	$(".OpcionesTop10Escuchado .Add").tooltip({position: "bottom right",offset: [2, -13], relative: true});
	$(".OpcionesTop10Escuchado .Quitar").tooltip({position: "bottom right",offset: [-2, -12], relative: true});

	ActualizarEventos();

	$(document).ready(function() {
		$('.LightBox .Close').live('click', function() {
			$('.LightBox').hide();
			$('.Mask').hide();
		});

		$('.OpenLightBox').live('click', function(e) {
			e.preventDefault();
			
			openLightBox($(this).attr('href'), $(this).attr('rel'));
		});
	});
});

// Actualiza los eventos. Sirve para solucionar cuando los datos 
// 	vienen por ajax y no se refrescan los metodos de JQuery
function ActualizarEventos()
{
	$(".Opciones .Share").tooltip({position: "bottom right",offset: [2, -15], relative: true});
	$(".Opciones .Add").tooltip({position: "bottom right",offset: [2, -13], relative: true});
	$(".Opciones .Quitar").tooltip({position: "bottom right",offset: [-2, -12], relative: true});
	$(".AddPlayerMenu").tooltip({position: "bottom right",offset: [-5,-10], relative: true});
	
	/*
	$(".draggable").draggable();
	$(".droppable").droppable ({
		drop: function() { alert('dropped'); }
	});
	*/
	
	/*
	TEMAS - Submenu playlists
	*/
	// Genero evento para cuando se desea agregar un tema a una lista cada vez que pase
	// 	el mouse por arriba del item del submenu busca las listas del usuario.
	$(".Arrow").mouseover(function(){
		// Obtengo el id del tema a agregar.
		var idTema = $(this).attr("tema_id");
		
		$(this).next().css('display', 'block');
		// Cargo listas.
		cargarPlaylists(idTema, $(this).next());
	});

	$(".Add").mouseover(function(){
		$(".PlaylistSubMenu").css('display', 'none');
	});

	//////////////////////////$("#featured").tabs({fx:{opacity: "toggle"}}).tabs("rotate", 5000, true);
}

function trim(cadena)
{
	for(i=0; i<cadena.length; )
	{
		if(cadena.charAt(i)==" ")
			cadena=cadena.substring(i+1, cadena.length);
		else
			break;
	}

	for(i=cadena.length-1; i>=0; i=cadena.length-1)
	{
		if(cadena.charAt(i)==" ")
			cadena=cadena.substring(0,i);
		else
			break;
	}
	
	return cadena;
}

function IsValidEmail(emailTextBox)
{
	var email = emailTextBox.value;
	var emailFilter=/^.+@.+\..{2,3}$/;
	
	if(!(emailFilter.test(email)))
	{
		return false;
	}	
	return true;
}

// Vuelve a recargar una pagina.
function refreshWindow()
{
	window.top.location.href = window.top.location.href;
}

/**************** HEADER: REFRESCO DE CANTIDADES DESCARGA ******************/
function getCalcularCreditosUsuarios(url)
{
	setTimeout("CalcularCreditosUsuario()", 2800);
	// self.location.href = url;
	$("#secretIFrame").attr("src", url.toString());
}

// Envio el formulario.
function CalcularCreditosUsuario()
{
	$.ajax({
		type: 'GET',
		url: 'header_div_logeado.php',
		timeout: 5000,
		success: function(data)
		{
			$('#Logued').html(data);
		},
		error: function (XMLHttpRequest, textStatus, errorThrown)
		{
			//$('#Logueado').html('Timeout contacting server..');
		}
	});
}

// Envio el formulario.
function CargarLogin()
{
	$.ajax({
		type: 'GET',
		url: 'header_div_logeado.php',
		timeout: 5000,
		success: function(data)
		{
			newData = '<div id="Logued">' + data + '</div>';
			$('#Panel').html(newData);
		},
		error: function (XMLHttpRequest, textStatus, errorThrown)
		{
			//$('#Logueado').html('Timeout contacting server..');
		}
	});
}
/**************** FIN DE HEADER: REFRESCO DE CANTIDADES DESCARGA ******************/

