/******** FOTO NOTICIA ********/

	var fotosPag = 5; // Número de fotos que sale en la paginación.
	function fotoNoticia(id,num,numTotal) {
		fotosN = document.getElementsByTagName('div');
		fotoOn = 1;
		fotoExp = new RegExp(id + "-");
		for(i=0;i<fotosN.length;i++) {
			if(fotosN[i].id.indexOf(id) == 0) {
				fotoOn = parseInt(fotosN[i].id.replace(fotoExp, ""));
				if(fotosN[i].style.display == "") {
					if(num == '+') num = fotoOn + 1;
					if(num == '-') num = fotoOn - 1;
				}
				fotosN[i].style.display = 'none';
			}
		}
		if(num == 0) num = numTotal;
		if((num > numTotal) || isNaN(num)) num = 1;
		if(fotoN = document.getElementById(id + '-' + num)) fotoN.style.display = "";
		indicePag = Math.ceil(num/fotosPag) - 1;
		for(i=1;i<=fotosPag;i++) {
			if(pag = document.getElementById(id + '-pag-' + i)) {
				pag.className = "";
				pagNum = i + (indicePag * fotosPag);
				if(pagNum > numTotal) {
					pag.innerHTML = "&nbsp;&nbsp;";
					pag.href = "#";
				}
				else {
					pag.innerHTML = i + (indicePag * fotosPag);
					pag.href = "JavaScript:fotoNoticia('" + id + "'," + pagNum + "," + numTotal + ");";
				}
			}
		}
		numPag = ((num - 1) % fotosPag) + 1;
		if(pag = document.getElementById(id + '-pag-' + numPag)) pag.className = "activo";
	}

	/******** FIN FOTO NOTICIA ********/
	/******** RANDOM ********/

function aleatorio(inferior,superior){
numPosibilidades = superior - inferior;
rand = Math.random() * numPosibilidades;
rand = Math.round(rand);
return parseInt(inferior) + rand;
}

/******** FIN RANDOM ********/

/******** GOOGLE  ********/
	function cs() {window.status=''};
	function ss(urlVisible){window.status=urlVisible;return true;};
	
	function google_ad_request_done(google_ads) {
		var i;
		var publi ='';
		accip = "off";
		if(google_ads.length > 0) {
			publi+='<div class="adds">';
			publi+='<div class="estilo_tit">Anuncios <strong>Google</strong></div>';
			publi+='<table class="addscontent" cellpadding="0" cellspacing="0">';
			for(i = 0; i < google_ads.length; ++i) {
				publi+='<tr>';
				publi+='<td class="estilo_txt">';
				publi+='<a href=\''+ google_ads[i].url + '\' target="_blank" onMouseOver="return ss(\'' + google_ads[i].visible_url + '\')" onMouseOut="cs()">';

				publi+='<span class="estilo_lnk">';
				publi+=google_ads[i].line1;
				publi+='</span>';
				publi+='<span class="estilo_descripcion">';
				publi+=google_ads[i].line2 + '&nbsp;';
				publi+=google_ads[i].line3 + '&nbsp;';
				publi+='</span>';
				publi+='<span class="estilo_url">';
				publi+=google_ads[i].visible_url;
				publi+='</span></a></td></tr>';
			}
			publi+='</table></div>';
			if(contNoxtrum = window.document.getElementById("publi1_noxtrum"))
				contNoxtrum.innerHTML = publi;
		}
	}
