var DHTML = (document.getElementById || document.all || document.layers);
/************************************
 * OBTENER DOMINIO DEL SITIO        *
 ************************************/
dominio = document.domain.toLowerCase();
pUrl = document.location.href.toLowerCase();
var site ;
//var dominio = "www.elnorte.com";
if (dominio.indexOf('busquedas') == -1){
	site = dominio.replace("www.","");
	site = site.replace("gruporeforma.","");
	site = site.replace("envivo.","");
	site = site.replace(".com","");}
else if (pUrl.indexOf('/elnorte/') != -1)
	site = 'elnorte';
else if (pUrl.indexOf('/reforma/') != -1)
	site = 'reforma';
else if (pUrl.indexOf('/mural/') != -1)
	site = 'mural';
else
	site = 'palabra';
//alert(site);
/************************************
 * OBTENER FECHA (PARA (S)HTML'S)   *
 ************************************/
function fecha(){
meses = new Array ('Ene','Feb','Mar','Abr','May','Jun','Jul','Ago','Sep','Oct','Nov','Dic');
dateVar = new Date();
document.write(dateVar.getDate() + '-' + meses[dateVar.getMonth()] + '-' + dateVar.getFullYear())
}
/************************************
 * IDENTIFICAR PLATAFORMA Y BROWSER *
 ************************************/
var navUA = navigator.userAgent.toLowerCase();
var tipoBrowser;
var tipoPlataforma;
if (navUA.indexOf('msie') != -1)
	tipoBrowser = 'explorer';
else if (navUA.indexOf('netscape') != -1)
	tipoBrowser = 'netscape';
else if (navUA.indexOf('firefox') != -1)
	tipoBrowser = 'firefox';
else if (navUA.indexOf('safari') != -1)
	tipoBrowser = 'safari';
if (navUA.indexOf('windows') != -1)
	tipoPlataforma = 'windows';
else
	tipoPlataforma = 'mac';
/****************************
 * FUNCIONES PARA MENU      *
 ****************************/
document.write('<IFRAME id="filtro" style="display: none; position:absolute; left:0px; top:74px; width:140px; height:400px; z-index:99;" src="javascript:false;" frameBorder="0" scrolling="no"></IFRAME>')
var pathXml = 'http://' + document.domain + '/';
if (pathXml.indexOf('.com') == -1)
	pathXml = pathXml + 'stageenlineagc/';
pathXml = pathXml + 'libre/online/menu/';
function getObj(name)
{
	if (document.getElementById)
		this.obj = document.getElementById(name);
	else if (document.all)
		this.obj = document.all[name];
	else if (document.layers)
		this.obj = document.layers[name];
	return this.obj;
}
function resizeFlash1(xframe,width,height)
{
	if (!DHTML) return;
	var x = getObj('menuO');
	x.height=400;
	x = getObj('menuE');
	if(!(x==null))x.height=400;
	if (tipoBrowser.indexOf('firefox') ==-1){
		ifF = getObj("filtro");
		if(!(ifF==null)){
			ifF.style.left = xframe;
			ifF.style.width = width;
			ifF.style.height = height+23;
			ifF.style.display='block';
			ifF.style.visibility='visible';
		}
	}
}
function resizeFlash2()
{
	if (!DHTML) return;
	var x = getObj('menuO');
	x.height=23;
	x = getObj('menuE');
	if(!(x==null))x.height=23;
	if (tipoBrowser.indexOf('firefox') ==-1){
		ifF = getObj("filtro")
		if(!(ifF==null)){
			ifF.style.display='none';
			ifF.style.visibility='hidden';
		}
	}
}
/****************************
 * FUNCIONES PARA IFRAME    *
 ****************************/
function resize_iFrame(iframe_name, lessH)
	{
	if (navigator.userAgent.indexOf('MSIE') != -1)
		{
			height = document.body.offsetHeight;
			var objIframe = getObj(iframe_name)
			objIframe.height=height - 122;
		}
	else if (navigator.userAgent.indexOf('Mozilla/') != -1)
		{
			height = document.documentElement.clientHeight;
			var objIframe = getObj(iframe_name)
			objIframe.height=height + 275;
		}
	//var objIframe = getObj(iframe_name)
	//objIframe.height=height - lessH;
}
/****************************
 * FUNCIONES PARA FECHA     *
 ****************************/
