function changeChannel(channel) {
	if (channel != '')
		top.location = channel;
}

function getValue(valor,pos) {
	var texto;
	var arreglo=valor.split('|');
	
	if (pos < arreglo.length) {
		texto = arreglo[pos];
	} else {
		texto="";
	}
	return texto;
}

function getCookie(nombre) {
	valor = "";
	if (document.cookie) {
		 var arreglo = document.cookie.split(escape(nombre) + '=');
		 if ( 2 <= arreglo.length ) {
			var arreglo2 = arreglo[1].split(';');
			valor = unescape(arreglo2[0]);
		 }
	}
	return valor;
}

function isLogged() {
	if (getCookie('MAYA_SSO_SGUP_ALL')) {
		return true;
	}
	return false;
}

function showHi() {
	var login = getValue(getCookie('SGUP_LOGIN'),0);
	
	if (login.length > 14) {
		login=login.substring(0,13)+'...';
	}
//	document.writeln('Hola '+login+', <a href="http://www.terra.com/SGUP/LoginOptOut.htm" target="_top">tu cuenta</a>');
}

function showDefault() {
//	document.writeln('<a href="http://www.terra.com/SGUP/form_registro.htm" target="_top">Reg&iacute;strate</a> | <a href="http://www.terra.com/SGUP/LoginOptOut.htm" target="_top">Login</a>');
}




// Terra header: OLD & NEW SITES

document.writeln('<div id="hd"><div class="lock">');
var url = ''+top.location+'';
if (url.indexOf('/turismo/') != -1)  {
document.writeln('<a href="http://www.terra.com/" target="_top" class="logo"><img src="http://www.terra.com/e/img/terra.gif" width="120" height="44" border="0" alt="Terra" /></a>');
} else {
document.writeln('<a href="http://en.terra.com/" target="_top" class="logo"><img src="http://www.terra.com/e/img/terra.gif" width="120" height="44" border="0" alt="Terra" /></a>');
}
document.writeln('<div class="links">');

// begin - canales y servicios 
var url = ''+top.location+'';
//if (url.indexOf('/turismo/') != -1)  {

document.writeln('<form name="header">');
document.writeln('<select name="canales" class="canales" onChange="changeChannel(document.header.canales.options[this.form.canales.selectedIndex].value)">');
for (i=0; i<arraycanales.length; i+=3) {
	if (arraycanales[i+1] == "") {
		document.write('<option value="">');
	} else {
		document.write('<option value=' + arraycanales[i+1] + '>');
	}
	document.write(arraycanales[i]);
}

document.writeln('</select>');
document.writeln('</form>');

//}
// end - canales y servicios

/*if (isLogged()) {
	showHi();
} else {
	showDefault();
}
*/
document.writeln('</div>');

document.writeln('</div></div>');

document.write('<script src="http://www.terra.com/includes/skstats_terraus.js" type="text/JavaScript"><\/script>');

// revenue science cookie with segments
var rsi_segs = [];
var rsSegs = "";
var segs_beg=document.cookie.indexOf('rsi_segs=');
if(segs_beg>=0) {
        segs_beg=document.cookie.indexOf('=',segs_beg)+1;
        if(segs_beg>0) {
                var segs_end=document.cookie.indexOf(';',segs_beg);
                if(segs_end==-1)
                        segs_end=document.cookie.length;
                rsi_segs=document.cookie.substring(segs_beg,segs_end).split('|');
        }
	var segLen=6;
	var segQS="",segArr=new Array();
	if (rsi_segs.length<segLen) {
        	segLen=rsi_segs.length;
	}
	for (var i=0;i<segLen;i++) {
    		segArr=rsi_segs[i].split("_");
    		if (segArr.length>1)
        		segQS+=("bt"+"="+segArr[1]+";");
	}
	rsSegs = segQS;
}
// revenue science cookie

//Comscore
var __cs_c1 = 2;
var __cs_c2 = "3000033";
var __cs_c3 = "";
var __cs_c4 = document.location.href;
var __cs_c5 = "";
var __cs_c6 = "";
var __cs_c15 = "";
var __cs_params = ["c1=", __cs_c1, "&c2=", __cs_c2, "&c3=", __cs_c3, "&c4=", __cs_c4, "&c5=", __cs_c5, "&c6=",__cs_c6, "&c15=", __cs_c15].join('');
document.write(unescape("%3Cscript src='" + (document.location.protocol == "https:" ? "https://sb" : "http://b") + ".scorecardresearch.com/beacon.js?" + __cs_params +"' %3E%3C/script%3E"));
document.write('<noscript><img src="http://b.scorecardresearch.com/b?c1=2&c2=3000033&c3=&c4='+document.location.href+'&c5=&c6=&c15=&cv=1.3&cj=1" style="display:none" width="0" height="0" alt="" /></noscript>');
