var base;
//var dominio = location.hostname.toLowerCase();
var protocolo = location.protocol.toUpperCase();


var cookiesSubDominioEsp = location.protocol + '//www';
var cookiesSubDominioGal = location.protocol + '//galegos';


// para las estadisticas
var _rsCI='es-caixagalicia';
var _rsCG='0';
var _rsDT=1;
var _rsSI=escape(window.location);
var _rsLP=location.protocol.indexOf('https')>-1?'https:':'http:';
var _rsRP=escape(document.referrer);
var _rsND=_rsLP+'//secure-uk.imrworldwide.com/';
var _rsDN='//secure-uk.imrworldwide.com/';
var _rsCC='0';

if (parseInt(navigator.appVersion)>=4) 
{
	var _rsRD=(new Date()).getTime();
	var _rsSE=0;
	var _rsSV='';
	var _rsSM=0;
}


//if (dominio=='www')
//{
//	base = 'http://www/';
//	baseHttps ='https://www/';
//}
//else
//{
	//base = 'http://www.caixagalicia.es/';	
	base = location.protocol + '//www.caixagalicia.es/';
	baseHttps = 'https://www.caixagalicia.es/';	
//}

var explorer= (document.all) ? 1 : 0;
var documento= (explorer) ? "document.all." : "document.";
var IE4 = (document.all && !document.getElementById) ? true : false;
var IE5 = (document.all && document.getElementById) ? true : false;
var IE = IE4 || IE5;
var NS4 = (document.layers) ? true : false;
var NS5 = (!document.all && document.getElementById) ? true : false;
var NS6 = NS5;
var NS = NS4||NS5;	

if (NS5) document.all = new Function("n", "return document.getElementById(n);");
//para vignette
if(location.href.indexOf(base)!=-1)
{
if(protocolo=='HTTP:')
{

	if (typeof(parent.frames['contenido']) != 'undefined')
	{   

	   if (this.name=="contenido")//contenido
	    {
	        if(typeof(parent.TipoEstilo)!= 'unknown')
	        {
			  if (parent.TipoEstilo==3)//netclub
				    document.write ('<link href="'+base+'includes/wvio004m_estilo_netclub.css" rel="stylesheet" type="text/css">'); 
	        }            
	    }
	  
	}
	else
	{	
	    if ((opener!=null & NS6) || (typeof(opener)!= 'undefined' & IE))//ventana fuera del frame
	    {
			if (opener != null) {
					 if (typeof(opener.parent) != 'undefined')
					 {
					 if ((typeof(opener.parent.TipoEstilo) != 'undefined') && (typeof(opener.parent.TipoEstilo) != 'unknown'))//no es un banner
					     {
					         if (opener.parent.TipoEstilo==3)//netclub
					         {
					             document.write ('<link href="'+base+'includes/wvio004m_estilo_netclub.css" rel="stylesheet" type="text/css">'); 
					         }
					     }
					}   
			}
	   } 
	}
   
}
}
function combo(combo){

	if (combo.selectedIndex>0)
	{
		if (opciones[combo[combo.selectedIndex].value].indexOf('javascript')==-1)
			parent.frames['contenido'].location.href = opciones[combo[combo.selectedIndex].value];
		else
			eval(opciones[combo[combo.selectedIndex].value]);
	}	
}

function pintaCombo(opciones){
	var cad = '';
	var op = '';
		
	op +='<option selected class="camposFormulario">De compras, taquilla ...</option>';
	document.write (op);
	for (n=0; n<opciones.length; n+=2)
		cad += '<option class="camposFormulario" value="'+ (n+1) +'">'+ opciones[n] +'</option>';
		document.write (cad);
		
}

 

function objCapa(idCapa)
{
    if (document.layers) return document.layers[idCapa];
    else return document.all(idCapa);
}

function abrirWnd(url)
{
    var tmp = url.substr(0, 5).toUpperCase();
    if (tmp != 'HTTP:' && tmp != 'HTTPS') url = base + url;

    window.open(url);
}

//-- Ventana sin botones
function abrirWnd2(url, ancho, alto, nombreVentana)
{
    var w;
    var h;
    if (ancho == null) w = 625;
    else w = ancho;
    if (alto == null) h = 400;
    else h = alto;

    var tmp = url.substr(0, 5).toUpperCase();
    if (tmp != 'HTTP:' && tmp != 'HTTPS') url = base + url;
    venta=window.open(url, nombreVentana, "top=0,left=0,toolbar=no,directories=no,location=no,status=no,scrollbars=yes,resizable=yes,copyhistory=no,width="+ w +",height="+ h);
}

