/*<span id="tcm:7-85159_tcm:7-289459-32">
*/

function goHome(strSection) {
	var strRepsolYPFMedia;
	strRepsolYPFMedia = getSiteActual("repsolypfmedia/").toLowerCase();

	if (strSection == null) {
		strRepsolYPFMedia = getSiteActual("");
	}
	else {

		// se le añade la barra al final para mantener la funcionalidad en caso que la función sea llamada desde la URL relativa
		// publicacion/repsolypfmedia/, porque en ese caso strSection = "/es_es/repsolypfmedia" y no contiene  la cadena buscada
		strSection = strSection + "/";

		if (strSection.toLowerCase().indexOf(strRepsolYPFMedia) < 0) {
			strRepsolYPFMedia = getSiteActual("");
		}

	}
            
	window.open (fncURLHome(0, strRepsolYPFMedia), "_top");    
}

function goHome2() {
    window.location = fncURLHome(0, getSiteActual(""));
}

function fncURLHome(intProtocolo, strRuta) {
    var strProtocolo;

    if (intProtocolo == 1) {
        strProtocolo = "https://";
    }
    else {
        strProtocolo = "http://";
    }

    if (strRuta == "") {
        strRuta = "/";
    }

    return (strProtocolo + window.location.hostname + strRuta);
}

function favoritos() {
	window.external.AddFavorite(location.href, document.title);
}
function alertas() {
	window.open ( getSiteActual("todo_sobre_repsol_ypf/informacion_para_accionistas_e_inversores/alertas_de_informacion_corporativa/"), "_top" );
}
function imprimir() {
	var printSelectionDIV = document.getElementById('printSelection');

	if (printSelectionDIV != null) {
		printContent('printSelection');
	} else {
		window.print();
	}
}

function guiaCampsa() {
    window.open (fncURLHome(0, "/sa/herramientas/abreguia/abreguia.aspx"), "_top" );
}

function goURL(intTipo, strRutaRelativa, inTarget) {
    if (intTipo == 4) {
        strRutaTotal = getServerURL (strRutaRelativa, 2, 0) + 'el_tiempo/';
    } else {
        if (intTipo == 1) {
            strRutaTotal =  fncURLHome(0, strRutaRelativa);
        } else {
            strRutaTotal = getServerURL (strRutaRelativa, intTipo, 0);
        }
    }
    if (inTarget == 0) {
        window.open ( strRutaTotal, "_top" );
    } else {
        window.open ( strRutaTotal, "_new" );
    }
}

function pintaFlashRefino(sRefineria) {
	sRutaFlash = '/imagenes/'
	sRutaFlash += getSiteActual('/caja_refineria__169367_tcm7-228374.swf')
	sRutaFlash += '?nomrefineria=' + sRefineria;
	sRutaGcampsa = getServerURL (ruta,2,0);
	sRutaEltiempo = getSiteActual('el_tiempo/');
	document.write('<object id="three_tier" codebase="http://active.macromedia.com/flash2/cabs/swflash.cab#version=3,0,0,0" height="135" width="400" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000">');
	document.write('<param name="_cx" value="10583">');
	document.write('<param name="_cy" value="3572">');
	document.write('<param name="FlashVars" value="">');
	document.write('<param name="Movie" value="' + sRutaFlash + '">');
	document.write('<param name="Src" value="' + sRutaFlash + '">');
	document.write('<param name="WMode" value="Transparent">');
	document.write('<param name="Play" value="0">');
	document.write('<param name="Loop" value="-1">');
	document.write('<param name="Quality" value="High">');
	document.write('<param name="SAlign" value="">');
	document.write('<param name="Menu" value="0">');
	document.write('<param name="Base" value="">');
	document.write('<param name="AllowScriptAccess" value="">');
	document.write('<param name="Scale" value="ShowAll">');
	document.write('<param name="DeviceFont" value="0">');
	document.write('<param name="EmbedMovie" value="0">');
	document.write('<param name="BGColor" value="FFFFFF">');
	document.write('<param name="SWRemote" value="">');
	document.write('<param name="MovieData" value="">');
	document.write('<param name="SeamlessTabbing" value="1">');
	document.write('<param name="Profile" value="0">');
	document.write('<param name="ProfileAddress" value="">');
	document.write('<param name="ProfilePort" value="0">');
	document.write('<embed src="' + sRutaFlash + '" swliveconnect="FALSE" width="400" height="135" quality="autohigh" wmode="transparent" bgcolor="#ffffff" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash">');
	document.write('</embed>');
	document.write('</object>');
}