function MostrarFechaActual()  
{  var nombre_mes = new Array("Ene", "Feb", "Mar", "Abr", "May", "Jun", "Jul", "Ago", "Sep", "Oct", "Nov", "Dic")

	var hoy_es = new Date()
	dia_mes = hoy_es.getDate()
	mes = hoy_es.getMonth() + 1
	anyo = hoy_es.getYear()

     if (anyo < 100)
     {  anyo = '19' + anyo }

	else 

     if ( ( anyo > 100 ) && ( anyo < 999 ) ) 
     {  var cadena_anyo = new String(anyo) ; anyo = '20' + cadena_anyo.substring(1,3) }

	document.write(dia_mes + "-" + nombre_mes[mes - 1] + "-" + anyo)    
 }
/****************************
 * FUNCIONES PARA COOKIES   *
 ****************************/
function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();}
	else 
		expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}
function getCookieVal (offset) {  
	var endstr = document.cookie.indexOf (";", offset);  
	if (endstr == -1)    
	endstr = document.cookie.length;  
	var clave = unescape(document.cookie.substring(offset, endstr));
	return clave.toLowerCase();
}
function Get_Cookie(name) {  
	var arg = name + "=";  
	var alen = arg.length;  
	var clen = document.cookie.length;  
	var i = 0;  
	while (i < clen) 
	{    
		var j = i + alen;    
		if (document.cookie.substring(i, j) == arg)      
			return getCookieVal (j);    
		i = document.cookie.indexOf(" ", i) + 1;    
		if (i == 0) break;   
	}  
	return null;
}
/****************************
 * FUNCIONES PARA CAMBIO DE *
 * TAMAÑO DE LETRA EN NOTAS *
 ****************************/
function setActiveStyleSheet(title) {
	var i, a, main;
	for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
		if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("rel").indexOf("alternate") != -1 && a.getAttribute("title")) {
			a.disabled = true;
			if(a.getAttribute("title") == title) a.disabled = false;
		}
	}
}
function getActiveStyleSheet() {
	var i, a;
	for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
		if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("rel").indexOf("alternate") != -1 && a.getAttribute("title") && !a.disabled) return a.getAttribute("title");
	}
	return null;
}
function getPreferredStyleSheet() {
	return ('1');
}
function wOL() {
	var cookie = Get_Cookie("style");
	var title = cookie ? cookie : getPreferredStyleSheet();
	if (title == 'null')
		title = '1';
	setActiveStyleSheet(title);
}
function wOUL() {
	var title = getActiveStyleSheet();
	createCookie("style", title, 365);
}

function wOULHome() {
	createCookie("cookiemasvisto",document.forma.configura.selectedIndex,7);
}
/****************************
 * FUNCIONES PARA VENTANAS  *
 ****************************/
function herramienta(direccion)
{
	LeftPosition = (screen.width) ? (screen.width-800)/2 : 0; 
	TopPosition = (screen.height) ? (screen.height-400)/2 : 0;
	window.open(direccion,'pagina','top=' + TopPosition + ',left=' + LeftPosition + ',width=800,height=400,directories=no,location=no,menubar=no,scrollbars=no,status=no,toolbar=no,resizable=no');
}

function herramientascroll(direccion)
{
	LeftPosition = (screen.width)  ? (screen.width-800)/2  : 0; 
	TopPosition  = (screen.height) ? (screen.height-400)/2 : 0;
	window.open(direccion,'pagina','top=' + TopPosition + ',left=' + LeftPosition + ',width=800,height=400,directories=no,location=no,menubar=no,scrollbars=yes,status=no,toolbar=no,resizable=no');
}

function musicaparanavegar(direccion)
{
	LeftPosition = (screen.width) ? (screen.width-800)/2 : 0; 
	TopPosition = (screen.height) ? (screen.height-400)/2 : 0;
	window.open(direccion,'paginamusicaparanavegar','top=' + TopPosition + ',left=' + LeftPosition + ',width=800,height=400,directories=no,location=no,menubar=no,scrollbars=no,status=no,toolbar=no,resizable=no');
}


