
//LS3_NAT_TRACK_PARAMS
var naturalSites=new Array("google.com","google.com.mx","search.yahoo.com","msn.com","t1msn.com.mx",
			   "altavista.com","hispavista.com","aol.com.mx",
			   "yahoo.net","dmoz.org", "todito.com", 
			   "terra.com.mx","search.live.com","bing.com");

var naturalPmsIds=new Array(78963944,78963944,78964053,78971833,78971833,
			    78979790,78971842,78971848,
			    78979805,78964076,79867016, 
			    79852678,3535943,3535943);

var naturalPmsSiteIds=new Array(305851,305851,305890,305914,305914,
				305869,305852,305853,
				305871,305934,309557,
				309559,4342936,4342936);


//LS3_JS_BASE_URL
var listBaseUrl = "http://listado.deremate.com.ve";

//LS3_JS_CORE_DPRD
//PROXY
function asignBuscadorEvents(){

var botonBuscar = document.getElementById('buscarButton');
        botonBuscar.onclick= innerSearch;
        if (botonBuscar.captureEvents) botonBuscar.captureEvents(Event.CLICK);	
var buscador = document.getElementById('as_inner_word');
	buscador.onblur= setBlur;
	buscador.onfocus= setFocus;
if (buscador.captureEvents) buscador.captureEvents(Event.BLUR|Event.FOCUS);
}

function asignQcatEvents(){
	var qCatLinks = document.getElementsByName("q_cat_link");
	for(i=0;i< qCatLinks.length;i++){
		qCatLinks[i].href = "javascript:openWindow('"+qCatLinks[i].id+"');";
	}
}


function asignMedallaEvents(tipoMedalla){	
var colMedals = document.getElementsByName(tipoMedalla);
	for(i=0;i< colMedals.length;i++){
		colMedals[i].onmouseout= delayHide();
		colMedals[i].onmouseover= deleteDelayHide();
		if (colMedals[i].captureEvents) colMedals[i].captureEvents(Event.MOUSEOVER | Event.MOUSEOUT);
}
}



asignBuscadorEvents();
asignQcatEvents();
asignMedallaEvents('MLID');
asignMedallaEvents('PLAT');
asignMedallaEvents('GOLD');
asignMedallaEvents('AUCT');
//END PROXY

var alwaysBanner = true;
var wordFocus = false;
netscape = "";
ver = navigator.appVersion; 
len = ver.length;
for(iln = 0; iln < len; iln++) {
	if (ver.charAt(iln) == "(") break;
}
netscape = (ver.charAt(iln+1).toUpperCase() != "C");

function setFocus(){
wordFocus = true;
}

function setBlur(){
wordFocus = false;
}

netscape = (ver.charAt(iln+1).toUpperCase() != "C");
function keyDown(DnEvents) {
	k = (netscape) ? DnEvents.which : window.event.keyCode;
	if (k == 13 && wordFocus==true) {
		innerSearch();
		return false;
	}else{
		return true;
	}
}
document.onkeydown = keyDown;
if (netscape) document.captureEvents(Event.KEYDOWN|Event.KEYUP);

function getChr(value) {
	var vHexCode = "0123456789ABCDEF"
	var hex = "" + vHexCode.charAt((value - (value % 16))/16) + vHexCode.charAt(value % 16)
	return unescape("%"+hex)
}