function enviarCV(paisOferta, referenciaOferta) {
	if (referenciaOferta != null){
		if (paisOferta == "espana") {
			window.open ( getSiteActual("todo_sobre_repsol_ypf/trabaja_con_nosotros/espana/titulados_superiores/curriculum.aspx?procedencia=12&numOferta=" +  referenciaOferta + ""), "_top" );
		} 
		if (paisOferta == "argentina") {
			window.open ( getSiteActual("todo_sobre_repsol_ypf/trabaja_con_nosotros/argentina/nuevos_profesionales/curriculum.aspx?procedencia=23&numOferta=" + referenciaOferta + ""), "_top" );
		}
		if (paisOferta == "ecuador") {
			window.open ( getSiteActual("todo_sobre_repsol_ypf/trabaja_con_nosotros/ecuador/titulados_superiores/curriculum.aspx?procedencia=68&numOferta=" + referenciaOferta + ""), "_top" );
		}
		if (paisOferta == "peru") {
			window.open ( getSiteActual("todo_sobre_repsol_ypf/trabaja_con_nosotros/peru/nuevos_profesionales/curriculum.aspx?procedencia=62&numOferta=" + referenciaOferta + ""), "_top" );
		}
		if (paisOferta == "bolivia") {
			window.open ( getSiteActual("todo_sobre_repsol_ypf/trabaja_con_nosotros/bolivia/nuevos_profesionales/curriculum.aspx?procedencia=65&numOferta=" + referenciaOferta + ""), "_top" );
		}
		if (paisOferta == "venezuela") {
			window.open ( getSiteActual("todo_sobre_repsol_ypf/trabaja_con_nosotros/venezuela/curriculum.aspx?procedencia=71&numOferta=" + referenciaOferta + ""), "_top" );
		}
	}else{
		if (paisOferta == "espana") {
			window.open ( getSiteActual("todo_sobre_repsol_ypf/trabaja_con_nosotros/espana/titulados_superiores/curriculum.aspx?procedencia=12"), "_top" );
		} 
		if (paisOferta == "argentina") {
			window.open ( getSiteActual("todo_sobre_repsol_ypf/trabaja_con_nosotros/argentina/nuevos_profesionales/curriculum.aspx?procedencia=23"), "_top" );
		}
		if (paisOferta == "ecuador") {
			window.open ( getSiteActual("todo_sobre_repsol_ypf/trabaja_con_nosotros/ecuador/titulados_superiores/curriculum.aspx?procedencia=68"), "_top" );
		}
		if (paisOferta == "peru") {
			window.open ( getSiteActual("todo_sobre_repsol_ypf/trabaja_con_nosotros/peru/nuevos_profesionales/curriculum.aspx?procedencia=62"), "_top" );
		}
		if (paisOferta == "bolivia") {
			window.open ( getSiteActual("todo_sobre_repsol_ypf/trabaja_con_nosotros/bolivia/nuevos_profesionales/curriculum.aspx?procedencia=65"), "_top" );
		}
		if (paisOferta == "venezuela") {
			window.open ( getSiteActual("todo_sobre_repsol_ypf/trabaja_con_nosotros/venezuela/curriculum.aspx?procedencia=71"), "_top" );
		}
	}
}
function autoclub() {
	window.open ( getSiteActual('autoclub/autoclub/portada/'), "_top" );
}
function motor() {
	window.open ( getSiteActual('motor/'), "_top" );
}
function competicion() {
	window.open ( getSiteActual('competicion/'), "_top" );
}
function guia_repsol() {
	window.open ( getSiteActual('guia_repsol/'), "_top" );
}

