var ie = (document.all)? true:false ;

function getHTTPObject() {
  var xmlhttp;
 
  if(window.XMLHttpRequest){
    xmlhttp = new XMLHttpRequest();
  }
  else if (window.ActiveXObject){
    xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
    if (!xmlhttp){
        xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
}
  return xmlhttp;
}
function imprSelecCondi01(nombre)
{
	document.getElementById("id01").style.display="none";
	document.getElementById("id02").style.display="none";
	var ficha = document.getElementById(nombre);
	var stringa="width=1,height=1";
	var ventimp = window.open('', 'popimpr',stringa);
	window.focus();
	ventimp.document.write( ficha.innerHTML );
	ventimp.document.close();
	ventimp.print();
	ventimp.close();
	document.getElementById("id01").style.display="block";
	document.getElementById("id02").style.display="block";
} 

function getObject(obj) {
  var theObj;
  if(document.all) {
    if(typeof obj=="string") {
      return document.all(obj);
    } else {
      return obj.style;
    }
  }
  if(document.getElementById) {
    if(typeof obj=="string") {
      return document.getElementById(obj);
    } else {
      return obj.style;
    }
  }
  return null;
}

function toCount(entrance,exit,text,characters) {
  var entranceObj=getObject(entrance);
  var exitObj=getObject(exit);
  var length=characters - entranceObj.value.length;
  if(length <= 0) {
    length=0;
    text='<span class="disable"> '+text+' </span>';
    entranceObj.value=entranceObj.value.substr(0,characters);
  }
  exitObj.innerHTML = text.replace("{CHAR}",length);
}

function menu_desplegable_mostrar(){
document.getElementById("submenu").style.display="block";
}

function menu_desplegable_ocultar(){
document.getElementById("submenu").style.display="none";
}

function AbrirVentana(URL, Ventana, Ancho, Alto, MargenS, MargenI, Barras)
{
	var win=null;
	win=window.open(URL, Ventana, "width="+Ancho+", height="+Alto+", scrollbars="+Barras+", top="+MargenS+", left="+MargenI+", resizable=No, toolbar=No");
	win.focus();
}

function getRadioButtonSelectedValue(ctrl)
{
	var valor = 0;
	mi_arrayPersoanliza = new Array();

    for(i=0;i<ctrl.length;i++)
    {    
		if(ctrl[i].checked) 
		{ valor = ctrl[i].value; }
	}
	
	if(valor==1) 
	{  
		mi_arrayPersoanliza[0] = 1;
		mi_arrayPersoanliza[1] = 2;
		mi_arrayPersoanliza[2] = 3;
	}

	if(valor==2) 
	{  
		mi_arrayPersoanliza[0] = 2;
		mi_arrayPersoanliza[1] = 1;
		mi_arrayPersoanliza[2] = 3;
	}

	if(valor==3) 
	{  
		mi_arrayPersoanliza[0] = 3;
		mi_arrayPersoanliza[1] = 2;
		mi_arrayPersoanliza[2] = 1;
	}

	
	setCookie('CookieSOMPersoanliza',mi_arrayPersoanliza,31); 
	location.href='index.php?variables='+mi_arrayPersoanliza;
//	alert(getCookie('CookieSOMPersoanliza'));
}


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 esMail(mail)
{
	var Template = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/; //Formato de direccion de correo electronico
	
		if (!Template.test(mail)) 
		{	
			return false;
		}		else
		{return true;}
	
}

var tex_Cate_agenda='';
var tex_Cate_agenda_repla='';
function iluminaCateAgenda(celda)
{ 
	
	if(document.getElementById(celda).className=="cls_categorias_on")
	{ 
		
		tex_Cate_agenda = document.getElementById('hidden_text_cate_agenda').value
		
		tex_Cate_agenda_repla = tex_Cate_agenda.replace( celda,'')
		
		document.getElementById('hidden_text_cate_agenda').value = tex_Cate_agenda_repla;
		document.getElementById(celda).className="cls_categorias_off"; 
	}
	else
	{ 
		tex_Cate_agenda_repla = document.getElementById('hidden_text_cate_agenda').value ;
		tex_Cate_agenda = celda + tex_Cate_agenda_repla;
		
		document.getElementById(celda).className="cls_categorias_on"; 
		document.getElementById('hidden_text_cate_agenda').value = tex_Cate_agenda;
	}
} 

function iluminaCateAgendaNanos(celda)
{ 
	if(document.getElementById(celda).className=="cls_categoriasnanos_on")
	{ 
		tex_Cate_agenda = document.getElementById('hidden_text_cate_agenda').value
		
		tex_Cate_agenda_repla = tex_Cate_agenda.replace( celda,'')
		
		document.getElementById('hidden_text_cate_agenda').value = tex_Cate_agenda_repla;
		document.getElementById(celda).className="cls_categoriasnanos_off"; 
	}
	else
	{ 
		tex_Cate_agenda_repla = document.getElementById('hidden_text_cate_agenda').value ;
		tex_Cate_agenda = celda + tex_Cate_agenda_repla;
		
		document.getElementById(celda).className="cls_categoriasnanos_on"; 
		document.getElementById('hidden_text_cate_agenda').value = tex_Cate_agenda;
	
	}
} 


function getfileextensionSimple(inputId, ID_DIV_EXTENSION) 
{  
	var fileinput = document.getElementById(inputId);  
	if(!fileinput ) return "";  
	var filename = fileinput.value;  
	if( filename.length == 0 ) return "";  
	var dot = filename.lastIndexOf(".");  
	if( dot == -1 ) return "";  
	var extension = filename.substr(dot,filename.length); 
	document.getElementById(ID_DIV_EXTENSION).value = extension;
} 

function getfileextension(inputId, ID_DIV_IMG, ID_DIV_EXTENSION, ANCHO, ALTO) 
{  
	var fileinput = document.getElementById(inputId);  
	if(!fileinput ) return "";  
	var filename = fileinput.value;  
	if( filename.length == 0 ) return "";  
	var dot = filename.lastIndexOf(".");  
	if( dot == -1 ) return "";  
	var extension = filename.substr(dot,filename.length); 
	if((extension=='.swf') || (extension=='.SWF'))
	{
		document.getElementById(ID_DIV_IMG).innerHTML="esta imagen es un objeto flash";
		document.getElementById(ID_DIV_EXTENSION).value = extension;
	} 
	else
	{
		document.getElementById(ID_DIV_IMG).innerHTML='<img src="'+filename+'" width="'+ANCHO+'" height="'+ALTO+'"/>';
		document.getElementById(ID_DIV_EXTENSION).value = extension;
	} 
} 

 /* Tiene que recibir:
 * 	nombre=nombre de la cookie
 * 	valor=valor de la cookie
 * 	caducidad=caducidad de la cookie en dias (-1 elimina la cookie)
 */
function setCookie(nombre, valor, caducidad) {
	//Si no tenemos caducidad para la cookie, la definimos a 31 dias
	if(!caducidad)
		caducidad = 31

	var expireDate = new Date() //coge la fecha actual
	expireDate.setDate(expireDate.getDate()+caducidad);

	//crea la cookie: incluye el nombre, la caducidad y la ruta donde esta guardada
	//cada valor esta separado por ; y un espacio
	document.cookie = nombre + "=" + escape(valor) + "; expires=" + expireDate.toGMTString() + "; path=/";
}


/*
 * Lee una cookie
 *
 * Tiene que recibir:
 * 	nombre=nombre de la cookie a leer
 */
function getCookie(nombre)
{
	/*
	 * document.cookie
	 * Contiene todas las cookies que estan al alcance de la paginas web en el formato:
	 * nombreCookie1=valor1; nombreCookie2=valor2
	 *
	 * document.cookie.length
	 * Contiene la longitud de la suma de todas las cookies
	 */
	if(document.cookie.length>0)
	{
		/*
		 * indexOf(caracter,desde) Devuelve la primera posicion que el caracter aparece
		 * devuelve -1 si no encuentra el caracter
		 */
		start=document.cookie.indexOf(nombre + "=");
		if (start!=-1)
		{
			//El inicio de la cookie, el nombre de la cookie mas les simbolo '='
			start=start + nombre.length+1; 
			//Buscamos el final de la cookie (es el simbolo ';')
			end=document.cookie.indexOf(";",start);
			//Si no encontramos el simbolo del final ';', el final sera el final de la cookie.
			if (end==-1)
				end=document.cookie.length;
			//Devolvemos el contenido de la cookie.
			//substring(start,end) devuelve la cadena entre el valor mas bajo y
			//el mas alto, indiferentemente de la posicion.
			return unescape(document.cookie.substring(start,end));
		}
	}
	//no hemos encontrado la cookie
	return "";
}
 
function ocultar_estrellas() 
{
	for (i=1;i<6;i++) 
	{
		document.getElementById('estrella'+i).src="images/star_blue.jpg";
	}
}
function mostrar_estrellas(numero) 
{
	for (i=1;i<numero+1;i++) 
	{
		document.getElementById('estrella'+i).src="images/star_yellow.jpg";
	}
}

/* inicio de votos*/
var httpVoto = getHTTPObject(); 

function votarSOM(val, cod, div, seccion)
{
	var URL = window.location.href;

	if(getCookie('CookieVotaSOM')==URL)
	{
		document.getElementById('id_estrellas').innerHTML="<span style='color:#FF0000'>&iexcl;Ud. ya registr&oacute; su voto!&nbsp;</span>";
	}
	else
	{
		var myrand=parseInt(Math.random()*99999999);
		var modurl= "regVoto.php?myrand="+myrand+"&cod="+cod+"&seccion="+seccion+"&val="+val+"&voto=si";
		httpVoto.open("GET", modurl, true);
		httpVoto.onreadystatechange =  function() {rsp_votarSOM(cod, seccion)};;
		httpVoto.send(null);

		setCookie('CookieVotaSOM',URL,1);
	}
}
	
function rsp_votarSOM(cod, seccion)
{
	if (httpVoto.readyState == 4) 
	{
		if(httpVoto.status == 200) 
		{
			estado = httpVoto.responseText;
			document.getElementById('id_estrellas').innerHTML=estado;
			muestraCantVotos(cod, seccion);
		}	
	} 
	else{document.getElementById('id_estrellas').innerHTML="procesando...&nbsp;";}
}



var httpVotoCta = getHTTPObject(); 
function muestraCantVotos(cod, seccion)
{
	var myrand=parseInt(Math.random()*99999999);
	var modurl= "regVoto.php?myrand="+myrand+"&cod="+cod+"&seccion="+seccion+"&voto=cuenta";
	httpVotoCta.open("GET", modurl, true);
	httpVotoCta.onreadystatechange =  rsp_muestraCantVotos;
	httpVotoCta.send(null);
}

function rsp_muestraCantVotos() 
{
	if (httpVotoCta.readyState == 4) 
	{
		if(httpVotoCta.status == 200) 
		{
			estado = httpVotoCta.responseText;
			document.getElementById('id_total_votos').innerHTML=estado;
		}	
	} 
	else{document.getElementById('id_total_votos').innerHTML="...";}
}


/* fin de votos*/

<!-- hide from other browsers	
//Start at the what pic:
var PicNumber=1;
//Time between pics switching in secs
var HowLongBetweenPic=4;

//SwitchPic Function
function SwitchPic(counter)
{
	if(counter < HowLongBetweenPic)
	{
		counter++;
		//DEBUG in the status bar at the bottom of the screen
		//window.status=""+counter+" - Imagen  "+PicNumber+" ";
		//Display pic in what <IMG> tag roll is what I called the image
		 /* document.roll.src = eval("Rollpic" + PicNumber); */
		document.getElementById('roll').style.backgroundImage = 'url('+eval("Rollpic" + PicNumber)+')';
	//	alert(eval("Rollpic" + PicNumber));
		//function calls itself
		CallSwitchPic=window.setTimeout("SwitchPic("+counter+")",1500); 
	}
	else
	{
		//if its not the last picture goto the next picture
		if(PicNumber < NumberOfPictures)
		{
			PicNumber++;
			SwitchPic(0);
		}
		//its the last picture go to the first one
		else
		{
			PicNumber=1;
			SwitchPic(0);
		}
	}
}
// Stop hiding from old browsers -->


// Efecto de la imagen. 
var slideCache = new Array(); 
function RunSlideShow(pictureName,imageFiles,displaySecs) 
{ 
var imageSeparator = imageFiles.indexOf(";"); 
var nextImage = imageFiles.substring(0,imageSeparator); 
if (document.all) 
{ 
document.getElementById(pictureName).style.filter="blendTrans(duration=2)"; 
document.getElementById(pictureName).filters.blendTrans.Apply(); 
} 
document.getElementById(pictureName).src = nextImage; 
if (document.all) 
{ 
document.getElementById(pictureName).filters.blendTrans.Play(); 
} 
var futureImages= imageFiles.substring(imageSeparator+1,imageFiles.length) 
+ ';' + nextImage; 
setTimeout("RunSlideShow('"+pictureName+"','"+futureImages+"',"+displaySecs+")", 
displaySecs*2500); 
// cambio de imagen. 
imageSeparator = futureImages.indexOf(";"); 
nextImage = futureImages.substring(0,imageSeparator); 
if (slideCache[nextImage] == null) { 
slideCache[nextImage] = new Image; 
slideCache[nextImage].src = nextImage; 
} 
} 


var http01 = getHTTPObject(); // We create the HTTP Object
function enviarMailing()
{
	if( esMail(document.formmailing.email.value) == false){alert("Introduzca email valido"); return;}

	var email = document.formmailing.email.value;
	var myrand=parseInt(Math.random()*99999999);
	var modurl= "send_mailing.php?e=1&myrand=" + myrand + "&email="+email;
	http01.open("GET", modurl, true);
	http01.onreadystatechange = rsp_enviarMailing;
	http01.send(null);
}
	
function rsp_enviarMailing() 
{
	if (http01.readyState == 4) 
	{
		if(http01.status == 200) 
		{
			result = http01.responseText;
			document.getElementById('ID_RESULT_LB').innerHTML=result; 
		}	
	} 
	else{document.getElementById('ID_RESULT_LB').innerHTML="<div style='100px'>cargando...</div>";}
}


var http02= getHTTPObject(); // We create the HTTP Object
function enviarSugerencia()
{
	if( trim(document.form1.nombre.value) == ""){alert("Introduzca su Nombre"); document.form1.nombre.focus(); return }
	if( esMail(document.form1.email.value) == false){alert("Introduzca e-mail valido"); document.form1.email.focus(); return ;}
	if( trim(document.form1.sugerencia.value) == ""){alert("Introduzca su sugerencia"); document.form1.sugerencia.focus(); return ;}

	var nombre = document.form1.nombre.value;
	var email = document.form1.email.value;
	var telefono = document.form1.telefono.value;
	var sugerencia = document.form1.sugerencia.value;

	var myrand=parseInt(Math.random()*99999999);
	var modurl= "send_sugerencias.php?e=1&myrand=" + myrand + "&nombre="+nombre+ "&email="+email+ "&telefono="+telefono+ "&sugerencia="+sugerencia;
	http02.open("GET", modurl, true);
	http02.onreadystatechange = rsp_enviarSugerencia;
	http02.send(null);
}
	
function rsp_enviarSugerencia() 
{
	if (http02.readyState == 4) 
	{
		if(http02.status == 200) 
		{
			result = http02.responseText;
			document.getElementById('ID_RESULT_LB').innerHTML=result; 
		}	
	} 
	else{document.getElementById('ID_RESULT_LB').innerHTML="<div style='100px'>cargando...</div>";}
}


var httpvalidarMailContrasenia= getHTTPObject(); // We create the HTTP Object
function validarMailContrasenia()
{ 
	if( esMail(document.form1.mail.value) == false){alert("Introduzca e-mail valido"); document.form1.mail.focus(); return ;}
	var mail = document.form1.mail.value;
	var myrand=parseInt(Math.random()*99999999);
	var modurl= "send_contrasena.php?e=1&myrand=" + myrand + "&mail="+mail;
	httpvalidarMailContrasenia.open("GET", modurl, true);
	httpvalidarMailContrasenia.onreadystatechange = rsp_validarMailContrasenia;
	httpvalidarMailContrasenia.send(null);
}
function rsp_validarMailContrasenia() 
{
	if (httpvalidarMailContrasenia.readyState == 4) 
	{
		if(httpvalidarMailContrasenia.status == 200) 
		{
			result = httpvalidarMailContrasenia.responseText;
			document.getElementById('ID_RESULT_LB').innerHTML=result; 
		}	
	} 
	else{document.getElementById('ID_RESULT_LB').innerHTML="<div style='100px'>cargando...</div>";}
}



var http03= getHTTPObject(); // We create the HTTP Object
function enviarRecomienda()
{
	if( esMail(document.form1.mail1.value) == false){alert("Introduzca tu e-mail valido"); document.form1.mail1.focus(); return ;}
	if( esMail(document.form1.mail2.value) == false){alert("Introduzca e-mail de destino valido"); document.form1.mail2.focus(); return ;}

	var mail1 = document.form1.mail1.value;
	var mail2 = document.form1.mail2.value;
	var urlPOST = document.form1.urlPOST.value;
	

	var myrand=parseInt(Math.random()*99999999);
	var modurl= "send_enviar.php?e=1&myrand=" + myrand + "&mail1="+mail1+ "&mail2="+mail2+"&urlPOST="+urlPOST;
	http03.open("GET", modurl, true);
	http03.onreadystatechange = rsp_enviarRecomienda;
	http03.send(null);
}
	
function rsp_enviarRecomienda() 
{
	if (http03.readyState == 4) 
	{
		if(http03.status == 200) 
		{
			result = http03.responseText;
			document.getElementById('ID_RESULT_LB').innerHTML=result; 
		}	
	} 
	else{document.getElementById('ID_RESULT_LB').innerHTML="<div style='100px'>cargando...</div>";}
}


var httpHOME_SMALL = getHTTPObject(); 
function cargarDetaHOME_SMALL()
{
	var myrand=parseInt(Math.random()*99999999);
	var modurl= "info_index1_1_destacados.php?myrand="+myrand;
	httpHOME_SMALL.open("GET", modurl, true);
	httpHOME_SMALL.onreadystatechange =  rsp_cargarDetaHOME_SMALL;
	httpHOME_SMALL.send(null);
}
	
function rsp_cargarDetaHOME_SMALL() 
{
	if (httpHOME_SMALL.readyState == 4) 
	{
		if(httpHOME_SMALL.status == 200) 
		{
			estado = httpHOME_SMALL.responseText;
			document.getElementById('ID_SPCIO_TOP_HOME_RAND_SMALL').innerHTML=estado;
			//so_init_home();
		}	
	} 
	else{document.getElementById('ID_SPCIO_TOP_HOME_RAND_SMALL').innerHTML="cargando informaci&oacute;n...";}
}



var httpHOME_LARGE = getHTTPObject(); 
function cargarDetaHOME_LARGE()
{
	var myrand=parseInt(Math.random()*99999999);
	var modurl= "info_index2_1_destacados.php?myrand="+myrand;
	httpHOME_LARGE.open("GET", modurl, true);
	httpHOME_LARGE.onreadystatechange =  rsp_cargarDetaHOME_LARGE;
	httpHOME_LARGE.send(null);
}
var varTotalImgDeta;	
function rsp_cargarDetaHOME_LARGE() 
{
	if (httpHOME_LARGE.readyState == 4) 
	{
		if(httpHOME_LARGE.status == 200) 
		{
			estado = httpHOME_LARGE.responseText;
			document.getElementById('ID_SPCIO_TOP_HOME_RAND_SMALL').innerHTML=estado;
			//so_init_deta_home();
			//varTotalImgDeta = document.getElementById('hiddenTotalDestaHome').value;
 			//setTimeout(varTotalImgDeta);.
		}	
	} 
	else{document.getElementById('ID_SPCIO_TOP_HOME_RAND_SMALL').innerHTML="cargando informaci&oacute;n...";}
}





 var http_regMasLeido = getHTTPObject(); 
function regMasLeido(seccion, titu, desc, cod)
{
	var URL = window.location.href;
	if(getCookie('CookieregMasLeidoSOM')!=URL)
	{
		var myrand=parseInt(Math.random()*99999999);
		var modurl= "regMasLeidoSOM.php?myrand="+myrand+"&seccion="+seccion+"&URL="+URL+"&titu="+titu+"&desc="+desc+"&cod="+cod;
		http_regMasLeido.open("GET", modurl, true);
		http_regMasLeido.onreadystatechange =  rsp_regMasLeido;
		http_regMasLeido.send(null);

		setCookie('CookieregMasLeidoSOM',URL,1);
		
	}
}

function rsp_regMasLeido() 
{
	if (http_regMasLeido.readyState == 4) 
	{
		if(http_regMasLeido.status == 200) 
		{
			estado = http_regMasLeido.responseText;
 		}	
	} 
	else
	{
		//document.getElementById('ID_SPCIO_TOP_HOME_RAND_SMALL').innerHTML="cargando informaci&oacute;n...";
	}
}

	
this.findLeftObj = function(obj) 
{  
	var curleft = 0;  
	if (obj.offsetParent) 
	{     
		while (obj.offsetParent) 
		{      
			curleft += obj.offsetLeft      
			obj = obj.offsetParent;      
		}  
	}  
	else 
	{   
		if(obj.x) 
		{     curleft += obj.x;    }  
	}  
	return(curleft);  
}             


this.findTopObj = function(obj) 
{  
	var curtop = 0;  
	if (obj.offsetParent) 
	{      
		while (obj.offsetParent) 
		{          
			curtop += obj.offsetTop          
			obj = obj.offsetParent;      
		}  
	}  
	else 
	{    
		if (obj.y) 
		{      
			curtop += obj.y;     
		}  
	}  
	return(curtop);  
}  
