// JavaScript Document
function pp(nueva,alto,ancho){
	var height = alto;
	var width = ancho;
	window.open(nueva,"","height="+height+",width="+width+",menubar=0,resizable=0,scrollbars=yes, status=0,titlebar=no,toolbar=0,left=50,top=0");
}
function EsVacio(x){
	var filter=/^\s*$/
	return filter.test(x);
}
function EsCorreo(x){
	var filter=/^[A-Za-z][A-Za-z0-9_.]*@[A-Za-z0-9_]+\.[A-Za-z0-9_.]+[A-za-z]$/;
	return filter.test(x);
}
function EsNum(x){
	var filter=/^\d*$/	
	return filter.test(x);
}

var rep = null;
function cerrar(){
	var ventana = document.getElementById("ventana");
	ventana.style.display = 'none';
}
function setRep(reproductor){
	rep = reproductor;
}
function cambiaRep(resultado){
	if(resultado[0].resultado=='true'){
		if(resultado[0].id_rep!=rep){
			var reproductor = document.getElementById("reproductor");
			setRep(resultado[0].id_rep);
			reproductor.innerHTML = resultado[0].codigo;
		}
	}
}
function getInfo(){
	x_getRep(rep,cambiaRep);
}
function getRep(){
	setInterval("getInfo()",3500)
}
function cambiaDiv(div){
	if($("#"+div).hasClass("ancho")){
		$("#"+div).removeClass("ancho");
		$("#"+div).addClass("normal");
		
		$("#video").removeClass("ancho896");
		$("#video").addClass("ancho597");
		
		$("#recientes").css({"margin-top":"0px"});
	}else{
		$("#"+div).removeClass("normal");
		$("#"+div).addClass("ancho");
		
		$("#video").removeClass("ancho597");
		$("#video").addClass("ancho896");
		
		$("#recientes").css({"margin-top":"15px"});
	}
}
function muestraBanner(){
	$("#banner_modal").removeClass("hide");
}

function setCss(title) {
	var i, a, main;
	for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
		if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
			a.disabled = true;
			if(a.getAttribute("title") == title) a.disabled = false;
		}
	}
	writeCookie("estilo",title,"8600");
}

function readCookie(name){
	var cookieValue = "";
	var search = name + "=";
	if(document.cookie.length > 0){ 
		offset = document.cookie.indexOf(search);
		if (offset != -1){ 
			offset += search.length;
			end = document.cookie.indexOf(";", offset);
			if (end == -1) end = document.cookie.length;
			cookieValue = unescape(document.cookie.substring(offset, end))
    	}
  	}
	return cookieValue;
}

function writeCookie(name, value, hours){
	var expire = "";
	if(hours != null){
		expire = new Date((new Date()).getTime() + hours * 3600000);
		expire = "; expires=" + expire.toGMTString();
  	}
  	document.cookie = name + "=" + escape(value) + expire;
}
if(readCookie("estilo")!=""){
	setCss(readCookie("estilo"));
}