function encodeNatural(toEncode) {
	toEncode= toEncode.replace(/\+/g, getChr(254));
	toEncode= toEncode.replace(/-/g, getChr(216));
	toEncode= toEncode.replace(/\s/g, '-');
	toEncode= toEncode.replace(/\t/g, '-');
	toEncode= toEncode.replace(/_/g, '*');
	return encodeURIComponent(toEncode);
}
function innerSearch(){	
var urlToRedirect;
	var currentUrl = document.URL;
	var word = document.getElementById('as_inner_word').value;

	setCookie("ml_list","searching");	
	setCookie('LAST_SEARCH', word, null);	
	
	var otherParams = currentUrl.substring(currentUrl.lastIndexOf("/")+1);
	if (otherParams && otherParams.indexOf("_")>-1) {
		otherParams = otherParams.substring(otherParams.indexOf("_"));
	} else {
		otherParams = "";
	}

	var check=document.getElementById('categ_check');
	if (check != null && check.checked){
		var currentUrlPath = currentUrl.substring(0,currentUrl.lastIndexOf('/')+1);
		urlToRedirect = currentUrlPath + encodeNatural (word)+'_CategID_'+check.value;
	}else{
		otherParams = otherParams.replace(/_CategID_[^_$]*/gi,"");
		otherParams = otherParams.replace(/_MetaCategIDs_[^_$]*/gi,"");
		urlToRedirect = listBaseUrl + "/" + encodeNatural(word);
	}

	if(getCookieValue('pr_categ') == 'AD' && otherParams.indexOf("_PrCategId_AD")==-1) {
		otherParams = otherParams + "_PrCategId_AD";
	}
	
	otherParams = otherParams.replace(/_Desde_[^_$]*/gi,"");
	otherParams = otherParams.replace(/_Qshow_[^_$]*/gi,"");
	otherParams = otherParams.replace(/_OrderId_[^_$]*/gi,"");
	otherParams = otherParams.replace(/_All_[^_$]*/gi,"");
	otherParams = otherParams.replace(/_EshopFilter_[^_$]*/gi,"");
	otherParams = otherParams.replace(/_FilterId_[^_$]*/gi,"");
	otherParams = otherParams.replace(/_FiltroId_[^_$]*/gi,"");
	otherParams = otherParams.replace(/_FiltroId2_[^_$]*/gi,"");
	otherParams = otherParams.replace(/_FiltroId3_[^_$]*/gi,"");
	otherParams = otherParams.replace(/_Bnr_[^_$]*/gi,"");
	otherParams = otherParams.replace(/_SearchBoth_[^_$]*/gi,"");
	otherParams = otherParams.replace(/_NickName_[^_$]*/gi,"");
	otherParams = otherParams.replace(/_CustId_[^_$]*/gi,"");

	otherParams = otherParams.replace(/_Marca_[^_$]*/gi,"");
	otherParams = otherParams.replace(/_Modelo_[^_$]*/gi,"");
	otherParams = otherParams.replace(/_YearMin_[^_$]*/gi,"");
	otherParams = otherParams.replace(/_YearMax_[^_$]*/gi,"");
	otherParams = otherParams.replace(/_noQCat_[^_$]*/gi,"");
	
	otherParams = otherParams.replace(/_PciaId_[^_$]*/gi,"");
	otherParams = otherParams.replace(/_OtherFilterID_[^_$]*/gi,"");
	otherParams = otherParams.replace(/_ItemTypeID_[^_$]*/gi,"");
	otherParams = otherParams.replace(/_AuctTypeID_[^_$]*/gi,"");
	otherParams = otherParams.replace(/_PriceMax_[^_$]*/gi,"");
	otherParams = otherParams.replace(/_PriceMin_[^_$]*/gi,"");

	otherParams = otherParams.replace(/_ProductID_[^_$]*/gi,"");
	otherParams = otherParams.replace(/_CantPuertas_[^_$]*/gi,"");
	otherParams = otherParams.replace(/_Combustible_[^_$]*/gi,"");
	otherParams = otherParams.replace(/_KmsMax_[^_$]*/gi,"");
	otherParams = otherParams.replace(/_KmsMin_[^_$]*/gi,"");
	
	otherParams = otherParams.replace(/_Qc_[^_$]*/gi,"");
	otherParams = otherParams.replace(/_Barrios_[^_$]*/gi,"");
	otherParams = otherParams.replace(/_Ambientes_[^_$]*/gi,"");
	otherParams = otherParams.replace(/_SupMin_[^_$]*/gi,"");
	otherParams = otherParams.replace(/_SupMax_[^_$]*/gi,"");
	otherParams = otherParams.replace(/_Ciudad_[^_$]*/gi,"");
	otherParams = otherParams.replace(/_MalertaOn_[^_$]*/gi,"");
	otherParams = otherParams.replace(/_AlertId_[^_$]*/gi,"");
	otherParams = otherParams.replace(/_OtherFilterID_[^_$]*/gi,"");
	otherParams = otherParams.replace(/_Aso_[^_$]*/gi,"");
	urlToRedirect = urlToRedirect + otherParams;
	
        var miForm = document.getElementById("formBuscar");
        if(miForm != null){
            miForm.action= "";
        }
        document.location.href = urlToRedirect;
        //El return false es para que no recargue la pagina
        return false;

}
function getSubdomain(){		
	var dom = ""+window.location.host;
	var pos = dom.indexOf("mercadoli");
	if(pos == -1)
		pos = dom.indexOf("deremate");
	if(pos == -1)
		pos = dom.indexOf("arremate");
	if (pos != -1)	
		dom = dom.substring(pos);		
	return dom;
}