function casayhogar() {
	window.open ( getSiteActual('casa_y_hogar/'), "_top" );
}

function tienda() {
                window.open (getServerURL ("/", 3, 0), "_top" );
}

function eltiempo()
{
              window.open ( getSiteActual('el_tiempo/'), "_top" );
}


function ventajas() {
	window.open ( getSiteActual('ventajas_del_portal/'), "_top" );
}
function productosyservicios() {
	window.open ( getSiteActual('productos_y_servicios/'), "_top" );
}
function tsry() {
	window.open ( getSiteActual('todo_sobre_repsol_ypf/'), "_top" );
}


function alvolante() {
	window.open ( getSiteActual('al_volante/'), "_top" );
}
function selecnacional() {
	window.open ( getSiteActual('seleccion/seleccion_nacional/portada/'), "_top" );
}
function guiaypf() {
	window.open ( "http://www.guiacampsa.com/GUIAYPF/ar_es/home/home.aspx", "_top" );
}

function stockcar() {
	window.open ( getSiteActual('competicion/stock_car_v8/'), "_top" );
}

function nuestroselegidos() {
	window.open ( getSiteActual('nuestros_elegidos/carlo_de_gavardo/'), "_top" );
}

function velocidade() {
	window.open ( getSiteActual('competicion/_velocidade/'), "_top" );
}

function consultaextracto(){

         var strValOK = "0123456789";
         var sValor;
         var bOk = true;
         sValor = document.Consulta.Valor.value.replace(" ", "");
					
                if (sValor=="")
	{
		alert('Introduzca los primeros seis digitos\nde su Tarjeta Repsol');
		bOk = false;
	}
	if (sValor.length<6 && bOk)
	{
		alert('Introduzca 6 digitos');
		bOk = false;
	}
                 if (bOk)
	{
		for (i = 0; i < sValor.length; i++) {
		        ch = sValor.charAt(i);
		         for (j = 0; j < strValOK.length; j++) {
		                    if (ch == strValOK.charAt(j)) {
		                    break;
		                    }
		           }
		           if (j == strValOK.length) {
		                    bOk = false;
			    alert('Introduzca valores numericos');
		                    break;
		           }
                                }
                }

                if (bOk)
	{
		if (sValor==409015 || sValor== 409016 || sValor== 409017) {
			window.open ("http://www.bbvanet.com", "_new");
		}
		else {
		        if (sValor==402040  || sValor== 459996  || sValor== 459997 || sValor== 409013 || sValor== 409014) {
                                                       window.open ( getSiteActual('productos_y_servicios/tarjetas/visa_repsol/consulta_de_extracto/Caixa.aspx'), "_top" );
		       }
		}
                     }
}





function formula1() {
	window.open ( getSiteActual('competicion/formula_1/portada/'), "_top" );
}

function moto() {
	window.open ( getSiteActual('competicion/motociclismo/portada/'), "_top" );
}

function rally() {
	window.open ( getSiteActual('competicion/rally/portada/'), "_top" );

}
function repsolmove() {
	window.open ( getSiteActual('productos_y_servicios/tarjetas/solred_puntos/introduo/'), "_top" );
}

function serviclub() {
	window.open ( 'sa/serviclub/', "_top" );
}

function piibe() {
        window.open ( getSiteActual('piibe/pub/proyecto_piibe/'), "_top" );
}