/******** GOOGLE  ********/	
	
       /******** MODULOS METHODE ********/
                                
        function canalesHoy(id,num,color) {
                colorPestana = ""
                if(!isNaN(color))
                        colorPestana = " pestcanal-" + color;
                pestanaOn = id + "-pestana-" + num;
                contenidoOn = id + "-contenido-" + num;
                bottomOn = id + "-bottom-" + num;
                contenidosN = document.getElementsByTagName('div');
                for(i=0;i<contenidosN.length;i++) {
                        if(contenidosN[i].id.indexOf(id) == 0) {
                                if((contenidosN[i].id == contenidoOn) || (contenidosN[i].id == bottomOn))
                                        contenidosN[i].style.display = "";
                                else
                                        contenidosN[i].style.display = "none";
                        }
                }
                pestanasN = document.getElementsByTagName('a');
                for(i=0;i<pestanasN.length;i++) {
                        if(pestanasN[i].id.indexOf(id) == 0) {
                                if(pestanasN[i].id == pestanaOn)
                                        pestanasN[i].className = "activo";
                                else
                                        pestanasN[i].className = "";
                        }
                }
                if(objColor = document.getElementById('color-' + id))
                        objColor.className = "modulocanaleshoy" + colorPestana;
        }

        function canalesClasi(id,canal) {
                contenidosN = document.getElementsByTagName('div');
                for(i=0;i<contenidosN.length;i++) {
                        if(contenidosN[i].id.indexOf(id) == 0) {
                                if(contenidosN[i].id == id + "-" + canal)
                                        contenidosN[i].style.display = "";
                                else
                                        contenidosN[i].style.display = "none";
                        }
                }
                pestanasN = document.getElementsByTagName('a');
                for(i=0;i<pestanasN.length;i++) {
                        if(pestanasN[i].id.indexOf(id) == 0) {
                                if(pestanasN[i].id == id + "-pestana-" + canal)
                                        pestanasN[i].className = "activo " + canal;
                                else
                                        pestanasN[i].className = "";
                        }
                }
        }

        function canalesInfo(id,num,numTotal) {
                contenidoOn = 1;
                contenidoExp = new RegExp(id + "-(contenido|fotografia)-");
                contenidosN = document.getElementsByTagName('div');
                for(i=0;i<contenidosN.length;i++) {
                        if(contenidosN[i].id.indexOf(id) == 0) {
                                contenidoOn = parseInt(contenidosN[i].id.replace(contenidoExp, ""));
                                if(contenidosN[i].style.display == "") {
                                        if(num == '+') num = contenidoOn + 1;
                                        if(num == '-') num = contenidoOn - 1;
                                }
                                contenidosN[i].style.display = "none";
                        }
                }
                if(num == 0) num = numTotal;
                if((num > numTotal) || isNaN(num)) num = 1;
                if(contenidoN = document.getElementById(id + '-fotografia-' + num)) contenidoN.style.display = "";
                if(contenidoN = document.getElementById(id + '-contenido-' + num)) contenidoN.style.display = "";
                numTxt = num.toString();
                if(num < 10)
                        numTxt = "0" + numTxt;
                if(contenidoN = document.getElementById(id + '-num')) contenidoN.innerHTML = numTxt;
        }

        function servicios(id,num) {
                contenidosN = document.getElementsByTagName('div');
                for(i=0;i<contenidosN.length;i++) {
                        if(contenidosN[i].id.indexOf(id + "-contenido-") == 0) {
                                if(contenidosN[i].id == id + "-contenido-" + num)
                                        contenidosN[i].style.display = "";
                                else
                                        contenidosN[i].style.display = "none";
                        }
                }
                pestanasN = document.getElementsByTagName('li');
                for(i=0;i<pestanasN.length;i++) {
                        if(pestanasN[i].id.indexOf(id + "-pestana-") == 0) {
                                if(pestanasN[i].id == id + "-pestana-" + num)
                                        pestanasN[i].className = "activa";
                                else
                                        pestanasN[i].className = "";
                        }
                }
        }

        /******** MODULOS METHODE  ********/	

	/************ AJAX **********/
	
	function createRequestObject() {
		var ro;
		var browser = navigator.appName;
		
		if(browser == "Microsoft Internet Explorer"){
			ro = new ActiveXObject("Microsoft.XMLHTTP");
		}
		else{
			ro = new XMLHttpRequest();
		}
		return ro;
	}  
	
	/************ FIN AJAX **********/