/****************************
 * FUNCIONES PARA ANUNCIOS  *
 ****************************/
 
 

_version=11;
if (navigator.userAgent.indexOf('Mozilla/3') != -1){
_version=10;} 

var oas='http://anuncios.gruporeforma.com/RealMedia/ads/';
var RN = new String (Math.random());
var RNS = RN.substring (2, 11); 

function DisplayAds (pagina, position, width, height)
{

	baseAddress = document.domain;
	baseAddress = baseAddress.toLowerCase( );

	var oaspage= sitepage + pagina +'/1' + RNS + '@' + position;
	var foto = baseURL.search('foto');
	var opi = baseURL.search('opinion');
	var indica = baseURL.search('indicador');
	var articulo = baseURL.search('articulo');
	var entrada= baseAddress ;									
	var r = entrada.search("elnorte.com");
	var s = entrada.search("reforma.com");
	var t = entrada.search("mural.com");
	var p= entrada.search("palabra.com");
	var imganuncio = "";	
	if (r > -1 || s > -1 || t > -1 || p > -1 )
	{

		if (_version < 11) {

		document.write ('<A HREF="' + oas + 'click_nx.cgi/'+ oaspage + '" TARGET="_top" ><IMG SRC="' + oas + 'adstream_nx.cgi/' + oaspage + '" BORDER="0" WIDTH="' + width + '" HEIGHT="' + height + '"></a>');
		}
		else
		{
			document.write ('<'+'SCRIPT LANGUAGE="JavaScript1.1" SRC="' + oas + 'adstream_jx.cgi/' + oaspage + '">');
			document.write ('\<\!-- --\>');
			document.write ('\<\/SCRIPT\>');
			document.write ('\<\!-- --\>');
		}
	}
	else
		{	
				
			baseSTG = '<img src="' + 'http://' + document.domain + '/stageenlineagc/img/';			
			if ((position=="TopRight" || position=="Right" || position=="Right1" || position=="Right2" || position=="Right3") && articulo < 0)
				imganuncio = 'anunpix.gif" width="180" height="60">';
			else
			 {
				if (position=="Top" || position=="Top1" || position=="Top2" || position=="Top3" )
					imganuncio = 'anunpix.gif" width="182" height="90">';
				else
					{ 
					if (position=="Middle1" || position=="Middle2")
						 imganuncio = 'anunpix.gif" width="270" height="132">';
					else
						{
						if ((position=="Right1" || position=="Right2" || position=="Right3") && articulo > 0)
						 imganuncio = 'anunpix.gif" width="120" height="115">';
						}						 
					}
			 }
			 document.write(baseSTG + imganuncio);
		}
		
}
/************************************
 * CONECTAR / DESCONECTAR           *
 ************************************/
function textosLogon(){
	if ((site != 'elnorte') && (site != 'reforma') && (site != 'mural') && (site != 'palabra'))
		siteTl = '/stageenlineagc/';
	else
		siteTl = 'http://www.' + site  + '.com/';
	var hola = siteTl + 'libre/acceso/registro/perfil.asp';;
	var ayuda = siteTl + 'libre/acceso/ayuda';;
	var conectar = siteTl + 'libre/acceso/acceso.htm';
	var desconectar = siteTl + 'libre/acceso/logout.asp';
	nivelcobro = 2;
	var grcuser = Get_Cookie('cusuarioss');
	if (grcuser == null){
		document.write('<td width=152 align=right><img src='+siteTl+'libre/online/imggc/pix.gif height=1 width=15 border=0></td>');
		document.write('<td width=100 align=left><a href=' + conectar + ' id=ligablanca><span class=arblanco12>conectar</span></a></td>');
	}
	else {
		document.write('<td width=152 align=right><a href=' + hola +'><span class=aramarillo12><b><u>Hola, ' + grcuser.substr(0,11) + '</u></b></span></a><img src='+siteTl+'libre/online/imggc/pix.gif height=1 width=15 border=0></td>');
		document.write('<td width=100 align=left><a href=' + desconectar + ' id=ligablanca><span class=arblanco12>desconectar</span></a></td>');
	}
}
/************************************
 * LIGA DEL BUSCADOR                *
 ************************************/