function usuariosRegistrados(reqPath,tienda) {
	// Mirar si estoy en un iframe
        if (parent.length > 0 ) { 
        	// En el caso que se llame a esta función desde un iframe la url de vuelta la recibimos ya 
                // Si ésta es vacía le mandamos a la home del portal
                if (tienda != "")
                {
	window.open ( getServerURL('/Tienda/login.asp?url=' + reqPath, 3, 1) , "_top");
	return;
                }
                
                if ( reqPath == ""  || reqPath == undefined ) { 
                	reqPath = getServerURL('', 1, 0)
                }
        } else {    
		// En caso contrario, si es una cabecera normal se coge la url
		reqPath = location.href;      
	} 
	// LA url destino tiene la pagina de logout y falta concatenarle la url de la pagina de vuelta. 
	reqPath = reqPath.replace('&' , '%26'); 
    
	window.open ( getServerURL(getSiteActual('herramientas/FormsLoginGenerico/default.aspx?URLPagina=' + reqPath), 1, 0), "_top");
} 





function registrate() {
		var	Url  = getSiteActual('herramientas/Registro/HomeRegistro.aspx')
        window.open ( "http://www.repsolypf.com" + Url, "_top" );
}

function recordarPass() {

	var	Url  = getSiteActual('herramientas/Registro/Recordar.aspx');
	window.open ( "http://www.repsolypf.com" + Url , "_top" );
}

function modificarUsu() { 
        window.open ( "/SA/herramientas/Registro/particulares/login.aspx?entry=seleccionopcion.aspx&noentry=../home/registro.aspx&tiporegistro=P", "_top" ); 
}


function getSiteActual(ruta) {
	return "/es_es/" + ruta;
}

function AbrirVentanaNueva(URL) {
	window.open (URL,"_new");
    }

function AbrirPopUp(URL,ancho,alto,izq,sup) {
	var Sx=((screen.availWidth - ancho)/2)-5;
	var Sy=((screen.availHeight - alto)/2)-15;
	window.open (URL,'new','width=' + ancho + 'px,height=' + alto + 'px,top=' + Sy + 'px,left=' + Sx + 'px,directories=0,scrollbars=1,status=0,location=0');
	}

function AbrirVentana(URL) {
        if (URL!="CHSEL") {
                creaCulturaActual(URL);
                window.open("http://www.repsolypf.com/" + URL + "/", "_top");
        }
        else {
                window.open("http://www.repsolypf.com/default.aspx?C=S", "_top");
        }

}

function AbrirVentanaEx(Protocol, URL, Ancho, Alto, ToolBar, MenuBar, LocationBar, StatusBar, ScrollBars, Resizable)
{
	var Page = "/comunes/b2b/Redirectb2b.asp";

    var Sw = Ancho;
    var Sh = Alto;
    var Sl = ((screen.availWidth - Ancho) / 2) - 5;
    var St = ((screen.availHeight - Alto) / 2) - 15;

    if (ScrollBars == 1)
    {
        Sw = Sw + 17;
        Sh = Sh + 17;
    }

    window.open (Page + "?Protocol=" + Protocol + "&URL=" + escape(URL), 'repsolypf', 'width=' + Sw + 'px,height=' + Sh + 'px,top=' + St + 'px,left=' + Sl + 'px,toolbar=' + ToolBar + ',menubar=' + MenuBar + ',location=' + LocationBar + ',status=' + StatusBar + ',scrollbars=' + ScrollBars + ',resizable=' + Resizable);
}

function eventoClick (eClick) {
    if (!eClick) var eClick = window.event;
    var oTarget = eClick.target || eClick.srcElement;

    if (oTarget.nodeType == 3) oTarget = oTarget.parentNode;

    if (oTarget.nodeName.toUpperCase() == "A") {
        var sUrlLink = oTarget.href.toLowerCase();
        var sUrlInter = "includes/_tcmInterIdioma.aspx".toLowerCase();
        var sTagJS = "javascript:".toLowerCase();
        if ((sUrlLink.indexOf(sUrlInter) >= 0) && (sUrlLink.indexOf(sTagJS) < 0)) {
            popupInteridioma (oTarget);
            return false;
        }
        else {
            return true;
        }
    }
    else {
        return true;
    }
}