function setCookie(cookieName,cookieValue,nDays) {
	setCookie(cookieName,cookieValue,nDays, null);
}	

function setCookie(cookieName,cookieValue,nDays,path) {
	var subdomain = getSubdomain();
	if (path == null)
		path ="/";
	if(nDays!=null){
		today  = new Date();
		expire = new Date();
		if (nDays==null || nDays==0) 
			nDays=1;
		expire.setTime(today.getTime() + 3600000*24*nDays);								
		document.cookie = cookieName+"="+cookieValue+";path="+path + ";domain=."+ subdomain +  ";expires="+expire.toGMTString();
	}
	else
		document.cookie = cookieName+"="+cookieValue+";path="+path+";domain=."+ subdomain;		
}

function setContextCookie(val){
	var urlBase=document.getElementsByTagName("base")[0].href.replace("www","pmspxl");
	urlBase=urlBase.substring(0,7+urlBase.substring(7).indexOf("/"));
	url = urlBase+"/jm/PmsPixel?ck="+val;
	var pixelDiv = document.getElementById("pmspxl");
	if(pixelDiv!=null)
		pixelDiv.innerHTML="<img width=0 height=0 src='"+url+"'>";
}

function performNaturalCheck(referrer, currentUrl){
	ind= getNaturalReferrerInd(referrer, currentUrl);
	if(ind == -1){
		return ;
	}
	pageId= getPageIdentification(currentUrl);
	
	naturalPmsSiteId= naturalPmsSiteIds[ind];
	naturalPmsId= naturalPmsIds[ind];
	
	key= "PMS"+naturalPmsId;
	setCookie("orgpms", naturalPmsSiteId, 30);
	setCookie("pmsword", pageId, 30);
	setCookie(key, key, 30);
}
function getPageIdentification(currentUrl){
	try{
		if ( oldUrl!=null){
			currentUrl= oldUrl;
		}
	}catch(e){}
	
	if(currentUrl.indexOf("jm/item") != -1)
		return "ITEM";
	if(currentUrl.indexOf("jm/search") != -1)
		return "SEARCH";
	if(currentUrl.indexOf("jm/themepage") != -1)
		return "THEMES";
	if(currentUrl.indexOf("/home")!= -1)
		return "HOME";
	if(currentUrl.indexOf("jm/guide")!= -1)
		return "GUIDES";
	if(currentUrl.indexOf("jm/catalog")!= -1)
		return "CATALOG";
	if(currentUrl.indexOf("jm/reviews")!= -1)
		return "REVIEWS";				
	if(currentUrl.length == 1 && currentUrl.lastIndexOf('/')==0)
		return "HOME";
	return "OTHER";	
}
function getNaturalReferrerInd(referrer, currentUrl){
	fromPms= getCookieValue("pmsonline");
	if(fromPms!=null){
		if(fromPms=="YES"){
			setCookie("pmsonline", currentUrl, null);
			return -1;
		}
		if(fromPms.toLowerCase()==currentUrl.toLowerCase())
			return -1;
	}
		
	iQueryIndex= referrer.indexOf("?");
	if(iQueryIndex != -1)
		referrer= referrer.substring(0, iQueryIndex);
	referrer= referrer.toLowerCase();
	finded= -1;
	for(var i= naturalSites.length-1; i>-1 && finded==-1; i--){
		if(referrer.indexOf(naturalSites[i])!=-1)
			finded = i;		
	}
	return finded;
}

