(function($){$.fn.hint=function(blurClass){if(!blurClass)blurClass='blur';return this.each(function(){var $$=$(this);var title=$$.attr('title');if(title){$$.blur(function(){if($$.val()==''){$$.val(title).addClass(blurClass);}}).focus(function(){if($$.val()==title){$$.val('').removeClass(blurClass);}
else{$$.removeClass(blurClass);}}).parents('form:first').submit(function(){if($$.val()==title){$$.val('').removeClass(blurClass);}}).end().blur();if($.browser.mozilla&&!$$.attr('autocomplete')){setTimeout(function(){if($$.val()==title)$$.val('');$$.blur();},10);}}});};})(jQuery);function Map(element,width,height,lat,lng,zoomLevel){this._zoomLevel=zoomLevel||13;this._latlng=lat?new GLatLng(lat,lng):new GLatLng(0,0);this._width=width;this._height=height;this._element=element;this._marker;this._map;};Map.prototype.showMapNewListing=function(){this._map=new GMap2(this._element,{size:new GSize(this._width,this._height)});this._map.addControl(new GLargeMapControl3D());if(this._latlng.lat()===0&&this._latlng.lng()===0)
{this.findLocation(currentPortal.country);}
else{this._showMarker();}};Map.prototype.findLocation=function(address){var self=this;var geoCoder=new GClientGeocoder();geoCoder.getLocations(address,function(location){var placeMark=location.Placemark[0];var latLngBox=placeMark.ExtendedData.LatLonBox;if(latLngBox){var latLngBound=new GLatLngBounds(new GLatLng(latLngBox.south,latLngBox.west),new GLatLng(latLngBox.north,latLngBox.east));self._zoomLevel=self._map.getBoundsZoomLevel(latLngBound);}
self._latlng=new GLatLng(placeMark.Point.coordinates[1],placeMark.Point.coordinates[0]);self._showMarker(true);});};Map.prototype.showMapListing=function(openInfoWindowHtml){this._map=new GMap2(this._element,{size:new GSize(this._width,this._height)});this._map.addControl(new GLargeMapControl3D());this._showMarker();if(openInfoWindowHtml){var listingInfo="<p style='font-size:16px; font-weight:bold;'>"+listing_name+"</span></p><p><strong>Address: </strong>"+listing_address+"</p>";this._marker.openInfoWindowHtml(listingInfo);this._marker.bindInfoWindowHtml(listingInfo);}};Map.prototype._showMarker=function(isDraggable){if(this._marker){this._map.setCenter(this._latlng,this._zoomLevel);this._marker.setLatLng(this._latlng);}
else{isDraggable=isDraggable||false;var markerIcon=new GIcon(G_DEFAULT_ICON);markerIcon.image="/stylesheets/marker-red.png";this._marker=new GMarker(this._latlng,{icon:markerIcon,draggable:isDraggable});this._map.setCenter(this._latlng,this._zoomLevel);this._map.addOverlay(this._marker);}};Map.prototype._initGoogleMap=function(){if(!window['GMap2']){var script=document.createElement("script");script.type="text/javascript";script.src='http://maps.google.com/maps?file=api&v=2.x&key='+currentPortal.map_key+'&async=2&callback='+callbackName;document.getElementsByTagName("head")[0].appendChild(script);}
else{callback();}};Map.prototype.getZoomLevel=function(){return this._map.getZoom();};Map.prototype.getLatLng=function(){return this._marker.getLatLng();};jQuery.noConflict();jQuery(document).ready(function(){InterfaceTranslation.init();header.update();subArea.init();RefineSearch.init();HiliListingHandler.init();LL.loadEventMaps([MainEventMap]);loadBillboard();document.onclick=function(){var dropDown=document.getElementById('div_dropDown');if(dropDown){PredictiveHelper.hideItem(document.getElementById('div_dropDown'));}};if(document.getElementById('subscriberEmail')){jQuery('#submitSubscriberEmail').attr("disabled",true);jQuery('#subscriberEmail').keyup(validateSubscriberEmail);}
jQuery('#txtSearch').hint();});jQuery.fn.outerHtml=function(){if(this.length){var div=jQuery('<div style="display:none"></div>');var clone=jQuery(this[0].cloneNode(false)).html(this.html()).appendTo(div);var outer=div.html();div.remove();return outer;}
else{return null;}};function validateSubscriberEmail(){if(isEmail(jQuery("#subscriberEmail").val())){jQuery('#submitSubscriberEmail').attr("disabled",false);}
else{jQuery('#submitSubscriberEmail').attr("disabled",true);}};var header={activeTab:'searchTab',update:function(){var c=getCookie("activeTab");if(c){this.activeTab=c;}
else{setCookie("activeTab",this.activeTab);}
jQuery("#tabHeaders").empty();jQuery('#uiTabs>div>h2').each(function(){var el=jQuery(this);var id=jQuery(el.parent()).attr('id');var tab;if(id==header.activeTab){tab='<li class="active"><span>'+el.text()+'</span></li>';el.parent().css({display:'block'});}else{tab='<li><a href="#" id="H'+id+'">'+el.text()+'</a></li>';el.parent().css({display:'none'});}
jQuery("#tabHeaders").append(tab);});jQuery('#tabHeaders li:first').addClass("first");jQuery("#tabHeaders a").click(function(){if(this.id.substring(1)=="newListingTab"){showCreateNewListingPopup();return false;}
header.switchTab(this);return false;});},switchTab:function(e){if(e){this.activeTab=e.id.substring(1);setCookie("activeTab",this.activeTab);header.update();}}};function getCookie(n){var c=""+document.cookie;var i=c.indexOf(n);if(i<0)return"";var j=c.indexOf(';',i);if(j<0)j=c.length;return unescape(c.substring(i+n.length+1,j));}
function setCookie(name,value,nDays){if(!nDays)nDays=1;var expire=new Date();expire.setTime(expire.getTime()+3600000*24*nDays);document.cookie=name+"="+escape(value)
+";expires="+expire.toGMTString()
+";path=/";}
function jL(s){return'javascript:'+s;}
ce=function(e,i,c,h){var x=document.createElement(e);if(i)x.id=i;if(c)x.className=c;if(h)x.innerHTML=h;return x;};createContent=function(message,fields){var c="";if(message)c="<p>"+message+"</p>";if(fields){c+='<table cellpadding="0" cellspacing="0"><tbody>';for(var i=0;i<fields.length;i++)
c+=fields[i].toString();c+="</tbody></table>";}else{this.formAction=null;}
return c;};isEmail=function(s){var re=/\b[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b/i;return re.test(s);};getEmail=function(listing_id,comm_id){postClick("email",listing_id);var url="/email/"+listing_id;jQuery.ajax({url:comm_id?url+"?comm_id="+comm_id:url,success:function(emailJSON){emailObj=JSON.parse(emailJSON);if(emailObj)document.location.href='mailto:'+emailObj.email;}});};getWebsite=function(params){var listing={listingUuid:params.split("/")[0],listingWebsite:params.split("/")[1],aliasName:params.split("/")[2]};postClick("website",listing.listingUuid);window.open('http://'+window.location.hostname+"/fwd/"+listing.listingWebsite+"?code="+listing.aliasName);};postClick=function(resource,listing_id){jQuery.ajax({type:"PUT",url:"http://"+window.location.hostname+"/core-api/api-statistics/listings/"+listing_id+"/"+resource+"?domain_name="+currentPortal.domain_name});};function getQueryParams(queryString){if(!queryString){queryString=document.location.search;}
queryString=queryString.split("+").join(" ");var params={},tokens,re=/[?&]?([^=]+)=([^&]*)/g;while(tokens=re.exec(queryString)){params[decodeURIComponent(tokens[1])]=decodeURIComponent(tokens[2]);}
return params;};loadBillboard=function(){if(!document.getElementById('Home'))return;if(currentPortal.billboards.length>0){bb=new BillboardManager(eval(currentPortal.billboards));bb.load();}};submitSearchBox=function(searchBoxId){var txtSearchBox=document.getElementById(searchBoxId);var isEmptyQuery=(txtSearchBox.value==txtSearchBox.title||jQuery.trim(txtSearchBox.value)=="");if(!isEmptyQuery){window.location='/search/?q='+encodeURIComponent(txtSearchBox.value);return false;}};var subArea={init:function(){if(!document.getElementById("moreArea"))return;var moreArea=document.getElementById("moreArea");var subArea=document.getElementById("subArea");moreArea.onmouseover=function(){subArea.style.display='block';}
subArea.onmouseout=function(){subArea.style.display='none';}
if(document.getElementById('Home')){this._addEventToAreasHomePage();}
else{this._addEventToAreasSubPage();}},_addEventToAreasSubPage:function(){var self=this;jQuery('.cols3>ul>li>a').not(jQuery('#moreArea>a')).click(function(){jQuery('.cols3>ul>li>a').removeClass('currentLocation');jQuery(this).addClass('currentLocation');jQuery('#subArea').hide();});jQuery('#subArea li a').click(function(){jQuery('#moreArea>a').empty();jQuery('#moreArea>a').append('<span>'+jQuery(this).html()+'</span>');jQuery('#moreArea>a').addClass('currentLocation');if(jQuery(this).html()===allLocationInterfaceTranslation&&jQuery('#txtSearch').val()===jQuery('#txtSearch').attr("title")){jQuery('#txtSearch').focus();return false;}});},_addEventToAreasHomePage:function(){var _self=this;jQuery('.cols3>ul>li>a').not(jQuery('#browseTab a')).not(jQuery('#moreArea>a')).not(jQuery('#subArea li a')).click(function(){return _self._submitSearch(jQuery(this),jQuery('#txtSearch'));});jQuery('.cols3>ul>li>a').not(jQuery('#moreArea>a')).click(function(){jQuery('.cols3>ul>li>a').removeClass('currentLocation');jQuery(this).addClass('currentLocation');jQuery('#subArea').hide();});jQuery('#subArea li a').click(function(){jQuery('#moreArea>a').empty();jQuery('#moreArea>a').append('<span>'+jQuery(this).html()+'</span>');jQuery('#moreArea>a').addClass('currentLocation');return _self._submitSearch(jQuery(this),jQuery('#txtSearch'));});},_submitSearch:function(link,query){if(link.html()===allLocationInterfaceTranslation&&query.val()===query.attr("title")){query.focus();return false;}
if(query.val()===query.attr("title"))return;return false;}};function loadGoogleMap(callback,callbackName){if(!window['GMap2']){var script=document.createElement("script");script.type="text/javascript";script.src='http://maps.google.com/maps?file=api&v=2.x&key='+currentPortal.map_key+'&async=2&callback='+callbackName;document.getElementsByTagName("head")[0].appendChild(script);}
else{callback();}};function showCreateNewListingPopup(){newListing={};showCreateNewListingKeyword();};function showCreateNewListingKeyword(){var keywordWrapper=jsgtk.Dom.create({"tag":"div","style":"display: block; padding: 10px;height:370px;width:468px"});var title=jsgtk.Dom.create({"append":keywordWrapper,"tag":"h3","style":"padding-bottom:5px;"});title.innerHTML=addKeyword+'<a target="_blank" style="text-decoration: underline; float: right;color:#666;" href="https://adwords.google.com/select/KeywordToolExternal">Discover profitable keywords</a>';var keywordTextArea=jsgtk.Dom.create({"append":keywordWrapper,"tag":"textarea","style":"height:310px;width:462px;","rows":"14","id":"listingKeyword","title":"Keywords are separated by comma (Required)"});var nextButton=jsgtk.Dom.create({"append":keywordWrapper,"tag":"input","type":"button","value":next,"style":"float:right;margin-left:5px;margin-top:5px;padding:2px 10px;"});jsgtk.Event.addDomListener(nextButton,"click",function(){if(jQuery("#listingKeyword").val()!==jQuery("#listingKeyword").attr("title")){newListing.keywords=jQuery("#listingKeyword").val();showCreateNewListingProfile();}});if(newListing.keywords===undefined){var popupContent={title:createNewListing,content:keywordWrapper};popup=new gtk.Popup(popupContent);popup.draw();}
else{popup.addContent(keywordWrapper);jQuery("#listingKeyword").val(newListing.keywords);}
jQuery('#listingKeyword').hint();};function showCreateNewListingProfile(){var root="http://"+window.location.host;var wrapper=jsgtk.Dom.create({"tag":"div","style":"display: block; padding: 10px;height:370px;width:468px"});var title=jsgtk.Dom.create({"append":wrapper,"tag":"h3","style":"padding-bottom:5px;"});title.innerHTML=buildListing+"<a href='/GoodListing/' style='text-decoration:underline;float:right;color:#666;' onclick='return popupWindow(\""+root+"/GoodListing.htm\");'>"+"Read the secret to a good listing</a>";var listingTextArea=jsgtk.Dom.create({"append":wrapper,"tag":"textarea","style":"height:310px;width:462px;","rows":"14","id":"listingProfile"});var footer=jsgtk.Dom.create({"append":wrapper,"tag":"div"});var backButton=jsgtk.Dom.create({"tag":"input","type":"button","value":back,"style":"float:left;margin-left:0px;margin-top:5px;padding:2px 10px;"});jsgtk.Event.addDomListener(backButton,"click",function(){newListing.profile=jQuery("#listingProfile").val();showCreateNewListingKeyword();});var nextButton=jsgtk.Dom.create({"tag":"input","type":"button","value":next,"style":"float:right;margin-left:5px;margin-top:5px;padding:2px 10px;"});jsgtk.Event.addDomListener(nextButton,"click",function(){newListing.profile=jQuery("#listingProfile").val();showCreateNewListingMap();});footer.appendChild(backButton);footer.appendChild(nextButton);popup.addContent(wrapper);if(newListing.profile!==undefined){jQuery('#listingProfile').val(newListing.profile);}
else{jQuery.get('/listingAddGuideLine.txt',function(x){jQuery('#listingProfile').val(x);});}};function showCreateNewListingMap(){var wrapper=jsgtk.Dom.create({"tag":"div","style":"display: block; padding: 10px;height:370px;width:470px"});var title=jsgtk.Dom.create({"append":wrapper,"tag":"h3","style":"padding-bottom:5px;"});title.innerHTML=addLocation;var locationText=jsgtk.Dom.create({"append":wrapper,"tag":"input","style":"margin-left:0px;margin-top:5px;padding:3px 10px;width:320px;","id":"findLocation"});var findLocationButton=jsgtk.Dom.create({"append":wrapper,"tag":"input","style":"margin-top:5px;padding:2px 5px;float:right;","type":"button","value":findLocation});jsgtk.Event.addDomListener(findLocationButton,"click",function(){newListingMap.findLocation(jQuery("#findLocation").val());});var listingMap=jsgtk.Dom.create({"append":wrapper,"tag":"div","style":"margin-top:2px;height:277px;","id":"listingMap"});listingMap.innerHTML="<p class='loading' style='height: 100%;'></p>";var footer=jsgtk.Dom.create({"append":wrapper,"tag":"div"});var backButton=jsgtk.Dom.create({"tag":"input","type":"button","value":back,"style":"float:left;margin-left:0px;margin:5px;padding:2px 10px;"});var nextButton=jsgtk.Dom.create({"tag":"input","type":"button","value":next,"style":"float:right;margin-left:5px;margin:5px;padding:2px 10px;"});jsgtk.Event.addDomListener(backButton,"click",function(){newListing.latlng=newListingMap.getLatLng();newListing.zoomLevel=newListingMap.getZoomLevel();showCreateNewListingProfile();});jsgtk.Event.addDomListener(nextButton,"click",function(){newListing.latlng=newListingMap.getLatLng();newListing.zoomLevel=newListingMap.getZoomLevel();showCreateNewListingSendMail();});footer.appendChild(backButton);footer.appendChild(nextButton);popup.addContent(wrapper);bindListingAddressWithFindLocation();loadGoogleMap(showNewListingGoogleMap,"showNewListingGoogleMap");};function showCreateNewListingSendMail(){var wrapper=jsgtk.Dom.create({"tag":"div","style":"display: block; padding: 10px;height:372px;width:468px;color: #333;"});var title=jsgtk.Dom.create({"append":wrapper,"tag":"h3","style":"padding-bottom:5px;"});title.innerHTML=subscribe+' & '+submit;var checkbox=jsgtk.Dom.create({"append":wrapper,"tag":"input","type":"checkbox","style":"margin-left:0px;margin-top:5px;padding:2px 10px;","id":"newListingOwner"});var span=jsgtk.Dom.create({"append":wrapper,"tag":"span","style":"display:block;left:35px;position:absolute;top:59px;"});span.innerHTML=listingOwner;var form=jsgtk.Dom.create({"append":wrapper,"tag":"table","style":"width:462px;margin-top:10px;"});form.innerHTML='<tr><td style="text-align:right;"><label>'+yourName+':</label></td><td><input id="yourName" style="font-size:16px;width:300px;padding:3px 2px;"/></td></tr><tr><td style="text-align:right;padding-top:5px;"><label name="email">'+yourEmail+':</label></td><td style="padding-top:5px;"><input id="yourEmail" style="font-size:16px;width:300px;padding:3px 2px;"/></tr>';var footer=jsgtk.Dom.create({"append":wrapper,"tag":"div","style":"margin-top: 222px;"});var backButton=jsgtk.Dom.create({"tag":"input","type":"button","value":back,"style":"float:left;margin-left:0px;margin:5px;padding:2px 10px;"});var okButton=jsgtk.Dom.create({"tag":"input","type":"button","value":submit,"style":"float:right;margin-left:5px;margin:5px;padding:2px 15px;","id":"submitEmail"});okButton.disabled=true;jsgtk.Event.addDomListener(okButton,"click",function(){newListing.isOwner=jQuery('#newListingOwner').is(':checked');newListing.yourName=jQuery("#yourName").val();newListing.yourEmail=jQuery("#yourEmail").val();jQuery.post("/email/create_new_listing",newListing);popup.close();});jsgtk.Event.addDomListener(backButton,"click",function(){newListing.isOwner=jQuery('#newListingOwner').is(':checked');newListing.yourName=jQuery("#yourName").val();newListing.yourEmail=jQuery("#yourEmail").val();showCreateNewListingMap();});footer.appendChild(backButton);footer.appendChild(okButton);popup.addContent(wrapper);jQuery('#yourName').keyup(validateNewListingOwner);jQuery('#yourEmail').keyup(validateNewListingOwner);if(newListing.isOwner!==undefined){jQuery('#newListingOwner').attr("checked",newListing.isOwner);jQuery("#yourName").val(newListing.yourName);jQuery("#yourEmail").val(newListing.yourEmail);validateNewListingOwner();}};function validateNewListingOwner(){if(jQuery("#yourName").val()&&isEmail(jQuery("#yourEmail").val())){jQuery('#submitEmail').attr("disabled",false);}
else{jQuery('#submitEmail').attr("disabled",true);}}
function showNewListingGoogleMap(){var width=470;var height=280;var element=document.getElementById("listingMap");if(newListing.latlng){newListingMap=new Map(element,width,height,newListing.latlng.lat(),newListing.latlng.lng(),newListing.zoomLevel);}
else{newListingMap=new Map(element,width,height);}
newListingMap.showMapNewListing();};function bindListingAddressWithFindLocation(){var textAddress=newListing.profile.match(/(ADDRESS):.*/i);if(textAddress){textAddress=textAddress[0].split(":")[1];}
textAddress=jQuery.trim(textAddress);jQuery("#findLocation").val(textAddress);};function popupWindow(url,width,height){var h=height||540;var w=width||500;var winLeft=(screen.width-w)/2;var winTop=(screen.height-h)/2;if(winLeft<0){winLeft=0;}
windowProps="height="+h+",width="+w+",top="+winTop+" ,left="+winLeft+",location=no,"
+"scrollbars=yes,menubars=no,toolbars=no,resizable=no,status=yes, directories=false";var newWindow=window.open(url,"Popup",windowProps);if(window.focus){newWindow.focus();}};RefineSearch={init:function(){var _self=this;this._locationName=jQuery("#moreArea a span").html();if(document.getElementById('Search')){this._setCurrentSearchLocation();this._setOptionsValue();this._addEventOnChange();}
else if(document.getElementById('Classification')){jQuery("#filters select option:first").attr('selected','selected');jQuery("#filters select").attr('disabled','disabled');}
else{jQuery("#filters select option:first").text(this._locationName);jQuery("#filters select").attr('disabled','disabled');}},_setCurrentSearchLocation:function(){var _self=this;if(this._locationName==="All locations"){jQuery("#filters select option:first").attr('selected','selected');}
else{jQuery("#filters select option").each(function(){if(jQuery(this).text()===_self._locationName){jQuery(this).attr("selected","selected");}});}},_addEventOnChange:function(){var _self=this;jQuery('#filters select').change(function(){_self._redirect(jQuery('#filters select').val());});},_redirect:function(url){window.location.href=url;},_setOptionsValue:function(){var locationUuids=[];jQuery('#subArea li a').each(function(){if(jQuery(this).attr('href')=='#'){locationUuids.push('#');}
else{locationUuids.push(this.href.split('/')[4]);}});var index=0;var _self=this;jQuery("#filters select option").each(function(){if(locationUuids[index]!='#'){jQuery(this).attr('value',_self._removeLocationUuidFromUrl(window.location.href)+'&location_uuid='+locationUuids[index]);}
else{jQuery(this).attr('value',window.location.href);}
index++;});},_removeLocationUuidFromUrl:function(url){var query=url.substring(url.indexOf('?'),url.length);var queryString=query.substring(1,query.length);var pair=queryString.split('&');for(var i=0;i<pair.length;i++){var params=pair[i].split('=');if(params[0]=='location_uuid'){url=url.replace(/&location_uuid.+/g,'');break;}}
return url;}};HiliListingHandler={init:function(){if(jQuery("#Search")){jQuery(".media").mouseover(function(){jQuery('.media').parent().css('background-color','white');jQuery('.adr').css('background-color','white');jQuery('.adr .region').css('background-color','white');jQuery('.adr .contactInfo').css('background-color','white');});jQuery(".media").mouseout(function(){jQuery('.media').parent().css('background-color','');jQuery('.adr').css('background-color','');jQuery('.adr .region').css('background-color','');jQuery('.adr .contactInfo').css('background-color','');});}}};gtk={};jsgtk={};jsgtk.Dom={ie:(function(){return(window.opera===undefined&&(navigator.userAgent.indexOf("Internet Explorer")>=0||navigator.userAgent.indexOf("MSIE")>=0))?true:false})(),ie6or7:(function(){return(window.opera===undefined&&(navigator.userAgent.indexOf("MSIE 6.0")>=0||navigator.userAgent.indexOf("MSIE 7.0")>=0))?true:false})(),doc:document,create:function(c){if(!c.tag){return null}var a;if((c.name||c.type)&&this.ie){var b=(c.name)?"name='"+c.name+"'":"";var e=(c.type)?"type='"+c.type+"'":"";var d="<"+c.tag+" "+b+" "+e+" />";a=this.doc.createElement(d);delete c.name}else{a=this.doc.createElement(c.tag)}delete c.tag;if(c.append){c.append.appendChild(a);delete c.append}c.edit=a;a=this.edit(c);return a},edit:function(e){var j=e.edit;delete e.edit;if(e.text){j.appendChild(this.doc.createTextNode(e.text));delete e.text}if(e.className){j.className=e.className;delete e.className}var b=e.style;if(b&&this.ie){var f=b.split(";"),d=f.length;for(var c=f.length;c--;){var h=f[c].replace(/ /g,"");if(h){var a=h.split(":");j.style[this._camelize(a[0])]=a[1]}}delete b}for(var g in e){if(j.tagName=="INPUT"&&this.ie&&(e[g]=="button"||e[g]=="submit"||e[g]=="radio"||e[g]=="checkbox")){j.property=e[g]}else{j.setAttribute(g,e[g])}}return j},_camelize:function(b){var e=b.split("-"),a=e.length;if(a==1){return e[0]}var d=b.charAt(0)=="-"?e[0].charAt(0).toUpperCase()+e[0].substring(1):e[0];for(var c=1;c<a;c++){d+=e[c].charAt(0).toUpperCase()+e[c].substring(1)}return d},getTextSize:function(c){var b=jsgtk.Dom.create({tag:"span",text:c});document.body.appendChild(b);var a=[b.offsetWidth,b.offsetHeight];document.body.removeChild(b);return a},showElement:function(a){a.style.display="block"},hideElement:function(a){a.style.display="none"},isShowed:function(a){return a.style.display==="none"?false:true},hilightCell:function(a,b){for(el in b){a.style[el]=b[el]}},SortTable:function(b){var a=new SortableTable(b)}};jsgtk.Event={addDomListener:function(a,c,d){if(a.addEventListener){a.addEventListener(c,d,false)}else{a.attachEvent("on"+c,d)}var b={obj:a,type:c,callback:d};return b},addListener:function(b,a,c){if(!b.listeners){b.listeners={}}if(!b.listeners[a]){b.listeners[a]=[]}b.listeners[a].push(c);return{obj:b,type:a,callback:c,isDomObj:false}},removeListener:function(a){if(a.obj.removeEventListener){a.obj.removeEventListener(a.type,a.callback,false)}else{a.obj.detachEvent("on"+a.type,a.callback)}},trigger:function(d,c){if(d.listeners&&d.listeners[c]){var a=[];for(var b=2;b<arguments.length;b++){a[b-2]=arguments[b]}for(var b=0;b<d.listeners[c].length;b++){d.listeners[c][b].apply(d,a)}}},stopBubble:function(a){if(a&&a.stopPropagation){a.stopPropagation()}else{window.event.cancelBubble=true}},stopDefault:function(a){if(a&&a.preventDefault){a.preventDefault()}else{window.event.returnValue=false}return false}};jsgtk.Util={clone:function(b){var a=function(){};a.prototype=b;var d=new a();d.constructor=a;return d},isMatched:function(a,b){return new RegExp(a).test(b)},arrayRemoveElement:function(e,c){var d=false;for(var b=0,a=e.length;b<a;b++){if(e[b]===c){d=true;return b}}if(d){e.splice(b,1)}},scrollX:function(){return(document.documentElement&&document.documentElement.scrollLeft)||window.pageXOffset||self.pageXOffset||document.body.scrollLeft},scrollY:function(){return(document.documentElement&&document.documentElement.scrollTop)||window.pageYOffset||self.pageYOffset||document.body.scrollTop},width:function(){return(document.documentElement&&document.documentElement.scrollWidth)?document.documentElement.scrollWidth:(document.body.scrollWidth>document.body.offsetWidth)?document.body.scrollWidth:document.body.offsetWidth},height:function(){return(document.documentElement&&document.documentElement.scrollHeight)?document.documentElement.scrollHeight:(document.body.scrollHeight>document.body.offsetHeight)?document.body.scrollHeight:document.body.offsetHeight},arraySwapElements:function(e,b,a){var d=e.indexOf(b);var c=e.indexOf(a);e[d]=null;e[c]=null;e[d]=a;e[c]=b},windowHeight:function(){var a=document.documentElement;return self.innerHeight||(a&&a.clientHeight)||document.body.clientHeight},windowWidth:function(){var a=document.documentElement;return self.innerWidth||(a&&a.clientWidth)||document.body.clientWidth},getWindowHeight:function(){return jsgtk.Util.windowHeight()},getWindowWidth:function(){return jsgtk.Util.windowWidth()},calculateTextWidthHeight:function(d){var c=jsgtk.Dom.create({append:document.body,tag:"span",style:"position:absolute;"});var d=jsgtk.Dom.create({append:c,tag:"text",text:d});var b=c.clientWidth;var a=c.clientHeight;document.body.removeChild(c);return[b,a]},getTextFromTop:function(b,a){return(b/2)-(a/2)},trim:function(a){return a.replace(/^\s+|\s+$/,"")},fullHeight:function(c){var a;document.body.appendChild(c);if(this.getStyle(c,"display")!="none"){a=c.offsetHeight||this.getHeight(c);document.body.removeChild(c);return a}var b=this.resetCSS(c,{display:"",visibility:"hidden",position:"absolute"});a=c.clientHeight||this.getHeight(c);this.restoreCSS(c,b);document.body.removeChild(c);return a},fullWidth:function(c){var b;document.body.appendChild(c);if(this.getStyle(c,"display")!="none"){b=c.offsetWidth||this.getWidth(c);document.body.removeChild(c);return b+jsgtk.Util.EXTRAPIXEL}var a=this.resetCSS(c,{display:"",visibility:"hidden",position:"absolute"});b=c.clientWidth||this.getWidth(c);this.restoreCSS(c,a);document.body.removeChild(c);return b+jsgtk.Util.EXTRAPIXEL},getStyle:function(c,a){if(c.style[a]){return c.style[a]}else{if(c.currentStyle){return c.currentStyle[a]}else{if(document.defaultView&&document.defaultView.getComputedStyle){a=a.replace(/([A-Z])/g,"-$1");a=a.toLowerCase();var b=document.defaultView.getComputedStyle(c,"");return b&&b.getPropertyValue(a)}else{return null}}}},getHeight:function(a){return parseInt(this.getStyle(a,"height"))},getWidth:function(a){return parseInt(this.getStyle(a,"width"))},pageX:function(a){return a.offsetParent?a.offsetLeft+this.pageX(a.offsetParent):a.offsetLeft},pageY:function(a){return a.offsetParent?a.offsetTop+this.pageY(a.offsetParent):a.offsetTop},getPageSize:function(){var k,i,j=document.body,a=window.innerHeight,f=window.scrollMaxY;if(a&&f){k=j.scrollWidth;i=a+f}else{if(j.scrollHeight>j.offsetHeight){k=j.scrollWidth;i=j.scrollHeight}else{k=j.offsetWidth;i=j.offsetHeight}}var l,e,g=document.documentElement;if(self.innerHeight){l=self.innerWidth;e=self.innerHeight}else{if(g&&g.clientHeight){l=g.clientWidth;e=g.clientHeight}else{if(j){l=j.clientWidth;e=j.clientHeight}}}var m=(i<e)?e:i,c=(k<l)?l:k;return[c,m,l,e]},resetCSS:function(c,d){var a={};for(var b in d){a[b]=c.style[b];c.style[b]=d[b]}return a},restoreCSS:function(b,c){for(var a in c){b.style[a]=c[a]}},debug:function(a){throw(a)},removeArrayElements:function(c,b,a){Array.remove(c,b,a)},getScrollX:function(){var a=document.documentElement;return pageXOffset||(a&&a.scrollLeft)||document.body.scrollLeft},getScrollY:function(){var a=document.documentElement;return self.pageYOffset||(a&&a.scrollTop)||document.body.scrollTop},detect:{init:function(){this.browser=this.searchString(this.dataBrowser)||"An unknown browser";this.version=this.searchVersion(navigator.userAgent)||this.searchVersion(navigator.appVersion)||"an unknown version";this.OS=this.searchString(this.dataOS)||"an unknown OS"},searchString:function(d){for(var a=0;a<d.length;a++){var b=d[a].string;var c=d[a].prop;this.versionSearchString=d[a].versionSearch||d[a].identity;if(b){if(b.indexOf(d[a].subString)!=-1){return d[a].identity}}else{if(c){return d[a].identity}}}},searchVersion:function(b){var a=b.indexOf(this.versionSearchString);if(a==-1){return}return parseFloat(b.substring(a+this.versionSearchString.length+1))},dataBrowser:[{string:navigator.userAgent,subString:"Chrome",identity:"Chrome"},{string:navigator.userAgent,subString:"OmniWeb",versionSearch:"OmniWeb/",identity:"OmniWeb"},{string:navigator.vendor,subString:"Apple",identity:"Safari",versionSearch:"Version"},{prop:window.opera,identity:"Opera"},{string:navigator.vendor,subString:"iCab",identity:"iCab"},{string:navigator.vendor,subString:"KDE",identity:"Konqueror"},{string:navigator.userAgent,subString:"Firefox",identity:"Firefox"},{string:navigator.vendor,subString:"Camino",identity:"Camino"},{string:navigator.userAgent,subString:"Netscape",identity:"Netscape"},{string:navigator.userAgent,subString:"MSIE",identity:"Explorer",versionSearch:"MSIE"},{string:navigator.userAgent,subString:"Gecko",identity:"Mozilla",versionSearch:"rv"},{string:navigator.userAgent,subString:"Mozilla",identity:"Netscape",versionSearch:"Mozilla"}],dataOS:[{string:navigator.platform,subString:"Win",identity:"Windows"},{string:navigator.platform,subString:"Mac",identity:"Mac"},{string:navigator.userAgent,subString:"iPhone",identity:"iPhone/iPod"},{string:navigator.platform,subString:"Linux",identity:"Linux"}]}};jsgtk.Util.detect.init();jsgtk.Util.EXTRAPIXEL=(jsgtk.Util.detect.OS=="Mac"&&jsgtk.Util.detect.browser=="Firefox")?1:0;Array.remove=function(d,c,b){var a=d.slice((b||c)+1||d.length);d.length=c<0?d.length+c:c;return d.push.apply(d,a)};function UUID(){this.id=this.createUUID()}UUID.prototype.valueOf=function(){return this.id};UUID.prototype.toString=function(){return this.id};UUID.prototype.createUUID=function(){var d=new Date(1582,10,15,0,0,0,0);var g=new Date();var j=g.getTime()-d.getTime();var b="-";var k=UUID.getIntegerBits(j,0,31);var i=UUID.getIntegerBits(j,32,47);var f=UUID.getIntegerBits(j,48,59)+"1";var c=UUID.getIntegerBits(UUID.rand(4095),0,7);var e=UUID.getIntegerBits(UUID.rand(4095),0,7);var a=UUID.getIntegerBits(UUID.rand(8191),0,7)+UUID.getIntegerBits(UUID.rand(8191),8,15)+UUID.getIntegerBits(UUID.rand(8191),0,7)+UUID.getIntegerBits(UUID.rand(8191),8,15)+UUID.getIntegerBits(UUID.rand(8191),0,15);return k+b+i+b+f+b+c+e+b+a};UUID.getIntegerBits=function(f,g,b){var a=UUID.returnBase(f,16);var d=new Array();var e="";var c=0;for(c=0;c<a.length;c++){d.push(a.substring(c,c+1))}for(c=Math.floor(g/4);c<=Math.floor(b/4);c++){if(!d[c]||d[c]==""){e+="0"}else{e+=d[c]}}return e};UUID.returnBase=function(a,b){return(a).toString(b).toUpperCase()};UUID.rand=function(a){return Math.floor(Math.random()*(a+1))};jsgtk.domDrag={obj:null,init:function(d,i,f,b,e,a,g,l,j,h,k,c){d.onmousedown=jsgtk.domDrag.start;d.hmode=j?false:true;d.vmode=h?false:true;d.root=i&&i!=null?i:d;if(d.hmode&&isNaN(parseInt(d.root.style.left))){d.root.style.left="0px"}if(d.vmode&&isNaN(parseInt(d.root.style.top))){d.root.style.top="0px"}if(!d.hmode&&isNaN(parseInt(d.root.style.right))){d.root.style.right="0px"}if(!d.vmode&&isNaN(parseInt(d.root.style.bottom))){d.root.style.bottom="0px"}d.minX=typeof f!="undefined"?f:null;d.minY=typeof e!="undefined"?e:null;d.maxX=typeof b!="undefined"?b:null;d.maxY=typeof a!="undefined"?a:null;d.minX=g?0:d.minX;d.maxX=g?0:d.maxX;d.minY=l?0:d.minY;d.maxY=l?0:d.maxY;d.xMapper=k?k:null;d.yMapper=c?c:null;d.root.onDragStart=new Function();d.root.onDragEnd=new Function();d.root.onDrag=new Function()},start:function(b){var c=jsgtk.domDrag.obj=this;b=jsgtk.domDrag.fixE(b);var d=parseInt(c.vmode?c.root.style.top:c.root.style.bottom);var a=parseInt(c.hmode?c.root.style.left:c.root.style.right);c.root.onDragStart(a,d,b);c.lastMouseX=b.clientX;c.lastMouseY=b.clientY;if(c.hmode){if(c.minX!=null){c.minMouseX=b.clientX-a+c.minX}if(c.maxX!=null){c.maxMouseX=c.minMouseX+c.maxX-c.minX}}else{if(c.minX!=null){c.maxMouseX=-c.minX+b.clientX+a}if(c.maxX!=null){c.minMouseX=-c.maxX+b.clientX+a}}if(c.vmode){if(c.minY!=null){c.minMouseY=b.clientY-d+c.minY}if(c.maxY!=null){c.maxMouseY=c.minMouseY+c.maxY-c.minY}}else{if(c.minY!=null){c.maxMouseY=-c.minY+b.clientY+d}if(c.maxY!=null){c.minMouseY=-c.maxY+b.clientY+d}}document.onmousemove=jsgtk.domDrag.drag;document.onmouseup=jsgtk.domDrag.end;return false},drag:function(f){f=jsgtk.domDrag.fixE(f);var g=jsgtk.domDrag.obj;var c=f.clientY;var d=f.clientX;var i=parseInt(g.vmode?g.root.style.top:g.root.style.bottom);var b=parseInt(g.hmode?g.root.style.left:g.root.style.right);var a,h;if(g.minX!=null){d=g.hmode?Math.max(d,g.minMouseX):Math.min(d,g.maxMouseX)}if(g.maxX!=null){d=g.hmode?Math.min(d,g.maxMouseX):Math.max(d,g.minMouseX)}if(g.minY!=null){c=g.vmode?Math.max(c,g.minMouseY):Math.min(c,g.maxMouseY)}if(g.maxY!=null){c=g.vmode?Math.min(c,g.maxMouseY):Math.max(c,g.minMouseY)}a=b+((d-g.lastMouseX)*(g.hmode?1:-1));h=i+((c-g.lastMouseY)*(g.vmode?1:-1));if(g.xMapper){a=g.xMapper(i)}else{if(g.yMapper){h=g.yMapper(b)}}jsgtk.domDrag.obj.root.style[g.hmode?"left":"right"]=a+"px";jsgtk.domDrag.obj.root.style[g.vmode?"top":"bottom"]=h+"px";jsgtk.domDrag.obj.lastMouseX=d;jsgtk.domDrag.obj.lastMouseY=c;jsgtk.domDrag.obj.root.onDrag(a,h,f);return false},end:function(){document.onmousemove=null;document.onmouseup=null;jsgtk.domDrag.obj.root.onDragEnd(parseInt(jsgtk.domDrag.obj.root.style[jsgtk.domDrag.obj.hmode?"left":"right"]),parseInt(jsgtk.domDrag.obj.root.style[jsgtk.domDrag.obj.vmode?"top":"bottom"]));jsgtk.domDrag.obj=null},fixE:function(a){if(typeof a=="undefined"){a=window.event}if(typeof a.layerX=="undefined"){a.layerX=a.offsetX}if(typeof a.layerY=="undefined"){a.layerY=a.offsetY}return a}};jsgtk.Util.DomDraggableAdapter={vDragInit:function(a,c,b){jsgtk.domDrag.init(a,null,null,null,c,b,true)},hDragInit:function(b,a,c){jsgtk.domDrag.init(b,null,a,c,null,null,false,true)},dragInit:function(b,a,d,e,c){jsgtk.domDrag.init(b,null,a,d,e,c,false,false)}};gobject={_signals:[],_signalCount:0,signalNew:function(a,b){var c={};if(this.signalLookup(a,b)){throw("RuntimeError: this signal is already binned to the type")}this._signalCount++;c[a]={type:b,id:this._signalCount};this._signals.push(c);return this._signalCount},signalLookup:function(a,c){for(var b=this._signals.length;b--;){if(this._signals[b][a]&&this._signals[b][a].type===c){return this._signals[b][a].id}if(this._signals[b][a]&&c instanceof this._signals[b][a].type){return this._signals[b][a].id}}return null}};gobject.GObject=function(){this.props={};this._signalHandlers={};this.emit=function(a){if(this._signalHandlers[a]){var b=[];for(var c=1;c<arguments.length;c++){b.push(arguments[c])}for(var c=0;c<this._signalHandlers[a].length;c++){this._signalHandlers[a][c].handler.apply(this,b.concat(this._signalHandlers[a][c].args))}}};this.connect=function(a,d){this._signalCheck(a);if(!this._signalHandlers[a]){this._signalHandlers[a]=[];this._handlerId++}var b=[];var e=new UUID().id;for(var c=2;c<arguments.length;c++){b.push(arguments[c])}this._signalHandlers[a].push({handler:d,args:b,id:e});return e};this.disconnect=function(e){for(var d in this._signalHandlers){var b=this._signalHandlers[d];for(var c=0,a=b.length;c<a;c++){if(b[c].id===e){b.splice(c,1);break}}}};this._signalCheck=function(a){var b=gobject.signalLookup(a,this);if(b){return b}throw("Undefined signal name: "+a)};this._removeSignal=function(b){for(var a in this._signalHandlers){if(a==b){delete this._signalHandlers.handlerId}}}};gtk.Object=function(){gobject.GObject.apply(this)};gtk.Widget=function(){gtk.Object.apply(this);this._domObj;this._width=this._minWidth=16;this._height=this._minHeight=16;this._parent=null;this._handlers=[];this._render=function(){this._domObj=jsgtk.Dom.create({tag:"div",className:"gtk_widget"})};this._render()};gtk.Widget.prototype=new gtk.Object();gtk.Widget.prototype.constructor=gtk.Widget;gtk.Widget.prototype.showLoading=function(){if(!this._loadingImgContainer){this._loadingImgContainer=this._constructLoading();this._appendLoading()}else{this._loadingImgContainer.style.display="table"}};gtk.Widget.prototype.hideLoading=function(){jsgtk.Dom.hideElement(this._loadingImgContainer)};gtk.Widget.prototype.setParent=function(a){this._parent=a};gtk.Widget.prototype.getParent=function(){return this._parent};gtk.Widget.prototype.getNode=function(){return this._domObj};gtk.Widget.prototype.resetMinWidth=function(a){this._isMinWidthChanged=a?true:false;this._minWidth=a;this._width=a};gtk.Widget.prototype.resetMinHeight=function(a){this._isMinHeightChanged=a?true:false;this._minHeight=a;this._height=a};gtk.Widget.prototype._constructLoading=function(){var a=jsgtk.Dom.create({tag:"table","class":"gtk_loading_bar_container_widget"});a.style.zIndex=gtk.SHOWLOADING_ZINDEX;var b=jsgtk.Dom.create({append:a,tag:"tr"});var c=jsgtk.Dom.create({append:b,tag:"td"});this._loadingImgFrame=jsgtk.Dom.create({append:c,tag:"div","class":"gtk_loading_frame"});this._loadingImg=jsgtk.Dom.create({append:this._loadingImgFrame,tag:"div","class":"gtk_loading_bar_widget"});return a};gtk.Widget.prototype._appendLoading=function(){var a=this._domObj.firstChild;if(a){this._domObj.insertBefore(this._loadingImgContainer,a)}else{this._domObj.appendChild(this._loadingImgContainer)}};gtk.Widget.prototype._resizeHeight=function(a){this._domObj.style.height=a+"px";this._height=a};gtk.Widget.prototype._resizeWidth=function(a){this._domObj.style.width=a+"px";this._width=a};gtk.Widget.prototype.getMinWidth=function(){return this._minWidth};gtk.Widget.prototype.getMinHeight=function(){return this._minHeight};gtk.Widget.prototype.resizeWidth=function(a){this._width=a;this._domObj.style.width=this._width+"px"};gtk.Widget.prototype.resizeHeight=function(a){this._height=a;this._domObj.style.height=this._height+"px"};gtk.Blank=function(){gtk.Widget.apply(this);this._render=function(){this._domObj.className+=" gtk_blank"};this._render();this.showLoading()};gtk.Blank.prototype=new gtk.Widget();gtk.Blank.prototype.constructor=gtk.Blank;gtk.Popup=function(a){gtk.Widget.apply(this);this._objectContent=a||null;this._title=null;this._bodyContent=null;this._width=this._minWidth=100;this._height=this._minHeight=100;this._headerHeight=26;this._loadingWidth=300;if(typeof a!=="undefined"){this._renderObj(a);this._initEvent()}};gtk.Popup.prototype=new gtk.Widget();gtk.Popup.prototype.constructor=gtk.Popup;gtk.Popup.prototype._renderObj=function(b){this._title=b.title||"Untitled";this._blankObject=this._createBlankContent();this._bodyContent=b.content||this._blankObject;this._imageURL=b.url||"";this._domObj.className+=" gtk_popup";this._domObj.id="gtk_popup";var a=jsgtk.Dom;this._headerDom=a.create({append:this._domObj,tag:"div",className:"gtk_popup_header"});this._titleDom=a.create({tag:"div",className:"gtk_popup_title",append:this._headerDom});this._titleDom.innerHTML=this._title;this._closeBtnDom=a.create({tag:"div",className:"gtk_popup_closebtn",title:"Close",append:this._headerDom});this._bodyDom=jsgtk.Dom.create({append:this._domObj,tag:"div",className:"gtk_popup_body"});if(this._imageURL===""&&this._bodyContent.tagName!=="IMG"){this._bodyDom.appendChild(this._bodyContent)}};gtk.Popup.prototype.draw=function(){if(this._imageURL!==""&&this._bodyContent.tagName==="IMG"){this._loadImage()}this._createModal();this._resize();this._setCentered();document.body.appendChild(this._domObj);this._fadeOpacity("gtk_popup",0,100,200,60);this._domObj.style.display="block";this.emit("shown")};gtk.Popup.prototype._loadImage=function(){var b=this;var c=jsgtk.Util;var d=c.getWindowWidth();var a=c.getWindowHeight();this._imageDom=jsgtk.Dom.create({append:document.body,tag:"img",style:"visibility: hidden"});this._bodyDom.appendChild(this._blankObject);this._imageDom.src=this._imageURL;this._imageDom.onload=function(){if(b._blankObject){b._bodyDom.removeChild(b._blankObject)}b._bodyDom.appendChild(b._bodyContent);b._bodyContent.src=b._imageURL;b._resize();b._setCentered();if(b._imageDom){document.body.removeChild(b._imageDom)}};this._imageDom.onerror=function(){var e=b._blankObject.firstChild.firstChild.firstChild;e.innerHTML="The image is missing!";e.className="gtk_popup_missing_image"}};gtk.Popup.prototype._disableScroll=function(){document.body.style.overflow="hidden";document.body.scroll="no"};gtk.Popup.prototype._enableScroll=function(){document.body.style.overflow="auto";document.body.scroll="yes"};gtk.Popup.prototype.setTitle=function(a){this._title=a||"Untitled";this._titleDom.innerHTML=a;this.emit("titlechanged")};gtk.Popup.prototype.addContent=function(a){this._bodyContent=a||this._createBlankContent();this._bodyDom.innerHTML="";this._bodyDom.appendChild(this._bodyContent);this._resize();this._setCentered();this.emit("contentchanged")};gtk.Popup.prototype._createBlankContent=function(){this._width=this._minWidth=this._loadingWidth;this._height=this._minHeight=100;var a=new gtk.Blank();a.getNode().style.width=this._width+"px";a.getNode().style.height=this._height-this._headerHeight+"px";return a.getNode()};gtk.Popup.prototype._fadeOpacity=function(f,e,a,d,c){var b=Math.ceil(c*(d/1000));var g=(a-e)/b;this._fadeOpacityStep(f,0,b,e,g,(d/b))};gtk.Popup.prototype._fadeOpacityStep=function(f,e,b,d,g,c){var a=this;this._setOpacity(document.getElementById(f),Math.round(parseInt(d)+(g*e)));if(e<b){setTimeout(function(){a._fadeOpacityStep(f,(e+1),b,d,g,c)},c)}};gtk.Popup.prototype._setOpacity=function(b,c){var a=c;if(c>100){c=a=100}else{if(c<0){c=a=0}}a/=100;if(c<1){c=1}b.style.opacity=(a);b.style.filter="alpha(opacity="+c+")"};gtk.Popup.prototype._setCentered=function(){var b=this._calculateOffsetCentered();var a=this._domObj.style;a.top=b[1]+"px";a.left=b[0]+"px"};gtk.Popup.prototype._calculateOffsetCentered=function(){var b=jsgtk.Util;var a=(b.getWindowWidth()-this._width)/2;var c=(b.getWindowHeight()-this._height)/2;return[a<=0?0:a,c<=0?0:c]};gtk.Popup.prototype.close=function(){this.emit("closed");this._domObj.style.display="none";this._domObj.parentNode.removeChild(this._domObj);this._modalDom.parentNode.removeChild(this._modalDom)};gtk.Popup.prototype._resize=function(){var d=jsgtk.Util;var e=d.getWindowWidth();var b=d.getWindowHeight();var c=this._calculateDomWidth();var a=this._calculateDomHeight()+this._headerHeight;this._width=c>this._minWidth?c:this._minWidth;this._height=a>this._minHeight?a:this._minHeight;this._resizeWidth(this._width);this._resizeHeight(this._height)};gtk.Popup.prototype._updateSize=function(){var b=this._calculateDomWidth();var a=this._calculateDomHeight()+this._headerHeight;this._width=b;this._height=a;this._resizeWidth(this._width);this._resizeHeight(this._height)};gtk.Popup.prototype._resizeWidth=function(a){this._domObj.style.width=a+"px";this._bodyDom.style.width=a+"px"};gtk.Popup.prototype._resizeHeight=function(a){this._domObj.style.height=a+2+"px";this._bodyDom.style.height=a-this._headerHeight+"px"};gtk.Popup.prototype._createModal=function(){var b=jsgtk.Util;var c=b.width();var a=b.height();this._modalDom=jsgtk.Dom.create({append:document.body,tag:"div",className:"gtk_popup_modal",id:"gtk_modal_layer"});this._modalDom.style.width=c+"px";this._modalDom.style.height=a+"px";this._fadeOpacity("gtk_modal_layer",0,30,300,60)};gtk.Popup.prototype._calculateDomHeight=function(){if(this._bodyContent){var b=this._bodyContent.cloneNode(true);b.style.position="absolute";b.style.display="block";var a=jsgtk.Util.fullHeight(b)+this._getMarginWidth();return a}return 0};gtk.Popup.prototype._calculateDomWidth=function(){if(this._bodyContent){var a=this._bodyContent.cloneNode(true);a.style.position="absolute";a.style.display="block";var b=jsgtk.Util.fullWidth(a)+this._getMarginWidth();return b}return 0};gtk.Popup.prototype._getMarginWidth=function(){var a=parseInt(this._bodyContent.style.margin)*2;if(isNaN(a)){a=0}return a};gtk.Popup.prototype._getPaddingWidth=function(){var a=parseInt(this._bodyContent.style.padding)*2;if(isNaN(a)){a=0}return a};gtk.Popup.prototype._initEvent=function(){var a=this;var b=jsgtk.Event;b.addDomListener(this._closeBtnDom,"mouseup",function(c){a.close();b.stopBubble(c)});b.addDomListener(this._closeBtnDom,"mousedown",function(c){b.stopBubble(c)});b.addDomListener(this._headerDom,"mouseover",function(c){a._enableDrag();b.stopBubble(c)});b.addDomListener(this._headerDom,"mouseout",function(c){a._disableDrag();b.stopBubble(c)});b.addDomListener(this._bodyDom,"mousedown",function(c){b.stopBubble(c)})};gtk.Popup.prototype._enableDrag=function(){var d=jsgtk.Util;var a=2,c=d.getWindowWidth()-this._width-22;var e=2,b=d.getWindowHeight()-this._height-7;d.DomDraggableAdapter.dragInit(this._domObj,a,c,e,b)};gtk.Popup.prototype._disableDrag=function(){var a=maxX=parseInt(this._domObj.style.left);var b=maxY=parseInt(this._domObj.style.top);jsgtk.Util.DomDraggableAdapter.dragInit(this._domObj,a,maxX,b,maxY)};gobject.signalNew("closed",gtk.Popup,null,null,[]);gobject.signalNew("shown",gtk.Popup,null,null,[]);gobject.signalNew("contentchanged",gtk.Popup,null,null,[]);gobject.signalNew("titlechanged",gtk.Popup,null,null,[]);PredictiveHelper={showItem:function(item){item.style.display='block';},hideItem:function(item){item.style.display='none';},hilightItem:function(item){item.style.color='#FFFFFF';item.style.backgroundColor='#0066FF';},dehilightItem:function(item){item.style.color='';item.style.backgroundColor='';},hilightIndex:function(index,elements){for(var i=0;i<elements.length;i++){if(i==index){PredictiveHelper.hilightItem(elements[i]);}else{PredictiveHelper.dehilightItem(elements[i]);}}},isHilighted:function(item){return(item.style.color!=''&&item.style.backgroundColor!='')?true:false;},clearContent:function(item){if(item)item.innerHTML="";},ajax:function(options){options={type:options.type||"GET",RequestHeader:options.requestHeader||"text/xml",url:options.url||"",timeout:options.timeout||5000,onComplete:options.onComplete||function(){},onError:options.onError||function(){},onSuccess:options.onSuccess||function(){},onProgress:options.onProgress||function(){},data:options.data||""};if(typeof XMLHttpRequest=='undefined'){http_request=new ActiveXObject(navigator.userAgent.indexOf("MSIE 5")>=0?"Microsoft.XMLHTTP":"Msxml2.XMLHTTP");}else{http_request=new XMLHttpRequest();if(http_request.overrideMimeType)http_request.overrideMimeType('text/xml');}
http_request.open(options.type,options.url,true);http_request.setRequestHeader("Content-Type",options.RequestHeader);var timeoutLength=options.timeout;var requestDone=false;setTimeout(function(){requestDone=true;},timeoutLength);http_request.onreadystatechange=function(){options.onProgress(http_request.readyState);if(http_request.readyState==4&&!requestDone){(httpSuccess(http_request))?options.onSuccess(httpData(http_request,options.type)):options.onError();options.onComplete();http_request=null;}};http_request.send(options.data);function httpSuccess(r){try{return!r.status&&location.protocol=="file:"||(r.status>=200&&r.status<300)||r.status==304||navigator.userAgent.indexOf("Safari")>=0&&typeof r.status=="undefined";}catch(e){}
return false;}
function httpData(r,type){var ct=r.getResponseHeader("content-type");var data=!type&&ct&&ct.indexOf("xml")>=0;data=type=="xml"||data?r.responseXML:r.responseText;if(type=="script")
eval.call(window,data);return data;}}};﻿MainEventMap={"EventHandlers":[{"event":"{LL.Event.INIT}","ObjectBuilders":[{"generator":"{PredictiveSearchManager}"},{"generator":"{PredictiveSearchView}"}],"MethodInvokers":[{"generator":"{PredictiveSearchManager}","method":"loadCache"}]},{"event":"{PredictiveSearchEvent.SEARCH_KEYPHRASES}","MethodInvokers":[{"generator":"{PredictiveSearchManager}","method":"searchKeyPhrases","arguments":"{[LL.lastEventObject.text]}"}]},{"event":"{PredictiveSearchEvent.SEARCH_RESULT}","MethodInvokers":[{"generator":"{PredictiveSearchManager}","method":"searchResults","arguments":"{[LL.lastEventObject.display_url]}"}]}]};﻿PredictiveSearchEvent=function(type,bubbles,cancelable){var _event=document.createEvent("Events");_event.initEvent(type,bubbles,cancelable);_event.text='';_event.listingId='';_event.data='';_event.listingName='';return _event;};PredictiveSearchEvent.SEARCH_KEYPHRASES="PredictiveSearchEvent.SEARCH_KEYPHRASES";PredictiveSearchEvent.SEARCH_RESULT="PredictiveSearchEvent.SEARCH_RESULT";PredictiveSearchEvent.SEARCH_IDS="PredictiveSearchEvent.SEARCH_IDS";PredictiveSearchEvent.FETCH_DATA="PredictiveSearchEvent.FETCH_DATA";﻿PredictiveSearchManager=function(){this.view=LL.Proxy.instance(PredictiveSearchView);var _self=this;var _interval=null;var _keyObj=[];var _keySearch=[];this.searchKeyPhrases=function(text){if(text=='')
return;if(text!=''){if(_interval)clearInterval(_interval);_interval=setInterval(function(){jQuery.getJSON("/listing_keyphrases?query="+text,function(data){if(!data)return;_self.view.displayResult(data);});clearInterval(_interval);},10);}};this.searchResults=function(display_url){window.location=display_url;};this.loadCache=function(){};};﻿
PredictiveSearchView=function(parentId){var _self=this;var _interval=null;var _index=-1;var _div_results=[];var _result=[];var _display_url='';var textbox_id='txtSearch';var div_container=document.getElementById("div_container");var searchButton=document.getElementById("btnSearch");document.getElementById("fieldset").appendChild(div_container);var input_textbox=document.getElementById('txtSearch');var div_dropDown=jsgtk.Dom.create({'append':div_container,'tag':'div','id':'div_dropDown'});var div_searchFor=jsgtk.Dom.create({'append':div_dropDown,'tag':'div','style':'text-align:center;'});var label_searchFor=jsgtk.Dom.create({'append':div_searchFor,'tag':'label','className':'label_searchFor'});var div_results_container=jsgtk.Dom.create({'append':div_dropDown,'tag':'div','className':'div_results_container'});div_dropDown.style.zIndex=50;input_textbox.value=query;if(jsgtk.Dom.ie){input_textbox.onkeydown=function(){_self.handleKeyPressed(window.event);};}else{input_textbox.onkeypress=function(e){_self.handleKeyPressed(e);};}
input_textbox.onclick=function(e){var event=e?e:window.event;event.cancelBubble=true;if(div_dropDown.childNodes[1].childNodes.length>0&&input_textbox.value!=""){PredictiveHelper.showItem(div_dropDown);PredictiveHelper.showItem(div_results_container);}};div_searchFor.onmouseover=function(){_display_url='';PredictiveHelper.hilightIndex(0,[div_searchFor]);if(_self.getDivResults().length>0&&_self.getIndex()!=-1)PredictiveHelper.dehilightItem(_self.getDivResults()[_self.getIndex()]);};div_searchFor.onclick=function(){PredictiveHelper.dehilightItem(div_searchFor);PredictiveHelper.hideItem(div_dropDown);PredictiveHelper.clearContent(div_dropDown.childNodes[1]);};this.handleKeyPressed=function(e){var _self=this;if(e.keyCode==13&&input_textbox.value!=""){if(_display_url==''&&(div_dropDown.style.display=='none'||_index==-1)){submitSearchBox(textbox_id);return;}
if(_index==0){PredictiveHelper.hideItem(div_dropDown);PredictiveHelper.clearContent(div_dropDown.childNodes[1]);this.setDivResults([]);return;}
PredictiveHelper.hideItem(div_dropDown);PredictiveHelper.clearContent(div_dropDown.childNodes[1]);this.setDivResults([]);var event=new PredictiveSearchEvent(PredictiveSearchEvent.SEARCH_RESULT);event.display_url=_display_url;document.dispatchEvent(event);_display_url=null;}
if(e.keyCode==9){if(document.getElementById('div_dropDown'))PredictiveHelper.hideItem(document.getElementById('div_dropDown'));}
if(e.keyCode!=40&&e.keyCode!=38&&e.keyCode!=13&&e.keyCode!=9){if(_interval){clearInterval(_interval);}
_interval=setInterval(function(){var text=input_textbox.value;PredictiveHelper.clearContent(div_dropDown.childNodes[1]);PredictiveHelper.showItem(div_dropDown);label_searchFor.innerHTML="Search for: "+text;var event=new PredictiveSearchEvent(PredictiveSearchEvent.SEARCH_KEYPHRASES);event.text=text;document.dispatchEvent(event);clearInterval(_interval);},500);}else{if(this.getDivResults().length>1)this.activateArrowControl(e);else{PredictiveHelper.hilightItem(div_searchFor);this.setIndex(0);}}};this.setDivResults=function(divResults){_div_results=divResults;};this.addDivResult=function(div_result){_div_results.push(div_result);};this.getDivResults=function(){return _div_results;};this.setIndex=function(index){_index=index;};this.getIndex=function(){return _index;};this.getResults=function(){return _result;};this.setResults=function(results){_result=results;};this.activateArrowControl=function(e){var index=this.getIndex();var div_results=this.getDivResults();var results=this.getResults();if(e.keyCode==40&&index<div_results.length-1){++index;this.setIndex(index);PredictiveHelper.hilightIndex(index,div_results);_display_url=(index!=0)?'http://'+window.location.host+'/listings/'+_result[index-1].alias_id:'';}else if(e.keyCode==38&&index>=1){index--;this.setIndex(index);PredictiveHelper.hilightIndex(index,div_results);_display_url=(index!=0)?'http://'+window.location.host+'/listings/'+_result[index-1].alias_id:'';}};this.displayResult=function(results){this.setIndex(-1);var div_results=[div_searchFor];this.setDivResults([]);if(results.length>0){PredictiveHelper.showItem(div_results_container);PredictiveHelper.clearContent(div_results_container);_self.addDivResult(div_searchFor);for(var i=0;i<results.length;i++){var div_result=jsgtk.Dom.create({'append':div_results_container,'tag':'div','style':'height: 19px;text-align:left;cursor: pointer;','text':results[i].name});(function(){var j=i;var div_hili=div_result;div_hili.onmouseover=function(){PredictiveHelper.dehilightItem(div_searchFor);PredictiveHelper.hilightIndex(j+1,_self.getDivResults());_display_url='http://'+window.location.host+'/listings/'+results[j].alias_id;_self.setIndex(j+1);};div_hili.onclick=function(){input_textbox.focus();PredictiveHelper.hideItem(div_dropDown);_self.setDivResults([]);PredictiveHelper.clearContent(div_dropDown.childNodes[1]);var event=new PredictiveSearchEvent(PredictiveSearchEvent.SEARCH_RESULT);event.display_url=_display_url;document.dispatchEvent(event);_display_url=null;};})();this.addDivResult(div_result);}
this.setResults(results);}else PredictiveHelper.hideItem(div_results_container);};};﻿
LL={lastReturn:null,lastHttpRequest:null,lastEventObject:null,loadEventMaps:function(eventMap){var preInit=new LL.Event(LL.Event.PRE_INIT,true,false);document.dispatchEvent(preInit);this._buildTagFactory();eventMap.forEach(function(eventMap){this._loadEventHandlers(eventMap);},this);var init=new LL.Event(LL.Event.INIT,true,false);document.dispatchEvent(init);},_loadEventHandlers:function(json){json.EventHandlers.forEach(function(eventHandlerJson){LL.TagFactory.create("EventHandlers",eventHandlerJson).executeTag();},this);},_buildTagFactory:function(){LL.TagFactory.add("EventHandlers",LL.EventHandler);LL.TagFactory.add("ObjectBuilders",LL.ObjectBuilder);LL.TagFactory.add("MethodInvokers",LL.MethodInvoker);LL.TagFactory.add("AjaxInvokers",LL.AjaxInvoker);LL.TagFactory.add("MethodInjectors",LL.MethodInjector);LL.TagFactory.add("PropertyInjectors",LL.PropertyInjector);}};LL.Utils={strip:function(str){str=str.replace(/^\s+/,'');return str.replace(/\s+$/,'');},stripCurlyBraces:function(str){str=LL.Utils.strip(str);str=str.substring(1,str.length-1);return LL.Utils.strip(str);},isDynamicValue:function(value){if(typeof value=='string'){value=LL.Utils.strip(value);if(value.charAt(0)=="{"&&value.charAt(value.length-1)=="}")return true;}
return false;}};LL.Proxy={instance:function(constructor,args,properties,cache){if(cache===false)return this.create(constructor,args||[],properties||{});var instance=(constructor.__singleton__)?constructor.__singleton__:this.create(constructor,args||[],properties||{});if(!constructor.__singleton__)constructor.__singleton__=instance;return instance;},create:function(constructor,args,properties){var a=args;a.concat(new Array(20-a.length));var instance=new constructor(a[0],a[1],a[2],a[3],a[4],a[5],a[6],a[7],a[8],a[9],a[10],a[11],a[12],a[13],a[14],a[15],a[16],a[17],a[18],a[19],a[20]);for(p in properties)instance[p]=properties[p];return instance;}};LL.Tag=function(executeChildren){this.children=[];this._evalString="";this.parse=function(json){for(key in json){if(this.childTags&&key in this.childTags){this._parseChildTag(key,json[key]);continue;}
if(LL.Utils.isDynamicValue(json[key])){this._parseDynamicValue(key,json[key]);continue;}
this[key]=json[key];}
this._setDefaultValues();};this.executeTag=function(executeChildTags){this._updateDynamicValues();this.callback();if(executeChildren!==false)this.executeChildTags();};var _self=this;this.executeChildTags=function(){_self.children.forEach(function(childTag){childTag.executeTag();},this);};this._updateDynamicValues=function(){eval(this._evalString);};this._parseChildTag=function(tagPlural,json){json.forEach(function(tagJson){this.children.push(LL.TagFactory.create(tagPlural,tagJson));},this);};this._parseDynamicValue=function(key,value){this._evalString+="this['"+key+"']="+LL.Utils.stripCurlyBraces(value)+";";};this._setDefaultValues=function(){if(this.defaultValues){for(key in this.defaultValues){if(typeof this[key]=="undefined"){this[key]=this.defaultValues[key];}}}};};LL.Binding=function(){var _self=this;this.__uuid__=new UUID().id;this.__eventListeners__=[];this.__bindableProperties__={};this._dispatchSetEvent=function(key,value){var event=document.createEvent("Events");event.initEvent(_self.__uuid__+":"+key,true,false);event["__binding__value"]=value;document.dispatchEvent(event);};this.__bindable__=function(key){this.__bindableProperties__[key]=true;this["__binding__"+key]=this[key];delete this[key];var _self=this;if(this.__defineSetter__){this.__defineGetter__(key,function(){return _self["__binding__"+key];});this.__defineSetter__(key,function(value){_self["__binding__"+key]=value;this._dispatchSetEvent(key,value);});}};this.get=function(key){return this["__binding__"+key];};this.set=function(key,value){this[key]=value;if(this.__bindableProperties__[key])this._dispatchSetEvent(key,value);};this.__bindCallback__=function(key,callback,scope){var _eventListener={type:this.__uuid__+":"+key,listener:function(e){;callback.apply(scope,[e["__binding__value"]]);},useCapture:false};document.addEventListener(_eventListener.type,_eventListener.listener,_eventListener.useCapture);this.__eventListeners__.push(_eventListener);};this.__bindProperty__=function(sourceKey,target,targetKey){var _eventListener={type:this.__uuid__+":"+sourceKey,listener:function(e){target[targetKey]=e["__binding__value"];},useCapture:false};document.addEventListener(_eventListener.type,_eventListener.listener,_eventListener.useCapture);this.__eventListeners__.push(_eventListener);};this.__unbindAll__=function(){while(this.__eventListeners__>0){var eventListener=this.__eventListeners__.pop();document.removeEventListener(eventListener.type,eventListener.listener,eventListener.useCapture);}};};LL.Event=function(type,bubbles,cancelable){var _event=document.createEvent("Events");_event.initEvent(type,bubbles,cancelable);return _event;};LL.Event.INIT="LL.Event.INIT";LL.Event.PRE_INIT="LL.Event.PRE_INIT";LL.XMLHttpRequest=function(){var httpRequest;if(window.XMLHttpRequest){httpRequest=new XMLHttpRequest();if(httpRequest.overrideMimeType){httpRequest.overrideMimeType('text/xml');}}
else if(window.ActiveXObject){try{httpRequest=new ActiveXObject("Msxml2.XMLHTTP");}
catch(e){httpRequest=new ActiveXObject("Microsoft.XMLHTTP");}}
return httpRequest;};LL.TagFactory={parsers:{},create:function(type,json){if(this.parsers[type])return new this.parsers[type](json);return null;},add:function(type,parser){this.parsers[type]=parser;}};LL.ObjectBuilder=function(json){LL.Tag.apply(this);this.generator;this.constructorArguments;this.properties;this.cache;this.parse(json);};LL.ObjectBuilder.prototype={callback:function(){var instance=LL.Proxy.instance(this.generator,this.constructorArguments,this.properties,this.cache);return instance;},defaultValues:{"cache":true}};LL.EventHandler=function(json){LL.Tag.apply(this,[false]);this.event;this.parse(json);};LL.EventHandler.prototype={callback:function(){var _self=this;document.addEventListener(this.event,function(e){LL.lastEventObject=e;_self.executeChildTags();},false);},childTags:{"ObjectBuilders":true,"MethodInvokers":true,"AjaxInvokers":true,"MethodInjectors":true,"PropertyInjectors":true}};LL.MethodInvoker=function(json){LL.Tag.apply(this);this.generator;this.method;this.arguments;this.parse(json);};LL.MethodInvoker.prototype={callback:function(){var instance=LL.Proxy.instance(this.generator);LL.lastReturn=instance[this.method].apply(instance,this.arguments);},defaultValues:{"arguments":[]}};LL.Injector=function(){LL.Tag.apply(this);this.source;this.target;this.mapping;this.callback=function(){var sourceInstance=(typeof this.source=='function')?LL.Proxy.instance(this.source):this.source;var targetInstance=(typeof this.target=='function')?LL.Proxy.instance(this.target):this.target;if(!sourceInstance.__bindableProperties__)LL.Binding.apply(sourceInstance);for(sourceKey in this.mapping){sourceInstance.__bindable__(sourceKey);this.bind(sourceInstance,targetInstance,sourceKey,this.mapping[sourceKey]);}};};LL.MethodInjector=function(json){LL.Tag.apply(this);LL.Injector.apply(this);this.parse(json);};LL.MethodInjector.prototype={bind:function(source,target,sourceKey,targetKey){target[targetKey](source[sourceKey]);source.__bindCallback__(sourceKey,target[targetKey],target);}};LL.PropertyInjector=function(json){LL.Tag.apply(this);LL.Injector.apply(this);this.parse(json);};LL.PropertyInjector.prototype={bind:function(source,target,sourceKey,targetKey){target[targetKey]=source[sourceKey];source.__bindProperty__(sourceKey,target,targetKey);}};LL.AjaxInvoker=function(json){LL.Tag.apply(this,[false]);this.method;this.url;this.queryString;this.async;this.user;this.password;this.headers;this.body;this.parse(json);};LL.AjaxInvoker.prototype={callback:function(){var _self=this;var httpRequest=new LL.XMLHttpRequest();httpRequest.onreadystatechange=function(){if(httpRequest.readyState==4){LL.lastHttpRequest=httpRequest;_self.executeChildTags();};};var requestUrl=this.url;if(this.queryString)requestUrl+="?"+this.queryString;httpRequest.open(this.method,requestUrl,this.async,this.user,this.password);for(p in this.headers){httpRequest.setRequestHeader(p,this.headers[p]);}
httpRequest.send(this.body);},defaultValues:{"queryString":"","async":true,"headers":{}},childTags:{"ObjectBuilders":true,"MethodInvokers":true,"AjaxInvokers":true,"MethodInjectors":true,"PropertyInjectors":true}};﻿RestService={get:function(url,progressCallBack,successCallBack){PredictiveHelper.ajax({type:'GET',url:url,onProgress:function(state){progressCallBack(state);},onSuccess:function(data){successCallBack(data);}});}};﻿SearchResult=function(results){this.results=results||[];this.resultsLength=0;this.getElements=function(){return this.results;};this.getFirst=function(resultsLength){this.resultsLength=resultsLength;var returned=[];for(var i=0;i<resultsLength;i++){returned.push(this.results[i]);}
return returned;};this.hasNext=function(){return(this.resultsLength<this.results.length)?true:false;};this.getElementsInRange=function(from,to){var results=[];for(var i=from;i<=to;i++){results.push(this.results[i]);}
this.resultsLength=to;return results;};this.appendElements=function(elements){for(var i=0;i<elements.length;i++){this.results.push(elements[i]);}};this.removeElementsInRange=function(from,to){var _length=parseInt(to)-parseInt(from);this.results.splice(parseInt(from),_length);};};SearchResultExtend=function(results){SearchResult.apply(this,results);this.appendElements=function(elements){if(this.results.length==0){this.results=this.results.concat(elements);return;}
for(var i=0;i<this.results.length;i++){for(var j=0;j<elements.length;j++){if(this.results[i].id==elements[j].id){elements.splice(j);break;}}}
if(elements.length>0)this.results=this.results.concat(elements);};};function BillboardManager(ads){var currentAd=Math.floor(Math.random()*ads.length);this.next=function(){currentAd++;if(currentAd>=ads.length)currentAd=0;this.load();}
this.previous=function(){currentAd--;if(currentAd<0)currentAd=ads.length-1;this.load();}
this.load=function(){var billboardDiv=document.getElementById("bbDiv");removeChildren(billboardDiv);removeBillboardCtrl();var link=null,isImage=false,obj=ce("object","billboard");obj.width='651px';obj.height='312px';obj.align="top";var paramMode=ce("param");paramMode.name="wmode";paramMode.value="transparent";var paramSrc=ce("param");paramSrc.name="src";paramSrc.value=ads[currentAd].url;obj.appendChild(paramMode);obj.appendChild(paramSrc);if(ads[currentAd].url.indexOf(".swf")==-1){obj.type="image/gif";if(ads[currentAd].navigate_url!='http://'){obj.style.cursor="pointer";link=ce("a","billboardLink");link.setAttribute('target','_blank');link.addEventListener("click",function(){postClick("billboard",ads[currentAd].listing_uuid);window.open(concateHttp(ads[currentAd].navigate_url));},false);link.appendChild(obj);isImage=true;}}
else{obj.type="application/x-shockwave-flash";if(ads[currentAd].navigate_url!='http://'){obj.style.cursor="pointer";link=ce("a","billboardLink");link.style.width="651px";link.style.height="312px";link.style.zIndex="99";link.style.position="absolute";link.style.left="0";link.style.top="0";link.setAttribute('target','_blank');link.addEventListener("click",function(){postClick("billboard",ads[currentAd].listing_uuid);window.open(concateHttp(ads[currentAd].navigate_url));},false);billboardDiv.appendChild(link);}}
obj.data=ads[currentAd].url;if(isImage)billboardDiv.appendChild(link);else billboardDiv.appendChild(obj);if(ads.length>1){var ctrl=ce("p","billboardCtrl");ctrl.innerHTML='<a href="javascript:bb.previous()">&lt;&lt;</a>&nbsp;&nbsp;&nbsp;<a href="javascript:bb.next()">&gt;&gt;</a>';insertAfter(billboardDiv,ctrl);}}}
function postClick(resource,listing_id){jQuery.ajax({type:"PUT",url:"http://"+window.location.hostname+"/core-api/api-statistics/listings/"+listing_id+"/"+resource+"?domain_name="+currentPortal.domain_name});};function insertAfter(referenceNode,newNode){referenceNode.parentNode.insertBefore(newNode,referenceNode.nextSibling);}
function removeChildren(node){if(node.hasChildNodes()){node.removeChild(node.firstChild);removeChildren(node);}}
function removeBillboardCtrl(){var ctrl=document.getElementById('billboardCtrl');if(ctrl){ctrl.parentNode.removeChild(ctrl);}}
function concateHttp(url){if(url.indexOf("http")==-1)
url="http://"+url;return url;}
function navigateTo(url){window.open(url);}
jQuery(document).ready(function(){if(jQuery('#Listing').length>0){listingTools.init(this);loadGoogleMap(showListingMap,"showListingMap");getAnalyticData(function(statistics){var views=0;var statisticLink=document.getElementById("visits");if(statistics.listing){views=statistics.listing.views;}
statisticLink.innerHTML="Visits, "+views+" times";});hideDiscoverMore();}});var listingTools={bubble:null,init:function(self){this.e=document.getElementById("listingTools1");var u="/listings/"+listing_alias_id;var _self=this;this.appendItem(saveAsText,u+'.txt',saveAsText);this.appendItem(saveAsContact,u+'.vcf',saveAsContact);if(navigator.appName=='Microsoft Internet Explorer')
this.appendItem('Add to Favorites',jL('bookmarkPage()'),'Add to Favorites');else
this.appendItem(addBookmark,jL('bookmarkPage()'),addBookmark);this.appendItem('Edit Profile',api+'v3-profile','Edit Profile');var listingToolsDom=document.getElementById('listingTools');if(listingToolsDom){listingToolsDom.appendChild(ce('div','','clear'));}},appendBubble:function(text,href,mOver){this.appendItem(text,href,text,mOver,function(){listingTools.bubble.hide(100);});},appendItem:function(text,href,id,mOver,mOut){var a=ce('a',id,'',text),n=ce('li');a.href=href;n.appendChild(a);if(this.e){this.e.appendChild(n);}}};function bookmarkPage(){var t=document.title,u=document.location.href,w=window;if(w.sidebar)w.sidebar.addPanel(t,u,'');else if(w.external)w.external.AddFavorite(u,t);else if(w.opera&&w.print)return true;};function showPopupImage(title,imageUrl){var imageDom=jsgtk.Dom.create({"tag":"img","style":"padding:10px;"});var obj={title:title,content:imageDom,url:imageUrl}
var popup=new gtk.Popup(obj);popup.draw();};function showPopupMap(){var width=600,height=450
map=jsgtk.Dom.create({"tag":"div","style":"display: block; padding: 10px; width:"+width+"px; height: "+height+"px;"});map.innerHTML="<div style='height: 450px;' id= 'map_popup'></div>";var popupContent={title:"Map",content:map};var popup=new gtk.Popup(popupContent);popup.draw();loadGoogleMap(showGoogleMap,"showGoogleMap");};function showGoogleMap(){var map=new Map(document.getElementById("map_popup"),600,450,google_map_lat,google_map_long,google_map_zoom_level);var openInfoWindowHtml=true;map.showMapListing(openInfoWindowHtml);};function showListingMap(){var listingMap=new Map(document.getElementById("listing_map"),540,220,google_map_lat,google_map_long,google_map_zoom_level);var openInfoWindowHtml=false;listingMap.showMapListing(openInfoWindowHtml);};function showPopupStatistic(){var chartDiv=jsgtk.Dom.create({"tag":"div","style":"display: block; width:"+800+"px; height: "+600+"px;"});var hostName="api.yoolk.com";if(window.location.host=="cambodiastaging.yoolk.com"){hostName="apistaging.yoolk.com";}
else if(window.location.host=="beta.yoolk.com"){hostName="apibeta.yoolk.com";}
var statisticIFrame=jsgtk.Dom.create({"tag":"iframe","src":"http://"+hostName+"/feature-statistics/?"+listing_uuid+"&"+domainName,"width":"100%","height":"100%","style":"{overflow: hidden};"});chartDiv.appendChild(statisticIFrame);var popupContent={title:"Listing Statistics",content:chartDiv};var popup=new gtk.Popup(popupContent);popup.draw();};function formatNumberWithComma(nStr){nStr+='';x=nStr.split('.');x1=x[0];x2=x.length>1?'.'+x[1]:'';var rgx=/(\d+)(\d{3})/;while(rgx.test(x1)){}
return x1+x2;};function buildTitle(labelString){var label=jsgtk.Dom.create({'tag':'span'});label.innerHTML=labelString;return label;};function getSinceDate(){var createdDate=new Date(listing_created_at.substring(0,10));return(createdDate.getFullYear()<2009)?'2009-01-01':listing_created_at.substring(0,10);};function toSignature(uri,verb,contentType,content){if(verb!=="POST"&&verb!=="PUT")content="";content=content.trim();var contentMd5=Crypt.md5(content),str=uri+verb+contentType+contentMd5;return Base64.encode(Crypt.sha1('41B02534-1528-11DF-806A-001D0943011C::'+str));};function authorization(){return'YOOLK '+'41B02534-1528-11DF-806A-001D0943011C'+':'+toSignature(api+"statistics/"+listing_alias_id+"?domain_name="+currentPortal.domain_name,"GET","","");};function getDomainName(){var host=location.href.split("/")[2];host='cambodiastaging.yoolk.com';var currentAPI=null;switch(host){case'yoolk.dev':currentAPI="api.yoolk.dev";break;case'cambodiastaging.yoolk.com':currentAPI="apistaging.yoolk.com";break;case'beta.yoolk.com':currentAPI="apibeta.yoolk.com";break;default:currentAPI="api.yoolk.com";break;}
return currentAPI;};function getAnalyticData(callback){jQuery.ajax({'beforeSend':function(xhr){xhr.setRequestHeader("Authorization",authorization())},url:"/core-api/api-statistics/listings/"+listing_uuid+"?display=tiny&domain_name="+currentPortal.domain_name,success:function(statistics){callback(JSON.parse(statistics));}});};function hideDiscoverMore(){if(jQuery('#features .linkList li').length==0){jQuery('#features').remove();}};jQuery(document).ready(function(){if(jQuery('#Search .listingList').length>0){listingList.init();}});var listingList={map:null,mapMarkers:{},init:function(){this.showMap();this.hightlightMapMarkers();this.fixedMapPosition();},showMap:function(){if(jQuery('#mapCanvas').length==0)return;var _self=this;var mapOptions={zoom:10,center:new google.maps.LatLng(0,0),mapTypeId:google.maps.MapTypeId.ROADMAP,disableDefaultUI:true,scrollwheel:false,disableDoubleClickZoom:true,draggable:false}
this.map=new google.maps.Map(jQuery("#mapCanvas")[0],mapOptions);this.setMarkers(this.map,listingCoordinates);google.maps.event.addListener(this.map,'click',function(event){_self._openFullMap();});},setMarkers:function(map,listingCoordinates){var _self=this;var bounds=new google.maps.LatLngBounds();for(var i=0,len=listingCoordinates.length;i<len;i++){var listing=listingCoordinates[i];var coord=new google.maps.LatLng(listing["coord"][0],listing["coord"][1]);var image=new google.maps.MarkerImage('/images/markers/small/red_Marker'+listing["map_index"]+'.png',new google.maps.Size(16,26),new google.maps.Point(0,0),new google.maps.Point(0,26));var marker=new google.maps.Marker({position:coord,map:map,icon:image,title:listing["name"],zIndex:len-listing["map_index"]});this.mapMarkers[listing["index"]]=marker;(function(listing){google.maps.event.addListener(marker,'click',function(event){_self._openFullMap({listing_uuid:listing["uuid"]});});google.maps.event.addListener(marker,'mouseover',function(event){jQuery('.listingList li#listing_'+listing['index']).addClass('lightYellow');});google.maps.event.addListener(marker,'mouseout',function(event){jQuery('.listingList li#listing_'+listing['index']).removeClass('lightYellow');});})(listing);bounds.extend(coord);onBoundsChanged();}
map.initialZoom=true;map.fitBounds(bounds);function onBoundsChanged(){google.maps.event.addListener(map,'zoom_changed',function(){zoomChangeBoundsListener=google.maps.event.addListener(map,'bounds_changed',function(event){if(this.getZoom()>13&&this.initialZoom==true){this.setZoom(13);this.initialZoom=false;}
google.maps.event.removeListener(zoomChangeBoundsListener);});});}},hightlightMapMarkers:function(){var _self=this;jQuery(".listingList li.listingResult").hover(function(){listingIndex=jQuery(this).attr('id').split('_')[1];marker=_self.mapMarkers[listingIndex];if(marker){marker.setAnimation(google.maps.Animation.BOUNCE);}},function(){listingIndex=jQuery(this).attr('id').split('_')[1];marker=_self.mapMarkers[listingIndex];if(marker){marker.setAnimation(null);}});},fixedMapPosition:function(){var mapContainer=jQuery("#mapContainer");var topPositionMapContainer=mapContainer.position().top;function setMapPosition(){var scrollTopWindow=jQuery(window).scrollTop();if(scrollTopWindow>=topPositionMapContainer){if(!mapContainer.hasClass("fixed")){mapContainer.addClass("fixed");}}
else{if(mapContainer.hasClass("fixed")){mapContainer.removeClass("fixed");}}};setMapPosition();jQuery(window).scroll(function(){setMapPosition();});},_openFullMap:function(options){var url='/map/?q=';params=getQueryParams();if(params['q'])url+=encodeURIComponent(params['q']);if(options){if(options.listing_uuid)url+='&listing_uuid='+options.listing_uuid;}
else{url+='&bbox='+this.map.getBounds().toUrlValue();}
window.location=url;}};jQuery(document).ready(function(){if(jQuery('#languages').length>0){InterfaceTranslation.init();}});InterfaceTranslation={init:function(){var currentLocale=jQuery('#languages li:first-child span').html();currentLocale=jQuery.trim(currentLocale);setCookie('language_uuid',currentLocale);this._addEventListener();},_addEventListener:function(){jQuery("#otherLanguages li>a").click(function(){var selectedLocale=jQuery(this).next().html();selectedLocale=jQuery.trim(selectedLocale);setCookie('language_uuid',selectedLocale);});}};jQuery(document).ready(function(){if(jQuery('#MapSearch').length>0){mapSearch.init();}});var mapSearch={map:null,mapMarkers:{},infoWindow:null,init:function(){this.changeSize();this.autoResize();this.showMap();this.hightlightMapMarkers();this.clickToShowInfoWindows();this.toggleCategories();this.submitSearch();this.showSelectedInfoWindow();},changeSize:function(){var contentHeight=jQuery(window).height()-jQuery('#content').position().top;var sidebarEle=jQuery('#sidebar');var fullMapEle=jQuery('#fullMap');sidebarEle.height(contentHeight);fullMapEle.height(contentHeight-2);var fullMapHeight=jQuery(window).width()-sidebarEle.width()-2;fullMapEle.width(fullMapHeight);},autoResize:function(){var _self=this;jQuery(window).resize(function(){_self.changeSize();});},showMap:function(){if(jQuery('#fullMap').length==0)return;var _self=this;var mapOptions={zoom:10,center:new google.maps.LatLng(0,0),mapTypeId:google.maps.MapTypeId.ROADMAP}
this.map=new google.maps.Map(jQuery("#fullMap")[0],mapOptions);this.setMarkers(this.map,listingCoordinates);google.maps.event.addListener(this.map,'click',function(event){_self._closeInfoWindow();});},setMarkers:function(map,listingCoordinates){var _self=this;var bounds=new google.maps.LatLngBounds();for(var i=0,len=listingCoordinates.length;i<len;i++){var listing=listingCoordinates[i];var coord=new google.maps.LatLng(listing["coord"][0],listing["coord"][1]);var image=new google.maps.MarkerImage('/images/markers/large/red_Marker'+listing["index"]+'.png',new google.maps.Size(21,34),new google.maps.Point(0,0),new google.maps.Point(0,34));var shadow=new google.maps.MarkerImage('/images/markers/large/shadow.png',new google.maps.Size(37,34),new google.maps.Point(0,0),new google.maps.Point(0,34));var marker=new google.maps.Marker({position:coord,map:map,icon:image,shadow:shadow,title:listing["name"],zIndex:len-listing["index"]});this.mapMarkers[listing["index"]]=marker;bounds.extend(coord);onBoundsChanged();onMouseoverMarker(marker,listing);onMouseoutMarker(marker,listing);attachInfoWindow(marker,listing);}
if(listingCoordinates.length==0&&bbox.length>0){var sw=new google.maps.LatLng(bbox[0],bbox[1]);var ne=new google.maps.LatLng(bbox[2],bbox[3]);bounds.extend(sw);bounds.extend(ne);}
map.initialZoom=true;map.fitBounds(bounds);function onBoundsChanged(){google.maps.event.addListener(map,'zoom_changed',function(){zoomChangeBoundsListener=google.maps.event.addListener(map,'bounds_changed',function(event){if(this.getZoom()>15&&this.initialZoom==true){this.setZoom(15);this.initialZoom=false;}
google.maps.event.removeListener(zoomChangeBoundsListener);});});}
function onMouseoverMarker(marker,listing){google.maps.event.addListener(marker,'mouseover',function(event){jQuery('.listingList li#listing_'+listing['index']).addClass('lightYellow');});}
function onMouseoutMarker(marker,listing){google.maps.event.addListener(marker,'mouseout',function(event){jQuery('.listingList li#listing_'+listing['index']).removeClass('lightYellow');});}
function attachInfoWindow(marker,listing){var infoWindow=_self._createInfoWindow(listing['index']);google.maps.event.addListener(marker,'click',function(event){_self._closeInfoWindow();infoWindow.open(map,marker);_self._toggleInfoWindowCategories();_self.infoWindow=infoWindow;});}},hightlightMapMarkers:function(){var _self=this;jQuery(".listingList li.listingResult").hover(function(){listingIndex=jQuery(this).attr('id').split('_')[1];marker=_self.mapMarkers[listingIndex];if(marker){marker.setAnimation(google.maps.Animation.BOUNCE);}},function(){listingIndex=jQuery(this).attr('id').split('_')[1];marker=_self.mapMarkers[listingIndex];if(marker){marker.setAnimation(null);}});},clickToShowInfoWindows:function(){var _self=this;jQuery(".listingList li.listingResult").click(function(){var listingIndex=jQuery(this).attr('id').split('_')[1];var marker=_self.mapMarkers[listingIndex];if(marker){var infoWindow=_self._createInfoWindow(listingIndex);_self._closeInfoWindow();infoWindow.open(_self.map,marker);_self._toggleInfoWindowCategories();_self.infoWindow=infoWindow;}});},showSelectedInfoWindow:function(){if(selectedListingIndex==-1)return;var marker=this.mapMarkers[selectedListingIndex];if(marker){var infoWindow=this._createInfoWindow(selectedListingIndex);this._closeInfoWindow();infoWindow.open(this.map,marker);this._toggleInfoWindowCategories();this.infoWindow=infoWindow;}},toggleCategories:function(){jQuery(".listingList .listingCategories").mouseover(function(){jQuery(this).children('.categoryList').show();});jQuery(".listingList .listingCategories .categoryList").mouseout(function(){jQuery(this).hide();});},submitSearch:function(){var _self=this;jQuery('#btnSearch').click(function(){var txtSearchBox=jQuery('#txtSearch');var isEmptyQuery=(txtSearchBox.val()==txtSearchBox.attr('title')||jQuery.trim(txtSearchBox.val())=="");if(!isEmptyQuery){var url='/map/?q=';url+=encodeURIComponent(txtSearchBox.val());url+='&bbox='+_self.map.getBounds().toUrlValue();window.location=url;return false;}});jQuery("#txtSearch").keyup(function(event){if(event.keyCode==13){jQuery("#btnSearch").click();event.preventDefault();}});},_createInfoWindow:function(listingIndex){listingInfoContent=jQuery('.listingList li#listing_'+listingIndex).outerHtml();contentString="<ol class='listingList infoWindow'>"+listingInfoContent+"</ol>";var infoWindow=new google.maps.InfoWindow({content:contentString});return infoWindow;},_toggleInfoWindowCategories:function(){jQuery(".infoWindow.listingList .listingCategories").mouseover(function(){jQuery(this).children('.categoryList').show();});jQuery(".infoWindow.listingList .listingCategories .categoryList").mouseout(function(){jQuery(this).hide();});},_closeInfoWindow:function(){if(this.infoWindow){this.infoWindow.close();}}};
