function AmarillasBar() {
this.hasFocus = false;
this.barId = "topBar";
this.barRef = null;
this.currentGuideId = null;
this.currentMarketId = null;
this.currentCityId = null;
this.currentZoneId = null;
this.currentGuideDescription = '';
this.currentMarketDescription = '';
this.currentCityDescription = 'Ciudad';
this.currentZoneDescription = 'Comuna';
this.currentKitchenRestaurantDescription = '';
this.firstChar = '';
this.company = null;
this.kitchenId = null;
this.restaurantId = null;
this.searchField = null;
this.method = null;
this.bClearQuote = true;
this.tempMarketId = null;
this.tempCityId = null;
this.tempZoneId = null;
this.tempMarketDescription = '';
this.tempCityDescription = 'Ciudad';
this.tempZoneDescription = 'Comuna';
this.currentActivityId = null;
this.currentActivityDescription = null;
this.oldSearchFieldValue = null;
this.NS = (document.all) ? false : true;
// Posicionamento dos popups
this.marketPopupLeft = 0;
this.marketPopupTop = 0;
this.activityPopupLeft = 0;
this.activityPopupTop = 0;
this.azPopupLeft = 0;
this.azPopupTop = 0;
this.locationPopupLeft = 0;
this.locationPopupTop = 0;
this.kitchenRestaurantsPopupLeft = 0;
this.kitchenRestaurantsPopupTop = 0;
this.guidePopupLeft = 0;
this.guidePopupTop = 0;
this.cityPopupLeft = 0;
this.cityPopupTop = 0;
this.zonePopupLeft = 0;
this.zonePopupTop = 0;
this.marketPopupWidth = 0;
this.activityPopupWidth = 0;
this.azPopupWidth = 0;
this.locationPopupWidth = 0;
this.kitchenRestaurantsPopupWidth = 0;
this.guidePopupWidth = 0;
this.cityPopupWidth = 0;
this.zonePopupWidth = 0;
function fixPosition() {
this.marketPopupLeft = this.NS ? 1:1;
this.marketPopupTop = this.NS ? 18:18;
this.activityPopupLeft = this.NS ? 0:0;
this.activityPopupTop = this.NS ? 17:5;
this.azPopupLeft = this.NS ? -76:-76;
this.azPopupTop = this.NS ? 17:5;
this.locationPopupLeft = this.NS ? -154:-154;
this.locationPopupTop = this.NS ? 17:5;
this.kitchenRestaurantsPopupLeft = this.NS ? 0:0;
this.kitchenRestaurantsPopupTop = this.NS ? 17:5;
this.guidePopupLeft = this.NS ? -1:-1;
this.guidePopupTop = this.NS ? 17:5;
this.cityPopupLeft = this.NS ? 1:1;
this.cityPopupTop = this.NS ? 18:18;
this.zonePopupLeft = this.NS ? 1:1;
this.zonePopupTop = this.NS ? 18:18;
this.marketPopupWidth = this.NS ? 0:0;
this.activityPopupWidth = this.NS ? 131:131;
this.azPopupWidth = this.NS ? 113:113;
this.locationPopupWidth = this.NS ? 285:285;
this.kitchenRestaurantsPopupWidth = this.NS ? 131:131;
this.guidePopupWidth = this.NS ? 2:1;
this.cityPopupWidth = this.NS ? 0:0;
this.zonePopupWidth = this.NS ? 1:1;
}
this.fixPosition = fixPosition;
// Acerta para mozilla
this.fixPosition();
function init() {
this.hasFocus = false;
this.barRef = document.getElementById(this.barId);
}
this.init = init;
function update() {
var html = "";
this.barRef.innerHTML = html;
}
this.update = update;
function clearQuote() {
if(!this.bClearQuote) {
return true;
}
this.bClearQuote = false;
document.getElementById("searchField").value = this.searchField.replace(/'/, "'").replace(/"/, "\"").replace(/&/, "&");
document.getElementById("searchField").select();
}
this.clearQuote = clearQuote;
function onFocus() {
window.focus = true;
var barLevel1 = document.getElementById("barLevel1");
barLevel1.style.backgroundImage = 'url("img/bkg_focus_left.png")';
barLevel1.style.backgroundPosition = 'right';
var barLevel2 = document.getElementById("barLevel2");
if(barLevel2) {
barLevel2.style.backgroundImage = 'url("img/bkg_focus_right.png")';
}
var barKitchenRestaurants = document.getElementById("barKitchenRestaurants");
if(barKitchenRestaurants) {
barKitchenRestaurants.style.backgroundImage = 'url("img/bkg_focus_right.png")';
}
var barAZ = document.getElementById("barAZ");
barAZ.style.backgroundImage = 'url("img/bkg_focus_right.png")';
var barLocation = document.getElementById("barLocation");
barLocation.style.backgroundImage = 'url("img/bkg_focus_right.png")';
var barRefresh = document.getElementById("barRefresh");
barRefresh.style.backgroundImage = 'url("img/bkg_focus_right.png")';
document.getElementById("searchField").focus();
}
this.onFocus = onFocus;
function onLostFocus() {
if(window.focus) {
window.focus = false;
return false;
}
if(window.lastPopup && window.lastPopup.isActive()) {
try {
window.lastPopup.destroy();
} catch(e) {}
}
if(window.dropAZ) {
try {
var cDrop = window.dropAZ;
window.dropAZ = null;
cDrop.destroy();
} catch(e) {}
}
if(window.dropActivity) {
try {
var cDrop = window.dropActivity;
window.dropActivity = null;
if(window.lastPopup && window.lastPopup.isActive()) {
window.lastPopup.destroy();
}
cDrop.destroy();
} catch(e) {}
}
if(window.dropKitchenRestaurant) {
try {
var cDrop = window.dropKitchenRestaurant;
window.dropKitchenRestaurant = null;
if(window.lastPopup && window.lastPopup.isActive()) {
window.lastPopup.destroy();
}
cDrop.destroy();
} catch(e) {}
}
if(window.dropLocation) {
try {
var cDrop = window.dropLocation;
window.dropLocation = null;
cDrop.destroy();
} catch(e) {}
}
var barLevel1 = document.getElementById("barLevel1");
barLevel1.style.backgroundImage = '';
var barLevel2 = document.getElementById("barLevel2");
if(barLevel2) {
barLevel2.style.backgroundImage = '';
}
var barKitchenRestaurants = document.getElementById("barKitchenRestaurants");
if(barKitchenRestaurants) {
barKitchenRestaurants.style.backgroundImage = '';
}
var barAZ = document.getElementById("barAZ");
barAZ.style.backgroundImage = '';
var barLocation = document.getElementById("barLocation");
barLocation.style.backgroundImage = '';
var barRefresh = document.getElementById("barRefresh");
barRefresh.style.backgroundImage = '';
}
this.onLostFocus = onLostFocus;
function onMouseOverLevel1() {
var imgLevel1 = document.getElementById("imgLevel1");
imgLevel1.src = 'img/arrow_focus_blue.gif';
var guideText = document.getElementById("guideText");
guideText.style.color = "#00469B";
}
this.onMouseOverLevel1 = onMouseOverLevel1;
function onMouseOutLevel1() {
var imgLevel1 = document.getElementById("imgLevel1");
imgLevel1.src = 'img/arrow_focus_gray.gif';
var guideText = document.getElementById("guideText");
guideText.style.color = "#535353";
}
this.onMouseOutLevel1 = onMouseOutLevel1;
function onMouseOverLevel2() {
var imgLevel2 = document.getElementById("imgLevel2");
imgLevel2.src = 'img/arrow_focus_blue.gif';
var searchText = document.getElementById("searchText");
searchText.style.color = "#00469B";
}
this.onMouseOverLevel2 = onMouseOverLevel2;
function onMouseOutLevel2() {
var imgLevel2 = document.getElementById("imgLevel2");
imgLevel2.src = 'img/arrow_focus_gray.gif';
var searchText = document.getElementById("searchText");
searchText.style.color = "#535353";
}
this.onMouseOutLevel2 = onMouseOutLevel2;
function onMouseOverKitchenRestaurants() {
var imgKitchenRestaurants = document.getElementById("imgKitchenRestaurants");
imgKitchenRestaurants.src = 'img/arrow_focus_blue.gif';
var kitchenRestaurantsText = document.getElementById("kitchenRestaurantsText");
kitchenRestaurantsText.style.color = "#00469B";
}
this.onMouseOverKitchenRestaurants = onMouseOverKitchenRestaurants;
function onMouseOutKitchenRestaurants() {
var imgKitchenRestaurants = document.getElementById("imgKitchenRestaurants");
imgKitchenRestaurants.src = 'img/arrow_focus_gray.gif';
var kitchenRestaurantsText = document.getElementById("kitchenRestaurantsText");
kitchenRestaurantsText.style.color = "#535353";
}
this.onMouseOutKitchenRestaurants = onMouseOutKitchenRestaurants;
function onLocationOver() {
if(window.dropLocation) {
return;
}
this.onFocus();
var barLocation = document.getElementById("barLocation");
var barLocationDesc = document.getElementById("barLocationDesc");
barLocation.style.width = '123';
barLocationDesc.style.display = 'inline';
//document.getElementById("tabBar").focus();
}
this.onLocationOver = onLocationOver;
function onLocationOut() {
if(window.dropLocation) {
return;
}
var barLocation = document.getElementById("barLocation");
var barLocationDesc = document.getElementById("barLocationDesc");
barLocationDesc.style.display = 'none';
barLocation.style.width = '18';
}
this.onLocationOut = onLocationOut;
function showGuidesPopup(cSpan, arrayGuides) {
this.onFocus();
window.clickOnMe = true;
var popup = new DropDownMenu("dropDownAmarillas");
popup.zIndex = 1000;
popup.height = 87;
popup.parent = this;
popup.backImage = 'img/bkg_drop_menu.png';
if(popup.isActive()) {
popup.destroy();
document.onmouseup = null;
return;
}
if(window.lastPopup && window.lastPopup.isActive()) {
window.lastPopup.destroy();
}
if(window.dropAZ) {
try {
var cDrop = window.dropAZ;
window.dropAZ = null;
cDrop.destroy();
} catch(e) {}
}
if(window.dropKitchenRestaurant) {
try {
var cDrop = window.dropKitchenRestaurant;
window.dropKitchenRestaurant = null;
if(window.lastPopup && window.lastPopup.isActive()) {
window.lastPopup.destroy();
}
cDrop.destroy();
} catch(e) {}
}
if(window.dropLocation) {
try {
var cDrop = window.dropLocation;
window.dropLocation = null;
cDrop.destroy();
} catch(e) {}
}
if(window.dropActivity) {
try {
var cDrop = window.dropActivity;
window.dropActivity = null;
if(window.lastPopup && window.lastPopup.isActive()) {
window.lastPopup.destroy();
}
cDrop.destroy();
} catch(e) {}
}
popup.left = findPosX(cSpan)+this.guidePopupLeft;
popup.top = findPosY(cSpan)+this.guidePopupTop;
popup.width = parseInt(cSpan.style.width)+this.guidePopupWidth;
if(arrayGuides) {
for(var index = 0; index < arrayGuides.length; index++) {
popup.addDropDownMenuItem(arrayGuides[index]);
}
}
popup.draw();
popup.menuDiv.onmousedown = function(e) {
window.focus = true;
}
this.onFocus();
window.lastPopup = popup;
}
this.showGuidesPopup = showGuidesPopup;
function setArrowDown() {
var imgArrowMarket = document.getElementById('imgArrowMarket');
var imgArrowCity = document.getElementById('imgArrowCity');
var imgArrowZone = document.getElementById('imgArrowZone');
imgArrowMarket.src='img/arrow_down_gray.gif';
imgArrowCity.src='img/arrow_down_gray.gif';
imgArrowZone.src='img/arrow_down_gray.gif';
}
this.setArrowDown = setArrowDown;
function showMarketPopup(cSpan, arrayMarket) {
this.onFocus();
window.clickOnMe = true;
var popup = new DropDownMenu("dropDownRM");
popup.zIndex = 1000;
popup.height = 95;
popup.parent = this;
var imgArrowMarket = document.getElementById('imgArrowMarket');
this.setArrowDown();
if(popup.isActive()) {
popup.destroy();
document.onmouseup = null;
return;
}
if(window.lastPopup && window.lastPopup.isActive()) {
window.lastPopup.destroy();
}
popup.left = findPosX(cSpan) + this.marketPopupLeft;
popup.top = findPosY(cSpan) + this.marketPopupTop;
popup.width = parseInt(cSpan.width) + parseInt(this.marketPopupWidth);
if(arrayMarket) {
for(var index = 0; index < arrayMarket.length; index++) {
popup.addDropDownMenuItem(arrayMarket[index]);
}
}
popup.draw();
popup.menuDiv.onmousedown = function(e) {
window.focus = true;
}
imgArrowMarket.src='img/arrow_up_gray.gif'
window.lastPopup = popup;
}
this.showMarketPopup = showMarketPopup;
function showCityPopup(cSpan, arrayCities) {
this.startRefreshAnimation();
this.onFocus();
window.clickOnMe = true;
var popup = new DropDownMenu("dropDownCity");
popup.zIndex = 1000;
popup.height = 95;
popup.parent = this;
var imgArrowCity = document.getElementById('imgArrowCity');
this.setArrowDown();
if(popup.isActive()) {
popup.destroy();
document.onmouseup = null;
this.stopRefreshAnimation();
return;
}
if(window.lastPopup && window.lastPopup.isActive()) {
window.lastPopup.destroy();
}
popup.left = findPosX(cSpan)+this.cityPopupLeft;
popup.top = findPosY(cSpan)+this.cityPopupTop;
popup.width = parseInt(cSpan.width) + parseInt(this.cityPopupWidth);
if(arrayCities) {
for(var index = 0; index < arrayCities.length; index++) {
popup.addDropDownMenuItem(arrayCities[index]);
}
}
popup.draw();
try {
popup.menuDiv.onmousedown = function(e) {
window.focus = true;
}
imgArrowCity.src='img/arrow_up_gray.gif';
window.lastPopup = popup;
} catch(e) {
alert("No existen ciudades para la región seleccionada.");
}
this.stopRefreshAnimation();
}
this.showCityPopup = showCityPopup;
function showZonePopup(cSpan, arrayZones) {
this.onFocus();
window.clickOnMe = true;
var popup = new DropDownMenu("dropDownZone");
popup.zIndex = 1000;
popup.height = 95;
popup.parent = this;
var imgArrowZone = document.getElementById('imgArrowZone');
this.setArrowDown();
if(popup.isActive()) {
popup.destroy();
document.onmouseup = null;
return;
}
if(window.lastPopup && window.lastPopup.isActive()) {
window.lastPopup.destroy();
}
popup.left = findPosX(cSpan)+this.zonePopupLeft;
popup.top = findPosY(cSpan)+this.zonePopupTop;
popup.width = parseInt(cSpan.width) + parseInt(this.zonePopupWidth);
if(arrayZones) {
for(var index = 0; index < arrayZones.length; index++) {
popup.addDropDownMenuItem(arrayZones[index]);
}
}
popup.draw();
try {
popup.menuDiv.onmousedown = function(e) {
window.focus = true;
}
imgArrowZone.src='img/arrow_up_gray.gif';
window.lastPopup = popup;
} catch(e) {
}
}
this.showZonePopup = showZonePopup;
function showActivityPopup(cSpan, arrayActivities) {
this.startRefreshAnimation();
if(window.dropActivity) {
var cDrop = window.dropActivity;
window.dropActivity = null;
if(window.lastPopup && window.lastPopup.isActive()) {
window.lastPopup.destroy();
}
cDrop.destroy();
this.stopRefreshAnimation();
return;
}
if(window.dropKitchenRestaurant) {
try {
var cDrop = window.dropKitchenRestaurant;
window.dropKitchenRestaurant = null;
if(window.lastPopup && window.lastPopup.isActive()) {
window.lastPopup.destroy();
}
cDrop.destroy();
} catch(e) {}
}
if(window.dropAZ) {
try {
var cDrop = window.dropAZ;
window.dropAZ = null;
cDrop.destroy();
} catch(e) {}
}
if(window.dropLocation) {
try {
var cDrop = window.dropLocation;
window.dropLocation = null;
cDrop.destroy();
} catch(e) {}
}
this.onFocus();
window.clickOnMe = true;
var dropDownArea = new DropDownArea("dropActivity");
dropDownArea.zIndex = 1000;
dropDownArea.top = findPosY(cSpan)+this.activityPopupTop;
dropDownArea.left = findPosX(cSpan)+this.activityPopupLeft;
dropDownArea.height = 86;
dropDownArea.width = parseInt(cSpan.width)+this.activityPopupWidth;
dropDownArea.backImage = "img/bkg_drop_menu.png";
var htmlCode = "
";
htmlCode += "";
htmlCode += "
";
dropDownArea.draw(htmlCode);
var divParent = document.getElementById("divActivityParent");
var popup = new DropDownMenu("dropDownActivity", divParent);
if(document.all) {
popup.width = dropDownArea.width-2;
popup.height = dropDownArea.height-1;
}
else {
popup.width = dropDownArea.width;
popup.height = dropDownArea.height;
popup.height = dropDownArea.height-1;
popup.forceAbsolutePosition = true;
popup.top = 1;
}
popup.backImage = 'img/bkg_drop_menu.png';
popup.drawExternalBorders = false;
if(popup.isActive()) {
popup.destroy();
document.onmouseup = null;
this.stopRefreshAnimation();
return;
}
if(window.lastPopup && window.lastPopup.isActive()) {
window.lastPopup.destroy();
}
if(arrayActivities) {
for(var index = 0; index < arrayActivities.length; index++) {
popup.addDropDownMenuItem(arrayActivities[index]);
}
}
popup.draw();
try {
popup.menuDiv.onmousedown = function(e) {
window.focus = true;
}
} catch(e) {};
this.stopRefreshAnimation();
window.dropActivity = dropDownArea;
}
this.showActivityPopup = showActivityPopup
function showKitchenRestaurantsPopup(cSpan, arrayRestaurant) {
this.startRefreshAnimation();
if(window.dropKitchenRestaurant) {
var cDrop = window.dropKitchenRestaurant;
window.dropKitchenRestaurant = null;
if(window.lastPopup && window.lastPopup.isActive()) {
window.lastPopup.destroy();
}
cDrop.destroy();
this.stopRefreshAnimation();
return;
}
if(window.dropActivity) {
try {
var cDrop = window.dropActivity;
window.dropActivity = null;
cDrop.destroy();
} catch(e) {}
}
if(window.dropAZ) {
try {
var cDrop = window.dropAZ;
window.dropAZ = null;
cDrop.destroy();
} catch(e) {}
}
if(window.dropLocation) {
try {
var cDrop = window.dropLocation;
window.dropLocation = null;
cDrop.destroy();
} catch(e) {}
}
this.onFocus();
window.clickOnMe = true;
var dropDownArea = new DropDownArea("dropKitchenRestaurant");
dropDownArea.zIndex = 1000;
dropDownArea.top = findPosY(cSpan) + this.kitchenRestaurantsPopupTop;
dropDownArea.left = findPosX(cSpan) + this.kitchenRestaurantsPopupLeft;
dropDownArea.height = 86;
dropDownArea.width = parseInt(cSpan.width)+this.kitchenRestaurantsPopupWidth;
dropDownArea.backImage = "img/bkg_drop_menu.png";
var htmlCode = "";
htmlCode += "";
htmlCode += "
";
dropDownArea.draw(htmlCode);
var divParent = document.getElementById("divKitchenRestaurantParent");
var popup = new DropDownMenu("dropDownKitchenRestaurant", divParent);
if(document.all) {
popup.width = dropDownArea.width-2;
popup.height = dropDownArea.height-1;
}
else {
popup.width = dropDownArea.width;
popup.height = dropDownArea.height;
popup.height = dropDownArea.height-1;
popup.forceAbsolutePosition = true;
popup.top = 1;
}
popup.backImage = 'img/bkg_drop_menu.png';
popup.drawExternalBorders = false;
if(popup.isActive()) {
popup.destroy();
document.onmouseup = null;
this.stopRefreshAnimation();
return;
}
if(window.lastPopup && window.lastPopup.isActive()) {
window.lastPopup.destroy();
}
if(arrayRestaurant) {
for(var i = 0; i < arrayRestaurant.length; i++) {
popup.addDropDownMenuItem(arrayRestaurant[i]);
}
}
popup.draw();
try {
popup.menuDiv.onmousedown = function(e) {
window.focus = true;
}
} catch(e) {};
this.stopRefreshAnimation();
window.dropKitchenRestaurant = dropDownArea;
}
this.showKitchenRestaurantsPopup = showKitchenRestaurantsPopup
function stopRefreshAnimation() {
document.getElementById("imgRefresh").src = "img/btn_refresh.gif";
}
this.stopRefreshAnimation = stopRefreshAnimation;
function startRefreshAnimation() {
document.getElementById("imgRefresh").src = "img/refresh_mov.gif";
}
this.startRefreshAnimation = startRefreshAnimation;
function enableBar() {
var topBarLoadProtection = document.getElementById("topBarLoadProtection");
topBarLoadProtection.style.zIndex = -1;
this.stopRefreshAnimation();
}
this.enableBar = enableBar;
function setCurrentMarket(marketId, marketDescription, isClick) {
var marketText = document.getElementById("marketText");
marketText.innerHTML = marketDescription;
marketText.title = marketDescription;
this.tempMarketId = marketId;
this.tempMarketDescription = marketDescription;
if(isClick) {
// Limpa outras combos
this.setCurrentCity(null, 'Ciudad', false);
arrayCities = new Array();
this.setCurrentZone(null, 'Comuna', false);
arrayZones = new Array();
if(window.lastPopup && window.lastPopup.isActive()) {
window.lastPopup.destroy();
}
// Carrega cidades por XMLHttpRequest
this.loadCity();
}
bar.setArrowDown();
}
this.setCurrentMarket = setCurrentMarket;
function loadCity() {
bar.startRefreshAnimation();
var xmlHttpWrapper = new XMLHTTPWrapper();
xmlHttpWrapper.callURL("location.do?method=loadCity&localeMarketId="+bar.tempMarketId, bar.onLoadCityComplete, null);
}
this.loadCity = loadCity;
function onLoadCityComplete(citiesText, parameters) {
var cities = citiesText.split("|");
arrayCities = new Array();
arrayCities.push(new DropDownMenuItem("bar.setCurrentCity(null, \"Ciudad\", true);", "Todas"));
for(var i = 0; i < cities.length; i++) {
var city = cities[i].split(",");
arrayCities.push(new DropDownMenuItem("bar.setCurrentCity(\""+city[0]+"\", \""+city[1]+"\", true);", city[1]));
}
bar.stopRefreshAnimation();
}
this.onLoadCityComplete = onLoadCityComplete;
function setCurrentCity(cityId, cityDescription, isClick) {
var cityText = document.getElementById("cityText");
cityText.innerHTML = cityDescription;
cityText.title = cityDescription;
this.tempCityId = cityId;
if(cityId != null && cityId != undefined) {
this.tempCityDescription = cityDescription;
}
if(isClick) {
// Limpa outras combos
this.setCurrentZone(null, 'Comuna', false);
arrayZones = new Array();
if(window.lastPopup && window.lastPopup.isActive()) {
window.lastPopup.destroy();
}
// Carrega cidades por XMLHttpRequest
this.loadZone();
}
bar.setArrowDown();
}
this.setCurrentCity = setCurrentCity;
function loadZone() {
bar.startRefreshAnimation();
var xmlHttpWrapper = new XMLHTTPWrapper();
xmlHttpWrapper.callURL("location.do?method=loadZone&localeMarketId="+bar.tempMarketId+"&localeCityId="+bar.tempCityId, bar.onLoadZoneComplete, null);
}
this.loadZone = loadZone;
function onLoadZoneComplete(zonesText, parameters) {
var zones = zonesText.split("|");
arrayZones = new Array();
arrayZones.push(new DropDownMenuItem("bar.setCurrentZone(null, \"Comuna\", true);", "Todas"));
for(var i = 0; i < zones.length; i++) {
var zone = zones[i].split(",");
arrayZones.push(new DropDownMenuItem("bar.setCurrentZone(\""+zone[0]+"\", \""+zone[1]+"\", true);", zone[1]));
}
bar.stopRefreshAnimation();
}
this.onLoadZoneComplete = onLoadZoneComplete;
function setCurrentZone(zoneId, zoneDescription, isClick) {
var zoneText = document.getElementById("zoneText");
zoneText.innerHTML = zoneDescription;
zoneText.title = zoneDescription;
this.tempZoneId = zoneId;
if(zoneId != null && zoneId != undefined) {
this.tempZoneDescription = zoneDescription;
}
if(isClick) {
if(window.lastPopup && window.lastPopup.isActive()) {
window.lastPopup.destroy();
}
}
bar.setArrowDown();
}
this.setCurrentZone = setCurrentZone;
function setCurrentGuide(guideId, guideDescription, isClick) {
var guideText = document.getElementById("guideText");
guideText.innerHTML = guideDescription;
guideText.title = guideDescription;
this.currentGuideId = guideId;
this.currentGuideDescription = guideDescription;
}
this.setCurrentGuide = setCurrentGuide;
function setCurrentActivity(activityId, activityDescription, isClick) {
this.currentActivityId = activityId;
// Seta descrição, removendo a informação de quantidade de anúncios
this.currentActivityDescription = activityDescription.replace(/(.*)(\(.*)/,"$1");
if(isClick) {
this.doRefresh();
}
}
this.setCurrentActivity = setCurrentActivity;
function setCurrentKitchenRestaurant(restautantId, restaurantDescription, type, isClick) {
if(type == "kitchen") {
this.kitchenId = restautantId;
this.restaurantId = null;
} else if(type == "restaurant") {
this.restaurantId = restautantId;
this.kitchenId = null;
} else {
this.restaurantId = restautantId;
this.kitchenId = restautantId;
}
this.currentKitchenRestaurantDescription = restaurantDescription;
if(isClick) {
this.doRefresh();
}
}
this.setCurrentKitchenRestaurant = setCurrentKitchenRestaurant;
function setCurrentFirstChar(firstChar, isClick) {
var divLetterAZ = document.getElementById("divLetterAZ");
if(firstChar == null) {
divLetterAZ.innerHTML = '
';
}
else {
divLetterAZ.innerHTML = ''+firstChar.toLowerCase()+'
';
}
this.firstChar = firstChar;
if(isClick) {
this.doRefresh();
}
}
this.setCurrentFirstChar = setCurrentFirstChar;
function doRefresh() {
var currentSearchValue = document.getElementById("searchField").value.replace(/^\"|\"$/g, "");
if(this.currentGuideId == 2) {
if((Trim(currentSearchValue).length == 0)
&& (!this.kitchenId)
&& (!this.restaurantId)) {
alert("El texto de búsqueda o el tipo de restaurant debe ser llenado.");
document.getElementById("searchField").focus();
return;
}
}
else {
if(Trim(currentSearchValue).length == 0) {
alert("El texto de búsqueda debe ser llenado.");
document.getElementById("searchField").focus();
return;
}
}
var bNewText = false;
if(currentSearchValue != this.oldSearchFieldValue.replace(/'/, "'").replace(/"/, "\"")) {
bNewText = true;
}
this.closePopups();
this.onTopBarChange(this.currentGuideId,
this.currentActivityId,
this.currentActivityDescription,
this.currentMarketId,
this.currentCityId,
this.currentZoneId,
this.firstChar,
currentSearchValue,
bNewText);
}
this.doRefresh = doRefresh;
function onTopBarChange(guideId, activityId, activityDescription, marketId, cityId, zoneId, firstChar, textSearch, bNewText) {
var myAction = "";
if(this.method != 'searchWord' && this.currentGuideId == 1) {
myAction = "searchAdvertises.do?method=searchAdvertises";
} else if (this.currentGuideId == 2) {
myAction = "searchAdvertisesRestaurant.do?method=searchAdvertisesRestaurant";
} else {
myAction = "searchWord.do?method=searchWord";
}
var url = '';
if(bNewText || (this.method == 'viewMoreInfo')) {
if (this.currentGuideId == 2) {
url += 'searchAdvertisesRestaurant.do?method=searchAdvertisesRestaurant';
} else {
url += 'searchWord.do?method=searchWord';
url += '&searchType=1100';
}
}
else {
url += myAction;
}
if(this.currentGuideId == 2) {
url += '&company='+escape(textSearch);
}
else {
url += '&keywordComplet='+escape(textSearch);
if(this.company) url += '&company='+this.company;
}
if(marketId || marketId == 0) url += '&localeMarketId='+marketId;
if(guideId || guideId == 0) url += '&guideId='+guideId;
if(cityId || cityId == 0) url += '&localeCityId='+cityId;
if(zoneId || zoneId == 0) url += '&localeZoneId='+zoneId;
if(!bNewText) {
if(activityId || activityId == 0) url += '&termoId='+activityId+'&activitySourcePage=test&activitySourceComponent=SearchBar';
if(activityDescription) url += '&termoDesc='+activityDescription;
if(this.kitchenId) url += '&kitchenId='+this.kitchenId;
if(this.restaurantId) url += '&restaurantId='+this.restaurantId;
if (this.method == 'searchAdvertises' && this.company == null) {
url += '&searchType=1300';
} else {
url += '&searchType=1100';
}
if(firstChar) url += '&firstChar='+firstChar;
}
url += '&status=P';
document.location=url;
}
this.onTopBarChange = onTopBarChange;
function closePopups() {
if(window.lastPopup && window.lastPopup.isActive()) {
window.lastPopup.destroy();
}
if(window.dropLocation) {
try {
var cDrop = window.dropLocation;
window.dropLocation = null;
cDrop.destroy();
} catch(e) {}
}
if(window.dropAZ) {
try {
var cDrop = window.dropAZ;
window.dropAZ = null;
cDrop.destroy();
} catch(e) {}
}
if(window.dropActivity) {
try {
var cDrop = window.dropActivity;
window.dropActivity = null;
cDrop.destroy();
if(window.lastPopup && window.lastPopup.isActive()) {
window.lastPopup.destroy();
}
} catch(e) {}
}
if(window.dropKitchenRestaurant) {
try {
var cDrop = window.dropKitchenRestaurant;
window.dropKitchenRestaurant = null;
if(window.lastPopup && window.lastPopup.isActive()) {
window.lastPopup.destroy();
}
cDrop.destroy();
} catch(e) {}
}
}
this.closePopups = closePopups;
function onAZ(ref) {
if(window.lastPopup && window.lastPopup.isActive()) {
window.lastPopup.destroy();
}
if(window.dropLocation) {
try {
var cDrop = window.dropLocation;
window.dropLocation = null;
cDrop.destroy();
} catch(e) {}
}
if(window.dropKitchenRestaurant) {
try {
var cDrop = window.dropKitchenRestaurant;
window.dropKitchenRestaurant = null;
if(window.lastPopup && window.lastPopup.isActive()) {
window.lastPopup.destroy();
}
cDrop.destroy();
} catch(e) {}
}
if(window.dropActivity) {
try {
var cDrop = window.dropActivity;
window.dropActivity = null;
if(window.lastPopup && window.lastPopup.isActive()) {
window.lastPopup.destroy();
}
cDrop.destroy();
} catch(e) {}
}
if(window.dropAZ) {
var cDrop = window.dropAZ;
window.dropAZ = null;
cDrop.destroy();
return;
}
var dropDownArea = new DropDownArea("dropAZ");
dropDownArea.zIndex = 1000;
dropDownArea.height = 78;
dropDownArea.width = this.azPopupWidth;
dropDownArea.left = findPosX(ref)+this.azPopupLeft;
dropDownArea.top = findPosY(ref)+this.azPopupTop;
dropDownArea.backImage = "img/bg_az.gif";
var htmlCode = "";
htmlCode += "";
htmlCode += "";
htmlCode += "";
htmlCode += document.getElementById("lettersBox").innerHTML;
htmlCode += "
";
htmlCode += "";
htmlCode += "
";
htmlCode += " ";
htmlCode += " | ";
htmlCode += " Todas | ";
htmlCode += " | ";
htmlCode += "
";
htmlCode += "
";
htmlCode += "
";
dropDownArea.draw(htmlCode);
dropDownArea.dropdownAreaDiv.onmousedown = function(e) {
window.focus = true;
return false;
}
window.dropAZ = dropDownArea;
}
this.onAZ = onAZ;
function arrowImgOver(idImgArrow) {
var imgArrow = document.getElementById(idImgArrow);
if(imgArrow.src.indexOf('arrow_down') != -1) {
imgArrow.src = "img/arrow_down_blue.gif";
} else {
imgArrow.src = "img/arrow_up_blue.gif";
}
}
this.arrowImgOver = arrowImgOver;
function arrowImgOut(idImgArrow) {
var imgArrow = document.getElementById(idImgArrow);
if(imgArrow.src.indexOf('arrow_down') != -1) {
imgArrow.src = "img/arrow_down_gray.gif";
} else {
imgArrow.src = "img/arrow_up_gray.gif";
}
}
this.arrowImgOut = arrowImgOut;
function onLocationClick(ref) {
if(window.lastPopup && window.lastPopup.isActive()) {
window.lastPopup.destroy();
}
if(window.dropAZ) {
try {
var cDrop = window.dropAZ;
window.dropAZ = null;
cDrop.destroy();
} catch(e) {}
}
if(window.dropKitchenRestaurant) {
try {
var cDrop = window.dropKitchenRestaurant;
window.dropKitchenRestaurant = null;
if(window.lastPopup && window.lastPopup.isActive()) {
window.lastPopup.destroy();
}
cDrop.destroy();
} catch(e) {}
}
if(window.dropActivity) {
try {
var cDrop = window.dropActivity;
window.dropActivity = null;
if(window.lastPopup && window.lastPopup.isActive()) {
window.lastPopup.destroy();
}
cDrop.destroy();
} catch(e) {}
}
if(window.dropLocation) {
var cDrop = window.dropLocation;
window.dropLocation = null;
if(window.lastPopup && window.lastPopup.isActive()) {
window.lastPopup.destroy();
}
cDrop.destroy();
return;
}
this.onFocus();
var dropDownArea = new DropDownArea("dropLocation");
dropDownArea.zIndex = 1000;
dropDownArea.height = 87;
dropDownArea.width = this.locationPopupWidth;
dropDownArea.backImage = "img/bg_location.gif";
dropDownArea.left = findPosX(ref) + this.locationPopupLeft;
dropDownArea.top = findPosY(ref)+this.locationPopupTop;
var htmlCode = "";
// Texto mudar cidade
htmlCode += "";
htmlCode += "Cambiar localidad:";
htmlCode += "
";
htmlCode += "";
dropDownArea.draw(htmlCode);
dropDownArea.dropdownAreaDiv.onmousedown = function(e) {
window.focus = true;
}
// Load cities
if(this.currentMarketId || this.currentMarketId == 0) {
this.loadCity();
}
// Load cities
if(this.currentCityId || this.currentCityId == 0) {
this.loadZone();
}
window.dropLocation = dropDownArea;
}
this.onLocationClick = onLocationClick;
function onLocationOkClick() {
this.currentMarketId = this.tempMarketId;
this.currentCityId = this.tempCityId;
this.currentZoneId = this.tempZoneId;
this.currentMarketDescription = this.tempMarketDescription;
this.currentCityDescription = this.tempCityDescription;
this.currentZoneDescription = this.tempZoneDescription;
this.setLocationBarDescription();
this.startRefreshAnimation();
this.doRefresh();
}
this.onLocationOkClick = onLocationOkClick;
function setLocationBarDescription() {
var desc = "";
if(this.currentMarketDescription.length > 0) {
desc += this.currentMarketDescription;
}
if(this.currentCityDescription.length > 0 && this.currentCityDescription != 'Ciudad') {
desc += " - " + this.currentCityDescription;
}
if(this.currentZoneDescription.length > 0 && this.currentZoneDescription != 'Comuna') {
desc += " - " + this.currentZoneDescription.toLowerCase();
}
document.getElementById("barLocationDesc").innerHTML = desc;
document.getElementById("barLocationDesc").title = desc;
}
this.setLocationBarDescription = setLocationBarDescription;
function checkEnter(e){
var characterCode = 0;
if(document.all) {
e = event;
}
characterCode = e.keyCode;
if(characterCode == 13){
this.doRefresh();
return false;
}
else{
return true;
}
}
this.checkEnter = checkEnter;
// get the current path displayed in the bar
// (ex: guide > keyword > activity)
function getPathDescription() {
var result = '';
result = this.currentGuideDescription;
result += ' > ' + this.searchField.replace(/'/, "'").replace(/"/, "\"");
if(this.currentActivityDescription != null && this.currentActivityDescription != '') {
result += ' > ' + this.currentActivityDescription;
}
return result;
}
this.getPathDescription = getPathDescription;
}