function keyPressEvent(E){
	performPopPms();
}
function clickEvent(E){
	performPopPms();
}
function performPopPms(){
	var t_orgpms= getCookieValue("t_orgpms");
	if(t_orgpms){
		var t_cust_id = getCookieValue("t_cust_id");
		var t_pmsword= getCookieValue("t_pmsword");
		var key= "PMS"+t_cust_id;
		//Persistir cookies de PMS
		setCookie("orgpms", t_orgpms, 30);
		setCookie(key, key, 1);
		setCookie("pmsword", t_pmsword, 30);
		// Eliminar cookies temporales
		setCookie("t_orgpms", t_orgpms, -10);
		setCookie("t_pmsword", t_pmsword, -10);
		setCookie("t_cust_id", t_cust_id, -10);
	}
}
var tasksClick = new Array();
function addClickListener(task){
	if (task!=null)
		tasksClick[tasksClick.length]=task;	
	return;
}
document.onclick = clickFired;
function clickFired(E){
	for(var i =0 ; i <tasksClick.length; i++){
		tasksClick[i](E);
	}
	return;
}
var tasksKey=new Array();
function addKeyListener(task){
	if (task!=null)
		tasksKey[tasksKey.length]=task;	
	return;
}
document.onkeypress = keypressFired;
function keypressFired(E){
	for(var i =0 ; i <tasksKey.length; i++){
		tasksKey[i](E);
	}
	return;
}

function getTrackCookie(){
  if(getCookieValue("clicked")== null || getCookieValue("clicked")=="0"){	
  	var value = getCookieValue("track_info");
  	if(value!=null){
  		arrayKeys = value.split(":");   	
  		var out = "/jm/ml.track.me?save_ck=N";
  		for (i=1; i < arrayKeys.length; i++)
    		out += "&k"+i+"="+arrayKeys[i];
		var img = new Image().src = out;
	  	setCookie("clicked","1",null);
  	}
  }
}
function getBase(urlBase){
	pos = urlBase.indexOf("//")+2;
	if (pos != -1){
		urlBasePart = urlBase.substring(pos);
	}else{
		alert("Error: URL Invalida");
	}
	
	pos2 = urlBasePart.indexOf("/")+pos;
	
	if (pos2 == -1)
		alert("Error: URL Invalida");
		
	return urlBase.substring(0,pos2);	
}

function setPrCategLink(lnk)
{
    var c=getCookieValue("pr_categ");
    if (c==null) 
    	c="";

    if (lnk.substring(0,1)=="/"){
    	base = getBase(document.getElementsByTagName('base')[0].href);
    }else{
    	base = document.getElementsByTagName('base')[0].href;
    }    	    
    window.location=base+lnk+"&as_pr_categ_id="+c;
}
function setLogPMS(){
	v = window.location.pathname;
	if ( v.indexOf("jms") > 0 || v.indexOf("org_item_abm") > 0 || v.indexOf("org_item_categ") > 0 || v.indexOf("l_calif.calif_users") > 0 || v.indexOf("l_calif.my_calif") > 0 || v.indexOf("l_calif.replay_users") > 0 || v.indexOf("l_calif.my_history") > 0 || v.indexOf("org_bid.ofertar") > 0 || v.indexOf("org_bid_new.ofertar") > 0 || v.indexOf("org_pago_placetopay") > 0 || v.indexOf("org_pagoitu") > 0)
	return;
	ck = getCookieValue("orguserid");

	urlPath= self.location.pathname;
	urlPath = urlPath.substr(1,urlPath.length);
	urlQueryString= self.location.search;
	try{
		if(oldUrl!=null){
			urlPath= getUrlPath(oldUrl);
			urlQueryString= getUrlQueryString(oldUrl);
		}
	}
	catch(Exception){
	}


	if (ck==null||ck.length < 4 ){
		document.write("<a target=\"_top\" href=\"/jm/login?url="+escape(urlPath)+escape(urlQueryString)+"\" class=hpcateg id=\"MENU:ENTRAR\">Entrar</a>");
		} else {
			document.write("<a target=\"_top\" href=\"/jm/logout\" class=hpcateg id=\"MENU:SALIR\">Salir</a>");

		}
}
function setTrackCookie(e){ 
	if (window.event) 
		e = window.event; 
	var srcEl = e.srcElement? e.srcElement : e.target;
        if(srcEl.id==null||srcEl.id=='') 
		srcEl = (srcEl.parentElement?srcEl.parentElement:srcEl.parentNode);
        var track = srcEl.id;
	if (track != null && track.indexOf(":")!=-1){
	   arr = track.split("$");
  	   trackID = arr[0];
  	   if(document.home_track_id && document.home_track_id!='')
  	       trackID=document.home_track_id+':'+trackID;
   	   setCookie("track_info",document.track_site_id+":"+trackID,null);
    	   setCookie("clicked","0",null);
        }
}