function popupInteridioma (strUrl) {
    var intMaxAncho = 575;
    var intMaxAlto = 230;
    var intAncho = (screen.availWidth * 0.95);
    var intAlto = (screen.availHeight * 0.95);
    if (intAncho > intMaxAncho) intAncho = intMaxAncho;
    if (intAlto > intMaxAlto) intAlto = intMaxAlto;
    var intTop = (screen.availHeight / 2) - (intAlto / 2);
    var intLeft = (screen.availWidth / 2 ) - (intAncho / 2);

    var strParametros;
    strParametros = "top=" + intTop;
    strParametros += ",left=" + intLeft;
    strParametros += ",width=" + intAncho;
    strParametros += ",height=" + intAlto;
    strParametros += ",toolbar=no";
    strParametros += ",location=no";
    strParametros += ",directories=no";
    strParametros += ",status=no";
    strParametros += ",menubar=no";
    strParametros += ",scrollbars=no";
    strParametros += ",resizable=no";
    strParametros += ",copyhistory=yes";
    window.open (strUrl, "", strParametros);
}

function creaCulturaDefecto(cultura)
{

 var d = new Date("January 31, 2050");
 SetCookie("DefaultCulture",cultura,d,"/",".repsolypf.com");
 if (getCookie("CurrentCulture")!=cultura) SetCookie("CurrentCulture",cultura,d,"/",".repsolypf.com");
}

function creaCulturaActual(cultura)
{

        SetCookie("CurrentCulture",cultura,"","/",".repsolypf.com");

}

function obtenerCulturaDefecto()
{
        return getCookie("DefaultCulture");
}

function obtenerCulturaActual()
{
        return getCookie("CurrentCulture");
}
function getCookie(name)
{
        var strCookies = document.cookie;
        var index = strCookies.indexOf(name + "=");

        if (index == -1)
        {
                return '';
        }
        else
        {
                var startstr = strCookies.indexOf("=", index) + 1;
                var endstr = strCookies.indexOf(";", index);

                if (endstr == -1)
                {
                        endstr = strCookies.length;
                }

                return unescape(strCookies.substring(startstr , endstr));
        }
  }

function SetCookie (nombre,valor,expiracion,path,dominio,segura) {
        var c = nombre + "=" + escape (valor) +
            ((expiracion) ? "; expires=" + expiracion.toGMTString() : "") +
            ((path) ? "; path=" + path : "") +
            ((dominio) ? "; domain=" + dominio : "") +
            ((segura) ? "; secure" : "");
        document.cookie = c;
}

function DeleteCookie(nombre,path,dominio) {
  if (getCookie(nombre)) {
        var d = new Date("January 01, 70");
        SetCookie(nombre,"",d,path,dominio);

  }
}

function GetObjectByName(n, d) {
	var p,i,x;
	if(!d)
		d=document;
	if((p=n.indexOf("?")) > 0 && parent.frames.length)
	{
		d=parent.frames[n.substring(p+1)].document;
		n=n.substring(0,p);
	}
	if(!(x=d[n]) && d.all)
		x=d.all[n];
	for (i=0;!x&&i<d.forms.length;i++)
		x=d.forms[i][n];
	for(i=0;!x&&d.layers&&i<d.layers.length;i++)
		x=findObj(n,d.layers[i].document);
	return x;
}

function Home_Galeria_Mostrar()
{
	var i,p,v,obj,args=Home_Galeria_Mostrar.arguments;

	for (i=0; i<(args.length-2); i+=3)
	{
		if ((obj=GetObjectByName(args[i])) != null)
		{
			v=args[i+2];
			if (obj.style)
			{
				obj=obj.style;
			}
			obj.display=v;
		}
	}
}


