$(document).ready(function(){overlayContainer=$("#popupContainer");
var o=function(p){adjustToCenter($("#popupContainer"));
$("a.close-overlay").click(function(){$("#popup-background").remove();
$("#popupContainer").html("");
return false
})
};
register_popup=function(p){var q={};
q.url=p;
q.activate_call=o,overlayContainer.loadJFrame(q)
};
bootstrap_popup=function(){$("a[target='"+overlayContainer.attr("id")+"']").click(function(){var p=$(this).attr("href");
var q={};
q.url=p;
register_popup(p);
return false
})
};
bootstrap_popup();
redirect=false;
$("#tlf__header").after('<div id="overlay" style="display:none;"></div>');
$(".lightbox").lightbox();
$("div#tlf__content div.info").each(function(){if(parseInt($(this).height())>=300){$(this).addClass("scroll")
}});
$(".more-handler").click(function(){$this=$(this);
$more=$this.next(".more-content");
$more.toggleClass("hide");
$this.remove()
});
$("div.shopbox #tlf__map").after($(document.createElement("br")).addClass("cl")).prepend($(document.createElement("a")).attr({"class":"expand-map underline",href:"#"}).text(GMAP_INCREASE_HEIGHT).click(function(){gm_toggleHeight();
return false
}));
wsl.initialize();
gs.initialize();
$("#jumpto2").change(function(){$.scrollTo("#jump_"+this.value,700);
return false
});
$("#detailedShoplist").click(function(){$.scrollTo($(".shoplistbox")[0],700);
return false
});
$("a.scroll-link").click(function(){$.scrollTo($(this).attr("href"),700);
return false
});
$("a.track-link").click(function(r){var q=$.base64Encode(this.href).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,",");
var p=siteURL("tracker/track_link/"+q);
$.ajax({url:p,async:false});
return true
});
if($.browser.flash&&$("#products-flash-carousel.active").size()>0){var c=new SWFObject(BASE_URL+"static/carousel/Carousel.swf","products-shoppage-products","608","177","9.0.0","#FFFFFF");
c.addVariable("xmlfile",products.xml);
c.addVariable("loaderColor","#FFFFFF");
c.addVariable("messages"," :: :: :: ");
c.addParam("allowScriptAccess","always");
c.write("products-flash-carousel");
$(".products-big").addClass("products-big-flash")
}var e=$("#products-label-products.carousel");
e.jcarousel({scroll:1,auto:1,wrap:"circular",buttonNextHTML:null,buttonPrevHTML:null,initCallback:function(q){var p=function(){q.pauseAuto();
q.options.auto=0
};
$('a.products-action[rel="next"]').click(function(){p();
q.next();
return false
});
$('a.products-action[rel="previous"]').click(function(){p();
q.prev();
return false
});
e.hover(function(){q.pauseAuto()
},function(){q.startAuto()
})
}});
$(".products-toggle a").click(function(){var u=$(this);
var p=$("#"+this.rel);
var r=u.siblings(".arrow");
if(p.is(":visible")){p.slideUp("fast");
r.text("→")
}else{var q=this.href;
var t=$(".products-result:visible");
var s=function(){if(p.html()==""){p.addClass("products-loading").slideDown("fast").load(q,function(){p.removeClass("products-loading")
})
}else{p.slideDown("fast")
}r.text("↓")
};
if(t.length==0){s()
}else{$(".arrow").text("→");
t.slideUp("fast",s)
}}return false
});
$(".faq-list p").css("display","none");
$(".faq-list h2").wrapInner("<span />").click(function(){$(this).next("p").slideToggle("fast")
});
initDefaultInputValues($("form label.default"));
$("div.error a").click(function(){var p=$($(this).attr("href"))[0];
$($(this).attr("href")).focus(function(){$(this).css("background-color","#ccc")
}).blur(function(){$(this).css("background-color","#fff")
});
if(p){p.focus();
return false
}else{return true
}});
$("p.labelenum a").click(function(q){var r=$(this).attr("href").split("_")[1];
var p=$("#lbl_"+r);
$(".labelinfo").removeClass("teaserActive");
p.toggleClass("teaserActive");
$.scrollTo(p,700,{offset:-150});
return false
});
$("#show_phone").click(function(){var p=$(this);
$.get(siteURL("shop/track_phone/"+p.attr("rel")));
p.remove();
$(".phone-number:first").slideDown(500);
return false
});
$(".show-phone-number").click(function(){var p=$(this);
$.get(siteURL("label/track_phone/"+p.attr("rel")));
p.next(".phone-number").slideDown(500);
p.remove();
return false
});
$(".social-bookmarking > a").hover(function(){var p=$(this).find("img");
p.attr("src",p.attr("src").replace(".png","_color.png"))
},function(){var p=$(this).find("img");
p.attr("src",p.attr("src").replace("_color.png",".png"))
});
$(".viewOnMap a").click(function(){var p=$(this);
var q=p.parent();
if(q.hasClass("opened")){q.removeClass("opened");
p.text(lang.line("show_map"))
}else{q.addClass("opened");
p.text(lang.line("close_map"))
}});
$("#show_all_maps").click(function(){$(".viewOnMap").addClass("opened");
$(".viewOnMap a").text(lang.line("close_map"))
});
$("#hide_all_maps").click(function(){$(".viewOnMap").removeClass("opened");
$(".viewOnMap a").text(lang.line("show_map"))
});
$("a.print").click(function(){url=$(this).attr("href");
window.open(url,"tlf_print","width=660,height=600,top=0,scrollbars=yes,menubar=yes,toolbar=yes,resizable=yes").focus();
return false
});
var b=function(p){if(p.row){var q=p.row.data.name;
$("#selectedLabelId").val(p.row.data.id);
$("#label").change(function(){$("#selectedLabelId").val("")
})
}else{var q=p.selectValue
}};
var h=function(p){$("#labelissuperbrand").val("false");
$("#selectedLabelId").val("")
};
var i=function(p){if($(p).hasClass("unselectable")){return false
}b(p);
if(p.row.type=="superbrand"){$("#label").val($("#label").val()+" "+SUPERBRAND_GROUP)
}$("#label").focus()
};
var d=function(q){var p=q.data.name_formatted;
var s="The URI you submitted has disallowed characters.";
var r=p;
if(q.type=="superbrand"){r+=" "+SUPERBRAND_GROUP
}if(q.type=="label"){if(!q.data.parent_id){r="<div>"+p+"</div>"
}else{r='<div class="indent">'+p+"</div>"
}}else{if(!q.data.is_selectable){r='<div class="unselectable">'+q.data.name+"</div>"
}}if(r!=s){return r
}else{}};
$("#search #label").autocomplete(BASE_URL+"index.php/autocompletion/searchlabel/",{dataType:"jsonp",delay:10,minChars:2,matchSubset:0,maxItemsToShow:30,onItemSelect:i,onFindValue:b,onChangeInput:h,formatItem:d,autoFill:false,resultsClass:"ac_results",width:"156",call_submit:function(){$(".ac_results").each(function(){$(this).css("display","none")
});
gs.submitButton()
},call_on_item_selected:function(p,q){if(p.row.type=="superbrand"){$("#labelissuperbrand").val("true");
var r=q.toLowerCase()
}else{if(p.row.type=="label"){$("#labelissuperbrand").val("false")
}}}});
var f=function(p){$("#selectedShopId").val(p.row.data.id)
};
var j=function(p){$("#selectedShopId").val("")
};
var g=function(p){f(p);
$("#shop").focus()
};
var n=function(p){var q=p.data.name_formatted;
q+="<br /><div class='indent'>"+p.data.street+"</div>";
return q
};
$("#search #shop").autocomplete(BASE_URL+"index.php/autocompletion/searchshop/",{dataType:"jsonp",delay:10,minChars:2,matchSubset:0,onItemSelect:g,onFindValue:f,onChangeInput:j,formatItem:n,cacheLength:0,autoFill:false,resultsClass:"ac_results",width:"156",call_submit:function(){$(".ac_results").each(function(){$(this).css("display","none")
});
gs.submitButton()
}});
var k=function(p){$("#selectedCityId").val(p.row.data.id)
};
var m=function(p){$("#selectedCityId").val("")
};
var l=function(p){k(p);
$("#city").focus()
};
var a=function(p){return p.data.name_formatted
};
$("#search #city").autocomplete(BASE_URL+"index.php/autocompletion/searchcity/",{dataType:"jsonp",delay:10,minChars:2,matchSubset:0,onItemSelect:l,onFindValue:k,onChangeInput:m,formatItem:a,autoFill:false,resultsClass:"ac_results",width:"206",call_submit:function(){$(".ac_results").each(function(){$(this).css("display","none")
});
gs.submitButton()
}});
if(!$.browser.msie||$.browser.version>=7){$(".imagesFlashContent > embed, .imagesFlashContent > object").mouseout(function(){try{this.SetVariable("scrolling","0")
}catch(p){}})
}$(".sortme").sortable({items:".sorty",containment:"parent",hoverClass:"sorting"});
$("#captcha_box a").click(function(){resetCaptcha();
return false
});
$("p.infoTextLangSel a[name^=lang]").click(function(){var p=$(this);
p.addClass("active");
p.siblings().removeClass("active");
$(".info .infoText").load(p.attr("href"));
return false
})
});
function resetCaptcha(){var a=$("#captcha_box img");
if(a){a.attr("src",a.attr("src").replace(/\/captcha\/[0-9]+/,"/captcha/"+new Date().getTime()))
}}function openBigImage(a){var b=$("a[title='"+a+"']");
if(b.length){b.click();
return
}var c=$("a[href='"+a+"']");
if(c.length){c.click();
return
}else{alert("No anchor with title/href "+a+" found")
}}var search={initialize:function(){$("#search").click(function(){search.submitButton()
})
},submitButton:function(){}};
var gs={data:{},searchController:"",initialize:function(){this.handleFocus();
gs.fieldAction();
$("#search").submit(function(){return false
});
$("#search-button").click(function(){gs.submitButton()
});
this.setDisabled($("#shop"))
},submitButton:function(){$("#search").ajaxSubmit({type:"GET",dataType:"jsonp",cache:true,success:function(a){gs.lookup(a)
}})
},fieldAction:function(){$("#label").change(function(){gs.setDisabled($("#shop"))
});
$("#city").keydown(function(){gs.setEnabled($("#shop"));
$("#shop").val("");
gs.setEnabled($("#label"))
}).change(function(){var a=$("#city").parent().find("label.default");
if($.trim($("#city").val())==""||$("#city").val().indexOf(a.text())===0){$("#shop").mouseover().mouseout()
}});
$("#label").mouseover(function(){gs.setEnabled($("#label"));
if($.trim($(this).val())!=""&&$(this).val()!=$(this).parent().find("label.default").text()){gs.setDisabled($("#shop"))
}});
$("#shop").mouseover(function(){var b=$("#city").parent().find("label.default");
if($.trim($("#city").val())==""||$("#city").val().indexOf(b.text())===0){gs.setDisabled($("#shop"));
var a=$("#shop").parent().find("label.default").text();
$("#shop").val(ENTER_TOWN_FIRST)
}else{gs.setEnabled($("#shop"));
if($.trim($("#shop").val())!=""&&$("#shop").val()!=$("#shop").parent().find("label.default").text()){gs.setDisabled($("#label"))
}}});
$("#shop").keydown(function(){if($(this).hasClass("disabled")){return
}if($.trim($(this).val())!=""&&$(this).val()!=$(this).parent().find("label.default").text()){gs.setDisabled($("#label"))
}$("#shop").focus()
})
},setDisabled:function(a){if(!$(a).length||$(a).hasClass("disabled")){return
}$(a).addClass("disabled").click(function(){$("#city").focus();
return false
}).css("cursor","default").keydown(function(){if($(this).hasClass("disabled")){return false
}}).blur();
hiddenDisabledElem=$(a).parent().find("input[name='"+$(a).attr("id")+"Disabled']");
if(!hiddenDisabledElem.length){$(a).parent().append('<input type="hidden" name="'+$(a).attr("id")+'Disabled" value="1">')
}else{hiddenDisabledElem.val("1")
}initDefaultInputValues($(a).parent().find("label.default"))
},setEnabled:function(a){if(!$(a).length||!$(a).hasClass("disabled")){return
}$(a).removeClass("disabled").unbind("click").css("cursor","auto");
hiddenDisabledElem=$(a).parent().find("input[name='"+$(a).attr("id")+"Disabled']");
if(hiddenDisabledElem.length){hiddenDisabledElem.val("")
}initDefaultInputValues($(a).parent().find("label.default"))
},lookup:function(a){switch(a.status){case"error":$("#morelabels").html('<p class="morelabels error">'+a.message+"</p>");
bootstrap_popup();
return false;
break;
case"success":window.location.href=a.message;
break;
default:}},disable:function(a){$(a).attr("disabled","disabled")
},enable:function(a){$(a).removeAttr("disabled")
},handleFocus:function(){$("#shop").focus(function(){});
$("#label").focus(function(){gs.setDisabled($("#shop"))
});
$("#city").focus(function(){})
}};
var wsl={data:{},seperator:"",initialize:function(){this.data.labelId=$("#labelId").val();
this.data.continentId=$("#continentId").val();
this.data.continentName=$("#continentName").val();
this.data.countryId=$("#countryId").val();
this.data.countryName=$("#countryName").val();
this.data.cityId=$("#cityId").val();
this.data.cityName=$("#cityName").val();
this.data.wslLayover=$("#wslLayover");
this.seperator="__";
this.loadWsl()
},loadMenuHandler:function(){$("#continentChoose").unbind().click(function(){wsl.continents();
return false
});
$("#countryChoose").unbind().click(function(){wsl.countries();
return false
});
$("#cityChoose").unbind().click(function(){wsl.cities();
return false
})
},reset:function(){this.resetContinent();
this.resetCountry();
this.resetCity()
},loadWsl:function(){if($("#wslContainer").length){$("#wslContainer").load(BASE_URL+"index.php/wsl/getWsl/"+$.base64Encode(this.data.labelId),function(){wsl.loadMenuHandler();
wsl.reset();
return false
})
}return false
},continents:function(){$("#treeCountries").css("visibility","hidden");
$("#treeCities").css("visibility","hidden");
$("#listOfContinents").load(BASE_URL+"index.php/wsl/getContinents/"+wsl.data.labelId,{show:$("#show").val()},function(){$(".scroll").jScrollPane({scrollbarWidth:7,dragMinHeight:25});
wsl.closeOtherLayovers($(this).attr("id"));
wsl.addCloseOnHead($(this).attr("id"));
$("#listOfContinents a").click(function(){$("#treeCountries").css("visibility","visible");
$("#treeCities").css("visibility","visible");
wsl.setContinent(this);
wsl.countries();
return false
})
});
return false
},countries:function(){$("#treeCities").css("visibility","hidden");
$("#listOfCountries").load(BASE_URL+"index.php/wsl/getCountries/",{labelId:wsl.data.labelId,continentId:wsl.data.continentId,show:$("#show").val()},function(){$(".scroll").jScrollPane({scrollbarWidth:7,dragMinHeight:25});
wsl.closeOtherLayovers($(this).attr("id"));
wsl.addCloseOnHead($(this).attr("id"));
$("#listOfCountries a").unbind().click(function(){$("#treeCities").css("visibility","visible");
wsl.setCountry(this);
wsl.cities();
return false
});
if($("#listOfCountries a").length==1){$("#listOfCountries a").click();
return
}$("#listOfCountries").removeClass("hide")
});
return false
},cities:function(){$("#listOfCities").load(BASE_URL+"index.php/wsl/getCities/",{labelId:wsl.data.labelId,countryId:wsl.data.countryId,show:$("#show").val()},function(){$(".scroll").jScrollPane({scrollbarWidth:7,dragMinHeight:25});
wsl.closeOtherLayovers($(this).attr("id"));
wsl.addCloseOnHead($(this).attr("id"));
$("#listOfCities a").unbind().click(function(){wsl.setCity(this);
wsl.closeLayover(this)
});
if($("#listOfCities a").length==1){wsl.setCity($("#listOfCities a")[0]);
window.location=$("#listOfCities a:first").attr("href");
return
}$("#listOfCities").removeClass("hide")
});
return false
},addCloseOnHead:function(a){$(".closeTree").click(function(b){$("#"+a).empty();
$("#treeCountries").css("visibility","visible");
$("#treeCities").css("visibility","visible")
})
},addCloseButton:function(){$("#overlay").show().css("background-image","none");
$(".layover").prepend('<div class="close"></div>');
$(".layover .close").css("cursor","pointer").unbind().click(function(){wsl.closeLayover()
})
},closeOtherLayovers:function(a){$(".wslList").each(function(){if($(this)[0].id!=a){$(this).empty()
}})
},closeLayover:function(a){$(a).parents().find(".wslList:first").empty()
},setContinent:function(a){var b=a.id.split(wsl.seperator);
wsl.data.continentId=b[1];
$("#continentId").val(b[1]);
$("#continentChoose").text(b[2]);
if(b[3]==1){$("#continentChoose").unbind().click(function(){return false
}).addClass("single")
}this.loadMenuHandler();
$("#countryChoose").text(wsl.getDefault("country")).removeClass("single");
$("#cityChoose").text(wsl.getDefault("city")).removeClass("single").css("font-weight","normal");
wsl.data.countryId="";
wsl.data.cityId=""
},resetContinent:function(){if(wsl.data.continentName.length){$("#continentChoose").text(wsl.data.continentName)
}if($("#continentCount").val()=="1"){$("#continentChoose").unbind().click(function(){return false
}).addClass("single")
}$("#treeCountries").show();
$("#treeCities").show()
},setCountry:function(a){var b=a.id.split(wsl.seperator);
wsl.data.countryId=b[1];
$("#countryId").val(b[1]);
$("#countryChoose").text(b[2]);
if(b[3]==1){$("#countryChoose").unbind().click(function(){return false
}).addClass("single")
}this.loadMenuHandler();
$("#cityChoose").text(wsl.getDefault("city")).removeClass("single").css("font-weight","normal");
wsl.data.cityId=""
},resetCountry:function(){if(wsl.data.countryName.length){$("#countryChoose").text(wsl.data.countryName)
}if($("#countryCount").val()=="1"){$("#countryChoose").unbind().click(function(){return false
}).addClass("single")
}},setCity:function(a){var b=a.id.split(wsl.seperator);
wsl.data.cityId=b[1];
$("#cityId").val(b[1]);
$("#cityChoose").text(b[2]);
if(b[3]==1){$("#cityChoose").unbind().click(function(){return false
}).addClass("single")
}},resetCity:function(){if(wsl.data.cityName.length){$("#cityChoose").text(wsl.data.cityName).css("font-weight","bold")
}if($("#cityCount").val()=="1"){$("#cityChoose").unbind().click(function(){return false
}).addClass("single")
}},getDefault:function(a){defaultVal="default";
defaultVal=$.ajax({type:"GET",url:BASE_URL+"index.php/wsl/getDefault/"+a,async:false}).responseText;
return defaultVal
}};
function initDefaultInputValues(a){return;
if(typeof(a)=="undefined"||!a.length){return
}a.hide().siblings("input,textarea").each(function(){if(this.value==""){this.value=$(this).prev().text()
}}).focus(function(){if(this.value==$(this).prev().text()){this.value=""
}}).blur(function(){if(this.value==""){this.value=$(this).prev().text()
}})
}var overlayContainer;
function adjustToCenter(b){var a=$(window).scrollTop()+Math.floor(($(window).height()-b.height())/2);
if(a<$(window).scrollTop()){a=$(window).scrollTop()
}b.css("top",a);
b.css("left",Math.floor(867-b.width())/2)
};