setCookie("cookieEnabled","true",null);
if(Math.random() < .5 && document.cookie.indexOf("cookieEnabled=true")!=-1) {
	out1 = "";
	var i = 1;
	if(document.home_track_id){
		arr_home_track_id = document.home_track_id.split(":");
		for(i=1;i<=arr_home_track_id.length;i++)
		out1 += "&k"+i+"="+arr_home_track_id[i-1];
	}
	var obj = ( document.layers? document.layers : (!document.getElementsByTagName && document.all ? document.all : document.getElementsByTagName("*")) );
	for(j=0;j<obj.length;j++){
		if(obj[j].id != null && obj[j].id.indexOf("$p")>0){
			out2 = out1;
			arr = obj[j].id.split("$");
			arrayKeys = arr[0].split(":");
			for (k=0; k < arrayKeys.length; k++)
			out2 += "&k"+(k+i)+"="+arrayKeys[k];
			document.write('<img src="/jm/ml.track.me?p=Y'+out2+'" width=1 height=1 border=0 bordercolor=white>') ;
		}
	}

}
var w;
var queryString = oldUrl.substr(oldUrl.indexOf("?"));
var oldPath = oldUrl.substr(0,oldUrl.indexOf("?"));

function h(lnk, k1, k2, k3, k4, k5, k6, k7){
 var c=getCookieValue("pr_categ");
 if (c==null) c=""; 
 out = ""; 
 if ( k1 != null ) {
 	out += "&k1="+k1;
 } else {
 	window.location=lnk+"&as_pr_categ_id="+c;
 	return;
 } 	
 if ( k2 != null )	out += "&k2="+k2;
 if ( k3 != null )	out += "&k3="+k3;
 if ( k4 != null )	out += "&k4="+k4;
 if ( k5 != null )	out += "&k5="+k5;
 if ( k6 != null )	out += "&k6="+k6;
 if ( k7 != null )	out += "&k7="+k7; 
 window.location.href="/jm/ml.track.me?"+out+"&go="+lnk+"&as_pr_categ_id="+c; 
}

var shownWindow;
var contentLoaded = true;

function openWindow(windowID){
	if (!contentLoaded) return ;
	if (shownWindow != null) hideWindow();
	
	var loadingDiv = document.getElementById( windowID );
	
	var screenSize={screenW:0,screenH:0};
	if(window.innerWidth){
		screenSize.screenW = window.innerWidth;
		screenSize.screenH = window.innerHeight;
	}else if (document.documentElement && document.documentElement.clientWidth){
		screenSize.screenW = document.documentElement.clientWidth;
		screenSize.screenH = document.documentElement.clientHeight;
	}else if (document.body){
		screenSize.screenW = document.body.clientWidth;
		screenSize.screenH = document.body.clientHeight;
	}
	
	var cwidth = "470";
	var cheight= "255";
	
	var cleft = (screenSize.screenW/2) - (cwidth / 2)  ;
	var ctop = 0;
	
	if( loadingDiv.style.setAttribute ){ //IE
		loadingDiv.style.setAttribute('left', parseInt(cleft ));
		loadingDiv.style.setAttribute('top', parseInt(ctop));		
		loadingDiv.style.setAttribute('visibility','visible');
	}else{
		loadingDiv.setAttribute('style',"position:absolute;left:"+cleft+"px;top:"+ctop+"px;visibility:visible");
	}
	shownWindow = loadingDiv;
	
}

function hideWindow(){	
	if (shownWindow == null) return ;	
	if( shownWindow.style.setAttribute ){//IE
		shownWindow.style.setAttribute( "visibility" , "hidden" );
	}else{
		shownWindow.setAttribute("style","visibility:hidden;position:absolute");		
	}
	shownWindow = null;
}