//-- Ventana de documentos
function abrirWnd3(url)
{
    venta=window.open(base+"wvio004m_documentos.asp?fich="+url,"", "top=0,left=0,toolbar=no,directories=no,location=no,status=no,scrollbars=yes,resizable=yes,copyhistory=no,width=500,height=400");
}


//-- Ventana sin botones a 800x600
function abrirWnd4(url, ancho, alto)
{
    var w;
    var h;
    if (ancho == null) w = 790;
    else w = ancho;
    if (alto == null) h = 590;
    else h = alto;

    var tmp = url.substr(0, 5).toUpperCase();
    if (tmp != 'HTTP:' && tmp != 'HTTPS') url = base + url;
    venta=window.open(url,"", "top=0,left=0,toolbar=no,directories=no,location=no,status=no,scrollbars=yes,resizable=yes,copyhistory=no, width="+ w +",height="+ h);
}

function abrirWnd5(url, ancho, alto)
{
    var param;
    var w;
    var h;
    if (ancho == null) w = 790;
    else w = ancho;
    if (alto == null) h = 590;
    else h = alto;

    param="?contenido=" + url;
    var tmp = url.substr(0, 5).toUpperCase();
    if (tmp != 'HTTP:' && tmp != 'HTTPS') url = base + url;
    venta=window.open(url,'ventana_principal', "top=0,left=0,toolbar=yes,directories=yes,location=yes,status=yes,scrollbars=yes,resizable=yes,copyhistory=no, width="+ w +",height="+ h);
}

//-- Recarga los frames de PARTICULAR con https
function abrirWnd6(url)
{
    top.location = baseHttps + 'wvio004m_particular.asp?contenido=' + url;
}

//-- Recarga los frames de EMPRESA con https
function abrirWnd7(url)
{
    top.location = baseHttps + 'wvio004m_empresa.asp?contenido=' + url;
}

//-- Recarga los frames de NETCLUB con https
function abrirWnd8(url)
{
    top.location = baseHttps + 'wvio004m_netclub.asp?contenido=' + url;
}

//-- Ventana de documentos INGLES
function abrirWnd9(url)
{
    venta=window.open(base+"wvio004m_documentosI.asp?fich="+url,"", "top=0,left=0,toolbar=no,directories=no,location=no,status=no,scrollbars=yes,resizable=yes,copyhistory=no,width=500,height=400");
}

function abrirWndActiva(url, ancho, alto)
{
    var w;
    var h;
    if (ancho == null) w = 790;
    else w = ancho;
    if (alto == null) h = 590;
    else h = alto;

    var tmp = url.substr(0, 5).toUpperCase();
    if (tmp != 'HTTP:' && tmp != 'HTTPS') url = base + url;
    venta=window.open(url,"", "menubar=yes,top=0,left=0,toolbar=yes,directories=yes,location=yes,status=yes,scrollbars=yes,resizable=yes,copyhistory=no, width="+ w +",height="+ h);
}


function abrir_ventana(url, titulo)
{
	venta=window.open(url,titulo);
	venta.focus();
}

function abrir_ventana_cdr(url, titulo)
{
	venta=window.open(url,titulo,"toolbar=no, location=no, directories=no, status=yes, menubar=no, scrollbars=yes, resizable=no, hotkeys=no, copyhistory=no,width=790,height=553,top=0,left=0",true);
	venta.focus();
}

function abrir_ventana4(url, titulo, ancho, alto)
{
	var w;
	if (ancho == null) w = 500;
	else w = ancho;
	if (alto == null) h = 400;
	else h = alto;
	venta=window.open(url,titulo, "top=0,left=0,toolbar=no,directories=no,location=no,status=no,scrollbars=yes,resizable=yes,copyhistory=no,width="+ w +",height="+ h);
}