function ligaBuscador(){
	if (pUrl.indexOf('plazaconsulta=elnorte') != -1) 
		sitePcob = 'elnorte';
	else if (pUrl.indexOf('plazaconsulta=reforma') != -1) 
		sitePcob = 'reforma';
	else if (pUrl.indexOf('plazaconsulta=mural') != -1) 
		sitePcob = 'mural';
	else if (pUrl.indexOf('plazaconsulta=palabra') != -1) 
		sitePcob = 'palabra';
	else	
		sitePcob = site;
	//document.buscador.action = 'http://busquedas.gruporeforma.com/'+sitePcob+'/default.asp';
	document.buscador.action = 'http://busquedas.gruporeforma.com/'+sitePcob+'/buscador/BuscaImpresa.aspx';
}   
/************************************
 * PARA USO EN EDITORIALES          *
 * EN EL ARCHIVO QUIERES.INC        *
 ************************************/
function muestra(time)
	{var str = Nombre.value;
	if(str.indexOf(" y ")>0){
	Nombre.value=str.substring(0,str.indexOf(" y "));
	}
	var valor = Nombre.value;
	var valor1 = IDSeccion.value;
	var palabra = "palabramonitor=" + valor;
	//alert(palabra);
	var secc = "&seccion=" + valor1;
	var dias = "&dias=" + time;
	var liga = '../../../alertas/articulo/formacorreo.asp?' + palabra + secc + dias;
	return liga;
	}           
/************************************
 * PARA USO EN EDITORIALES          *
 * EN EL ARCHIVO QUIERES_RECIBIR.INC *
 ************************************/
function muestra1(time)
	{var str = Nombre.value;
	var valor = NombreM.value;
	var valor1 = IDSeccion.value;
	var palabra = "palabramonitor=" + valor;
	//alert(palabra);
	var secc = "&seccion=" + valor1;
	var dias = "&dias=" + time;
	var liga = '../../../alertas/articulo/formacorreo.asp?' + palabra + secc + dias;
	return liga;
	}
/************************************
 * FUNCION PARA RESIZE DE UNA       *
 * PAGINA Q ABRE EN POP UP          *
 ************************************/

function resizePopup(alto, ancho){
	window.resizeTo(alto,ancho);	
	if (navigator.userAgent.indexOf("Mac") >= 0)
			{
			 window.resizeTo(alto,ancho-40);
			}
	
}
/***********************************
* FUNCION PARA OBTENER LA POSICIÓN *
* PARA EL DIV DE ARTICULO CON FOTO *
* HORIZONTAL, PARA LOS ANUNCIOS    *
* DINAMICOS                        *
************************************/
	// this function returns the x, y position
	// works in IE and Mozilla.
	
var ie=document.all
var dom=document.getElementById
var ns4=document.layers
var calunits=document.layers? "" : "px"
	
	function getElementPosition(element){
		var x=0,y=0;
		while (element!=null){
			x+=element.offsetLeft-element.scrollLeft;
			y+=element.offsetTop-element.scrollTop;
			element=element.offsetParent;
		}
		return {x:x,y:y};
	}
	// Browser compatible element getter
	function getElement(id){
		if (document.all)
		return document.all[id];
		if (document.getElementById(id))
		return document.getElementById(id);
		return null;
	}
		// generic display function
	function findElement(id){
		// Get the element by its id
		element = getElement(id);
		// make sure that the element was found
		if (! element) return;
		// get the object that will contain the x,y coordinates
		position = getElementPosition(element);
		// display the coordinates
		var ycoords = position.y + 40;
		crossobj=(dom)?document.getElementById("layer2").style : ie? document.all.layer2 : document.layer2;
		crossobj.top=ycoords;
		}
		
/************************************
 * PARA USO EN EDITORIALES          *
 * SE USA EN HISTORICOS				*
 ************************************/
 
function cambiaTab(celda){
	document.getElementById('divcelda1').style.display = "none";
	document.getElementById('celda1').style.cursor = "hand";
	document.getElementById('divcelda2').style.display = "none";
	document.getElementById('celda2').style.cursor = "hand";
	var nombreDiv = 'div' + celda;
	document.getElementById(nombreDiv).style.display = "block";
	document.getElementById(celda).style.cursor = "arrow";
	celdaSel = celda
	
}