function getScreenSize(){
	var screenW = 0, screenH = 0;
	if (parseInt(navigator.appVersion)>3) {
	 screenW = screen.width;
	 screenH = screen.height;
	}
	else if (navigator.appName == "Netscape" 
	    && parseInt(navigator.appVersion)==3
    	&& navigator.javaEnabled()
	   ) 
	{
	 var jToolkit = java.awt.Toolkit.getDefaultToolkit();
	 var jScreenSize = jToolkit.getScreenSize();
	 screenW = jScreenSize.width;
	 screenH = jScreenSize.height;
	}
	retval={screenW:0,screenH:0};
	retval.screenW = screenW;
	retval.screenH = screenH;	
	return retval;
}

// flags del banner
var lowResolution=false;
var downloadBanner=false;

function hideBanner(){
	var banner = document.getElementById("oasTOP");	
	banner.style.display="none";
}
function expandBanner(){
	var banner = document.getElementById("oasTOP");	
	if(banner.style.setAttribute){
		banner.style.setAttribute("height",'90px');
		banner.style.setAttribute("visibility","visible");
	}else{
		banner.setAttribute("style","visibility:visible;height:90px");
	}
}

function getWindowSize() {
  var width = 0, height = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    width = window.innerWidth;
    height = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    width = document.documentElement.clientWidth;
    height = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    width = document.body.clientWidth;
    height = document.body.clientHeight;
  }
  var size = new Array(width, height);
  return size;
}

function setSizeFlags() {
	var size = getWindowSize();
	lowResolution = size[0]<=800 || size[1]<=500;
}

window.onresize  = function() {
	setSizeFlags();
}


document.onclick = hideHelp;
		
var helpPop;
var baseT;
var baseL;
var popY;
var popX;
var hideFlag = false;
		
		
function safeShowHelp(pop_id, clickevent, pos) {

    hideHelp();

    if (document.all) { // MSIE
        var iebody = (document.compatMode && document.compatMode != "BackCompat") ? document.documentElement : document.body;
        popX = clickevent.clientX;
        popY = clickevent.clientY;
        baseT = iebody.scrollTop;
        baseL = iebody.scrollLeft;
        popX += baseL;
        popY += baseT;
    } else { // Netscape, etc.
        popX = clickevent.clientX;
        popY = clickevent.clientY;
        baseT = window.pageYOffset
        baseL = window.pageXOffset
        popX += baseL;
        popY += baseT;
    }

    popY += 31;
    popX -= 140;

    helpPop = document.getElementById(pop_id);

    var flecha;
    for (i = 0; i < helpPop.childNodes.length; i++) {
        if (helpPop.childNodes[i].className == "caja_ayu_flecha") {
            flecha = helpPop.childNodes[i];
        }
    }
    if (helpPop.style.setAttribute) { //IE
        if (pos == 'R') {
            popX -= 115;
            flecha.style.setAttribute('left', '242px');
        } else {
            flecha.style.setAttribute('left', '130px');
        }

        helpPop.style.setAttribute('display', 'block');
        helpPop.style.setAttribute('visibility', 'visible');
        helpPop.style.setAttribute('top', parseInt(popY) + 'px');
        helpPop.style.setAttribute('left', parseInt(popX) + 'px');
        helpPop.style.setAttribute('z-index', '3');
    } else {
        if (pos == 'R') {
            popX -= 115;
            flecha.style.left = '242px';
        } else {
            flecha.style.left = '130px';
        }
        helpPop.setAttribute('style', "display:block;visibility:visible;top:" + parseInt(popY) + "px;left:" + parseInt(popX) + "px;position:absolute");

    }
    hideFlag = false;
    delayHide(3000);
}
		
var intervalID;
function delayHide( millis ){			
if (millis == null) millis = 1000;
			deleteDelayHide();
			intervalID = setInterval('hideHelp();', millis);
}
		
function deleteDelayHide(){			
	window.clearInterval( intervalID );
}
		
function hideHelp(){
	if(hideFlag){
	if(helpPop!=null){
		if( helpPop.style.setAttribute ){ //IE
			helpPop.style.setAttribute('display', 'none');
			helpPop.style.setAttribute('visibility','hidden');
		}else{
			helpPop.setAttribute('style',"display:none;visibility:hidden;");
		}
		helpPop = null;
	}
	}else{
	hideFlag=true;
	}
}
		