//redirecciona la pagina que inicialmente esta sin frames a la situación inicial dentro del frame contenido
function sinFrame()
{
	if(protocolo=='HTTP:')
	{
		if (typeof(buscaPagina) == 'undefined')
		{
			buscaPagina="particular";
		}
   
	   	if (typeof(parent.frames['contenido']) == 'undefined')
	   	{ 
	        	if (buscaPagina=="particular") 
				document.location.replace(base+"wvio004m_particular.asp?contenido="+ escape(location.href));
			else if (buscaPagina=="empresa") 
				document.location.replace(base+"wvio004m_empresa.asp?contenido="+ escape(location.href));
	        	else if (buscaPagina=="netclub") 
				document.location.replace(base+"wvio004m_netclub.asp?contenido="+ escape(location.href));		
	        	else if (buscaPagina=="emigrantes") 
				document.location.replace(base+"wvio004m_emigrantes.asp?contenido="+ escape(location.href));		
			else if(buscaPagina=="mediweb")
				document.location.replace(base+"wvio004m_mediweb.asp?contenido="+ escape(location.href));
		}
	  	else 
		{
			if(typeof(parent.opener)!= 'undefined')
		      	{
				if (document.all) 
				{
					try
					{
			 	   		parent.document.title = document.title;
		 	   		}
		 	   		catch(e)
		 	   		{
		 	   		}
		 		}
		     	}
		}
	}
}


//- ocultarAtras: si 'true' (por defecto) NO se muestra la imagen de volver. En caso contrario se muestra si hay algo
// en la historia
// conframes: si 'true' (por defecto) Se abrira la pagina con frames. 
// si 'false' Se abrira la pagina sola sin meterla dentro del frame de caixa
function crearPiePagina(ocultarAtras,conframes)
{

    var cad;
    var cont = (document.layers) ? 1 : 0;
   
    cad = '<br><table width="100%" border="0" cellpadding=0 cellspacing=2>';
    cad +='<tr><td width="100%">';
    
    if (typeof(buscaPagina) == 'undefined')
	buscaPagina="particular";

    if (history.length>cont && ocultarAtras!=true) cad += '<a href="javascript:history.back()"><span class="sepSeccion"><img border=0 src="'+base+'images/wvio004m_atras.gif"></span><span class="txtPie">Atr&aacute;s</span></a>';

    cad +='</td>';
    cad +='<td align=right>';
    cad +='<a href="javascript:void(0)" onclick="location.hash=\'top\';">';
    cad +='<span class="txtPie">Subir</span>';
    cad +='<span class="sepSeccion">';
    cad +='<img border="0" src="'+base+'images/wvio004m_arriba.gif">';
    cad +='</span>';
    cad +='</a>';
    cad +='</td>';
    cad +='</tr>';
    cad +='<tr><td colspan=2 class=linPiePag><img src="'+base+'images/wvio004m_pto.gif"></td></tr>';
    cad +='<tr><td colspan=2 class=txtPiePag align="center">'+ (new Date).getFullYear() +' Caixa Galicia. Todos los derechos reservados.</td></tr>';
    cad +='<tr><td align="center" colspan=2><a href="javascript:abrirWnd2(\'' + base +'wvio004_contenido/ESP/pags/wvio004m_AVISOLEGAL.htm\',null,null,null);" style="text-decoration:none"><span class="txtPiePag">Aviso Legal - </span></a>';
	cad +='<a href="javascript:abrirWnd2(\'' + base + 'wvio004_contenido/ESP/pags/wvio004m_POLITICA_PRIVACIDAD.htm\',null,null,null);" style="text-decoration:none"><span class="txtPiePag">Pol&iacute;tica de Privacidad </span></a>';
	if (buscaPagina!="netclub") 
		cad +='<a href="' + base + 'wvio004_contenido/esp/asp/wvio004c_mapaweb.asp" style="text-decoration:none"><span class="txtPiePag">- Mapa Web</span></a>';
    cad +='</td></tr></table>';
    cad +='<script type="text/javascript" src="http://as00.estara.com/as/InitiateCall2.php?accountid=200106283305&amp;Template=68945"></script>';
    document.write(cad);
    crearEstadistica();
	//if (conframes!=false){sinFrame();}
	//if (conframes!=false){setTimeout('sinFrame();',100);}

}

