// banners
ordval=Math.floor (Math.random()*1000000);


function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function GetDomain () {
var url = ""+window.location+"";
if (url.indexOf("terra.com.pr",0) != -1)
        pcountry = "pr";
else
        pcountry = "us";
}
GetDomain();

function mm(url,pref) {
        options = "scrollbars=no,height=470,width=700";
        if (pref == null) pref = 0;
        newWindow = window.open("http://www.terra.com/multimedia/mm_choice3.html?video="+url+"&pref="+pref,'mmedia',options);
}

function audio(audiofile) {
	options = "scrollbars=no,height=200,width=285";
	newWindow = window.open("http://www.terra.com/multimedia/audio/audio.html?audio="+audiofile,'audio',options);
}

function openTvPlayer(szQs) {
        var szUrl = new String("http://multimedia.terra.com/ot_frameset.asp");
        if (szQs != "") {
                szUrl += szQs;
        }
	window.open(szUrl, "entplayer","height=615,width=800,toolbar=0,directories=0, location=0,status=0,scrollbars=1,resize=1,menubar=0,copyhistory=1");
}

function popcompras(prod) {
    options = "scrollbars=no,height=240,width=500";
    newWindow = window.open("http://php.terra.com/compras/pop.php?p="+prod,'lista',options);
}

function pgSearch(mode) {

    if (document.pg.cat.options[document.pg.cat.selectedIndex].value != "") {
        if (document.pg.keyword.value == "") {
            if (document.pg.cat.options[document.pg.cat.selectedIndex].value == "M") {
                document.pg.action = "http://terra.pricegrabber.com/home_mostpopmu.php/mode=" + mode;
            } else if (document.pg.cat.options[document.pg.cat.selectedIndex].value == "P") {
                document.pg.action = "http://terra.pricegrabber.com/home_mostpopm.php/mode=" + mode;
            } else {
                if (document.pg.cat.options[document.pg.cat.selectedIndex].value != "") {
                    document.pg.action = "http://terra.pricegrabber.com/home_mostpop.php/topcat_id="+document.pg.cat.options[document.pg.cat.selectedIndex].value+"/mode=" + mode;
                }
            }
        } else {
            document.pg.action = "http://terra.pricegrabber.com/search_gen_top.php/topcat_id=" + document.pg.cat.options[document.pg.cat.selectedIndex].value + "&form_keyword=" + document.pg.keyword.value + "/mode=" + mode; 
    
        }
    } else {
        document.pg.action = "http://terra.pricegrabber.com/search_gen_top.php/form_keyword=" + document.pg.keyword.value + "/mode=" + mode;
    }
    document.pg.submit();
}

function pgMasCompras(mode) {
	if (document.pgBox.tpcat.options[document.pgBox.tpcat.selectedIndex].value == "M") {
		document.pgBox.action = "http://terra.pricegrabber.com/home_mostpopmu.php/mode=" + mode;
		document.pgBox.submit();
	} else if (document.pgBox.tpcat.options[document.pgBox.tpcat.selectedIndex].value == "P") {
		document.pgBox.action = "http://terra.pricegrabber.com/home_mostpopm.php/mode=" + mode;
		document.pgBox.submit();
	} else {
		if (document.pgBox.tpcat.options[document.pgBox.tpcat.selectedIndex].value != "") {
			document.pgBox.action = "http://terra.pricegrabber.com/home_mostpop.php/topcat_id="+document.pgBox.tpcat.options[document.pgBox.tpcat.selectedIndex].value+"/mode=" + mode;
			document.pgBox.submit();
		}
	}
}

function mOvr(src,clrOver) {
  if (!src.contains(event.fromElement)) {
         src.style.background = clrOver;
        }
}
function mOut(src,clrIn) {
  if (!src.contains(event.toElement)) {
         src.style.background = clrIn;
        }
}


// tabs
function MM_findObj(n, d) { //v4.01
  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=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

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 estaLogeado() {
        if (getCookie('MAYA_SSO_SGUP_ALL')) {
                return true;
        }
        return false;
}