var Url = {
                encode : function (string) {
                                return escape(this._utf8_encode(string));
                },
                
                 decode : function (string) {
                                return this._utf8_decode(unescape(string));
                },

                _utf8_encode : function (string) {
                               string = string.replace(/\r\n/g,"\n");
                                var utftext = "";

                               for (var n = 0; n < string.length; n++) {
                                               var c = string.charCodeAt(n);
                                               if (c < 128) {
                                                               utftext += String.fromCharCode(c);
                                               } else if((c > 127) && (c < 2048)) {
                                                               utftext += String.fromCharCode((c >> 6) | 192);
                                                               utftext += String.fromCharCode((c & 63) | 128);
                                               } else {
                                                               utftext += String.fromCharCode((c >> 12) | 224);
                                                               utftext += String.fromCharCode(((c >> 6) & 63) | 128);
                                                               utftext += String.fromCharCode((c & 63) | 128);
                                               }
                }

                               return utftext;
                },

                _utf8_decode : function (utftext) {
                                var string = "";
                                var i = 0;
                                var c = c1 = c2 = 0;

                               while ( i < utftext.length ) {
                                                c = utftext.charCodeAt(i);
                                               if (c < 128) {
                                                               string += String.fromCharCode(c);
                                                               i++;
                                                } else if((c > 191) && (c < 224)) {
                                                                  c2 = utftext.charCodeAt(i+1);
                                                               string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
                                                               i += 2;
                                                } else {
                                                                  c2 = utftext.charCodeAt(i+1);
                                                               c3 = utftext.charCodeAt(i+2);
                                                               string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
                                                                i += 3;
                                                 }
                                 }
                               return string;
                 }
}

function replaceWeirdChars( word ) {
                word = word.replace('Á','A');
                word = word.replace('É','E');
                word = word.replace('Í','I');
                word = word.replace('Ó','O');
                word = word.replace('Ú','U');
                word = word.replace(/\./g,"");
                return word;
}

function appendQcatFilters() {
                url = document.location.href ; 
                partes = url.split('/'); 
                url = partes[partes.length-1];
                partes = url.split('_'); 
                url = 'Query='+replaceWeirdChars(Url.decode(partes[0]))+'&' ;
                i=1;
                while (i<partes.length) {
                               url += partes[i] +'='+ replaceWeirdChars(Url.decode(partes[i+1]))+ '&' ;
                               i+=2;
                }
                url = url.substring(0,url.length-1);
                return url;
}


//LS3_JS_PMS
//pmspixel.js
function setSearchCookie(word){
	var searching = getCookieValue("ml_list");		
	if(searching !="searching")
		return;	
	if(word!=null && word != "")
		setContextCookie("S"+word);
	setCookie("ml_list","");
		
}
function pmsCtxCk(word,categ){
	if(word!=""){		
		var links = document.getElementsByTagName("a");
		for(i=0;i<links.length;i++){
			if(links[i].toString().indexOf("http://articulo.")!=-1 || links[i].toString().indexOf("http://produto.")!=-1 || links[i].toString().indexOf("/jm/item?")!=-1){			
				setSearchCookie(word);
				break;
			}
		}	
	}else{	
		if(categ!="" && categ!="##CATEG_L2##"){
			setContextCookie('V'+categ);
		}
	}	
}

//DEJA_VU_JS
var _d=document;
var _path=document.location.protocol+"//dejavu.mlapps.com/jm/ml.dejavu.web.NavPixel";
var _img= new Image(1,1);

function loadDejavu(siteId,	categId){
	_img.src = _path+"?"+"_siteId="+siteId+"&_categId="+categId+"&_Referer="+escape(_d.referrer)+"&_Cookies="+escape(_d.cookie);
}

function callDejavu(dejavuMap){	
	var temp=_path+"?";
	for (var key in	dejavuMap) {
		temp += key + "=" + dejavuMap[key] + "&";
	}
	
	temp += "_Referer="+escape(_d.referrer)+"&_Cookies="+escape(_d.cookie);
	
	try {
		var MLs=screen;
		temp +="&_Res="+MLs.width+"x"+MLs.height+"x"+MLs.colorDepth;
	} catch (e) {
		temp +="&_Res=na";
	}
	
	_img.src=temp;
}