function crearPiePaginaIngles(ocultarAtras,conframes)
{
  
    var cad;
    var cont = (document.layers) ? 1 : 0;
    
    cad = '<br><table width="100%" border="0" cellpadding=0 cellspacing=2>';
    cad +='<tr><td width="100%">';
    
    if (typeof(buscaPagina) == 'undefined')
	buscaPagina="particular";

    if (history.length>cont && ocultarAtras!=true) cad += '<a href="javascript:history.back()"><span class="sepSeccion"><img border=0 src="'+base+'images/wvio004m_atras.gif"></span><span class="txtPie">Back</span></a>';

    cad +='</td>';
    cad +='<td align=right>';
    cad +='<a href="javascript:void(0)" onclick="location.hash=\'top\';">';
    cad +='<span class="txtPie">Up</span>';
    cad +='<span class="sepSeccion">';
    cad +='<img border="0" src="'+base+'images/wvio004m_arriba.gif">';
    cad +='</span>';
    cad +='</a>';
    cad +='</td>';
    cad +='</tr>';
    cad +='<tr><td colspan=2 class=linPiePag><img src="'+base+'images/wvio004m_pto.gif"></td></tr>';
    cad +='<tr><td colspan=2 class=txtPiePag align="center">'+ (new Date).getFullYear() +' Caixa Galicia. Todos los derechos reservados.</td></tr>';
    cad +='<tr><td align="center" colspan=2><a href="javascript:abrirWnd2(\'' + base +'wvio004_contenido/ESP/pags/wvio004m_AVISOLEGAL.htm\',null,null,null);" style="text-decoration:none"><span class="txtPiePag">Aviso Legal - </span></a>';
    cad +='<a href="javascript:abrirWnd2(\'' + base + 'wvio004_contenido/ESP/pags/wvio004m_POLITICA_PRIVACIDAD.htm\',null,null,null);" style="text-decoration:none"><span class="txtPiePag">Pol&iacute;tica de Privacidad </span></a>';
    if (buscaPagina!="netclub") 
		cad +='<a href="' + base + 'wvio004_contenido/esp/asp/wvio004c_mapaweb.asp" style="text-decoration:none"><span class="txtPiePag">- Mapa Web</span></a>';
    cad +='</td></tr></table>';
    cad +='<script type="text/javascript" src="http://as00.estara.com/as/InitiateCall2.php?accountid=200106283305&amp;Template=68945"></script>';
    document.write(cad);
    crearEstadistica();
    if (conframes!=false){sinFrame();}
       	
}

function crearEstadistica()
{
	//Nielsen 5.1
	//if (parseInt(navigator.appVersion)>=4) {
    //   _rsCL='<scr'+'ipt language="JavaScript" type="text/javascript" src="'+_rsND+'v5.js"><\/scr'+'ipt>';
  	//} else {
    //	_rsCL='<img src="'+_rsND+'cgi-bin/m?ci='+_rsCI+'&cg='+_rsCG+'&si='+_rsSI+'&rp='+_rsRP+'">';
  	//}
  
	//Nielsen 5.2
  	if (parseInt(navigator.appVersion)>=4) 
	{
		//_rsCL='<scr'+'ipt language="JavaScript" type="text/javascript" src="'+_rsND+'v5.js"><\/scr'+'ipt>';
		_rsCL='<script type="text/javascript" src="'+_rsND+'v52.js"></script>';
  	}
  	else
  	{
    	//_rsCL='<img src="'+_rsND+'cgi-bin/m?ci='+_rsCI+'&cg='+_rsCG+'&si='+_rsSI+'&rp='+_rsRP+'">';
		_rsCL='<img src="'+_rsND+'cgi-bin/m?ci='+_rsCI+'&amp;cg='+_rsCG+'" alt=""/>';
  	}
  
  	var sc=document.createElement('script');
	sc.type="text/javascript";
	sc.src="http://www.google-analytics.com/urchin.js";
	
	try
	{
		var sc_in=document.createElement('script');
		sc_in.type="text/javascript";
		sc_in.innerHTML='_uacct="UA-1210457-9";urchinTracker();';
	}
	catch(e)
	{
		try
		{
			sc.onreadystatechange=function(){ try{ _uacct="UA-1210457-9";urchinTracker();}catch(e){} };
		}
		catch(e)
		{
			try
			{
				sc.onload=function(){ _uacct="UA-1210457-9";urchinTracker(); };
			}
			catch(e)
			{
				try
				{
					console.error(e.name+'-'+e.message);
				}
				catch(e)
				{}
			}
		}
	}
		
	document.getElementsByTagName('head')[0].appendChild(sc);
	document.write(_rsCL);
}

