
/************************************
 * OBTENER DOMINIO DEL SITIO        *
 ************************************/
dominio = document.domain.toLowerCase();
pUrl = document.location.href.toLowerCase();
var site ;
var developer=false;
//var dominio = "www.elnorte.com";

if (dominio.indexOf('.com') < 0) {    
    site = 'edtimd052sw'}
else {
    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 if (pUrl.indexOf('palabra') != -1)        
	    site='palabra'	    
    else
        {
	    site = 'elnorte'; //PONERLO EN ELNORTE CUANDO YA NO ESTE EN DESARROLLO
	    developer=true;
	    }
    } 
    
 if (dominio.indexOf('.com') != -1)
	{
        var sitepage= site + ".com/"; 
    }
     
/****************************
 * 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 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)
{
    //sitepage = 'elnorte.com/'
	var oaspage= sitepage + pagina +'/1' + RNS + '@' + position;
	//var foto = baseURL.search('foto');
	//var opi = baseURL.search('opinion');
	//var indica = baseURL.search('indicador');
	if (dominio.indexOf('.com') != -1)
	{
	    var imganuncio = '';	
		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
        document.write ('<img src="libre/online07/img/cartier_iphone.gif" border="0" width="320" height="45"/>');
}
/************************************
 * PLECA CONECTAR / DESCONECTAR      *
 ************************************/
//function textosLogon(ligaMiCajon,imagenMiCajon,imagenPix){
//	var hola = 'http://www.' + site  + '.com/' + 'libre/acceso/registro/perfil.asp';
//	nivelcobro = 2;
//	var grcuser = Get_Cookie('cusuarioss');		
//	if (grcuser != null){
//	    document.write('<a href=' + hola + '><span class="argris13"><strong>Hola, <u>'+ grcuser.substr(0,11) +'</u></strong></span></a>&#160;|');		
//	    document.write('<a href="' + ligaMiCajon + '"><img height="22" width="30" align="absMiddle" border="0" src="'+imagenMiCajon+'"><span class="argris12">mi cajón</span></a>');		
//	}
//	else
//	    document.write('<img height="1" width="30" align="absMiddle" border="0" src="'+imagenPix+'">');
//}

//function plecaLogon(){    
//	if ((site != 'elnorte') && (site != 'reforma') && (site != 'mural') && (site != 'palabra'))
//	    siteTl = '/stageenlinea/';	
//	else siteTl = 'http://www.' + site  + '.com/';
//	var ayuda = 'http://www.' + site  + '.com/' + 'libre/acceso/ayuda';
//	var conectar = 'http://www.' + site  + '.com/' + 'libre/acceso/acceso.htm';
//	var desconectar = 'http://www.' + site  + '.com/' + 'libre/acceso/logout.asp';
//	nivelcobro = 2;
//	var grcuser = Get_Cookie('cusuarioss');
//	if (grcuser == null){
//        document.write('<a href=' + conectar + '><img height="20" width="108" border="0" src="' + siteTl + 'Libre/Online07/Sociales/imagenes/comunes/pestana_conectar.gif" /></a>');        
//	}
//	else {
//		document.write('<a href=' + desconectar + '><img height="20" width="108" border="0" src="' + siteTl + 'Libre/Online07/Sociales/imagenes/comunes/pestana_desconectar.gif" /></a>');
//	}
//}

////pinta los trs
//function mOvr(obj,clrOver) {
//	if (navigator.appName == 'Netscape' || !obj.contains(event.fromElement)) {
//    obj.style.cursor = 'pointer';
//    obj.style.backgroundColor = clrOver;
//	}
//}
//function mOut(obj,clrIn) {
//	if (navigator.appName == 'Netscape' || !obj.contains(event.toElement)) {
//	  obj.style.cursor = 'default';
//	  obj.style.backgroundColor = clrIn;
//	}
//}

// hide show divs

function layerBehaivor(div,span,img, claseHide, claseVisible)
{
    var div= document.getElementById(div);
    var span= document.getElementById(span);
    var img= document.getElementById(img);    
    if (div.className=="layerVisible")
    {
        div.className="layerHide";
        if (claseHide==null)
            span.className="artitulo";
        else
            span.className=claseHide;
        if (img!=null) img.src=img.src.replace("flecha_over","flecha_go");        
        cambiaStatusSecciones(div.id.toLowerCase(),'hide')
    }
    else
    {        
        div.className="layerVisible";
        if (claseVisible==null)
            span.className="artituloOp";
        else            
            span.className=claseVisible;
       if (img!=null) img.src=img.src.replace("flecha_go","flecha_over");
       cambiaStatusSecciones(div.id.toLowerCase(),'show')
    }  
    
}

//ESTATUS DE SECCIONES DIVS ABIERTOS CERRADOS
function cambiaStatusSecciones(divId, status)
{
    //alert(plazaid);
    divId= "{"+divId+"}" 
    var statusSecciones=Get_Cookie('statusSeccionesIphone_' + plazaid);
    if (statusSecciones!=null) 
    {
        if (status=='hide')
            statusSecciones=statusSecciones.replace(divId,"");            
        else            
            if (statusSecciones.indexOf(divId)==-1)                
                statusSecciones+=divId;
        createCookie('statusSeccionesIphone_' + plazaid,statusSecciones,30);
    }
    else
        createCookie('statusSeccionesIphone_' + plazaid,divId,30);
    //alert(Get_Cookie('statusSecciones'));     
}

//Hace que suba la barra de direccion URL
function up()
{
    window.setTimeout (function() {window.scrollTo(0, 1)},100);
}

//FUNCION PARA REALIZAR EL RANDOM EN OPINIONES
function randomArray ( arreglo ) 
{
  var i = arreglo.length;
  if ( i == 0 ) return false;
  while ( --i ) {
     var j = Math.floor( Math.random() * ( i + 1 ) );
     var tempi = arreglo[i];
     var tempj = arreglo[j];
     arreglo[i] = tempj;
     arreglo[j] = tempi;
   }
}

function twodigits(s)
{    
    if (s<10)
    {
        s="0"+s;
    }
    return s;
}