function votarticulo(puntos) {
		
		var direccion;
		
		if (window.document.location.href.indexOf('?') > 0) {
			var campos = window.document.location.href.split('?');
			direccion = campos[0];
		}
		else {
			direccion = window.document.location.href;
		}	
		
		var http = createRequestObject();
		http.open("get", "/backend/votaciones/votar.php?puntos=" + puntos + "&url=" + direccion + "&r=" + Math.random());
		http.onreadystatechange = function () {
			if(http.readyState == 4){
				if (http.responseText) {
					gracias = "<div class=label>Gracias por votar</div>";
					document.getElementById('contenidoestrellas').innerHTML = gracias;
					getEstrellas();
					getVotos();
						
				}
			}	
		};
		http.send(null);		
	}
	
	function getEstrellas() {
		
		var direccion;
		
		if (window.document.location.href.indexOf('?') > 0) {
			var campos = window.document.location.href.split('?');
			direccion = campos[0];
		}
		else {
			direccion = window.document.location.href;
		}
		
		var http = createRequestObject();
		http.open("get", "/backend/votaciones/estrellas.php?url=" + direccion);
		http.onreadystatechange = function () {
			if(http.readyState == 4){
				if (http.responseText) {
					var estrellas = http.responseText;
					
					if (estrellas.indexOf(".")) {
			
						campos = estrellas.split(".");
						estrellas = campos[0];	
						var media = (campos[1] > 0) ? 1 : 0;
					}
					
					var contenido = '';
					
					for (i = 0; i < estrellas; i++) {
						contenido += '<img src="/img/star_on.gif" alt="' + i +' votos" />';
					}
					
					if (media == 1) {
						contenido += '<img src="/img/star_on_md.gif" alt="' + estrellas +' votos" />';
						estrellas++;
					}
					
					for (i = estrellas; i < 5; i++) {
						contenido += '<img src="/img/star_off.gif" alt="' + i +' votos" />';	
					}
					
					window.document.getElementById('resultados-votos').innerHTML = contenido;
						
				}
			}	
		};
		http.send(null);
			
	}
	
	function getVotos() {
		
		var direccion;
		
		if (window.document.location.href.indexOf('?') > 0) {
			var campos = window.document.location.href.split('?');
			direccion = campos[0];
		}
		else {
			direccion = window.document.location.href;
		}
		
		var http = createRequestObject();
		//http.open("get", "/backend/votaciones/votos.php?url=" + direccion +"&r=" + Math.random());
		http.open("get", "/backend/votaciones/votos.php?url=" + direccion);
		http.onreadystatechange = function () {
			if(http.readyState == 4){
				if (http.responseText) {
					var votos = http.responseText;
					if (votos == 1) {
						window.document.getElementById('numvotos-votos').innerHTML = votos + ' voto';
					}
					else {
						window.document.getElementById('numvotos-votos').innerHTML = votos + ' votos';
					}
				}
			}	
		};
		http.send(null);
			
	}

	var http = createRequestObject();
                                
        http.open('get', '/acceso.php?pag=' + window.document.location.href + '&resolucion=' + screen.width + 'x' + screen.height + '&r=' + Math.random());
        http.send(null);

	/************ COOKIES ***********/

        function setCookie(name, value, expires, path, domain, secure) {
                var curCookie = name + "=" + escape(value) + ((expires) ? "; expires=" + expires : "") + ((path) ? "; path=" + path : "") + ((domain) ? "; domain=" + domain : "") + ((secure) ? "; secure" : "");
                document.cookie = curCookie;
        }

        function getCookie(name) {
                var dc = document.cookie;
                var prefix = name + "=";
                var begin = dc.indexOf("; " + prefix);
                if (begin == -1) {
                        begin = dc.indexOf(prefix);
                if (begin != 0) return null;
                } else
                        begin += 2;
                var end = document.cookie.indexOf(";", begin);
                if (end == -1)
                        end = dc.length;
                return unescape(dc.substring(begin + prefix.length, end));
        }

        /************ FIN COOKIES ***********/


function presentarticker(capa){
        document.getElementById('tickereconomiaoff').style.display = 'none';
        document.getElementById('tickereconomia').style.display = 'block';
}

function tienda(modulo,maximo){
                for (iq = 1; iq < maximo+1; iq++) {
                        bloque = "modulotienda" + iq;
                        //alert('oculto ' + bloque);
                        document.getElementById(bloque).style.display = 'none';
                }
       
                presentar = "modulotienda" + modulo;
                //alert('presento ' + presentar );
                document.getElementById(presentar).style.display = 'block';
       
	}

/************ TEXTLINK ***********/

function activaTextLink(){
$(document).ready(function() {
if( $("#publiEspecial").css("display") == 'none' ) {
$("#publiEspecial").css("display","");
}
});
}

/************ FIN TEXTLINK ***********/