function Home_Galeria_Ocultar()
{
	var i,args=Home_Galeria_Ocultar.arguments;
	for (i=0; i<args.length; i++)
	{
		Home_Galeria_Mostrar(args[i],'','none');
	}
}

function cv2(URL) {
	window.opener.location = URL;
	window.opener.focus();
	}

function mandarInterIdioma(formulario) {
	eval("document." + formulario + ".submit()");
}

function tcmBuscarGeneral(texto) {

        document.tcmBuscar.target = "_top";
		var Url  = getSiteActual('herramientas/buscadorweb/default.aspx');
		document.tcmBuscar.action ="http://www.repsolypf.com" + Url;
        document.tcmBuscar.texto.value=texto;
		document.tcmBuscar.submit();
	   }

function abreess(){
	location.href="/se/gerenteseess/acceso.asp"
}

function enviar(path,titulo) {
	var strHref = window.location.href;
	var arrURL = strHref.split("/");
	// Ejemplo: http://www.repsolypf.com/es_es
	//arrURL[0] = http: | arrURL[1] = | arrURL[2] = www.repsolypf.com | arrURL[3] = es_es

	if (path.indexOf("http") == -1 )
	{
		path = "http:/" + arrURL[1] + "/" + arrURL[2] + path;
	}

	var propiedades = "toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=450,height=450,top=50,left=200";

	window.open ( "/es_es/herramientas/EnviarAmigo/Default.aspx?titulo=" + titulo + "&link=" + path, "Amigo" , propiedades );
}


/* SteveW */
function printContent(nombre) {
	var _tcmContent = document.getElementById(nombre);
	var printWindow = window.open(' ', 'popimpr', 'toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=520,height=450,top=0,left=0');

	printWindow.document.write( "<html><head><title>" + document.title + "</title>");
	printWindow.document.write( "<link rel=\"stylesheet\" type=\"text/css\" id=\"tcmPrintWindow\" media=\"all\" href=\"" + document.styleSheets[0].href + "\" />");
	printWindow.document.write( "</head><body>" );
	printWindow.document.write( _tcmContent.innerHTML );
	printWindow.document.write( "</body></html>" );

	printWindow.document.close();
	printWindow.print( );
	printWindow.close();
}



function getServerURL(ruta, tipo, protocol) {
	var sReturn = "";

	if (protocol == 1) {
		sReturn = "https://";
	} else {
		sReturn = "http://";
	}

	if (tipo == 0) {
		sReturn = sReturn + "servicios.repsolypf.com";
	} else if (tipo == 1) {
		sReturn = sReturn + "www.repsolypf.com";
	} else if (tipo == 2) {
		sReturn = sReturn + "www.guiacampsa.com";
	} else if (tipo == 3) {
		sReturn = sReturn + "tienda.repsolypf.com";
	}

	return sReturn + ruta;
}


function LogOut(urlDestino, urlOrigen)
{
           // Mirar si estoy en un iframe
                if (parent.length > 0 )
                {
                        // En el caso que se llame a esta función desde un iframe la url de vuelta la recibimos ya
                        // Si ésta es vacía le mandamos a la home del portal
                if (urlOrigen == "")
                {
                                urlOrigen = getServerURL('', 1, 0)
                }
                }
                else
                {
                // En caso contrario, si es una cabecera normal se coge la url
                        urlOrigen = location.href;
                }
        // LA url destino tiene la pagina de logout y falta concatenarle la url de la pagina de vuelta.
        urlDestino = urlDestino + urlOrigen.replace('&' , '%26');

        window.open ( urlDestino , "_top");
}



function VerificarCookie(){
	var _url = document.location.pathname;
	var _caa = getSiteActual("").split("/");
	var _ca = _caa[1];
	if (obtenerCulturaActual()=="") {
		if(obtenerCulturaDefecto()==_ca) {
			creaCulturaActual(obtenerCulturaDefecto());
		} else {
			creaCulturaActual(_ca);
		}
	}
}

VerificarCookie();

/*
</span>*/