/************************************
 * PARA USO EN EDITORIALES          *
 * SE USA EN HISTORICOS				*
 ************************************/

/*function mOut(celda){
	if (celdaSel !=celda)
	document.getElementById(celda).bgColor = "#ffffff";
}*/

/************************************
 * PARA USO EN EDITORIALES          *
 * SE USA EN HISTORICOS				*
 ************************************/

function ShowHideLayer(id,pos){
	if (document.getElementById(id).style.display == "none")
		{
		document.getElementById(id).style.display = "block";
		}
	else {
		document.getElementById(id).style.display = "none"; 
		}
} 
		

/*Función para la navegación de las Fotos Dinámicas de Portada y de Articulos*/function actualizafotosmenu(){	baseAddress = document.domain;
	baseAddress = baseAddress.toLowerCase( );

	var stagenorte= baseAddress.search('edtweb05');
	var stagenorte1= baseAddress.search('edtimd050sw');
	var stagereforma= baseAddress.search('cicweb08');
	var stagemural= baseAddress.search('cioweb01');
	var stagepalabra = baseAddress.search('edtweb08');
	var publico= baseAddress.search('.com');
					
	if (stagenorte > -1 || stagenorte1 > -1) {folderplaza= "elnorte";}
	if (stagereforma > -1) {folderplaza= "reforma";}			
	if (stagemural > -1)   {folderplaza= "mural";}
	if (stagepalabra > -1) {folderplaza= "palabra";}
	if (publico > -1) 
		{
			var entrada= baseAddress ;									
			var r = entrada.search("elnorte.com");
			var s = entrada.search("reforma.com");
			var t = entrada.search("mural.com");
			var p= entrada.search("palabra.com");
		}
									
	if (r > -1)	{folderplaza= "elnorte";}
	if (s > -1)	{folderplaza= "reforma";}			
	if (t > -1) {folderplaza= "mural";}
	if (p > -1) {folderplaza= "palabra";}
}function DateAdd (fecha,dias) {
  var buffer = Date.parse(fecha);
	dias *= 24; //dias
	dias *= 60; //minutos
	dias *= 60; //segundos
	dias *= 1000; //milisegundos
	fecha = new Date(buffer+dias);
 	buffer = null;
  return fecha;
}
function fechaArreglada (fecha,periocidad)
{
	var fechaAux = new Date();
	var weekdayAux = fecha.getDay();
	var diasAtras = 0;
	fechaEncontrada = false;
	do
	{
	  if (parseInt(Math.pow(2,weekdayAux)&periocidad) > 0)
		{
			fechaEncontrada = true;
		}
		else
		{
		  diasAtras++;
			weekdayAux-=1;
			weekdayAux%=7;
			if(weekdayAux<0)weekdayAux+=7;
		}
	}
	while(!fechaEncontrada);
	fechaAux=DateAdd(fecha,-diasAtras);
	return fechaAux;
}
function ligaEII(seccion,periodicidad){
//Periodicidad 1-domingo, 2-lunes, 4-martes, 8-miercoles, 16-jueves, 32-viernes, 64-sabado, 127-diario
    fechaLiga = new Date();
    fechaAux=fechaArreglada(fechaLiga,periodicidad)
    DirAux=new String(fechaAux.getFullYear())
    Dir=DirAux.slice(2)
    DirAux=new String(fechaAux.getMonth()+1)
    if(DirAux.length==1)DirAux='0'+DirAux
    Dir=Dir+DirAux
    DirAux=new String(fechaAux.getDate())
    if(DirAux.length==1)DirAux='0'+DirAux
 	LeftPosition = (screen.width) ? (screen.width-640)/2 : 0;
	TopPosition = (screen.height) ? (screen.height-440)/2 : 0;
    var ligaTopMag = 'http://www.' + site + '.com/edicionimpresa/interactiva/default.asp?fecha='+Dir+DirAux+'&seccion='+seccion;
	window.open(ligaTopMag,'paginaMag','top=' + TopPosition + ',left=' + LeftPosition + ',width=800,height=400,directories=no,location=no,menubar=no,scrollbars=no,status=no,toolbar=no,resizable=no');
}


