jQuery.fn.extend({selectbox:function(options){return this.each(function(){new jQuery.SelectBox(this,options);});}});jQuery.SelectBox=function(selectobj,options){var opt=options||{};opt.inputClass=opt.inputClass||"selectbox";opt.containerClass=opt.containerClass||"selectbox-wrapper";opt.hoverClass=opt.hoverClass||"selected";opt.debug=opt.debug||false;var elm_id=selectobj.id;var active=-1;var inFocus=false;var hasfocus=0;var $select=$(selectobj);var $container=setupContainer(opt);var $input=setupInput(opt);$select.hide().before($input).before($container);init();$position=$input.position();$height=$input.outerHeight(true);$container.css({position:'absolute',top:$position.top+$height,left:$position.left});$input.click(function(){if(!inFocus){$container.toggle();}}).focus(function(){if($container.not(':visible')){inFocus=true;$container.show();}}).keydown(function(event){switch(event.keyCode){case 38:event.preventDefault();moveSelect(-1);break;case 40:event.preventDefault();moveSelect(1);break;case 13:event.preventDefault();setCurrent();hideMe();break;}}).blur(function(){if($container.is(':visible')&&hasfocus>0){if(opt.debug)console.log('container visible and has focus');}else{hideMe();}});function hideMe(){hasfocus=0;$container.hide();}
function init(){$container.append(getSelectOptions()).hide();var width=$input.width();$container.width(width);}
function setupContainer(options){var container=document.createElement("div");$container=$(container);$container.attr('id',elm_id+'_container');$container.addClass(options.containerClass);return $container;}
function setupInput(options){var input=document.createElement("input");var $input=$(input);$input.attr("id",elm_id+"_input");$input.attr("type","text");$input.addClass(options.inputClass);$input.attr("autocomplete","off");$input.attr("readonly","readonly");$input.attr("tabIndex",$select.attr("tabindex"));return $input;}
function moveSelect(step){var lis=$("li",$container);if(!lis)return;active+=step;if(active<0){active=0;}else if(active>=lis.size()){active=lis.size()-1;}
lis.removeClass(opt.hoverClass);$(lis[active]).addClass(opt.hoverClass);}
function setCurrent(){var li=$("li."+opt.hoverClass,$container).get(0);var el=li.id;$select.val(el);$input.val($(li).text());$select.change();return true;}
function getCurrentSelected(){return $select.val();}
function getCurrentValue(){return $input.val();}
function getSelectOptions(){var select_options=new Array();var ul=document.createElement('ul');$select.children('option').each(function(){var li=document.createElement('li');li.setAttribute('id',$(this).val());li.innerHTML=$(this).html();if($(this).is(':selected')){$input.val($(this).text());$(li).addClass(opt.hoverClass);}
ul.appendChild(li);$(li).mouseover(function(event){hasfocus=1;if(opt.debug)console.log('out on : '+this.id);jQuery(event.target,$container).addClass(opt.hoverClass);}).mouseout(function(event){hasfocus=-1;if(opt.debug)console.log('out on : '+this.id);jQuery(event.target,$container).removeClass(opt.hoverClass);}).click(function(event){if(opt.debug)console.log('click on :'+this.id);$(this).addClass(opt.hoverClass);setCurrent();hideMe();});});return ul;}};jQuery.cookie=function(name,value,options){if(typeof value!='undefined'){options=options||{};if(value===null){value='';options.expires=-1;}
var expires='';if(options.expires&&(typeof options.expires=='number'||options.expires.toUTCString)){var date;if(typeof options.expires=='number'){date=new Date();date.setTime(date.getTime()+(options.expires*24*60*60*1000));}else{date=options.expires;}
expires='; expires='+date.toUTCString();}
var path=options.path?'; path='+(options.path):'';var domain=options.domain?'; domain='+(options.domain):'';var secure=options.secure?'; secure':'';document.cookie=[name,'=',encodeURIComponent(value),expires,path,domain,secure].join('');}else{var cookieValue=null;if(document.cookie&&document.cookie!=''){var cookies=document.cookie.split(';');for(var i=0;i<cookies.length;i++){var cookie=jQuery.trim(cookies[i]);if(cookie.substring(0,name.length+1)==(name+'=')){cookieValue=decodeURIComponent(cookie.substring(name.length+1));break;}}}
return cookieValue;}};(function($){var keyString="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";var uTF8Encode=function(string){string=string.replace(/\x0d\x0a/g,"\x0a");var output="";for(var n=0;n<string.length;n++){var c=string.charCodeAt(n);if(c<128){output+=String.fromCharCode(c);}else if((c>127)&&(c<2048)){output+=String.fromCharCode((c>>6)|192);output+=String.fromCharCode((c&63)|128);}else{output+=String.fromCharCode((c>>12)|224);output+=String.fromCharCode(((c>>6)&63)|128);output+=String.fromCharCode((c&63)|128);}}
return output;};var uTF8Decode=function(input){var string="";var i=0;var c=c1=c2=0;while(i<input.length){c=input.charCodeAt(i);if(c<128){string+=String.fromCharCode(c);i++;}else if((c>191)&&(c<224)){c2=input.charCodeAt(i+1);string+=String.fromCharCode(((c&31)<<6)|(c2&63));i+=2;}else{c2=input.charCodeAt(i+1);c3=input.charCodeAt(i+2);string+=String.fromCharCode(((c&15)<<12)|((c2&63)<<6)|(c3&63));i+=3;}}
return string;}
$.extend({base64Encode:function(input){var output="";var chr1,chr2,chr3,enc1,enc2,enc3,enc4;var i=0;input=uTF8Encode(input);while(i<input.length){chr1=input.charCodeAt(i++);chr2=input.charCodeAt(i++);chr3=input.charCodeAt(i++);enc1=chr1>>2;enc2=((chr1&3)<<4)|(chr2>>4);enc3=((chr2&15)<<2)|(chr3>>6);enc4=chr3&63;if(isNaN(chr2)){enc3=enc4=64;}else if(isNaN(chr3)){enc4=64;}
output=output+keyString.charAt(enc1)+keyString.charAt(enc2)+keyString.charAt(enc3)+keyString.charAt(enc4);}
return output;},base64Decode:function(input){var output="";var chr1,chr2,chr3;var enc1,enc2,enc3,enc4;var i=0;input=input.replace(/[^A-Za-z0-9\+\/\=]/g,"");while(i<input.length){enc1=keyString.indexOf(input.charAt(i++));enc2=keyString.indexOf(input.charAt(i++));enc3=keyString.indexOf(input.charAt(i++));enc4=keyString.indexOf(input.charAt(i++));chr1=(enc1<<2)|(enc2>>4);chr2=((enc2&15)<<4)|(enc3>>2);chr3=((enc3&3)<<6)|enc4;output=output+String.fromCharCode(chr1);if(enc3!=64){output=output+String.fromCharCode(chr2);}
if(enc4!=64){output=output+String.fromCharCode(chr3);}}
output=uTF8Decode(output);return output;}});})(jQuery);(function($){$.fn.dwaynefield=function(options){var options=$.extend({swap:'text'},options);this.each(function(){var field=$(this);var defaultValue=field.val();var currentClass=field.attr('class');switch(options.swap){case'text':$(field).focus(function(){if(this.value==defaultValue){this.value='';}
if(this.value==defaultValue){this.value='';}});$(field).blur(function(){if(this.value==""){this.value=defaultValue;}});break;case'class':$(field).focus(function(){if($(field).attr("class")==currentClass){$(field).attr('class','blurredField');}});$(field).blur(function(){if($(field).attr('class')!=currentClass&&field.value==""){$(field).attr('class',currentClass);}});break;}});return this;};})(jQuery);"use strict";jQuery.log=function(message){if(window.console){console.log(message);}else{alert(message);}};var LocalClassifieds=(function(){function getReferrerCookie(){var referrer,r,domain,path,txt;referrer=($.cookie('REFERRER'));if(referrer!==null){r=referrer.replace(/"/g,'').split("@");domain=r[0];path=r[1];txt=r[2];$("#referrerlink").attr('href',domain);$("#referrerlogo").attr('src',path);$("#referrerlogo").attr('alt',txt);$("#newspaperSource").css('display','block');}}
function readReferrerCookie(){alert($.cookie('REFERRER'));}
function init_image_modals(){$("a.colorbox").colorbox({initialWidth:"60",initialHeight:"60",close:""});$("#cboxWrapper").click(function(){$.fn.colorbox.close();});$().bind('cbox_closed',function(){$('.resultBoxThumbnail').scrollTop(0);});}
function init_special_offers(){$('.termsLink').bind('click',function(event){event.preventDefault();if(!$(this).hasClass('hideMe')&&!($("ul.bottom:animated").size()>0)){$(this).html('Hide Terms &amp; Conditions').addClass('hideMe').parent().next('.bottom').slideDown('slow');}else{if(!($("ul.bottom:animated").size()>0)){$(this).html('Terms &amp; Conditions').removeClass('hideMe').parent().next('.bottom').slideUp('slow');}}});}
function init_search(){$("#locationArea").change(function(){$("#topSearch input, #topSearch button").attr('disabled','disabled').css('cursor','default');$("#category_input").css('background','none').css('background-color','#eee').css('cursor','default');window.location=$("#locationArea").val();});$('#topSearch form').submit(function(){$("#locationArea_input").attr('disabled','disabled').css('background','none').css('background-color','#eee').css('cursor','default');if($('#keywords').val()==='Keyword Search'){$('#keywords').val('');}});}
$.fn.frostModal=function(){var $mask=$('#mask'),$modal=$('.windowModal'),$body=$('body'),$html=$('html'),$close=$('.close'),$windowHeight=$(window).height(),$windowWidth=$(window).width(),$modalHeight=$modal.outerHeight(),$modalWidth=$modal.outerWidth(),top=($windowHeight-$modalHeight)/2,left=($windowWidth-$modalWidth)/2,_showModal,_closeModal,_moveModal;$modal.css({top:top,left:left});_showModal=function(){$body.css({overflow:'hidden',height:'100%',margin:0,width:'100%'});$html.css({overflow:'hidden',height:'100%',margin:0,width:'100%'});$mask.css({display:'block',opacity:0}).animate({opacity:0.8},500);$modal.css({display:'block',opacity:0}).animate({opacity:1.0},500);var $modalOffset=$modal.offset(),$modalWidth=$modal.outerWidth(),$closePosition=$modalOffset.left+$modalWidth;$close.css({display:'block',top:$modalOffset.top-8,left:$closePosition-12});};_closeModal=function(){$body.css({overflow:'visible',height:'auto',margin:0,width:'auto'});$html.css({overflow:'auto',height:'auto',margin:0,width:'auto'});$mask.hide();$modal.hide();$close.hide();};_moveModal=function(){$modal.css('top',top);};$mask.bind('click',function(){_closeModal();});$('.close',$body).bind('click',function(){_closeModal();});return this.each(function(){$(this).bind('click',function(e){_showModal();});});};function init_dwaynefield_frost_modal(){$("#q").dwaynefield();$('#pageHeader a').frostModal();}
function init_carousels(){var initMarketingPromos=$('.promo-carousel ul').children().length;if($('.promo-carousel').is('div')&&initMarketingPromos>1){$('#promoController').show();$(".promo-carousel").jCarouselLite({auto:7000,speed:500,btnNext:"#nextPromo",btnPrev:"#previousPromo",visible:1,scroll:1,afterEnd:function(a){a.each(function(){$("#promoType").html($(this).find("input").attr("value"));});}});}}
var flyOutOpen=false,debug=false,isIE=$.browser.msie,isIE_Six=false,isIE_Seven=false,wrapHeight,flyOutToggle,runAccordian;if(isIE&&$.browser.version==="6.0"){isIE_Six=true;}else{isIE_Six=false;}
if(isIE&&$.browser.version==="7.0"){isIE_Seven=true;}else{isIE_Seven=false;}
wrapHeight=function(){$('#bkMenuWrapper').height($('#bkMenu').outerHeight(true));};flyOutToggle=function(closeSwitch){var $getListChildren,getWidthFlyOutUderbugen;if(!(closeSwitch==="close")&&debug){$.log("Clicked on "+this.className);}
if(closeSwitch==="close"){$("#bkMenu .listingBlock").animate({width:"170px"},150,"linear",function(){});$("#bkMenu .listingBlock a.fullList").html("Full List");flyOutOpen=false;return false;}
if($(this).hasClass("fullListClose")){$(this).css('outline','none');$(this).parent().parent().stop().animate({width:"170px"},500);$('#bkMenu .listingBlock a.fullList').html("Full List");flyOutOpen=false;return false;}
if($(this).hasClass("fullList")&&($(this).html()==="Full List")){$(this).css('outline','none');$getListChildren=$(this).siblings('.fullListContainer').children('ul');getWidthFlyOutUderbugen=function(){var total=0;$getListChildren.each(function(){total+=$(this).outerWidth(true);});return Number(total);};$(this).siblings(".fullListContainer").height($(this).parent().outerHeight()-2).width(getWidthFlyOutUderbugen()+20);$(this).parent().stop().animate({width:getWidthFlyOutUderbugen()+212+'px'},500);$(this).html("Hide");flyOutOpen=true;return false;}
if($(this).hasClass("fullList")&&($(this).html()==="Hide")){$(this).css('outline','none');$(this).parent().stop().animate({width:"170px"},500);$(this).html("Full List");flyOutOpen=false;return false;}
return false;};runAccordian=function(){var accordianBlock,smallHeight,newHeight;$(this).css('outline','none');if($(this).parent().parent().hasClass("listingBlock")){if(!($("div:animated").size()>0)){if(flyOutOpen){flyOutToggle("close");}
if(!(isIE)){$(this).parent().parent().switchClass("listingBlock","closedListingBlock",350,"easeInOutQuint",function(){if(!flyOutOpen){$(this).css({width:"170px"});}});}else{$(this).parent().parent().animate({height:"34px",paddingBottom:"1px"},{step:function(now){if(isIE_Six){wrapHeight();}},duration:350,easing:"easeInOutQuint",complete:function(){if(isIE_Six){wrapHeight();}
$(this).removeClass("listingBlock");$(this).addClass("closedListingBlock");}});}}}else{if(!($("div:animated").size()>0)){if(flyOutOpen){flyOutToggle("close");}
if(!(isIE)){$("#bkMenu .listingBlock").switchClass("listingBlock","closedListingBlock",350,"easeInOutQuint",function(){if(!flyOutOpen){$(this).css({width:"170px"});}});$(this).parent().parent().switchClass("closedListingBlock","listingBlock",550,"easeInOutQuint",function(){});}else{$("#bkMenu .listingBlock").animate({height:"34px",paddingBottom:"1px"},350,"easeInOutQuint",function(){$(this).removeClass("listingBlock");$(this).addClass("closedListingBlock");if(!flyOutOpen){$(this).css({width:"170px"});}});accordianBlock=$(this).parent().parent();smallHeight=accordianBlock.css('height');accordianBlock.css('height','auto');newHeight=accordianBlock.height();accordianBlock.css('height',smallHeight);accordianBlock.animate({height:newHeight+"px",paddingBottom:"23px"},{step:function(now){if(isIE_Six){wrapHeight();}},duration:350,easing:"easeInOutQuint",complete:function(){accordianBlock.css('height','auto');if(isIE_Six){wrapHeight();}
$(this).removeClass("closedListingBlock");$(this).addClass("listingBlock");if(!flyOutOpen){$(this).css({width:"170px"});}}});}}}
return false;};function init_menu(){if(isIE_Six){wrapHeight();}
$("#bkMenu div.listingBlock a.fullList").css("cursor","pointer").live("mousedown",flyOutToggle);$("#bkMenu div.listingBlock div.fullListContainer a.fullListClose").css("cursor","pointer").live("click",flyOutToggle);$("#bkMenu div.bkMenuHeader h3").css("cursor","pointer").bind("click",runAccordian);}
function init_list_animation(){$('.fullList').bind('click',function(event){event.preventDefault();if(!$(this).hasClass('hideMe')&&!($("ul.bottom:animated").size()>0)){$(this).html('Hide').addClass('hideMe').prev('.bottom').slideDown('slow');}else{if(!($("ul.bottom:animated").size()>0)){$(this).html('Full List').removeClass('hideMe').prev('.bottom').slideUp('slow');}}});}
function init_custom_select_boxes(){$(".customSelectbox").selectbox();$(".customSelectbox").removeAttr('disabled');if(isIE&&(isIE_Six||isIE_Seven)){$(function(){var zIndexNumber=1000;$('div#bd div').each(function(){$(this).css('zIndex',zIndexNumber);zIndexNumber-=10;});});}}
function cleanShortlistCookie(oldCookieValue){var cookieName='_lcsl',cookieValue=$.cookie(cookieName),ids;oldCookieValue=$.base64Decode(oldCookieValue);if(oldCookieValue===cookieValue){$('#shortlistPersonalised').css('display','inline');ids='';$('#mc input[type=checkbox]').each(function(){ids+=$(this).attr('id')+'.';});ids=ids.substring(0,ids.length-1);$.cookie(cookieName,ids,{expires:7,path:'/'});}else{$('#shortlistPersonalised').css('display','none');}}
function initialiseShortlistCheckboxes(cookieName){var cookieValue=$.cookie(cookieName),ids,selectorString,i;if(cookieValue!==null&&cookieValue!==''){ids=cookieValue.split('.');selectorString='';for(i=0;i<ids.length;++i){selectorString+='#'+ids[i]+',';}
selectorString=selectorString.substring(0,selectorString.length-1);$(selectorString).each(function(){$(this).attr('checked',true);});}}
function addAdIDToCookie(adID,cookieName){var cookieValue=$.cookie(cookieName);cookieValue=cookieValue!==null&&cookieValue!==''?cookieValue+'.'+adID:adID;$.cookie(cookieName,cookieValue,{expires:7,path:'/'});}
function removeAdIDFromCookie(adID,cookieName){var cookieValue=$.cookie(cookieName),oldIDs,newIDs,i,currentID;if(cookieValue!==null&&cookieValue!==''){oldIDs=cookieValue.split('.');newIDs='';for(i=0;i<oldIDs.length;++i){currentID=oldIDs[i];if(currentID!==adID){newIDs+=currentID+'.';}}
cookieValue=newIDs.substring(0,newIDs.length-1);}
$.cookie(cookieName,cookieValue,{expires:7,path:'/'});}
function updateShortlistLink(cookieName){var cookieValue=$.cookie(cookieName),numAdItems=0,$link=$('.shortList .shortListLink a'),newURL,newLink;if(cookieValue===null||cookieValue===''){if($link.length){$link.parent().html($link.html());}}else{numAdItems=cookieValue.split('.').length;newURL='/shortlist/'+$.base64Encode(cookieValue)+'/';if($link.length){$link.attr('href',newURL);}else{newLink='<a href="'+newURL+'">'+$('.shortList .shortListLink').html()+'</a>';$('.shortList .shortListLink').html(newLink);}}
$('.shortList .count').html(numAdItems);}
$.fn.lcCheckbox=function(){var cookieName='_lcsl';this.each(function(){var $parentWrapper,$allCheckBoxes,$allCheckBoxesByClass,titleVal,remTitleVal;$parentWrapper=$(this);$allCheckBoxes=$parentWrapper.find('input:checkbox');$allCheckBoxes.wrap('<span class="checkBoxWrapper"></span>').after('<span class="boxUnChecked"></span>').css('opacity',0);initialiseShortlistCheckboxes(cookieName);$allCheckBoxes.filter(':checked').each(function(index){$(this).next('span').removeClass().addClass('boxChecked');});titleVal=$parentWrapper.find('.boxUnChecked').siblings('input[type=checkbox]').attr('title');$parentWrapper.find('.boxUnChecked').attr('title',titleVal);remTitleVal="Remove from Short List";$parentWrapper.find('.boxChecked').attr('title',remTitleVal);$allCheckBoxesByClass=$parentWrapper.find('.boxUnChecked, .boxChecked');$allCheckBoxesByClass.bind('click',function(event){var $checkBox,checked,adID;$checkBox=$(this).prev('input:checkbox');checked=$checkBox.attr('checked');adID=$checkBox.attr('id');if(!checked){$(this).removeClass().addClass('boxChecked');$checkBox.attr('checked',true);$(this).attr('title',remTitleVal);addAdIDToCookie(adID,cookieName);}else{$(this).removeClass().addClass('boxUnChecked');$checkBox.attr('checked',false);$(this).attr('title',titleVal);removeAdIDFromCookie(adID,cookieName);}
updateShortlistLink(cookieName);});});$('li.shortListPageItem span.checkBoxWrapper span').bind("click",function(){if($(this).hasClass("boxUnChecked")){$(this).parent().parent().addClass("faded");}
else{$(this).parent().parent().removeClass("faded");}});};function init_ad_spaces(){$.pageAdCount=function(count){var adSpace0,adSpace1,adSpace2,adSpace3,adSpace4,adSpace5,adSpace6,adSpace7,adSpace8,adSpace9,adSpace10,adSpace11,adSpace12,adSpace13,adSpace14,reg,result,adZones,i,check,advertiesmentMarkup;adSpace0=$('#adSpace0')!==null&&$('#adSpace0').html();adSpace1=$('#adSpace1')!==null&&$('#adSpace1').html();adSpace2=$('#adSpace2')!==null&&$('#adSpace2').html();adSpace3=$('#adSpace3')!==null&&$('#adSpace3').html();adSpace4=$('#adSpace4')!==null&&$('#adSpace4').html();adSpace5=$('#adSpace5')!==null&&$('#adSpace5').html();adSpace6=$('#adSpace6')!==null&&$('#adSpace6').html();adSpace7=$('#adSpace7')!==null&&$('#adSpace7').html();adSpace8=$('#adSpace8')!==null&&$('#adSpace8').html();adSpace9=$('#adSpace9')!==null&&$('#adSpace9').html();adSpace10=$('#adSpace10')!==null&&$('#adSpace10').html();adSpace11=$('#adSpace11')!==null&&$('#adSpace11').html();adSpace12=$('#adSpace12')!==null&&$('#adSpace12').html();adSpace13=$('#adSpace13')!==null&&$('#adSpace13').html();adSpace14=$('#adSpace14')!==null&&$('#adSpace14').html();reg='/(AE[0-2]{1}|noimage)\\.gif/mig';result=eval(reg);adZones=count;for(i=0;i<adZones;i++){if($('#adSpace'+i).is('div')){check=$('#adSpace'+i).html();if(check.search(result)>0){$('#adSpace'+i).hide();}}}
advertiesmentMarkup='<div class="advertiseText"><span>Advertisement</span></div>';if(adSpace1&&adSpace1.search(result)<0){$('#adSpace1').before(advertiesmentMarkup);}
if(adSpace2&&adSpace2.search(result)<0){$('#adSpace2').before(advertiesmentMarkup);}
if(adSpace3&&adSpace3.search(result)<0){$('#adSpace3').before(advertiesmentMarkup);}
if(adSpace4&&adSpace4.search(result)<0){$('#adSpace4').before(advertiesmentMarkup);}
if((adSpace9&&adSpace9.search(result)<0)||(adSpace10&&adSpace10.search(result)<0)||(adSpace11&&adSpace11.search(result)<0)){$('#sponsoredLinks').before('<div class="advertiseText sponsoredTop"><span>Sponsored links</span></div>');}
if((adSpace5&&adSpace5.search(result)<0)||(adSpace6&&adSpace6.search(result)<0)||(adSpace7&&adSpace7.search(result)<0)||(adSpace8&&adSpace8.search(result)<0)){$('.partnerCenter1').before('<div id="partnerCenter" class="advertiseText"><span>Partner Center</span></div>');}else{$('.partnerCenter1').hide();$('.partnerCenter2').hide();}};}
function init(){getReferrerCookie();init_custom_select_boxes();init_search();init_menu();init_list_animation();init_image_modals();init_dwaynefield_frost_modal();init_carousels();init_ad_spaces();init_special_offers();}
return{init:init,updateShortlistLink:updateShortlistLink,cleanShortlistCookie:cleanShortlistCookie,readReferrerCookie:readReferrerCookie};}());$(document).ready(function(){$("img:not(.promo-carousel img, .carouselBody img)").lazyload({threshold:250});LocalClassifieds.init();try{LocalClassifiedsPage.init();}catch(error){}});