function cambiaImg(obj, sImg)
{
    document.images[obj].src = sImg;
}

function recomendar(titulo,url)
{
    if ((typeof(titulo)=='unknown') || (titulo==null)) titulo='';
    if ((typeof(url)=='unknown') || (url==null)) url='';
    
    if ((url != '') && (url.indexOf('http://')==-1) && (url.indexOf('HTTP://')==-1)) url = base + url;

    var pagina = 'wvio004_contenido/esp/asp/wvio004c_Recomendar.asp?titulo=' + titulo + '&url=' + url;
    var ventana = abrirWnd4(pagina, 410, 410);
}

function setCookie2(name, value, expires, path, domain, secure) {
  var curCookie = name + "=" + escape(value) +
      ((expires) ? "; expires=" + expires.toGMTString() : "") +
      ((path) ? "; path=" + path : "") +
      ((domain) ? "; domain=" + domain : "") +
      ((secure) ? "; secure" : "");
  document.cookie = curCookie;
}

function SetCookie (name, value, expires, path, domain, secure) {
     var argv = SetCookie.arguments;

     var argc = SetCookie.arguments.length;

     var expires = (argc > 2) ? argv[2] : null;
     var path = (argc > 3) ? argv[3] : null;
     var domain = (argc > 4) ? argv[4] : null;
     var secure = (argc > 5) ? argv[5] : false;
     document.cookie = name + "=" + escape (value) +
       ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
       ((path == null) ? "" : ("; path=" + path)) +
       ((domain == null) ? "" : ("; domain=" + domain)) +
       ((secure == true) ? "; secure" : "");
   }
   
function DeleteCookie (name) {
     var exp = new Date();
     exp.setTime (exp.getTime() - 1);  // This cookie is history
     var cval = GetCookie (name);
     document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
   }

 function getCookieVal (offset) {
     var endstr = document.cookie.indexOf (";", offset);
     if (endstr == -1)
       endstr = document.cookie.length;
     return unescape(document.cookie.substring(offset, endstr));
   }
   function GetCookie (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;
   }

   
      function saveCookie(name, data, expires) {
          var expDate = expires
          if (expDate != "") {
              expDate = "; expires=" + expDate.toGMTString() 
          }
          //alert ("The cookie: " + name + "=" + escape(data) + expDate )
          document.cookie = name + "=" + escape(data) + expDate
      }
      


//---------------------- Carga los banner. Solo para compatibilidad con NS47
var GC_matBanner=new Array();
function GC_addBanner(id, url)
{	
	if (GC_matBanner==null) GC_matBanner = new Array();
	GC_matBanner[GC_matBanner.length] = [id, url];	
}

function GC_iniBanner()
{
	var i;
	
	if (document.layers==null) return;
	for (i=0; i<GC_matBanner.length;i++) 
	{
		GC_escribeBannerNS(GC_matBanner[i][0], GC_matBanner[i][1]);
	}		
}

function GC_escribeBannerNS(sCapa, sUrl) 
{
   	var obj = document.layers[sCapa];	
   	var ancho = obj.clip.width;
   	var alto = obj.clip.height;
   	var lay = new Layer (ancho, obj);
   	lay.document.open();
    lay.document.write('<layer src="'+ sUrl +'" top=0 left=0 width='+ancho+' height='+alto+'></layer>'); 
    lay.document.close();    
    lay.visibility = 'show';
    return true;
}

if (document.layers) window.onload=GC_iniBanner;

//----------------------------------------------
/*
function abrirWnd9(url)
{    
    window.open(url, "", "top=0,left=0,toolbar=no,directories=no,location=no,status=no,scrollbars=no,resizable=no,copyhistory=no,width=698,height=553");
//	window.open(base + url,'_blank','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=644,height=459');
}
*/

function ver_opcion_menu(el)
{
	if (el.parentNode.getElementsByTagName('ul')[0])
	{
		if (el.parentNode.getElementsByTagName('ul')[0].className == 'oculto')
		{
			el.parentNode.className=el.parentNode.className + ' desplegado';
			el.parentNode.getElementsByTagName('ul')[0].className = ''
		}
		else
		{
			el.parentNode.className=el.parentNode.className.replace('desplegado','');			
			el.parentNode.getElementsByTagName('ul')[0].className = 'oculto';
		}
	}
			
}