function uw_tracker(e){if(!e){return }var nn=e.nodeName;if(!(nn&&nn.length)){return }if(nn=="A"){uw_mlrUtag(e)}else{if(nn=="INPUT"){if(e.type=="button"||e.type=="submit"){uw_mlrUtag(e)}}}}function uw_mlr(e){if(!e){return }uw_mlrByStr(uw_getHook(e))}function uw_mlrByStr(o){if(o&&o.length){utag.link({listing_link:utag_data.mlr+"|"+o+"_none"})}}function uw_utag(e){if(!e){return }uw_utagByStr(uw_getHook(e))}function uw_utagByStr(o){if(o&&o.length){utag.link({link_name:o,link_attr1:"alt"})}}function uw_mlrUtag(e){if(!e){return }uw_mlrUtagByStr(uw_getHook(e))}function uw_mlrUtagByStr(o){if(o&&o.length){utag.link({link_name:o,link_attr1:"alt",listing_link:utag_data.mlr+"|"+o+"_none"})}}function uw_getHook(e){if(!e){return }var o;o=$(e).attr("name");if(o&&o.length){return o}else{return""}}function uw_firePageView(){try{utag.view(utag_data)}catch(e){}}function uw_detectClickForm(){$('a[name$="_submit"]').each(function(){var n=$(this).attr("name");if(n&&n.length){if("contact_submit"==n){uw_mlrByStr("contact_start")}else{if("appointment_submit"==n){uw_mlrByStr("appointment_start")}}}})}function lead_show_our_websites(url){window.open(url)}function lead_print_page(){window.print()}function lead_bookmark_us(url,title){if(window.sidebar){window.sidebar.addPanel(title,url,"")}else{if(window.opera&&window.print){var elem=document.createElement("a");elem.setAttribute("href",url);elem.setAttribute("title",title);elem.setAttribute("rel","sidebar");elem.click()}else{if(document.all){window.external.AddFavorite(url,title)}}}}function lead_subscribe_newsletter(){var email=document.getElementById("lead_news_subscriber_id").value;if(email==null||email==""){alert("subscriber email is required");return }var url="mailto:merchantemail@merchantshop.com?subject=Subscribe to news letter&body=Email is : "+email;document.location=url}function newPopup(url){popupWindow=window.open(url,"popUpWindow","height=700,width=800,left=10,top=10,resizable=yes,scrollbars=yes,toolbar=yes,menubar=no,location=no,directories=no,status=yes")}function fbs_click(urlWeb,desc){var u=urlWeb;
var t=desc;window.open("http://www.facebook.com/sharer.php?u="+encodeURIComponent(u)+"&t="+encodeURIComponent(t),"sharer","toolbar=0,status=0,width=450,height=450");return false}function twitter_click(tweetValue){tweet=tweetValue;window.open("http://twitter.com/home?status="+encodeURIComponent(tweet));return false}function enable(e){$(e).removeAttr("disabled")}function disable(e){$(e).attr("disabled","disabled")}function clear(e){$(e).val("")}function isRequired(e){return $(e).hasClass("required")}function isError(response){return $(response).find("code").text()!="OK"}function gatherText(response){var str="";$(response).find("message").each(function(){if(str.length>0){str+="<br/>"}str+=$(this).text()});return str}function convertFormToXml(e){var xmltmp="<xmlFormInput>";$("#"+e+" input").each(function(){if(this.type!="button"&&this.type!="reset"&&!($(this).hasClass("unsent"))){var value=$(this).val().replace(/\"/g,"&quot;").replace(/&/g,"&amp;");var name=$(this).attr("name").replace(/\"/g,"&quot;").replace(/&/g,"&amp;");xmltmp=xmltmp.concat('<field name="'+name+'" required="'+isRequired(this)+'" value="'+value+'" />')}});$("#"+e+" textarea").each(function(){var value=$(this).val().replace(/\"/g,"&quot;").replace(/&/gi,"&amp;");var name=$(this).attr("name").replace(/\"/g,"&quot;").replace(/&/gi,"&amp;");xmltmp=xmltmp.concat('<field name="'+name+'" required="'+isRequired(this)+'" value="'+value+'" />')});return xmltmp.concat("</xmlFormInput>")}function sendEmailUsForm(){var inputVal=payloadEmailUs();if(!inputVal){errorEmailUs();activateEmailUs()}else{try{$.ajax({async:false,cache:false,url:"/form/ws/sendwebform/contactus",type:"POST",data:inputVal,dataType:"text/xml",success:function(data,status,req){successEmailUs(req.responseXML)},error:function(req,status,error){successEmailUs(req.responseXML)}})}catch(ex){errorEmailUs()}finally{activateEmailUs()}}}function sendSendToFriendForm(){var inputVal=payloadSendToFriend();if(!inputVal){errorSendToFriend();activateSendToFriend()}else{try{$.ajax({async:false,cache:false,url:"/form/ws/sendwebform/contactus",data:inputVal,type:"POST",dataType:"text/xml",success:function(data,status,req){successSendToFriend(req.responseXML)
},error:function(req,status,error){successSendToFriend(req.responseXML)}})}catch(ex){errorSendToFriend()}finally{activateSendToFriend()}}}function payloadEmailUs(){var src=$("#form_email_us input[name='merchant_xml_file']").val();var tmpStr;try{$.ajax({type:"GET",async:false,url:src,dataType:"text",success:function(data){tmpStr=data}})}catch(ex){tmpStr=""}if(!tmpStr){return""}else{return"&merchantAddresses="+encodeURIComponent(tmpStr)+"&xmlFormInput="+encodeURIComponent(convertFormToXml("form_email_us"))}}function payloadSendToFriend(){var src=$("#form_send_to_friend input[name='merchant_xml_file']").val();var tmpStr;try{$.ajax({type:"GET",async:false,url:src,dataType:"text",success:function(data){tmpStr=data}})}catch(ex){tmpStr=""}if(!tmpStr){return""}else{return"&merchantAddresses="+encodeURIComponent(tmpStr)+"&xmlFormInput="+encodeURIComponent(convertFormToXml("form_send_to_friend"))}}function resetEmailUs(){$("#form_email_us").clearForm();activateEmailUs();$("#email_us_id").hide()}function resetSendToFriend(){$("#form_send_to_friend").clearForm();activateSendToFriend();$("#dialog_send_to_friend").hide()}function activateEmailUs(){enable('#form_email_us input[name="name"]');enable('#form_email_us input[name="email"]');enable('#form_email_us textarea[name="comment"]');enable("#submit_email_us");$("#email_us_loaderCircle").hide()}function activateSendToFriend(){enable('#form_send_to_friend input[name="name"]');enable('#form_send_to_friend input[name="email"]');enable('#form_send_to_friend input[name="email_friend"]');enable("#submit_send_to_friend");$("#send_to_friend_loaderCircle").hide()}function deactivateEmailUs(){disable('#form_email_us input[name="name"]');disable('#form_email_us input[name="email"]');disable('#form_email_us textarea[name="comment"]');disable("#submit_email_us");$("#email_us_loaderCircle").show()}function deactivateSendToFriend(){disable('#form_send_to_friend input[name="name"]');disable('#form_send_to_friend input[name="email"]');disable('#form_send_to_friend input[name="email_friend"]');disable("#submit_send_to_friend");
$("#send_to_friend_loaderCircle").show()}function successEmailUs(response){var err=isError(response);var msg=gatherText(response);var tma="";if($(response).find("code").text()=="TOO_MANY_ATTEMPT"){tma=" (rsp code: 0001)"}if(msg==""){if($("html").attr("lang")=="fr"){msg=(err?"Le service n'est pas disponible pour l'instant."+tma:"Le courriel été envoyé.")}else{msg=(err?"Service unavailable. Please try again later."+tma:"Email sent.")}}feedbackEmailUs(msg,err)}function successSendToFriend(response){var err=isError(response);var msg=gatherText(response);var tma="";if($(response).find("code").text()=="TOO_MANY_ATTEMPT"){tma=" (rsp code: 0001)"}if(msg==""){if($("html").attr("lang")=="fr"){msg=(err?"Le service n'est pas disponible pour l'instant."+tma:"Le courriel été envoyé.")}else{msg=(err?"Service unavailable. Please try again later."+tma:"Email sent.")}}feedbackSendToFriend(msg,err)}function errorEmailUs(){if($("html").attr("lang")=="fr"){feedbackEmailUs("Le service n'est pas disponible pour l'instant.",true)}else{feedbackEmailUs("Service unavailable. Please try again later.",true)}}function errorSendToFriend(){if($("html").attr("lang")=="fr"){feedbackSendToFriend("Le service n'est pas disponible pour l'instant.",true)}else{feedbackSendToFriend("Service unavailable. Please try again later.",true)}}function feedbackEmailUs(msg,err){if(err){$("#form_email_us_message").html('<p class="ssoSmallMsgBox msgRed">'+msg+"</p>")}else{$("#form_email_us_message").html('<p class="ssoSmallMsgBox msgGreen">'+msg+"</p>");$("#form_email_us").clearForm()}}function feedbackSendToFriend(msg,err){if(err){$("#dialog_send_to_friend_message").html('<p class="ssoSmallMsgBox msgRed">'+msg+"</p>")}else{$("#dialog_send_to_friend_message").html('<p class="ssoSmallMsgBox msgGreen">'+msg+"</p>");$("#form_send_to_friend").clearForm()}}(function($){$.fn.dropmenu=function(custom){var defaults={openAnimation:"fadeIn",closeAnimation:"slide",openClick:false,openSpeed:300,closeSpeed:300,closeDelay:100,onHide:function(){},onHidden:function(){},onShow:function(){},onShown:function(){}};
var settings=$.extend({},defaults,custom);var menu=this;var currentPage=0;var delayTimer="";init();function init(){var items=menu.find(":has(li,div) > a").append('<span class="arrow"></span>');$.each(items,function(i,val){if(items.eq(i).parent().is("li")){items.eq(i).next().addClass("submenu").parent().addClass("haschildren")}else{items.eq(i).parent().find("ul").show()}});if(settings.openClick){menu.find(".submenu").css("display","none");menu.find(":has(li,div) > a").parent().bind("mouseleave",handleHover).bind("mouseenter",function(){window.clearInterval(delayTimer)});menu.find("a span.arrow").bind("click",handleHover)}else{menu.find(":has(li,div) > a").bind("mouseenter",handleHover).parent().bind("mouseleave",handleHover).bind("mouseenter",function(){window.clearInterval(delayTimer)})}}function handleHover(e){if(e.type=="mouseenter"||e.type=="click"){window.clearInterval(delayTimer);var current_submenu=$(e.target).parent().find(".submenu:not(:animated):not(.open)");if(current_submenu.html()==null){current_submenu=$(e.target).parent().next(".submenu:not(:animated):not(.open)")}if(current_submenu.html()!=null){settings.onShow.call(current_submenu);closeAllMenus();current_submenu.prev().addClass("selected");current_submenu.css("z-index","90");current_submenu.stop().hide();openMenu(current_submenu)}}if(e.type=="mouseleave"||e.type=="mouseout"){current_submenu=$(e.target).parents(".submenu");if(current_submenu.length!=1){var current_submenu=$(e.target).parent().parent().find(".submenu");if(current_submenu.html()==null){var current_submenu=$(e.target).parent().find(".submenu");if(current_submenu.html()==null){var current_submenu=$(e.target).parent().parent().parent().find(".submenu")}}}if(current_submenu.html()!=null){if(settings.closeDelay==0){current_submenu.parent().find("a").removeClass("selected");closeMenu(current_submenu)}else{window.clearInterval(delayTimer);delayTimer=setInterval(function(){window.clearInterval(delayTimer);closeMenu(current_submenu)},settings.closeDelay)}}}}function openMenu(object){switch(settings.openAnimation){case"slide":openSlideAnimation(object);
break;case"fade":openFadeAnimation(object);break;default:openSizeAnimation(object);break}}function openSlideAnimation(object){object.addClass("open").slideDown(settings.openSpeed,function(){settings.onShown.call(this)})}function openFadeAnimation(object){object.addClass("open").fadeIn(settings.openSpeed,function(){settings.onShown.call(this)})}function openSizeAnimation(object){object.addClass("open").show(settings.openSpeed,function(){settings.onShown.call(this)})}function closeMenu(object){settings.onHide.call(object);switch(settings.closeAnimation){case"slide":closeSlideAnimation(object);break;case"fade":closeFadeAnimation(object);break;default:closeSizeAnimation(object);break}}function closeSlideAnimation(object){object.slideUp(settings.closeSpeed,closeCallback)}function closeFadeAnimation(object){object.fadeOut(settings.closeSpeed,function(){$(this).removeClass("open");$(this).prev().removeClass("selected")})}function closeSizeAnimation(object){object.hide(settings.closeSpeed,function(){$(this).removeClass("open");$(this).prev().removeClass("selected")})}function closeAllMenus(){var submenus=menu.find(".submenu.open");$.each(submenus,function(i,val){$(submenus[i]).css("z-index","1");closeMenu($(submenus[i]))})}function closeCallback(object){$(this).removeClass("open");if($(this).prev().attr("class")=="selected"){settings.onHidden.call(this)}$(this).prev().removeClass("selected")}return this}})(jQuery);$.fn.clearForm=function(){return this.each(function(){$(":input",this).each(function(){var type=this.type,tag=this.tagName.toLowerCase();if(type=="text"||type=="password"||tag=="textarea"){this.value=""}else{if(type=="checkbox"||type=="radio"){this.checked=false}else{if(tag=="select"){this.selectedIndex=-1}}}})})};function menu_con(){$("#main-menu>li>ul").parent().mouseenter(function(){$(this).children("a").addClass("over").end().find(">ul").slideDown("fast",function(){MenuClose=false})}).mouseleave(function(){var $currentMenu=$(this);$currentMenu.find(">ul").stop(true,true).slideUp("fast",function(){$currentMenu.children("a").removeClass("over");
MenuClose=true})})}var Hashtable=(function(){var p="function";var n=(typeof Array.prototype.splice==p)?function(s,r){s.splice(r,1)}:function(u,t){var s,v,r;if(t===u.length-1){u.length=t}else{s=u.slice(t+1);u.length=t;for(v=0,r=s.length;v<r;++v){u[t+v]=s[v]}}};function a(t){var r;if(typeof t=="string"){return t}else{if(typeof t.hashCode==p){r=t.hashCode();return(typeof r=="string")?r:a(r)}else{if(typeof t.toString==p){return t.toString()}else{try{return String(t)}catch(s){return Object.prototype.toString.call(t)}}}}}function g(r,s){return r.equals(s)}function e(r,s){return(typeof s.equals==p)?s.equals(r):(r===s)}function c(r){return function(s){if(s===null){throw new Error("null is not a valid "+r)}else{if(typeof s=="undefined"){throw new Error(r+" must not be undefined")}}}}var q=c("key"),l=c("value");function d(u,s,t,r){this[0]=u;this.entries=[];this.addEntry(s,t);if(r!==null){this.getEqualityFunction=function(){return r}}}var h=0,j=1,f=2;function o(r){return function(t){var s=this.entries.length,v,u=this.getEqualityFunction(t);while(s--){v=this.entries[s];if(u(t,v[0])){switch(r){case h:return true;case j:return v;case f:return[s,v[1]]}}}return false}}function k(r){return function(u){var v=u.length;for(var t=0,s=this.entries.length;t<s;++t){u[v+t]=this.entries[t][r]}}}d.prototype={getEqualityFunction:function(r){return(typeof r.equals==p)?g:e},getEntryForKey:o(j),getEntryAndIndexForKey:o(f),removeEntryForKey:function(s){var r=this.getEntryAndIndexForKey(s);if(r){n(this.entries,r[0]);return r[1]}return null},addEntry:function(r,s){this.entries[this.entries.length]=[r,s]},keys:k(0),values:k(1),getEntries:function(s){var u=s.length;for(var t=0,r=this.entries.length;t<r;++t){s[u+t]=this.entries[t].slice(0)}},containsKey:o(h),containsValue:function(s){var r=this.entries.length;while(r--){if(s===this.entries[r][1]){return true}}return false}};function m(s,t){var r=s.length,u;while(r--){u=s[r];if(t===u[0]){return r}}return null}function i(r,s){var t=r[s];return(t&&(t instanceof d))?t:null}function b(t,r){var w=this;var v=[];
var u={};var x=(typeof t==p)?t:a;var s=(typeof r==p)?r:null;this.put=function(B,C){q(B);l(C);var D=x(B),E,A,z=null;E=i(u,D);if(E){A=E.getEntryForKey(B);if(A){z=A[1];A[1]=C}else{E.addEntry(B,C)}}else{E=new d(D,B,C,s);v[v.length]=E;u[D]=E}return z};this.get=function(A){q(A);var B=x(A);var C=i(u,B);if(C){var z=C.getEntryForKey(A);if(z){return z[1]}}return null};this.containsKey=function(A){q(A);var z=x(A);var B=i(u,z);return B?B.containsKey(A):false};this.containsValue=function(A){l(A);var z=v.length;while(z--){if(v[z].containsValue(A)){return true}}return false};this.clear=function(){v.length=0;u={}};this.isEmpty=function(){return !v.length};var y=function(z){return function(){var A=[],B=v.length;while(B--){v[B][z](A)}return A}};this.keys=y("keys");this.values=y("values");this.entries=y("getEntries");this.remove=function(B){q(B);var C=x(B),z,A=null;var D=i(u,C);if(D){A=D.removeEntryForKey(B);if(A!==null){if(!D.entries.length){z=m(v,C);n(v,z);delete u[C]}}}return A};this.size=function(){var A=0,z=v.length;while(z--){A+=v[z].entries.length}return A};this.each=function(C){var z=w.entries(),A=z.length,B;while(A--){B=z[A];C(B[0],B[1])}};this.putAll=function(H,C){var B=H.entries();var E,F,D,z,A=B.length;var G=(typeof C==p);while(A--){E=B[A];F=E[0];D=E[1];if(G&&(z=w.get(F))){D=C(F,z,D)}w.put(F,D)}};this.clone=function(){var z=new b(t,r);z.putAll(w);return z}}return b})();new function(settings){var $separator=settings.separator||"&";var $spaces=settings.spaces===false?false:true;var $suffix=settings.suffix===false?"":"[]";var $prefix=settings.prefix===false?false:true;var $hash=$prefix?settings.hash===true?"#":"?":"";var $numbers=settings.numbers===false?false:true;jQuery.query=new function(){var is=function(o,t){return o!=undefined&&o!==null&&(!!t?o.constructor==t:true)};var parse=function(path){var m,rx=/\[([^[]*)\]/g,match=/^([^[]+)(\[.*\])?$/.exec(path),base=match[1],tokens=[];while(m=rx.exec(match[2])){tokens.push(m[1])}return[base,tokens]};var set=function(target,tokens,value){var o,token=tokens.shift();if(typeof target!="object"){target=null
}if(token===""){if(!target){target=[]}if(is(target,Array)){target.push(tokens.length==0?value:set(null,tokens.slice(0),value))}else{if(is(target,Object)){var i=0;while(target[i++]!=null){}target[--i]=tokens.length==0?value:set(target[i],tokens.slice(0),value)}else{target=[];target.push(tokens.length==0?value:set(null,tokens.slice(0),value))}}}else{if(token&&token.match(/^\s*[0-9]+\s*$/)){var index=parseInt(token,10);if(!target){target=[]}target[index]=tokens.length==0?value:set(target[index],tokens.slice(0),value)}else{if(token){var index=token.replace(/^\s*|\s*$/g,"");if(!target){target={}}if(is(target,Array)){var temp={};for(var i=0;i<target.length;++i){temp[i]=target[i]}target=temp}target[index]=tokens.length==0?value:set(target[index],tokens.slice(0),value)}else{return value}}}return target};var queryObject=function(a){var self=this;self.keys={};if(a.queryObject){jQuery.each(a.get(),function(key,val){self.SET(key,val)})}else{jQuery.each(arguments,function(){var q=""+this;q=q.replace(/^[?#]/,"");q=q.replace(/[;&]$/,"");if($spaces){q=q.replace(/[+]/g," ")}jQuery.each(q.split(/[&;]/),function(){var key=decodeURIComponent(this.split("=")[0]||"");var val=decodeURIComponent(this.split("=")[1]||"");if(!key){return }if($numbers){if(/^[+-]?[0-9]+\.[0-9]*$/.test(val)){val=parseFloat(val)}else{if(/^[+-]?[0-9]+$/.test(val)){val=parseInt(val,10)}}}val=(!val&&val!==0)?true:val;if(val!==false&&val!==true&&typeof val!="number"){val=val}self.SET(key,val)})})}return self};queryObject.prototype={queryObject:true,has:function(key,type){var value=this.get(key);return is(value,type)},GET:function(key){if(!is(key)){return this.keys}var parsed=parse(key),base=parsed[0],tokens=parsed[1];var target=this.keys[base];while(target!=null&&tokens.length!=0){target=target[tokens.shift()]}return typeof target=="number"?target:target||""},get:function(key){var target=this.GET(key);if(is(target,Object)){return jQuery.extend(true,{},target)}else{if(is(target,Array)){return target.slice(0)}}return target},SET:function(key,val){var value=!is(val)?null:val;
var parsed=parse(key),base=parsed[0],tokens=parsed[1];var target=this.keys[base];this.keys[base]=set(target,tokens.slice(0),value);return this},set:function(key,val){return this.copy().SET(key,val)},REMOVE:function(key){return this.SET(key,null).COMPACT()},remove:function(key){return this.copy().REMOVE(key)},EMPTY:function(){var self=this;jQuery.each(self.keys,function(key,value){delete self.keys[key]});return self},load:function(url){var hash=url.replace(/^.*?[#](.+?)(?:\?.+)?$/,"$1");var search=url.replace(/^.*?[?](.+?)(?:#.+)?$/,"$1");return new queryObject(url.length==search.length?"":search,url.length==hash.length?"":hash)},empty:function(){return this.copy().EMPTY()},copy:function(){return new queryObject(this)},COMPACT:function(){function build(orig){var obj=typeof orig=="object"?is(orig,Array)?[]:{}:orig;if(typeof orig=="object"){function add(o,key,value){if(is(o,Array)){o.push(value)}else{o[key]=value}}jQuery.each(orig,function(key,value){if(!is(value)){return true}add(obj,key,build(value))})}return obj}this.keys=build(this.keys);return this},compact:function(){return this.copy().COMPACT()},toString:function(){var i=0,queryString=[],chunks=[],self=this;var encode=function(str){str=str+"";if($spaces){str=str.replace(/ /g,"+")}return encodeURIComponent(str)};var addFields=function(arr,key,value){if(!is(value)||value===false){return }var o=[encode(key)];if(value!==true){o.push("=");o.push(encode(value))}arr.push(o.join(""))};var build=function(obj,base){var newKey=function(key){return !base||base==""?[key].join(""):[base,"[",key,"]"].join("")};jQuery.each(obj,function(key,value){if(typeof value=="object"){build(value,newKey(key))}else{addFields(chunks,newKey(key),value)}})};build(this.keys);if(chunks.length>0){queryString.push($hash)}queryString.push(chunks.join($separator));return queryString.join("")}};return new queryObject(location.search,location.hash)}}(jQuery.query||{});if(jQuery){(function(){$.extend($.fn,{contextMenu:function(o,callback){if(o.menu==undefined){return false}if(o.inSpeed==undefined){o.inSpeed=150
}if(o.outSpeed==undefined){o.outSpeed=75}if(o.inSpeed==0){o.inSpeed=-1}if(o.outSpeed==0){o.outSpeed=-1}$(this).each(function(){var el=$(this);var offset=$(el).offset();$("#"+o.menu).addClass("contextMenu");$(this).mousedown(function(e){var evt=e;evt.stopPropagation();$(this).mouseup(function(e){e.stopPropagation();var srcElement=$(this);$(this).unbind("mouseup");if(evt.button==2){$(".contextMenu").hide();var menu=$("#"+o.menu);if($(el).hasClass("disabled")){return false}var d={},x,y;if(self.innerHeight){d.pageYOffset=self.pageYOffset;d.pageXOffset=self.pageXOffset;d.innerHeight=self.innerHeight;d.innerWidth=self.innerWidth}else{if(document.documentElement&&document.documentElement.clientHeight){d.pageYOffset=document.documentElement.scrollTop;d.pageXOffset=document.documentElement.scrollLeft;d.innerHeight=document.documentElement.clientHeight;d.innerWidth=document.documentElement.clientWidth}else{if(document.body){d.pageYOffset=document.body.scrollTop;d.pageXOffset=document.body.scrollLeft;d.innerHeight=document.body.clientHeight;d.innerWidth=document.body.clientWidth}}}(e.pageX)?x=e.pageX:x=e.clientX+d.scrollLeft;(e.pageY)?y=e.pageY:y=e.clientY+d.scrollTop;$(document).unbind("click");$(menu).css({top:y,left:x}).fadeIn(o.inSpeed);$(menu).find("A").mouseover(function(){$(menu).find("LI.hover").removeClass("hover");$(this).parent().addClass("hover")}).mouseout(function(){$(menu).find("LI.hover").removeClass("hover")});$(document).keypress(function(e){switch(e.keyCode){case 38:if($(menu).find("LI.hover").size()==0){$(menu).find("LI:last").addClass("hover")}else{$(menu).find("LI.hover").removeClass("hover").prevAll("LI:not(.disabled)").eq(0).addClass("hover");if($(menu).find("LI.hover").size()==0){$(menu).find("LI:last").addClass("hover")}}break;case 40:if($(menu).find("LI.hover").size()==0){$(menu).find("LI:first").addClass("hover")}else{$(menu).find("LI.hover").removeClass("hover").nextAll("LI:not(.disabled)").eq(0).addClass("hover");if($(menu).find("LI.hover").size()==0){$(menu).find("LI:first").addClass("hover")}}break;
case 13:$(menu).find("LI.hover A").trigger("click");break;case 27:$(document).trigger("click");break}});$("#"+o.menu).find("A").unbind("click");$("#"+o.menu).find("LI:not(.disabled) A").click(function(){$(document).unbind("click").unbind("keypress");$(".contextMenu").hide();if(callback){callback($(this).attr("href").substr(1),$(srcElement),{x:x-offset.left,y:y-offset.top,docX:x,docY:y})}return false});setTimeout(function(){$(document).click(function(){$(document).unbind("click").unbind("keypress");$(menu).fadeOut(o.outSpeed);return false})},0)}})});if($.browser.mozilla){$("#"+o.menu).each(function(){$(this).css({MozUserSelect:"none"})})}else{if($.browser.msie){$("#"+o.menu).each(function(){$(this).bind("selectstart.disableTextSelect",function(){return false})})}else{$("#"+o.menu).each(function(){$(this).bind("mousedown.disableTextSelect",function(){return false})})}}$(el).add($("UL.contextMenu")).bind("contextmenu",function(){return false})});return $(this)},disableContextMenuItems:function(o){if(o==undefined){$(this).find("LI").addClass("disabled");return($(this))}$(this).each(function(){if(o!=undefined){var d=o.split(",");for(var i=0;i<d.length;i++){$(this).find('A[href="'+d[i]+'"]').parent().addClass("disabled")}}});return($(this))},enableContextMenuItems:function(o){if(o==undefined){$(this).find("LI.disabled").removeClass("disabled");return($(this))}$(this).each(function(){if(o!=undefined){var d=o.split(",");for(var i=0;i<d.length;i++){$(this).find('A[href="'+d[i]+'"]').parent().removeClass("disabled")}}});return($(this))},disableContextMenu:function(){$(this).each(function(){$(this).addClass("disabled")});return($(this))},enableContextMenu:function(){$(this).each(function(){$(this).removeClass("disabled")});return($(this))},destroyContextMenu:function(){$(this).each(function(){$(this).unbind("mousedown").unbind("mouseup")});return($(this))}})})(jQuery)}if(typeof console=="undefined"){var console={};console.log=function(a){return }}function KMDelegateOption(a,b){this.RunDefaultHandler=a;this.ClientDelegateName=b;
this.Clone=function(c,d){this.RunDefaultHandler=c;if(jQuery.isArray(d)){this.ClientDelegateName=d.slice()}else{this.ClientDelegateName=d}}}KMDirectionTurn={};KMDirectionTurn.UTurnPatterns=["U-turn","demi-tour"];KMDirectionTurn.LeftTurnPatterns=["Turn left","Tourner à gauche"];KMDirectionTurn.RightTurnPatterns=["Turn right","Tourner à droite"];KMDirectionTurn.LeftRampPatterns=["Bear left","ramp left","Prendre à gauche","la gauche"];KMDirectionTurn.RightRampPatterns=["Bear right","ramp right","Prendre à droite","la droite"];KMDirectionTurn.StraightPatterns=["Keep straight","Continuer"];KMDirectionTurn.DepartPatterns=["Depart","Départ"];KMDirectionTurn.ArrivePatterns=["Arrive","Arrivée"];KMDirectionTurn.IsTextMatchedToPattern=function(c,f){if(jQuery.isArray(c)&&!String.IsNullOrEmpty(f)){for(var b=0;b<c.length;b++){var e=c[b];var d=new RegExp(e,"gi");var a=f.match(d);if(a!=null&&a.length>0){return true}}}return false};KMDirectionTurn.GetDirectionTurnType=function(a){if(KMDirectionTurn.IsTextMatchedToPattern(KMDirectionTurn.UTurnPatterns,a)){return KMDirectionTurnType.UTurn}if(KMDirectionTurn.IsTextMatchedToPattern(KMDirectionTurn.LeftTurnPatterns,a)){return KMDirectionTurnType.LeftTurn}if(KMDirectionTurn.IsTextMatchedToPattern(KMDirectionTurn.RightTurnPatterns,a)){return KMDirectionTurnType.RightTurn}if(KMDirectionTurn.IsTextMatchedToPattern(KMDirectionTurn.LeftRampPatterns,a)){return KMDirectionTurnType.LeftRamp}if(KMDirectionTurn.IsTextMatchedToPattern(KMDirectionTurn.RightRampPatterns,a)){return KMDirectionTurnType.RightRamp}if(KMDirectionTurn.IsTextMatchedToPattern(KMDirectionTurn.StraightPatterns,a)){return KMDirectionTurnType.Straight}if(KMDirectionTurn.IsTextMatchedToPattern(KMDirectionTurn.DepartPatterns,a)){return KMDirectionTurnType.Depart}if(KMDirectionTurn.IsTextMatchedToPattern(KMDirectionTurn.ArrivePatterns,a)){return KMDirectionTurnType.Arrive}return KMDirectionTurnType.None};var KMDirectionTurnType={None:0,UTurn:1,LeftTurn:2,RightTurn:3,LeftRamp:4,RightRamp:5,Straight:6,Depart:7,Arrive:8};String.IsNullOrEmpty=function(a){if(a){if(typeof (a)=="string"){if(a.length>0){return false
}}if(a!=null){return false}}return true};String.prototype.Trim=function(){return this.replace(/^\s\s*/,"").replace(/\s\s*$/,"")};KMObject={};KMObject.Extend=function(c,a){function b(){}b.prototype=a.prototype;c.prototype=new b();c.prototype.constructor=c;c.baseConstructor=a;c.superClass=a.prototype};function KMRouteSegment(){this.SegmentType=KMRouteSegmentType.Unknown;this.DestinationIndex=-1;this.IndexArray=[];this.LegArray=[]}var KMRouteSegmentType={Unknown:0,Destination:1,Leg:2};GetQueryStringVariable=function(a){var c=window.location.search.substring(1);var d=c.split("&");for(var b=0;b<d.length;b++){var e=d[b].split("=");if(e[0]==a){return e[1]}}return""};DebugPointArray=function(b){if(jQuery.isArray(b)){var a="";for(var c=0;c<b.length;c++){a+=b[c].Debug()}return a}return""};DebugArray=function(a){if(jQuery.isArray(a)){var b="";for(var c=0;c<a.length;c++){b+="["+a[c]+"]"}return b}return""};FloatEquals=function(o,n,k){var d=false;var f=Math.floor(o);var e=Math.floor(n);if(f!=e){return false}var b=Math.pow(10,k);var c=Math.floor(o*b);var a=Math.floor(n*b);if(c==a){return true}var h=String(o).length;var g=String(n).length;if(h>=g){d=String(o).indexOf(String(n))==0}else{d=String(n).indexOf(String(o))==0}if(d){return true}var q=ChopFloatToPrecision(o,k);var p=ChopFloatToPrecision(n,k);d=q==p;if(d){return true}var m=parseFloat(o).toFixed(k);var l=parseFloat(n).toFixed(k);d=m==l;return d};GetFloatPrecision=function(a){var b=new String(a);if(b.indexOf(".")>-1){return b.length-b.indexOf(".")-1}else{return 0}};ChopFloatToPrecision=function(b,d){var c=GetFloatPrecision(b);if(c==0||c<=d){return b}var e=new String(b);var a=e.length;var h=e.indexOf(".");var f=a-(c-d);var g=e.substr(0,f);return parseFloat(g)};AddressKindOfEquals=function(f,e){if(String.IsNullOrEmpty(f)||String.IsNullOrEmpty(e)){return false}var d=f.replace(/\,/gi,"").replace(/\./gi,"");var h=e.replace(/\,/gi,"").replace(/\./gi,"");if(String.IsNullOrEmpty(d)||String.IsNullOrEmpty(h)){return false}var g=new RegExp(h,"gi");var c=d.match(g);if(c!=null&&c.length>0){return true
}g=new RegExp(d,"gi");c=h.match(g);if(c!=null&&c.length>0){return true}return false};AddressIndexInArray=function(c,b){if(jQuery.isArray(b)){for(var d=0;d<b.length;d++){if(AddressKindOfEquals(c,b[d])){return d}}}return -1};VEShapeLayer.prototype.ReferenceID=null;VEShapeLayer.prototype.Group=null;VEShapeLayer.prototype.GeocodeIndex=null;VEShape.prototype.ReferenceID=null;VEShape.prototype.ShapeLayerID=null;VEShape.prototype.IsClustered=false;VEShape.prototype.IsInMapView=false;VEShape.prototype.Payload=null;VEShape.prototype.Group=null;VELatLongRectangle.prototype.Centre=null;VELatLongRectangle.prototype.Zoom=null;VEPixel.prototype.IntX=function(){return this.x.toFixed()};VEPixel.prototype.IntY=function(){return this.y.toFixed()};VEPixel.prototype.Debug=function(){return"("+this.IntX()+","+this.IntY()+")"};VEPixel.prototype.IndexInArray=function(a){if(jQuery.isArray(a)){for(var c=0;c<a.length-1;c++){var e=a[c];var b=a[c+1];var f=false;var d=false;if(e.IntX()<=b.IntX()){if(this.IntX()>=e.IntX()&&this.IntX()<=b.IntX()){f=true}}else{if(this.IntX()>=b.IntX()&&this.IntX()<=e.IntX()){f=true}}if(e.IntY()<=b.IntY()){if(this.IntY()>=e.IntY()&&this.IntY()<=b.IntY()){d=true}}else{if(this.IntY()>=b.IntY()&&this.IntY()<=e.IntY()){d=true}}if(f&&d){return(c+1)}}}return -1};VELatLong.prototype.Debug=function(){return"("+this.Latitude+","+this.Longitude+")"};VELatLong.prototype.KindOfEquals=function(a,b){if(b===undefined){b=6}if(FloatEquals(this.Latitude,a.Latitude,b)&&FloatEquals(this.Longitude,a.Longitude,b)){return true}if(FloatEquals(this.Latitude,a.Latitude,b-1)&&FloatEquals(this.Longitude,a.Longitude,b-1)){return true}return false};VELatLong.prototype.KindOfInArray=function(a){if(jQuery.isArray(a)){for(var b=0;b<a.length;b++){if(a[b].KindOfEquals(this)){return b}}}return -1};VELatLongRectangle.prototype.Debug=function(){return"TopLeft: "+this.TopLeftLatLong.Debug()+", BottomRight: "+this.BottomRightLatLong.Debug()};VEMap.prototype.GetShapeGuidFromPrimitiveID=function(a){var d=a.replace(/[^_]/g,"").length;if(d==3){var c=a.lastIndexOf("_");
var b=a.substring(0,c);return b}return a};VEMap.prototype.LatLongToPixelArray=function(b){var c=[];for(var a=0;a<b.length;a++){c.push(this.LatLongToPixel(b[a],this.GetZoomLevel()))}return c};VEMap.prototype.PixelToLatLongArray=function(b){var c=[];for(var a=0;a<b.length;a++){c.push(this.PixelToLatLong(b[a]))}return c};VERoute.prototype.GetLocations=function(){var a=[];if(this.RouteLegs!=null){for(var b=0;b<=this.RouteLegs.length-1;b++){a.push(this.RouteLegs[b].StartLocation)}a.push(this.RouteLegs[this.RouteLegs.length-1].EndLocation)}return a};VERoute.prototype.GetShapePointsOfAllLegs=function(){if(this.RouteLegs!=null&&this.ShapePoints!=null){var f=new Array(this.RouteLegs.length);for(i=0;i<=this.RouteLegs.length-1;i++){f[i]=[];var d=this.RouteLegs[i];var e=d.StartLocation;var b=d.EndLocation;var a=0;for(var c=0;c<this.ShapePoints.length;c++){if(e.KindOfEquals(this.ShapePoints[c])){a=1}if(a==1){f[i].push(this.ShapePoints[c])}if(b.KindOfEquals(this.ShapePoints[c])){a=2;f[i].push(this.ShapePoints[c])}if(a==2){break}}}return f}return null};VERoute.prototype.GetShapePointsOfLeg=function(a){if(this.RouteLegs!=null&&this.ShapePoints!=null){var b=this.GetShapePointsOfAllLegs();if(b!=null){if(a>0&&a<b.length){return b[a]}}}return null};VERoute.prototype.GetRouteSegmentArray=function(f){if(this.RouteLegs==null||!jQuery.isArray(this.RouteLegs)){return null}if(!jQuery.isArray(f)){return null}var h=this.GetLocations();var c=[];for(var e=0;e<f.length;e++){var l=f[e];var g=l.KindOfInArray(h);c.push(g)}var m=[];var d=-1;var b=-1;for(var e=0;e<c.length;e++){b=d;d=c[e];if(e==0){var k=new KMRouteSegment();k.SegmentType=KMRouteSegmentType.Destination;k.DestinationIndex=e;k.IndexArray=null;k.LegArray=null;m.push(k)}if(e>0){if(d-b>=1){var a=new KMRouteSegment();a.SegmentType=KMRouteSegmentType.Leg;a.DestinationIndex=-1;a.IndexArray=[];a.LegArray=[];for(j=b;j<=d-1;j++){a.IndexArray.push(j);a.LegArray.push(this.RouteLegs[j])}m.push(a)}var k=new KMRouteSegment();k.SegmentType=KMRouteSegmentType.Destination;k.DestinationIndex=e;k.IndexArray=null;
k.LegArray=null;m.push(k)}}return m};function KMCacheManager(){var d;var c="divDataCache";function e(){if(!d&&GetQueryStringVariable("state")!="clear"){try{d=new JSTONE(JSON)}catch(f){}}}function b(f){if(f!=null&&typeof (f)=="string"){f=f.replace(/'/gi,"");f=f.replace(/#/gi,"");f=f.replace(/\$/gi,"");f=f.replace(/%/gi,"");f=f.replace(/\^/gi,"");f=f.replace(/!/gi,"");f=f.replace(/</gi,"");f=f.replace(/>/gi,"");f=f.replace(/~/gi,"");f=f.replace(/"/gi,"");f=f.replace(/\//gi,"");f=f.replace(/\*/gi,"")}return f}function a(f){if(f!=null&&typeof (f)=="string"){f=b(f);f=f.replace(/;/gi,"")}return f}this.Save=function(f,g){e();if(d==undefined||d==null){return""}d.write(f,g)};this.Retrieve=function(f){e();if(d==undefined||d==null){return""}return d.read(f)};this.SetClientCookie=function(h,l,g,n,k,m){var f=new Array();if(h!=null&&l!=null){f.push(a(h)+"="+a(l))}if(g!=null){f.push("expires="+g)}if(n!=null){f.push("path="+n)}if(k!=null){f.push("domain="+k)}if(m!=null&&m){f.push("secure")}document.cookie=f.join("; ")};this.GetClientCookie=function(){return b(document.cookie)};this.GetClientCookieByName=function(f){var l=document.cookie.split(";");var m=f+"=";var k=null;for(var h=0;h<l.length;h++){var g=l[h];while(g.charAt(0)==" "){g=g.substring(1,g.length)}if(g.indexOf(m)==0){k=g.substring(m.length,g.length)}}return k};this.SaveObjectToClientCache=function(h,k){if(typeof k!="object"){return }if(String.IsNullOrEmpty(h)){return }var g=JSON.stringify(k);if(jQuery("#"+c).length==0){var l=document.createElement("div");l.setAttribute("id",c);jQuery(l).css("display","none");jQuery(l).appendTo("body")}if(jQuery("#"+h).length==0){var f=document.createElement("div");f.setAttribute("id",h);jQuery("#"+c).append(f)}jQuery("#"+h).text(g)};this.GetObjectFromClientCache=function(g){if(String.IsNullOrEmpty(g)){return null}if(jQuery("#"+g).length==0){return null}var f=jQuery("#"+g).text();var k=null;try{k=JSON.parse(f)}catch(h){return null}return k}}function KMClusterManager(mapInstance,shapeLayerManager,shapeManager){var _clusterManager=this;var _mapInstance=mapInstance;
var _shapeLayerManager=shapeLayerManager;var _shapeManager=shapeManager;var _clusterShapeLayer=null;var _clusterMapDelegateOption=new KMDelegateOption(true,"");this.Debug=true;this.SetClusterShapeLayer=function(shapeLayer,image){_clusterShapeLayer=shapeLayer;var options=new VEClusteringOptions();options.Callback=this.OnClusterMapHandler;if(!String.IsNullOrEmpty(image)){var customIcon=new VECustomIconSpecification();customIcon.Image=image;options.Icon=customIcon}_clusterShapeLayer.SetClusteringConfiguration(VEClusteringType.Grid,options)};this.SetClusterShapeLayerByID=function(shapeLayerID,image){var shapeLayer=_shapeLayerManager.GetShapeLayer(shapeLayerID);this.SetClusterShapeLayer(shapeLayer,image)};this.GetClusterShapes=function(){if(_clusterShapeLayer!=null){return _clusterShapeLayer.GetClusteredShapes(VEClusteringType.Grid)}return null};this.SetClusterMapDelegateOption=function(option){_clusterMapDelegateOption.Clone(option.RunDefaultHandler,option.ClientDelegateName)};this.OnClusterMapHandler=function(clusters){if(_clusterMapDelegateOption.RunDefaultHandler){if(_clusterManager.Debug){console.log("KMClusterManager.OnClusterMapHandler: Number of clusters: %s",clusters.length)}}if(jQuery.isArray(_clusterMapDelegateOption.ClientDelegateName)){for(var i=0;i<_clusterMapDelegateOption.ClientDelegateName.length;i++){var delegate=_clusterMapDelegateOption.ClientDelegateName[i];if(!String.IsNullOrEmpty(delegate)){eval(delegate)(_clusterManager,clusters)}}}else{if(!String.IsNullOrEmpty(_clusterMapDelegateOption.ClientDelegateName)){eval(_clusterMapDelegateOption.ClientDelegateName)(_clusterManager,clusters)}}}}function KMListManager(listParentDiv){var _listParentDiv=listParentDiv;var _listItemMouseOverDelegateOption=new KMDelegateOption(true,"");var _listItemMouseOutDelegateOption=new KMDelegateOption(true,"");var _listItemMouseOverCSSClass=null;var _listItemMouseOutCSSClass=null;this.ItemCount=null;this.SetListItemMouseOverDelegate=function(option){_listItemMouseOverDelegateOption.Clone(option.RunDefaultHandler,option.ClientDelegateName)
};this.SetListItemMouseOutDelegate=function(option){_listItemMouseOutDelegateOption.Clone(option.RunDefaultHandler,option.ClientDelegateName)};this.ListItemMouseOverCSSClass=function(cssClass){_listItemMouseOverCSSClass=cssClass};this.ListItemMouseOutCSSClass=function(cssClass){_listItemMouseOutCSSClass=cssClass};this.CreateList=function(veShapeLayer,listItemDataBoundDelegate){this.ItemCount=veShapeLayer.GetShapeCount();if(_listParentDiv==null){return }if(this.ItemCount==0){return }if(String.IsNullOrEmpty(listItemDataBoundDelegate)){return }jQuery("#"+_listParentDiv).empty();for(var i=0;i<this.ItemCount;i++){var veShape=veShapeLayer.GetShapeByIndex(i);var itemDiv=jQuery(document.createElement("div"));var id="div_"+veShape.ReferenceID;jQuery(itemDiv).attr("id",id);BindHoverEvents(itemDiv);jQuery("#"+_listParentDiv).append(itemDiv);eval(listItemDataBoundDelegate)(veShape,itemDiv)}};function GetShapeId(divElement){var shapeId=null;if(divElement!=null){shapeId=divElement.id.replace("div_","")}return shapeId}function ListItemMouseOver(e){var target=e.currentTarget;var shapeId=GetShapeId(target);if(_listItemMouseOverCSSClass!=null){jQuery(target).addClass(_listItemMouseOverCSSClass)}if(!String.IsNullOrEmpty(_listItemMouseOverDelegateOption.ClientDelegateName)){eval(_listItemMouseOverDelegateOption.ClientDelegateName)(e,shapeId)}}function ListItemMouseOut(e){var target=e.currentTarget;var shapeId=GetShapeId(target);if(_listItemMouseOutCSSClass!=null){jQuery(target).addClass(_listItemMouseOutCSSClass)}if(!String.IsNullOrEmpty(_listItemMouseOutDelegateOption.ClientDelegateName)){eval(_listItemMouseOutDelegateOption.ClientDelegateName)(e,shapeId)}}function BindHoverEvents(div){jQuery(div).bind("mouseover",ListItemMouseOver);jQuery(div).bind("mouseout",ListItemMouseOut)}}function KMMapManager(){var _mapManager=this;var _mapInstance;var _shapeLayerManager;var _shapeManager;var _clusterManager;var _resizeDelegateOption=new KMDelegateOption(true,"");var _changeMapStyleDelegateOption=new KMDelegateOption(true,"");var _changeViewDelegateOption=new KMDelegateOption(true,"");
var _initModeDelegateOption=new KMDelegateOption(true,"");var _startPanDelegateOption=new KMDelegateOption(true,"");var _endPanDelegateOption=new KMDelegateOption(true,"");var _startZoomDelegateOption=new KMDelegateOption(true,"");var _endZoomDelegateOption=new KMDelegateOption(true,"");var _clickDelegateOption=new KMDelegateOption(true,"");var _doubleClickDelegateOption=new KMDelegateOption(true,"");var _mouseOverDelegateOption=new KMDelegateOption(true,"");var _mouseOutDelegateOption=new KMDelegateOption(true,"");var _obliqueEnterDelegateOption=new KMDelegateOption(true,"");var _obliqueLeaveDelegateOption=new KMDelegateOption(true,"");var _errorDelegateOption=new KMDelegateOption(true,"");this.MapInstance=null;this.MapDivName=null;this.MapElement=null;this.ShapeLayerManager=null;this.ShapeManager=null;this.ClusterManager=null;this.Debug=true;this.GetMap=function(divName,centerLatitude,centerLongitude,zoom,onLoadMap,enhancedRoad){this.MapDivName=divName;this.MapElement=document.getElementById(this.MapDivName);_mapInstance=new VEMap(this.MapDivName);this.MapInstance=_mapInstance;_shapeLayerManager=new KMShapeLayerManager(this.MapInstance);this.ShapeLayerManager=_shapeLayerManager;_shapeManager=new KMShapeManager(this.MapInstance,this.ShapeLayerManager);this.ShapeManager=_shapeManager;_clusterManager=new KMClusterManager(this.MapInstance,this.ShapeLayerManager,this.ShapeManager);this.ClusterManager=_clusterManager;if(!String.IsNullOrEmpty(onLoadMap)){_mapInstance.onLoadMap=onLoadMap}if(enhancedRoad===undefined){enhancedRoad=true}var mapOptions=new VEMapOptions();mapOptions.DashboardColor="black";mapOptions.UseEnhancedRoadStyle=true;mapOptions.EnableBirdseye=false;_mapInstance.LoadMap(new VELatLong(centerLatitude,centerLongitude),zoom,VEMapStyle.Road,false,VEMapMode.Mode2D,false,0,mapOptions);_mapInstance.SetScaleBarDistanceUnit(VEDistanceUnit.Kilometers);_mapInstance.AttachEvent("onresize",this.OnResizeHandler);_mapInstance.AttachEvent("onchangemapstyle",this.OnChangeMapStyleHandler);_mapInstance.AttachEvent("onchangeview",this.OnChangeViewHandler);
_mapInstance.AttachEvent("oninitmode",this.OnInitModeHandler);_mapInstance.AttachEvent("onstartpan",this.OnStartPanHandler);_mapInstance.AttachEvent("onendpan",this.OnEndPanHandler);_mapInstance.AttachEvent("onstartzoom",this.OnStartZoomHandler);_mapInstance.AttachEvent("onendzoom",this.OnEndZoomHandler);_mapInstance.AttachEvent("onclick",this.OnClickHandler);_mapInstance.AttachEvent("ondoubleclick",this.OnDoubleClickHandler);_mapInstance.AttachEvent("onmouseover",this.OnMouseOverHandler);_mapInstance.AttachEvent("onmouseout",this.OnMouseOutHandler);_mapInstance.AttachEvent("onobliqueenter",this.OnObliqueEnterHandler);_mapInstance.AttachEvent("onobliqueleave",this.OnObliqueLeaveHandler);_shapeManager.UpdateShapesInMapView()};this.AddControl=function(control){if(control==null){return }_mapInstance.AddControl(control)};this.DetachResizeHandler=function(){_mapInstance.DetachEvent("onresize",this.OnResizeHandler)};this.DetachChangeMapStyleHandler=function(){_mapInstance.DetachEvent("onchangemapstyle",this.OnChangeMapStyleHandler)};this.DetachChangeViewHandler=function(){_mapInstance.DetachEvent("onchangeview",this.OnChangeViewHandler)};this.DetachInitModeHandler=function(){_mapInstance.DetachEvent("oninitmode",this.OnInitModeHandler)};this.DetachStartPanHandler=function(){_mapInstance.DetachEvent("onstartpan",this.OnStartPanHandler)};this.DetachEndPanHandler=function(){_mapInstance.DetachEvent("onendpan",this.OnEndPanHandler)};this.DetachStartZoomHandler=function(){_mapInstance.DetachEvent("onstartzoom",this.OnStartZoomHandler)};this.DetachEndZoomHandler=function(){_mapInstance.DetachEvent("onendzoom",this.OnEndZoomHandler)};this.DetachClickHandler=function(){_mapInstance.DetachEvent("onclick",this.OnClickHandler)};this.DetachDoubleClickHandler=function(){_mapInstance.DetachEvent("ondoubleclick",this.OnDoubleClickHandler)};this.DetachMouseOverHandler=function(){_mapInstance.DetachEvent("onmouseover",this.OnMouseOverHandler)};this.DetachMouseOutHandler=function(){_mapInstance.DetachEvent("onmouseout",this.OnMouseOutHandler)
};this.DetachObliqueEnterHandler=function(){_mapInstance.DetachEvent("onobliqueenter",this.OnObliqueEnterHandler)};this.DetachObliqueLeaveHandler=function(){_mapInstance.DetachEvent("onobliqueleave",this.OnObliqueLeaveHandler)};this.SetResizeDelegateOption=function(option){_resizeDelegateOption.Clone(option.RunDefaultHandler,option.ClientDelegateName);_mapInstance.AttachEvent("onresize",this.OnResizeHandler)};this.SetChangeMapStyleDelegateOption=function(option){_changeMapStyleDelegateOption.Clone(option.RunDefaultHandler,option.ClientDelegateName);_mapInstance.AttachEvent("onchangemapstyle",this.OnChangeMapStyleHandler)};this.SetChangeViewDelegateOption=function(option){_changeViewDelegateOption.Clone(option.RunDefaultHandler,option.ClientDelegateName);_mapInstance.AttachEvent("onchangeview",this.OnChangeViewHandler)};this.SetInitModeDelegateOption=function(option){_initModeDelegateOption.Clone(option.RunDefaultHandler,option.ClientDelegateName);_mapInstance.AttachEvent("oninitmode",this.OnInitModeHandler)};this.SetStartPanDelegateOption=function(option){_startPanDelegateOption.Clone(option.RunDefaultHandler,option.ClientDelegateName);_mapInstance.AttachEvent("onstartpan",this.OnStartPanHandler)};this.SetEndPanDelegateOption=function(option){_endPanDelegateOption.Clone(option.RunDefaultHandler,option.ClientDelegateName);_mapInstance.AttachEvent("onendpan",this.OnEndPanHandler)};this.SetStartZoomDelegateOption=function(option){_startZoomDelegateOption.Clone(option.RunDefaultHandler,option.ClientDelegateName);_mapInstance.AttachEvent("onstartzoom",this.OnStartZoomHandler)};this.SetEndZoomDelegateOption=function(option){_endZoomDelegateOption.Clone(option.RunDefaultHandler,option.ClientDelegateName);_mapInstance.AttachEvent("onendzoom",this.OnEndZoomHandler)};this.SetClickDelegateOption=function(option){_clickDelegateOption.Clone(option.RunDefaultHandler,option.ClientDelegateName);_mapInstance.AttachEvent("onclick",this.OnClickHandler)};this.SetDoubleClickDelegateOption=function(option){_doubleClickDelegateOption.Clone(option.RunDefaultHandler,option.ClientDelegateName);
_mapInstance.AttachEvent("ondoubleclick",this.OnDoubleClickHandler)};this.SetMouseOverDelegateOption=function(option){_mouseOverDelegateOption.Clone(option.RunDefaultHandler,option.ClientDelegateName);_mapInstance.AttachEvent("onmouseover",this.OnMouseOverHandler)};this.SetMouseOutDelegateOption=function(option){_mouseOutDelegateOption.Clone(option.RunDefaultHandler,option.ClientDelegateName);_mapInstance.AttachEvent("onmouseout",this.OnMouseOutHandler)};this.SetObliqueEnterDelegateOption=function(option){_obliqueEnterDelegateOption.Clone(option.RunDefaultHandler,option.ClientDelegateName);_mapInstance.AttachEvent("onobliqueenter",this.OnObliqueEnterHandler)};this.SetObliqueLeaveDelegateOption=function(option){_obliqueLeaveDelegateOption.Clone(option.RunDefaultHandler,option.ClientDelegateName);_mapInstance.AttachEvent("onobliqueleave",this.OnObliqueLeaveHandler)};this.SetErrorDelegateOption=function(option){_errorDelegateOption.Clone(option.RunDefaultHandler,option.ClientDelegateName);_mapInstance.AttachEvent("onerror",this.OnErrorHandler)};this.OnResizeHandler=function(e){if(_resizeDelegateOption.RunDefaultHandler){_shapeManager.UpdateShapesInMapView();if(_mapManager.Debug){console.log("KMMapManager.OnResizeHandler: %s",_mapInstance.GetMapView().Debug())}}HandleClientDelegate(_resizeDelegateOption,e)};this.OnChangeMapStyleHandler=function(e){if(_changeMapStyleDelegateOption.RunDefaultHandler){if(_mapManager.Debug){console.log("KMMapManager.OnChangeMapStyleHandler: %s",_mapInstance.GetMapView().Debug())}}HandleClientDelegate(_changeMapStyleDelegateOption,e)};this.OnChangeViewHandler=function(e){if(_changeViewDelegateOption.RunDefaultHandler){_shapeManager.UpdateShapesInMapView();if(_mapManager.Debug){console.log("KMMapManager.OnChangeViewHandler: %s",_mapInstance.GetMapView().Debug())}}HandleClientDelegate(_changeViewDelegateOption,e)};this.OnInitModeHandler=function(e){if(_initModeDelegateOption.RunDefaultHandler){_shapeManager.UpdateShapesInMapView();if(_mapManager.Debug){console.log("KMMapManager.OnInitModeHandler: %s",_mapInstance.GetMapView().Debug())
}}HandleClientDelegate(_initModeDelegateOption,e)};this.OnStartPanHandler=function(e){if(_startPanDelegateOption.RunDefaultHandler){if(_mapManager.Debug){console.log("KMMapManager.OnStartPanHandler: %s",_mapInstance.GetMapView().Debug())}}HandleClientDelegate(_startPanDelegateOption,e)};this.OnEndPanHandler=function(e){if(_endPanDelegateOption.RunDefaultHandler){if(_mapManager.Debug){console.log("KMMapManager.OnEndPanHandler: %s",_mapInstance.GetMapView().Debug())}}HandleClientDelegate(_endPanDelegateOption,e)};this.OnStartZoomHandler=function(e){if(_startZoomDelegateOption.RunDefaultHandler){if(_mapManager.Debug){console.log("KMMapManager.OnStartZoomHandler: %s",_mapInstance.GetMapView().Debug())}}HandleClientDelegate(_startZoomDelegateOption,e)};this.OnEndZoomHandler=function(e){if(_endZoomDelegateOption.RunDefaultHandler){if(_mapManager.Debug){console.log("KMMapManager.OnEndZoomHandler: %s",_mapInstance.GetMapView().Debug())}}HandleClientDelegate(_endZoomDelegateOption,e)};this.OnClickHandler=function(e){if(_clickDelegateOption.RunDefaultHandler){if(_mapManager.Debug){console.log("KMMapManager.OnClickHandler: %s => %s",e.eventName,e.elementID)}}HandleClientDelegate(_clickDelegateOption,e)};this.OnDoubleClickHandler=function(e){if(_doubleClickDelegateOption.RunDefaultHandler){var zoom=_mapInstance.GetZoomLevel();if(_mapManager.Debug){console.log("KMMapManager.OnDoubleClickHandler: %s => %s",e.eventName,e.elementID)}}HandleClientDelegate(_doubleClickDelegateOption,e)};this.OnMouseOverHandler=function(e){if(_mouseOverDelegateOption.RunDefaultHandler){if(_mapManager.Debug){console.log("KMMapManager.OnMouseOverHandler: %s => %s",e.eventName,e.elementID)}}HandleClientDelegate(_mouseOverDelegateOption,e)};this.OnMouseOutHandler=function(e){if(_mouseOutDelegateOption.RunDefaultHandler){if(_mapManager.Debug){console.log("KMMapManager.OnMouseOutHandler: %s => %s",e.eventName,e.elementID)}}HandleClientDelegate(_mouseOutDelegateOption,e)};this.OnObliqueEnterHandler=function(e){if(_obliqueEnterDelegateOption.RunDefaultHandler){if(_mapManager.Debug){console.log("KMMapManager.OnObliqueEnterHandler: %s",_mapInstance.GetMapView().Debug())
}}HandleClientDelegate(_obliqueEnterDelegateOption,e)};this.OnObliqueLeaveHandler=function(e){if(_obliqueLeaveDelegateOption.RunDefaultHandler){if(_mapManager.Debug){console.log("KMMapManager.OnObliqueLeaveHandler: %s",_mapInstance.GetMapView().Debug())}}HandleClientDelegate(_obliqueLeaveDelegateOption,e)};this.OnErrorHandler=function(e){if(_errorDelegateOption.RunDefaultHandler){if(_mapManager.Debug){console.log("KMMapManager.OnErrorHandler: %s",e.error)}}HandleClientDelegate(_errorDelegateOption,e)};HandleClientDelegate=function(delegateOption,e){if(jQuery.isArray(delegateOption.ClientDelegateName)){for(var i=0;i<delegateOption.ClientDelegateName.length;i++){var delegate=delegateOption.ClientDelegateName[i];if(!String.IsNullOrEmpty(delegate)){eval(delegate)(_mapManager,e)}}}else{if(!String.IsNullOrEmpty(delegateOption.ClientDelegateName)){eval(delegateOption.ClientDelegateName)(_mapManager,e)}}}}KMNavigationManager={};KMNavigationManager.GetCurrentViewURL=function(b){if(b==null){return null}var e=window.location.href.replace(window.location.search,"");var k=b.GetMapView();var h=k.TopLeftLatLong;var a=k.BottomRightLatLong;var d=b.GetCenter();var l=h.Latitude+":"+h.Longitude+":"+a.Latitude+":"+a.Longitude;var g=d.Latitude+":"+d.Longitude;var f=b.GetZoomLevel();jQuery.query.SET("mv",l);jQuery.query.SET("c",g);jQuery.query.SET("z",f);return e+jQuery.query.toString()};KMNavigationManager.GetMapViewFromQueryString=function(){var f=window.location.href;var a=jQuery.query.get("mv");var g=a.split(":");if(g==null||g.length!=4){return null}var b=null;try{var e=new VELatLong(g[0],g[1]);var c=new VELatLong(g[2],g[3]);b=new VELatLongRectangle(e,c);b.Centre=KMNavigationManager.GetMapCenterFromQueryString();b.Zoom=KMNavigationManager.GetMapZoomFromQueryString()}catch(d){console.log("KMNavigationManager.GetMapViewFromQueryString: %s",g.toString());return null}return b};KMNavigationManager.GetMapCenterFromQueryString=function(){var e=jQuery.query.get("c");var a=e.split(":");if(a==null||a.length!=2){return null}var d=null;try{d=new VELatLong(a[0],a[1])
}catch(b){console.log("KMNavigationManager.GetMapCenterFromQueryString: %s",a.toString());return null}return d};KMNavigationManager.GetMapZoomFromQueryString=function(){return jQuery.query.get("z")};function KMShapeLayerManager(b){var c=b;var a=new Hashtable();this.DefaultGroupName="{9E2CA069-A266-4ff4-AAD7-C9CEDA52B47B}";this.Debug=true;this.AddShapeLayer=function(h,f,g,e){if(this.GetShapeLayer(h)==null){var d=new VEShapeLayer();d.ReferenceID=h;d.Group=!String.IsNullOrEmpty(f)?f:this.DefaultGroupName;if(!String.IsNullOrEmpty(g)){d.SetTitle(g)}if(!String.IsNullOrEmpty(e)){d.SetDescription(e)}c.AddShapeLayer(d);a.put(h,d)}};this.GetShapeLayerCollection=function(){return a.values()};this.ShowShapeLayer=function(e){var d=this.GetShapeLayer(e);if(d!=null){d.Show()}};this.HideShapeLayer=function(e){var d=this.GetShapeLayer(e);if(d!=null){d.Hide()}};this.IsShapeLayerVisible=function(e){var d=this.GetShapeLayer(e);if(d!=null){return d.IsVisible()}return false};this.GetShapeCount=function(e){var d=this.GetShapeLayer(e);if(d!=null){return d.GetShapeCount()}return 0};this.GetShapeLayer=function(d){return a.get(d)};this.DeleteShapeLayer=function(e){var d=this.GetShapeLayer(e);if(d!=null){c.DeleteShapeLayer(d);a.remove(e)}};this.ClearShapeLayer=function(e){var d=this.GetShapeLayer(e);if(d!=null){d.DeleteAllShapes()}};this.GetShapeLayersByGroup=function(f){var e=[];for(var g in a.keys()){var d=a.get(g);if(d!=null&&d.Group==f){e.push(d)}}return e};this.DeleteShapeLayersByGroup=function(e){var d=this.GetShapeLayersByGroup(e);if(d!=null&&d.length>0){for(var f in d){this.DeleteShapeLayer(f)}}};this.ShowShapeLayersByGroup=function(e){var d=this.GetShapeLayersByGroup(e);if(d!=null&&d.length>0){for(var f in d){this.ShowShapeLayer(f)}}};this.HideShapeLayersByGroup=function(e){var d=this.GetShapeLayersByGroup(e);if(d!=null&&d.length>0){for(var f in d){this.HideShapeLayer(f)}}}}KMShapeLayerManager.CreateList=function(listParentDiv,veShapeList,listItemDataBoundDelegate){if(listParentDiv==null){return }jQuery("#"+listParentDiv).empty();if(veShapeList==null||veShapeList.length==0){return 
}if(String.IsNullOrEmpty(listItemDataBoundDelegate)){return }for(var i=0;i<veShapeList.length;i++){var veShape=veShapeList[i];var itemDiv=jQuery(document.createElement("div"));var id=veShape.ReferenceID;jQuery(itemDiv).attr("id",id);jQuery("#"+listParentDiv).append(itemDiv);eval(listItemDataBoundDelegate)(veShape,itemDiv)}};function KMShapeManager(b,e){var d=b;var a=e;var c=new Hashtable();this.DefaultShapeLayerID="{B3A792C8-21D8-4a9b-87FF-1C6D0B6C4D2D}";this.Debug=true;this.AddShapes=function(g,f){var l=a.GetShapeLayer(g);if(l!=null){var k=new Hashtable();if(jQuery.isArray(f)){for(var h=0;h<f.length;h++){if(!String.IsNullOrEmpty(f[h].ReferenceID)){k.put(f[h].ReferenceID,f[h])}}}else{if(!String.IsNullOrEmpty(f.ReferenceID)){k.put(f.ReferenceID,f)}}c.put(g,k);l.AddShape(f)}};this.DeleteShapes=function(f){var g=a.GetShapeLayer(f);if(g!=null){c.remove(f);g.DeleteAllShapes()}};this.DeleteShapesByGroup=function(g,m){var l=a.GetShapeLayer(g);var k=c.get(shapeLaterID);if(l!=null&&k!=null&&!String.IsNUllOrEmpty(m)){var f=this.GetShapesByGroup(g,m);for(var h=0;h<f.length;h++){k.remove(f[h].ReferenceID);l.DeleteShape(f[h])}}};this.GetShapeByElementID=function(f){var g=null;if(f!=null){g=d.GetShapeByID(f)}return g};this.GetShapeByReferenceID=function(h,k){var f=null;if(h!=null&&k!=null){var g=c.get(h);if(g!=null){f=g.get(k)}}return f};this.GetShapesByShapeLayerID=function(g){var f=c.get(g);if(f!=null){return f.values()}return null};this.GetShapesByGroup=function(l,m){var k=c.get(l);if(k!=null&&!String.IsNUllOrEmpty(m)){var f=[];var g=k.values();for(var h=0;h<g.length;h++){if(g[h].Group==m){f.push(g[h])}}return f}return null};this.IsPointInMapView=function(f){var g=d.GetMapView();var m=g.TopLeftLatLong;var o=g.BottomRightLatLong;var n=Math.min(m.Latitude,o.Latitude);var l=Math.max(m.Latitude,o.Latitude);var h=Math.min(m.Longitude,o.Longitude);var k=Math.max(m.Longitude,o.Longitude);if(f!=null){if(f.Latitude>=n&&f.Latitude<=l&&f.Longitude>=h&&f.Longitude<=k){return true}}return false};this.UpdateShapesInMapView=function(){var k=c.values();
for(var l=0;l<k.length;l++){var g=k[l].values();for(var h=0;h<g.length;h++){var f=g[h];var m=f.GetPoints();f.IsInMapView=this.IsPointInMapView(m[0])}}}}function onGeocodeClick(address1){setVal();address=address1;StartGeocoding(address)}function StartGeocoding(address){map.Find(null,address,null,null,null,null,null,null,null,null,GeocodeCallback)}function GeocodeCallback(shapeLayer,findResults,places,moreResults,errorMsg){var resHtml="";if(places==null){alert((errorMsg==null)?"There were no results":errorMsg);return }var place=places[0];var location=place.LatLong;var latitude=location.Latitude;var longitude=location.Longitude;lati=latitude;longi=longitude;var pin=new VEShape(VEShapeType.Pushpin,location);pin.SetCustomIcon("<div class='main-mh-pin main-mh-pin-3d'></div>");map.AddShape(pin)}function ShowTurnByTurn(route){setVal();var turns="";turns+="<h3>Distance:</strong> "+route.Distance.toFixed(1)+" km";if(g_ShowTravelTime){turns+="<br/><strong>Time:</strong> "+GetTime(route.Time)}turns+="</h3>";turns+='<div><span style="display:inline-block;padding-right: 3px;" class="casu-from-pin"></span><span style="font-weight: bold;">'+jQuery("#txtStart_"+global_direction_ctr).val()+"</span></div>";var legs=route.RouteLegs;var leg=null;var turnNum=0;turns+="<ol>";for(var i=0;i<legs.length;i++){leg=legs[i];var legNum=i+1;var turn=null;var legDistance=null;var itineraryLength=leg.Itinerary.Items.length;for(var j=0;j<leg.Itinerary.Items.length;j++){var routeTurnID=g_RouteTurnIDTemplate.replace("{0}",i).replace("{1}",j);turnNum++;turn=leg.Itinerary.Items[j];var turnShape=turn.Shape;var position=turn.LatLong;var shapeIconHtml="";var padding=(turnNum<10)?"&nbsp;":"";shapeIconHtml=g_TurnIconHtmlTemplate.replace("{0}",padding+turnNum+padding);var shape=new VEShape(VEShapeType.Pushpin,turn.LatLong);shape.SetCustomIcon(shapeIconHtml);shape.SetZIndex(2003,2000);shape.Hide();g_RouteShapeLayer.AddShape(shape);turns+="<li id='{0}' routeturntroup='1' shape_id='{1}'>".replace("{0}",routeTurnID).replace("{1}",shape.guid);turns+=turn.Text;legDistance=turn.Distance;
if(legDistance>0){turns+=" ("+legDistance.toFixed(1)+" km";if(g_ShowTravelTime){if(turn.Time!=null){turns+="; "+GetTime(turn.Time)}}turns+=")"}turns+="</li>"}}turns+="</ol>";turns+='<div><span style="display:inline-block;padding-right: 3px;" class="casu-to-pin"></span><span style="font-weight: bold;">'+jQuery("#txtEnd_"+global_direction_ctr).val()+"</span></div>";jQuery("[routeturntroup=1]").live("mouseover",RouteTurn_OnMouseOver);jQuery("[routeturntroup=1]").live("mouseout",RouteTurn_OnMouseOut);jQuery("[routeturntroup=1]").live("click",RouteTurn_OnClick);SetDirections(turns);$("#directionsBox_"+global_direction_ctr).show();showDirections(global_direction_ctr)}function GetDirections(){setVal();g_RouteShapeLayer.DeleteAllShapes();g_DragPointShapeLayer.DeleteAllShapes();g_DestinationShapeLayer.DeleteAllShapes();g_PointArray=[];g_NumberOfGotRoute=1;var locations=[];locations.push(jQuery("#txtStart_"+global_direction_ctr).val());dinfo=$("#direction_input_"+global_direction_ctr);if(dinfo){flds=$(dinfo).val().split("`");if(flds[1]=="true"){locations.push(new VELatLong(parseFloat(flds[3]),parseFloat(flds[4])))}else{locations.push(flds[2])}}var options=GetRouteOptions();map.GetDirections(locations,options)}function OnGotRoute(route){setVal();if(route.RouteLegs==null||route.RouteLegs.length==0){return }if(g_ShowTurnByTurn){ShowTurnByTurn(route)}if(g_PointArray.length==0){g_PointArray.push(route.RouteLegs[0].StartLocation);g_PointArray.push(route.RouteLegs[0].EndLocation)}if(g_NumberOfGotRoute==1){map.SetMapView(route.ShapePoints)}g_NumberOfGotRoute++;var shape=new VEShape(VEShapeType.Polyline,route.ShapePoints);shape.ReferenceID="Route";shape.SetLineColor(new VEColor(24,93,198,0.6));shape.SetLineWidth(5);shape.HideIcon();shape.SetTitle(g_RouteTitle);shape.SetZIndex(1000,2000);g_RouteShapeLayer.AddShape(shape);var startPoint=new VEShape(VEShapeType.Pushpin,route.RouteLegs[0].StartLocation);startPoint.ReferenceID="0";startPoint.SetCustomIcon('<div class="casu-from-pin"></div>');startPoint.SetZIndex(2001,2000);g_RouteShapeLayer.AddShape(startPoint);
var numLegs=route.RouteLegs.length;if(numLegs>1){for(i=1;i<=numLegs-1;i++){var wayPoint=new VEShape(VEShapeType.Pushpin,route.RouteLegs[i].StartLocation);wayPoint.ReferenceID=i;wayPoint.SetCustomIcon("<div class='casu-poi-via'></div>");wayPoint.SetZIndex(2001,2000);g_RouteShapeLayer.AddShape(wayPoint);var primitiveID=wayPoint.Primitives[0].iid;jQuery("#"+primitiveID).contextMenu({menu:"myRouteContextMenu"},function(action,el,pos){RouteContextMenuAction(action,el,pos)})}}var endPoint=new VEShape(VEShapeType.Pushpin,route.RouteLegs[numLegs-1].EndLocation);endPoint.ReferenceID=numLegs;endPoint.SetCustomIcon('<div class="casu-to-pin"></div>');endPoint.SetZIndex(2002,2000);g_RouteShapeLayer.AddShape(endPoint);map.AttachEvent("onmouseover",HandleMouseOverRoute)}function HandleMouseOverRoute(e){setValByMapElemId(e);if(e.elementID!=null){if(map.GetShapeByID(e.elementID).GetTitle().match(g_RouteTitle)){map.DetachEvent("onmouseover",HandleMouseOverRoute);var x=e.mapX;var y=e.mapY;var LL=map.PixelToLatLong(new VEPixel(x,y));g_DragPoint=new VEShape(VEShapeType.Pushpin,LL);g_DragPoint.SetCustomIcon("<div class='casu-poi-via'></div>");g_DragPoint.SetZIndex(1000,2000);g_DragPointShapeLayer.AddShape(g_DragPoint);map.AttachEvent("onmousemove",HandleMouseOverRouteMove)}}}function HandleMouseOverRouteMove(e){setValByMapElemId(e);if(e.elementID!=null){if(map.GetShapeByID(e.elementID).GetTitle().match(g_RouteTitle)){var x=e.mapX;var y=e.mapY;var LL=map.PixelToLatLong(new VEPixel(x,y));g_DragPoint.SetPoints(LL);map.AttachEvent("onmousedown",HandleMouseDown)}}else{map.DetachEvent("onmousedown",HandleMouseDown);map.DetachEvent("onmousemove",HandleMouseOverRouteMove);g_DragPointShapeLayer.DeleteAllShapes();map.AttachEvent("onmouseover",HandleMouseOverRoute)}}function HandleMouseDown(e){setValByMapElemId(e);if(e.elementID!=null&&e.leftMouseButton){map.DetachEvent("onmousemove",HandleMouseOverRouteMove);map.AttachEvent("onmousemove",HandleDragPointMove);map.AttachEvent("onmouseup",HandleMouseUp)}}function HandleDragPointMove(e){setValByMapElemId(e);
var x=e.mapX;var y=e.mapY;var LL=map.PixelToLatLong(new VEPixel(x,y));g_DragPoint.SetPoints(LL);return true}function HandleMouseUp(e){setValByMapElemId(e);map.DetachEvent("onmousemove",HandleDragPointMove);map.DetachEvent("onmouseup",HandleMouseUp);if(e.leftMouseButton){var x=e.mapX;var y=e.mapY;var LL=map.PixelToLatLong(new VEPixel(x,y));g_PointArray.splice(g_PointArray.length-1,0,LL);g_DragPoint=null;g_DragPointShapeLayer.DeleteAllShapes();Reroute()}}function Reroute(){setVal();g_RouteShapeLayer.DeleteAllShapes();var options=GetRouteOptions();map.GetDirections(g_PointArray,options)}function GetRouteOptions(){var options=new VERouteOptions();options.DrawRoute=false;options.DistanceUnit=VERouteDistanceUnit.Kilometer;options.SetBestMapView=false;options.RouteCallback=OnGotRoute;return options}function SetDirections(s){var d=document.getElementById("directions_"+global_direction_ctr);d.innerHTML=s}function GetTime(time){if(time==null){return("")}if(time>60){var seconds=time%60;var minutes=time-seconds;minutes=minutes/60;if(minutes>60){var minLeft=minutes%60;var hours=minutes-minLeft;hours=hours/60;return(hours+" hour(s), "+minLeft+" minute(s), "+seconds+" second(s)")}else{return(minutes+" minutes, "+seconds+" seconds")}}else{return(time+" seconds")}}function RouteTurn_OnMouseOver(e){setValByMapElemId(e);var id=e.srcElement.id;if(!String.IsNullOrEmpty(id)){jQuery("#"+id).removeClass().addClass("RouteTurnHoverStyle");var shape_id=jQuery("#"+id).attr("shape_id");var shape=g_RouteShapeLayer.GetShapeByID(shape_id);if(shape!=null){shape.Show()}}}function RouteTurn_OnMouseOut(e){setValByMapElemId(e);var id=e.srcElement.id;if(!String.IsNullOrEmpty(id)){jQuery("#"+id).removeClass().addClass("RouteTurnStyle");var shape_id=jQuery("#"+id).attr("shape_id");var shape=g_RouteShapeLayer.GetShapeByID(shape_id);if(shape!=null){shape.Hide()}}}function RouteTurn_OnClick(e){setValByMapElemId(e);var id=e.srcElement.id;if(!String.IsNullOrEmpty(id)){var shape_id=jQuery("#"+id).attr("shape_id");var shape=g_RouteShapeLayer.GetShapeByID(shape_id);
if(shape!=null){g_mapManager.MapInstance.SetCenter(shape.GetPoints()[0])}}}function MapContextMenuAction(action,el,pos){if(action=="add_destination"){if(g_PointArray!=null&&g_PointArray.length>0){setVal();var shapeIconHtml="<img src='/images/blue_dot.gif'>";var pixel=new VEPixel(pos.x+5,pos.y+5);var shape=new VEShape(VEShapeType.Pushpin,map.PixelToLatLong(pixel));shape.SetCustomIcon(shapeIconHtml);shape.SetZIndex(2004,2000);shape.Hide();var LL=map.PixelToLatLong(pixel);g_PointArray.splice(g_PointArray.length-1,0,LL);g_DragPoint=null;g_DragPointShapeLayer.DeleteAllShapes();Reroute()}}}function RouteContextMenuAction(action,el,pos){if(action=="delete_destination"){setVal();var primitiveID=jQuery(el).attr("id");var shape=map.GetShapeByID(primitiveID);if(shape!=null){if(g_PointArray!=null&&g_PointArray.length>0){if(shape.ReferenceID>0&&shape.ReferenceID<g_PointArray.length-1){g_PointArray.splice(shape.ReferenceID,1);g_RouteShapeLayer.DeleteShape(shape);g_DragPoint=null;g_DragPointShapeLayer.DeleteAllShapes();Reroute()}}}}}function callGetDirections(ctr){$("#directionsBox_"+global_direction_ctr).hide();global_direction_ctr=ctr;setVal();GetDirections()}function hideDirections(ctr){global_direction_ctr=ctr;$("#directions_"+global_direction_ctr).slideUp(300)}function showDirections(ctr){global_direction_ctr=ctr;$("#directions_"+global_direction_ctr).slideDown(300)}function setVal(){map=mapList[global_direction_ctr];g_RouteShapeLayer=routeShapeLayerList[global_direction_ctr];g_DragPointShapeLayer=dragPointShapeLayerList[global_direction_ctr];g_DestinationShapeLayer=destinationShapeLayerList[global_direction_ctr];g_RouteTitle=routeTitleList[global_direction_ctr]}function setValByMapElemId(e){var i;for(i=0;i<mapList.length;i++){var k=mapList[i].GetShapeByID(e.elementID);if(mapList[i].GetShapeByID(e.elementID)!=null){global_direction_ctr=i;setVal();break}}}var g_debugMode=false;var g_mapManager=null;var g_mapManager=new KMMapManager();var g_RouteShapeLayer=null;var routeShapeLayerList=new Array();var g_DragPointShapeLayer=null;
var dragPointShapeLayerList=new Array();var g_DestinationShapeLayer=null;var destinationShapeLayerList=new Array();var g_PointArray=null;var g_RouteTitle="My_Route";var routeTitleList=new Array();var g_DragPoint;var g_ShowTurnByTurn=true;var g_ShowTravelTime=false;var g_RouteTurnIDTemplate="Route_Turn_{0}_{1}";var g_TurnIconHtmlTemplate="<div style=\"background-image: url('/images/turnpointPushpin.png');\" class='drivingDirectionsTurnIcon drivingDirectionsTurnListIcon'><div class='drivingDirectionsTurnIconText'>{0}</div></div>";var g_NumberOfGotRoute=0;var map=null;var mapList=new Array();var mapOptions=null;var pin=null;var global_direction_ctr=0;function InitMaps(){$('div[id^="directionsBox"]').each(function(){$(this).hide()});$('div[id^="mapdiv"]').each(function(){id=$(this).attr("id");idx=id.substring(id.lastIndexOf("_")+1,id.length);if(id.indexOf("multi")>0){InitMapMultiPins(id,idx)}else{lati=$("#mer_address_"+idx+"_lati").attr("value");longi=$("#mer_address_"+idx+"_longi").attr("value");InitMap(id,idx,lati,longi)}})}function InitMap(mapDivId,indx,lati,longi){g_mapManager.Debug=false;g_mapManager.GetMap(mapDivId,lati,longi,13,null);mapList[indx]=g_mapManager.MapInstance;pin=new VEShape(VEShapeType.Pushpin,new VELatLong(lati,longi));pin.SetCustomIcon("<div class='main-mh-pin main-mh-pin-3d'></div>");mapList[indx].AddShape(pin);routeShapeLayerList[indx]=new VEShapeLayer();mapList[indx].AddShapeLayer(routeShapeLayerList[indx]);dragPointShapeLayerList[indx]=new VEShapeLayer();mapList[indx].AddShapeLayer(dragPointShapeLayerList[indx]);destinationShapeLayerList[indx]=new VEShapeLayer();mapList[indx].AddShapeLayer(destinationShapeLayerList[indx]);routeTitleList[indx]="My_Route_"+mapDivId;jQuery("#"+mapDivId).contextMenu({menu:mapDivId+"ContextMenu"},function(action,el,pos){MapContextMenuAction(action,el,pos)})}function casu_split(e){if(e&&e.length){return e.split("`")}return""}function InitMapMultiPins(mapDivId,indx){latlonArray=new Array();sumLat=0;sumLon=0;multipins_clear(indx);map=showAllPins(mapDivId);$("#"+mapDivId+"_form input").each(function(idx){flds=casu_split($(this).val());
pin=new VEShape(VEShapeType.Pushpin,new VELatLong(flds[2],flds[3]));map.AddShape(pin);pin.SetCustomIcon("<div class='main-mh-pin main-mh-pin-3d'><span>"+flds[0]+"</span></div>");pin.SetTitle(flds[1]);aId="map_"+indx+"_address_pin_"+(idx+1);if($("#"+aId).length){$("#"+aId).attr("pinId",pin.GetID());$("#"+aId).attr("mapIdx",indx)}dlg=$("<div/>");id="dialog_"+pin.GetID();$(dlg).attr("id",id);$(dlg).attr("value",flds[1]);$(dlg).attr("style","display:none");$(dlg).html('<h3 class="wss-widget-text-bold"><br>Address</h3><p>'+((flds[4])?flds[4]+"<br>":"")+((flds[5])?flds[5]+"<br>":"")+((flds[6])?flds[6]:"")+((flds[7])?" ("+flds[7]+") <br>":"")+((flds[8])?flds[8]:""));dinput=$("<input/>");$(dinput).attr("type","hidden");$(dinput).attr("value",indx+"`direction_input_"+indx+"`"+flds[9]+"`"+flds[10]+"`"+flds[2]+"`"+flds[3]);$(dlg).append(dinput);$("body").append(dlg);map.AttachEvent("onclick",function(e){if(e.elementID){shape=map.GetShapeByID(e.elementID);if(shape){openMapDialog(shape,e.elementID)}}})});routeShapeLayerList[indx]=new VEShapeLayer();map.AddShapeLayer(routeShapeLayerList[indx]);dragPointShapeLayerList[indx]=new VEShapeLayer();map.AddShapeLayer(dragPointShapeLayerList[indx]);destinationShapeLayerList[indx]=new VEShapeLayer();map.AddShapeLayer(destinationShapeLayerList[indx]);mapList[indx]=map;routeTitleList[indx]="My_Route_"+mapDivId;jQuery("#"+mapDivId).contextMenu({menu:mapDivId+"ContextMenu"},function(action,el,pos){MapContextMenuAction(action,el,pos)})}function multipins_clear(indx){$("#txtStart_"+indx).val("");$("#txtEnd_"+indx).val("")}function showAllPins(e){$("#"+e+"_form input").each(function(idx){flds=casu_split($(this).val());latlonArray[idx]=new VELatLong(flds[2],flds[3])});latlonCenter=new VELatLong(0,0);map=new VEMap(e);mapOptions=new VEMapOptions();mapOptions.DashboardColor="black";mapOptions.UseEnhancedRoadStyle=true;mapOptions.EnableBirdseye=false;map.LoadMap(latlonCenter,15,VEMapStyle.Road,false,VEMapMode.Mode2D,true,0,mapOptions);map.SetMapView(latlonArray);map.ClearInfoBoxStyles();return map}function moveToPin(e){mapIdx=$(e).attr("mapIdx");
pinId=$(e).attr("pinId");map=mapList[mapIdx];if(map){shape=map.GetShapeByID(pinId);if(shape){map.SetCenterAndZoom(shape.GetPoints()[0],15)}}populateDirectionBox("dialog_"+pinId)}function openMapDialog(shape,eId){t=$("#"+eId);if(shape&&t){x=$(t).offset().left-$(window).scrollLeft()+20;y=$(t).offset().top-$(window).scrollTop()+20;id="dialog_"+shape.GetID();$("#"+id).dialog({autoOpen:false,resizable:false,title:$("#"+id).attr("value"),width:220,position:[x,y]});populateDirectionBox(id);$("#"+id).dialog("open")}}function populateDirectionBox(dialogId){t=$("#"+dialogId+" input").get(0);ta=casu_split($(t).val());$("#txtEnd_"+ta[0]).val(ta[3]);if($("#direction_input_"+ta[0])){$("#direction_input_"+ta[0]).remove()}dinput=$("<input/>");$(dinput).attr("id","direction_input_"+ta[0]);$(dinput).attr("type","hidden");$(dinput).attr("value",ta[0]+"`"+ta[2]+"`"+ta[3]+"`"+ta[4]+"`"+ta[5]);$("#directionsAddress_"+ta[0]).append(dinput)}(function($,undefined){$.ui=$.ui||{};if($.ui.version){return }$.extend($.ui,{version:"1.8.10",keyCode:{ALT:18,BACKSPACE:8,CAPS_LOCK:20,COMMA:188,COMMAND:91,COMMAND_LEFT:91,COMMAND_RIGHT:93,CONTROL:17,DELETE:46,DOWN:40,END:35,ENTER:13,ESCAPE:27,HOME:36,INSERT:45,LEFT:37,MENU:93,NUMPAD_ADD:107,NUMPAD_DECIMAL:110,NUMPAD_DIVIDE:111,NUMPAD_ENTER:108,NUMPAD_MULTIPLY:106,NUMPAD_SUBTRACT:109,PAGE_DOWN:34,PAGE_UP:33,PERIOD:190,RIGHT:39,SHIFT:16,SPACE:32,TAB:9,UP:38,WINDOWS:91}});$.fn.extend({_focus:$.fn.focus,focus:function(delay,fn){return typeof delay==="number"?this.each(function(){var elem=this;setTimeout(function(){$(elem).focus();if(fn){fn.call(elem)}},delay)}):this._focus.apply(this,arguments)},scrollParent:function(){var scrollParent;if(($.browser.msie&&(/(static|relative)/).test(this.css("position")))||(/absolute/).test(this.css("position"))){scrollParent=this.parents().filter(function(){return(/(relative|absolute|fixed)/).test($.curCSS(this,"position",1))&&(/(auto|scroll)/).test($.curCSS(this,"overflow",1)+$.curCSS(this,"overflow-y",1)+$.curCSS(this,"overflow-x",1))}).eq(0)}else{scrollParent=this.parents().filter(function(){return(/(auto|scroll)/).test($.curCSS(this,"overflow",1)+$.curCSS(this,"overflow-y",1)+$.curCSS(this,"overflow-x",1))
}).eq(0)}return(/fixed/).test(this.css("position"))||!scrollParent.length?$(document):scrollParent},zIndex:function(zIndex){if(zIndex!==undefined){return this.css("zIndex",zIndex)}if(this.length){var elem=$(this[0]),position,value;while(elem.length&&elem[0]!==document){position=elem.css("position");if(position==="absolute"||position==="relative"||position==="fixed"){value=parseInt(elem.css("zIndex"),10);if(!isNaN(value)&&value!==0){return value}}elem=elem.parent()}}return 0},disableSelection:function(){return this.bind(($.support.selectstart?"selectstart":"mousedown")+".ui-disableSelection",function(event){event.preventDefault()})},enableSelection:function(){return this.unbind(".ui-disableSelection")}});$.each(["Width","Height"],function(i,name){var side=name==="Width"?["Left","Right"]:["Top","Bottom"],type=name.toLowerCase(),orig={innerWidth:$.fn.innerWidth,innerHeight:$.fn.innerHeight,outerWidth:$.fn.outerWidth,outerHeight:$.fn.outerHeight};function reduce(elem,size,border,margin){$.each(side,function(){size-=parseFloat($.curCSS(elem,"padding"+this,true))||0;if(border){size-=parseFloat($.curCSS(elem,"border"+this+"Width",true))||0}if(margin){size-=parseFloat($.curCSS(elem,"margin"+this,true))||0}});return size}$.fn["inner"+name]=function(size){if(size===undefined){return orig["inner"+name].call(this)}return this.each(function(){$(this).css(type,reduce(this,size)+"px")})};$.fn["outer"+name]=function(size,margin){if(typeof size!=="number"){return orig["outer"+name].call(this,size)}return this.each(function(){$(this).css(type,reduce(this,size,true,margin)+"px")})}});function visible(element){return !$(element).parents().andSelf().filter(function(){return $.curCSS(this,"visibility")==="hidden"||$.expr.filters.hidden(this)}).length}$.extend($.expr[":"],{data:function(elem,i,match){return !!$.data(elem,match[3])},focusable:function(element){var nodeName=element.nodeName.toLowerCase(),tabIndex=$.attr(element,"tabindex");if("area"===nodeName){var map=element.parentNode,mapName=map.name,img;if(!element.href||!mapName||map.nodeName.toLowerCase()!=="map"){return false
}img=$("img[usemap=#"+mapName+"]")[0];return !!img&&visible(img)}return(/input|select|textarea|button|object/.test(nodeName)?!element.disabled:"a"==nodeName?element.href||!isNaN(tabIndex):!isNaN(tabIndex))&&visible(element)},tabbable:function(element){var tabIndex=$.attr(element,"tabindex");return(isNaN(tabIndex)||tabIndex>=0)&&$(element).is(":focusable")}});$(function(){var body=document.body,div=body.appendChild(div=document.createElement("div"));$.extend(div.style,{minHeight:"100px",height:"auto",padding:0,borderWidth:0});$.support.minHeight=div.offsetHeight===100;$.support.selectstart="onselectstart" in div;body.removeChild(div).style.display="none"});$.extend($.ui,{plugin:{add:function(module,option,set){var proto=$.ui[module].prototype;for(var i in set){proto.plugins[i]=proto.plugins[i]||[];proto.plugins[i].push([option,set[i]])}},call:function(instance,name,args){var set=instance.plugins[name];if(!set||!instance.element[0].parentNode){return }for(var i=0;i<set.length;i++){if(instance.options[set[i][0]]){set[i][1].apply(instance.element,args)}}}},contains:function(a,b){return document.compareDocumentPosition?a.compareDocumentPosition(b)&16:a!==b&&a.contains(b)},hasScroll:function(el,a){if($(el).css("overflow")==="hidden"){return false}var scroll=(a&&a==="left")?"scrollLeft":"scrollTop",has=false;if(el[scroll]>0){return true}el[scroll]=1;has=(el[scroll]>0);el[scroll]=0;return has},isOverAxis:function(x,reference,size){return(x>reference)&&(x<(reference+size))},isOver:function(y,x,top,left,height,width){return $.ui.isOverAxis(y,top,height)&&$.ui.isOverAxis(x,left,width)}})})(jQuery);(function($,undefined){if($.cleanData){var _cleanData=$.cleanData;$.cleanData=function(elems){for(var i=0,elem;(elem=elems[i])!=null;i++){$(elem).triggerHandler("remove")}_cleanData(elems)}}else{var _remove=$.fn.remove;$.fn.remove=function(selector,keepData){return this.each(function(){if(!keepData){if(!selector||$.filter(selector,[this]).length){$("*",this).add([this]).each(function(){$(this).triggerHandler("remove")})}}return _remove.call($(this),selector,keepData)
})}}$.widget=function(name,base,prototype){var namespace=name.split(".")[0],fullName;name=name.split(".")[1];fullName=namespace+"-"+name;if(!prototype){prototype=base;base=$.Widget}$.expr[":"][fullName]=function(elem){return !!$.data(elem,name)};$[namespace]=$[namespace]||{};$[namespace][name]=function(options,element){if(arguments.length){this._createWidget(options,element)}};var basePrototype=new base();basePrototype.options=$.extend(true,{},basePrototype.options);$[namespace][name].prototype=$.extend(true,basePrototype,{namespace:namespace,widgetName:name,widgetEventPrefix:$[namespace][name].prototype.widgetEventPrefix||name,widgetBaseClass:fullName},prototype);$.widget.bridge(name,$[namespace][name])};$.widget.bridge=function(name,object){$.fn[name]=function(options){var isMethodCall=typeof options==="string",args=Array.prototype.slice.call(arguments,1),returnValue=this;options=!isMethodCall&&args.length?$.extend.apply(null,[true,options].concat(args)):options;if(isMethodCall&&options.charAt(0)==="_"){return returnValue}if(isMethodCall){this.each(function(){var instance=$.data(this,name),methodValue=instance&&$.isFunction(instance[options])?instance[options].apply(instance,args):instance;if(methodValue!==instance&&methodValue!==undefined){returnValue=methodValue;return false}})}else{this.each(function(){var instance=$.data(this,name);if(instance){instance.option(options||{})._init()}else{$.data(this,name,new object(options,this))}})}return returnValue}};$.Widget=function(options,element){if(arguments.length){this._createWidget(options,element)}};$.Widget.prototype={widgetName:"widget",widgetEventPrefix:"",options:{disabled:false},_createWidget:function(options,element){$.data(element,this.widgetName,this);this.element=$(element);this.options=$.extend(true,{},this.options,this._getCreateOptions(),options);var self=this;this.element.bind("remove."+this.widgetName,function(){self.destroy()});this._create();this._trigger("create");this._init()},_getCreateOptions:function(){return $.metadata&&$.metadata.get(this.element[0])[this.widgetName]
},_create:function(){},_init:function(){},destroy:function(){this.element.unbind("."+this.widgetName).removeData(this.widgetName);this.widget().unbind("."+this.widgetName).removeAttr("aria-disabled").removeClass(this.widgetBaseClass+"-disabled ui-state-disabled")},widget:function(){return this.element},option:function(key,value){var options=key;if(arguments.length===0){return $.extend({},this.options)}if(typeof key==="string"){if(value===undefined){return this.options[key]}options={};options[key]=value}this._setOptions(options);return this},_setOptions:function(options){var self=this;$.each(options,function(key,value){self._setOption(key,value)});return this},_setOption:function(key,value){this.options[key]=value;if(key==="disabled"){this.widget()[value?"addClass":"removeClass"](this.widgetBaseClass+"-disabled ui-state-disabled").attr("aria-disabled",value)}return this},enable:function(){return this._setOption("disabled",false)},disable:function(){return this._setOption("disabled",true)},_trigger:function(type,event,data){var callback=this.options[type];event=$.Event(event);event.type=(type===this.widgetEventPrefix?type:this.widgetEventPrefix+type).toLowerCase();data=data||{};if(event.originalEvent){for(var i=$.event.props.length,prop;i;){prop=$.event.props[--i];event[prop]=event.originalEvent[prop]}}this.element.trigger(event,data);return !($.isFunction(callback)&&callback.call(this.element[0],event,data)===false||event.isDefaultPrevented())}}})(jQuery);(function($,undefined){var uiDialogClasses="ui-dialog ui-widget ui-widget-content ui-corner-all ",sizeRelatedOptions={buttons:true,height:true,maxHeight:true,maxWidth:true,minHeight:true,minWidth:true,width:true},resizableRelatedOptions={maxHeight:true,maxWidth:true,minHeight:true,minWidth:true},attrFn=$.attrFn||{val:true,css:true,html:true,text:true,data:true,width:true,height:true,offset:true,click:true};$.widget("ui.dialog",{options:{autoOpen:true,buttons:{},closeOnEscape:true,closeText:"close",dialogClass:"",draggable:true,hide:null,height:"auto",maxHeight:false,maxWidth:false,minHeight:150,minWidth:150,modal:false,position:{my:"center",at:"center",collision:"fit",using:function(pos){var topOffset=$(this).css(pos).offset().top;
if(topOffset<0){$(this).css("top",pos.top-topOffset)}}},resizable:true,show:null,stack:true,title:"",width:300,zIndex:1000},_create:function(){this.originalTitle=this.element.attr("title");if(typeof this.originalTitle!=="string"){this.originalTitle=""}this.options.title=this.options.title||this.originalTitle;var self=this,options=self.options,title=options.title||"&#160;",titleId=$.ui.dialog.getTitleId(self.element),uiDialog=(self.uiDialog=$("<div></div>")).appendTo(document.body).hide().addClass(uiDialogClasses+options.dialogClass).css({zIndex:options.zIndex}).attr("tabIndex",-1).css("outline",0).keydown(function(event){if(options.closeOnEscape&&!event.isDefaultPrevented()&&event.keyCode&&event.keyCode===$.ui.keyCode.ESCAPE){self.close(event);event.preventDefault()}}).attr({role:"dialog","aria-labelledby":titleId}).mousedown(function(event){self.moveToTop(false,event)}),uiDialogContent=self.element.show().removeAttr("title").addClass("ui-dialog-content ui-widget-content").appendTo(uiDialog),uiDialogTitlebar=(self.uiDialogTitlebar=$("<div></div>")).addClass("ui-dialog-titlebar ui-widget-header ui-corner-all ui-helper-clearfix").prependTo(uiDialog),uiDialogTitlebarClose=$('<a href="#"></a>').addClass("ui-dialog-titlebar-close ui-corner-all").attr("role","button").hover(function(){uiDialogTitlebarClose.addClass("ui-state-hover")},function(){uiDialogTitlebarClose.removeClass("ui-state-hover")}).focus(function(){uiDialogTitlebarClose.addClass("ui-state-focus")}).blur(function(){uiDialogTitlebarClose.removeClass("ui-state-focus")}).click(function(event){self.close(event);return false}).appendTo(uiDialogTitlebar),uiDialogTitlebarCloseText=(self.uiDialogTitlebarCloseText=$("<span></span>")).addClass("ui-icon ui-icon-closethick").text(options.closeText).appendTo(uiDialogTitlebarClose),uiDialogTitle=$("<span></span>").addClass("ui-dialog-title").attr("id",titleId).html(title).prependTo(uiDialogTitlebar);if($.isFunction(options.beforeclose)&&!$.isFunction(options.beforeClose)){options.beforeClose=options.beforeclose}uiDialogTitlebar.find("*").add(uiDialogTitlebar).disableSelection();
if(options.draggable&&$.fn.draggable){self._makeDraggable()}if(options.resizable&&$.fn.resizable){self._makeResizable()}self._createButtons(options.buttons);self._isOpen=false;if($.fn.bgiframe){uiDialog.bgiframe()}},_init:function(){if(this.options.autoOpen){this.open()}},destroy:function(){var self=this;if(self.overlay){self.overlay.destroy()}self.uiDialog.hide();self.element.unbind(".dialog").removeData("dialog").removeClass("ui-dialog-content ui-widget-content").hide().appendTo("body");self.uiDialog.remove();if(self.originalTitle){self.element.attr("title",self.originalTitle)}return self},widget:function(){return this.uiDialog},close:function(event){var self=this,maxZ,thisZ;if(false===self._trigger("beforeClose",event)){return }if(self.overlay){self.overlay.destroy()}self.uiDialog.unbind("keypress.ui-dialog");self._isOpen=false;if(self.options.hide){self.uiDialog.hide(self.options.hide,function(){self._trigger("close",event)})}else{self.uiDialog.hide();self._trigger("close",event)}$.ui.dialog.overlay.resize();if(self.options.modal){maxZ=0;$(".ui-dialog").each(function(){if(this!==self.uiDialog[0]){thisZ=$(this).css("z-index");if(!isNaN(thisZ)){maxZ=Math.max(maxZ,thisZ)}}});$.ui.dialog.maxZ=maxZ}return self},isOpen:function(){return this._isOpen},moveToTop:function(force,event){var self=this,options=self.options,saveScroll;if((options.modal&&!force)||(!options.stack&&!options.modal)){return self._trigger("focus",event)}if(options.zIndex>$.ui.dialog.maxZ){$.ui.dialog.maxZ=options.zIndex}if(self.overlay){$.ui.dialog.maxZ+=1;self.overlay.$el.css("z-index",$.ui.dialog.overlay.maxZ=$.ui.dialog.maxZ)}saveScroll={scrollTop:self.element.scrollTop(),scrollLeft:self.element.scrollLeft()};$.ui.dialog.maxZ+=1;self.uiDialog.css("z-index",$.ui.dialog.maxZ);self.element.attr(saveScroll);self._trigger("focus",event);return self},open:function(){if(this._isOpen){return }var self=this,options=self.options,uiDialog=self.uiDialog;self.overlay=options.modal?new $.ui.dialog.overlay(self):null;self._size();self._position(options.position);
uiDialog.show(options.show);self.moveToTop(true);if(options.modal){uiDialog.bind("keydown.ui-dialog",function(event){if(event.keyCode!==$.ui.keyCode.TAB){return }var tabbables=$(":tabbable",this),first=tabbables.filter(":first"),last=tabbables.filter(":last");if(event.target===last[0]&&!event.shiftKey){first.focus(1);return false}else{if(event.target===first[0]&&event.shiftKey){last.focus(1);return false}}})}$(self.element.find(":tabbable").get().concat(uiDialog.find(".ui-dialog-buttonpane :tabbable").get().concat(uiDialog.get()))).eq(0).focus();self._isOpen=true;self._trigger("open");return self},_createButtons:function(buttons){var self=this,hasButtons=false,uiDialogButtonPane=$("<div></div>").addClass("ui-dialog-buttonpane ui-widget-content ui-helper-clearfix"),uiButtonSet=$("<div></div>").addClass("ui-dialog-buttonset").appendTo(uiDialogButtonPane);self.uiDialog.find(".ui-dialog-buttonpane").remove();if(typeof buttons==="object"&&buttons!==null){$.each(buttons,function(){return !(hasButtons=true)})}if(hasButtons){$.each(buttons,function(name,props){props=$.isFunction(props)?{click:props,text:name}:props;var button=$('<button type="button"></button>').click(function(){props.click.apply(self.element[0],arguments)}).appendTo(uiButtonSet);$.each(props,function(key,value){if(key==="click"){return }if(key in attrFn){button[key](value)}else{button.attr(key,value)}});if($.fn.button){button.button()}});uiDialogButtonPane.appendTo(self.uiDialog)}},_makeDraggable:function(){var self=this,options=self.options,doc=$(document),heightBeforeDrag;function filteredUi(ui){return{position:ui.position,offset:ui.offset}}self.uiDialog.draggable({cancel:".ui-dialog-content, .ui-dialog-titlebar-close",handle:".ui-dialog-titlebar",containment:"document",start:function(event,ui){heightBeforeDrag=options.height==="auto"?"auto":$(this).height();$(this).height($(this).height()).addClass("ui-dialog-dragging");self._trigger("dragStart",event,filteredUi(ui))},drag:function(event,ui){self._trigger("drag",event,filteredUi(ui))},stop:function(event,ui){options.position=[ui.position.left-doc.scrollLeft(),ui.position.top-doc.scrollTop()];
$(this).removeClass("ui-dialog-dragging").height(heightBeforeDrag);self._trigger("dragStop",event,filteredUi(ui));$.ui.dialog.overlay.resize()}})},_makeResizable:function(handles){handles=(handles===undefined?this.options.resizable:handles);var self=this,options=self.options,position=self.uiDialog.css("position"),resizeHandles=(typeof handles==="string"?handles:"n,e,s,w,se,sw,ne,nw");function filteredUi(ui){return{originalPosition:ui.originalPosition,originalSize:ui.originalSize,position:ui.position,size:ui.size}}self.uiDialog.resizable({cancel:".ui-dialog-content",containment:"document",alsoResize:self.element,maxWidth:options.maxWidth,maxHeight:options.maxHeight,minWidth:options.minWidth,minHeight:self._minHeight(),handles:resizeHandles,start:function(event,ui){$(this).addClass("ui-dialog-resizing");self._trigger("resizeStart",event,filteredUi(ui))},resize:function(event,ui){self._trigger("resize",event,filteredUi(ui))},stop:function(event,ui){$(this).removeClass("ui-dialog-resizing");options.height=$(this).height();options.width=$(this).width();self._trigger("resizeStop",event,filteredUi(ui));$.ui.dialog.overlay.resize()}}).css("position",position).find(".ui-resizable-se").addClass("ui-icon ui-icon-grip-diagonal-se")},_minHeight:function(){var options=this.options;if(options.height==="auto"){return options.minHeight}else{return Math.min(options.minHeight,options.height)}},_position:function(position){var myAt=[],offset=[0,0],isVisible;if(position){if(typeof position==="string"||(typeof position==="object"&&"0" in position)){myAt=position.split?position.split(" "):[position[0],position[1]];if(myAt.length===1){myAt[1]=myAt[0]}$.each(["left","top"],function(i,offsetPosition){if(+myAt[i]===myAt[i]){offset[i]=myAt[i];myAt[i]=offsetPosition}});position={my:myAt.join(" "),at:myAt.join(" "),offset:offset.join(" ")}}position=$.extend({},$.ui.dialog.prototype.options.position,position)}else{position=$.ui.dialog.prototype.options.position}isVisible=this.uiDialog.is(":visible");if(!isVisible){this.uiDialog.show()}this.uiDialog.css({top:0,left:0}).position($.extend({of:window},position));
if(!isVisible){this.uiDialog.hide()}},_setOptions:function(options){var self=this,resizableOptions={},resize=false;$.each(options,function(key,value){self._setOption(key,value);if(key in sizeRelatedOptions){resize=true}if(key in resizableRelatedOptions){resizableOptions[key]=value}});if(resize){this._size()}if(this.uiDialog.is(":data(resizable)")){this.uiDialog.resizable("option",resizableOptions)}},_setOption:function(key,value){var self=this,uiDialog=self.uiDialog;switch(key){case"beforeclose":key="beforeClose";break;case"buttons":self._createButtons(value);break;case"closeText":self.uiDialogTitlebarCloseText.text(""+value);break;case"dialogClass":uiDialog.removeClass(self.options.dialogClass).addClass(uiDialogClasses+value);break;case"disabled":if(value){uiDialog.addClass("ui-dialog-disabled")}else{uiDialog.removeClass("ui-dialog-disabled")}break;case"draggable":var isDraggable=uiDialog.is(":data(draggable)");if(isDraggable&&!value){uiDialog.draggable("destroy")}if(!isDraggable&&value){self._makeDraggable()}break;case"position":self._position(value);break;case"resizable":var isResizable=uiDialog.is(":data(resizable)");if(isResizable&&!value){uiDialog.resizable("destroy")}if(isResizable&&typeof value==="string"){uiDialog.resizable("option","handles",value)}if(!isResizable&&value!==false){self._makeResizable(value)}break;case"title":$(".ui-dialog-title",self.uiDialogTitlebar).html(""+(value||"&#160;"));break}$.Widget.prototype._setOption.apply(self,arguments)},_size:function(){var options=this.options,nonContentHeight,minContentHeight,isVisible=this.uiDialog.is(":visible");this.element.show().css({width:"auto",minHeight:0,height:0});if(options.minWidth>options.width){options.width=options.minWidth}nonContentHeight=this.uiDialog.css({height:"auto",width:options.width}).height();minContentHeight=Math.max(0,options.minHeight-nonContentHeight);if(options.height==="auto"){if($.support.minHeight){this.element.css({minHeight:minContentHeight,height:"auto"})}else{this.uiDialog.show();var autoHeight=this.element.css("height","auto").height();
if(!isVisible){this.uiDialog.hide()}this.element.height(Math.max(autoHeight,minContentHeight))}}else{this.element.height(Math.max(options.height-nonContentHeight,0))}if(this.uiDialog.is(":data(resizable)")){this.uiDialog.resizable("option","minHeight",this._minHeight())}}});$.extend($.ui.dialog,{version:"1.8.17",uuid:0,maxZ:0,getTitleId:function($el){var id=$el.attr("id");if(!id){this.uuid+=1;id=this.uuid}return"ui-dialog-title-"+id},overlay:function(dialog){this.$el=$.ui.dialog.overlay.create(dialog)}});$.extend($.ui.dialog.overlay,{instances:[],oldInstances:[],maxZ:0,events:$.map("focus,mousedown,mouseup,keydown,keypress,click".split(","),function(event){return event+".dialog-overlay"}).join(" "),create:function(dialog){if(this.instances.length===0){setTimeout(function(){if($.ui.dialog.overlay.instances.length){$(document).bind($.ui.dialog.overlay.events,function(event){if($(event.target).zIndex()<$.ui.dialog.overlay.maxZ){return false}})}},1);$(document).bind("keydown.dialog-overlay",function(event){if(dialog.options.closeOnEscape&&!event.isDefaultPrevented()&&event.keyCode&&event.keyCode===$.ui.keyCode.ESCAPE){dialog.close(event);event.preventDefault()}});$(window).bind("resize.dialog-overlay",$.ui.dialog.overlay.resize)}var $el=(this.oldInstances.pop()||$("<div></div>").addClass("ui-widget-overlay")).appendTo(document.body).css({width:this.width(),height:this.height()});if($.fn.bgiframe){$el.bgiframe()}this.instances.push($el);return $el},destroy:function($el){var indexOf=$.inArray($el,this.instances);if(indexOf!=-1){this.oldInstances.push(this.instances.splice(indexOf,1)[0])}if(this.instances.length===0){$([document,window]).unbind(".dialog-overlay")}$el.remove();var maxZ=0;$.each(this.instances,function(){maxZ=Math.max(maxZ,this.css("z-index"))});this.maxZ=maxZ},height:function(){var scrollHeight,offsetHeight;if($.browser.msie&&$.browser.version<7){scrollHeight=Math.max(document.documentElement.scrollHeight,document.body.scrollHeight);offsetHeight=Math.max(document.documentElement.offsetHeight,document.body.offsetHeight);
if(scrollHeight<offsetHeight){return $(window).height()+"px"}else{return scrollHeight+"px"}}else{return $(document).height()+"px"}},width:function(){var scrollWidth,offsetWidth;if($.browser.msie){scrollWidth=Math.max(document.documentElement.scrollWidth,document.body.scrollWidth);offsetWidth=Math.max(document.documentElement.offsetWidth,document.body.offsetWidth);if(scrollWidth<offsetWidth){return $(window).width()+"px"}else{return scrollWidth+"px"}}else{return $(document).width()+"px"}},resize:function(){var $overlays=$([]);$.each($.ui.dialog.overlay.instances,function(){$overlays=$overlays.add(this)});$overlays.css({width:0,height:0}).css({width:$.ui.dialog.overlay.width(),height:$.ui.dialog.overlay.height()})}});$.extend($.ui.dialog.overlay.prototype,{destroy:function(){$.ui.dialog.overlay.destroy(this.$el)}})}(jQuery));(function($,undefined){$.ui=$.ui||{};var horizontalPositions=/left|center|right/,verticalPositions=/top|center|bottom/,center="center",support={},_position=$.fn.position,_offset=$.fn.offset;$.fn.position=function(options){if(!options||!options.of){return _position.apply(this,arguments)}options=$.extend({},options);var target=$(options.of),targetElem=target[0],collision=(options.collision||"flip").split(" "),offset=options.offset?options.offset.split(" "):[0,0],targetWidth,targetHeight,basePosition;if(targetElem.nodeType===9){targetWidth=target.width();targetHeight=target.height();basePosition={top:0,left:0}}else{if(targetElem.setTimeout){targetWidth=target.width();targetHeight=target.height();basePosition={top:target.scrollTop(),left:target.scrollLeft()}}else{if(targetElem.preventDefault){options.at="left top";targetWidth=targetHeight=0;basePosition={top:options.of.pageY,left:options.of.pageX}}else{targetWidth=target.outerWidth();targetHeight=target.outerHeight();basePosition=target.offset()}}}$.each(["my","at"],function(){var pos=(options[this]||"").split(" ");if(pos.length===1){pos=horizontalPositions.test(pos[0])?pos.concat([center]):verticalPositions.test(pos[0])?[center].concat(pos):[center,center]
}pos[0]=horizontalPositions.test(pos[0])?pos[0]:center;pos[1]=verticalPositions.test(pos[1])?pos[1]:center;options[this]=pos});if(collision.length===1){collision[1]=collision[0]}offset[0]=parseInt(offset[0],10)||0;if(offset.length===1){offset[1]=offset[0]}offset[1]=parseInt(offset[1],10)||0;if(options.at[0]==="right"){basePosition.left+=targetWidth}else{if(options.at[0]===center){basePosition.left+=targetWidth/2}}if(options.at[1]==="bottom"){basePosition.top+=targetHeight}else{if(options.at[1]===center){basePosition.top+=targetHeight/2}}basePosition.left+=offset[0];basePosition.top+=offset[1];return this.each(function(){var elem=$(this),elemWidth=elem.outerWidth(),elemHeight=elem.outerHeight(),marginLeft=parseInt($.curCSS(this,"marginLeft",true))||0,marginTop=parseInt($.curCSS(this,"marginTop",true))||0,collisionWidth=elemWidth+marginLeft+(parseInt($.curCSS(this,"marginRight",true))||0),collisionHeight=elemHeight+marginTop+(parseInt($.curCSS(this,"marginBottom",true))||0),position=$.extend({},basePosition),collisionPosition;if(options.my[0]==="right"){position.left-=elemWidth}else{if(options.my[0]===center){position.left-=elemWidth/2}}if(options.my[1]==="bottom"){position.top-=elemHeight}else{if(options.my[1]===center){position.top-=elemHeight/2}}if(!support.fractions){position.left=Math.round(position.left);position.top=Math.round(position.top)}collisionPosition={left:position.left-marginLeft,top:position.top-marginTop};$.each(["left","top"],function(i,dir){if($.ui.position[collision[i]]){$.ui.position[collision[i]][dir](position,{targetWidth:targetWidth,targetHeight:targetHeight,elemWidth:elemWidth,elemHeight:elemHeight,collisionPosition:collisionPosition,collisionWidth:collisionWidth,collisionHeight:collisionHeight,offset:offset,my:options.my,at:options.at})}});if($.fn.bgiframe){elem.bgiframe()}elem.offset($.extend(position,{using:options.using}))})};$.ui.position={fit:{left:function(position,data){var win=$(window),over=data.collisionPosition.left+data.collisionWidth-win.width()-win.scrollLeft();position.left=over>0?position.left-over:Math.max(position.left-data.collisionPosition.left,position.left)
},top:function(position,data){var win=$(window),over=data.collisionPosition.top+data.collisionHeight-win.height()-win.scrollTop();position.top=over>0?position.top-over:Math.max(position.top-data.collisionPosition.top,position.top)}},flip:{left:function(position,data){if(data.at[0]===center){return }var win=$(window),over=data.collisionPosition.left+data.collisionWidth-win.width()-win.scrollLeft(),myOffset=data.my[0]==="left"?-data.elemWidth:data.my[0]==="right"?data.elemWidth:0,atOffset=data.at[0]==="left"?data.targetWidth:-data.targetWidth,offset=-2*data.offset[0];position.left+=data.collisionPosition.left<0?myOffset+atOffset+offset:over>0?myOffset+atOffset+offset:0},top:function(position,data){if(data.at[1]===center){return }var win=$(window),over=data.collisionPosition.top+data.collisionHeight-win.height()-win.scrollTop(),myOffset=data.my[1]==="top"?-data.elemHeight:data.my[1]==="bottom"?data.elemHeight:0,atOffset=data.at[1]==="top"?data.targetHeight:-data.targetHeight,offset=-2*data.offset[1];position.top+=data.collisionPosition.top<0?myOffset+atOffset+offset:over>0?myOffset+atOffset+offset:0}}};if(!$.offset.setOffset){$.offset.setOffset=function(elem,options){if(/static/.test($.curCSS(elem,"position"))){elem.style.position="relative"}var curElem=$(elem),curOffset=curElem.offset(),curTop=parseInt($.curCSS(elem,"top",true),10)||0,curLeft=parseInt($.curCSS(elem,"left",true),10)||0,props={top:(options.top-curOffset.top)+curTop,left:(options.left-curOffset.left)+curLeft};if("using" in options){options.using.call(elem,props)}else{curElem.css(props)}};$.fn.offset=function(options){var elem=this[0];if(!elem||!elem.ownerDocument){return null}if(options){return this.each(function(){$.offset.setOffset(this,options)})}return _offset.call(this)}}(function(){var body=document.getElementsByTagName("body")[0],div=document.createElement("div"),testElement,testElementParent,testElementStyle,offset,offsetTotal;testElement=document.createElement(body?"div":"body");testElementStyle={visibility:"hidden",width:0,height:0,border:0,margin:0,background:"none"};
if(body){jQuery.extend(testElementStyle,{position:"absolute",left:"-1000px",top:"-1000px"})}for(var i in testElementStyle){testElement.style[i]=testElementStyle[i]}testElement.appendChild(div);testElementParent=body||document.documentElement;testElementParent.insertBefore(testElement,testElementParent.firstChild);div.style.cssText="position: absolute; left: 10.7432222px; top: 10.432325px; height: 30px; width: 201px;";offset=$(div).offset(function(_,offset){return offset}).offset();testElement.innerHTML="";testElementParent.removeChild(testElement);offsetTotal=offset.top+offset.left+(body?2000:0);support.fractions=offsetTotal>21&&offsetTotal<22})()}(jQuery));(function($){$.fn.adGallery=function(options){var defaults={loader_image:"loader.gif",start_at_index:0,description_wrapper:false,thumb_opacity:0.7,animate_first_image:false,animation_speed:400,width:false,height:false,display_next_and_prev:true,display_back_and_forward:true,scroll_jump:0,slideshow:{enable:true,autostart:false,speed:5000,start_label:"Start",stop_label:"Stop",stop_on_scroll:true,countdown_prefix:"(",countdown_sufix:")",onStart:false,onStop:false},effect:"slide-hori",theme:"classic",enable_keyboard_move:true,cycle:true,callbacks:{init:false,afterImageVisible:false,beforeImageVisible:false}};var settings=$.extend(false,defaults,options);if(options&&options.slideshow){settings.slideshow=$.extend(false,defaults.slideshow,options.slideshow)}if(!settings.slideshow.enable){settings.slideshow.autostart=false}var galleries=[];$(this).each(function(){var gallery=new AdGallery(this,settings);galleries[galleries.length]=gallery});return galleries};function VerticalSlideAnimation(img_container,direction,desc){var current_top=parseInt(img_container.css("top"),10);if(direction=="left"){var old_image_top="-"+this.image_wrapper_height+"px";img_container.css("top",this.image_wrapper_height+"px")}else{var old_image_top=this.image_wrapper_height+"px";img_container.css("top","-"+this.image_wrapper_height+"px")}if(desc){desc.css("bottom","-"+desc[0].offsetHeight+"px");
desc.animate({bottom:0},this.settings.animation_speed*2)}if(this.current_description){this.current_description.animate({bottom:"-"+this.current_description[0].offsetHeight+"px"},this.settings.animation_speed*2)}return{old_image:{top:old_image_top},new_image:{top:current_top}}}function HorizontalSlideAnimation(img_container,direction,desc){var current_left=parseInt(img_container.css("left"),10);if(direction=="left"){var old_image_left="-"+this.image_wrapper_width+"px";img_container.css("left",this.image_wrapper_width+"px")}else{var old_image_left=this.image_wrapper_width+"px";img_container.css("left","-"+this.image_wrapper_width+"px")}if(desc){desc.css("bottom","-"+desc[0].offsetHeight+"px");desc.animate({bottom:0},this.settings.animation_speed*2)}if(this.current_description){this.current_description.animate({bottom:"-"+this.current_description[0].offsetHeight+"px"},this.settings.animation_speed*2)}return{old_image:{left:old_image_left},new_image:{left:current_left}}}function ResizeAnimation(img_container,direction,desc){var image_width=img_container.width();var image_height=img_container.height();var current_left=parseInt(img_container.css("left"),10);var current_top=parseInt(img_container.css("top"),10);img_container.css({width:0,height:0,top:this.image_wrapper_height/2,left:this.image_wrapper_width/2});return{old_image:{width:0,height:0,top:this.image_wrapper_height/2,left:this.image_wrapper_width/2},new_image:{width:image_width,height:image_height,top:current_top,left:current_left}}}function FadeAnimation(img_container,direction,desc){img_container.css("opacity",0);return{old_image:{opacity:0},new_image:{opacity:1}}}function NoneAnimation(img_container,direction,desc){img_container.css("opacity",0);return{old_image:{opacity:0},new_image:{opacity:1},speed:0}}function AdGallery(wrapper,settings){this.init(wrapper,settings)}AdGallery.prototype={wrapper:false,image_wrapper:false,gallery_info:false,nav:false,loader:false,preloads:false,thumbs_wrapper:false,scroll_back:false,scroll_forward:false,next_link:false,prev_link:false,slideshow:false,image_wrapper_width:0,image_wrapper_height:0,current_index:0,current_image:false,current_description:false,nav_display_width:0,settings:false,images:false,in_transition:false,animations:false,init:function(wrapper,settings){var context=this;
this.wrapper=$(wrapper);this.settings=settings;this.setupElements();this.setupAnimations();if(this.settings.width){this.image_wrapper_width=this.settings.width;this.image_wrapper.width(this.settings.width);this.wrapper.width(this.settings.width)}else{this.image_wrapper_width=this.image_wrapper.width()}if(this.settings.height){this.image_wrapper_height=this.settings.height;this.image_wrapper.height(this.settings.height)}else{this.image_wrapper_height=this.image_wrapper.height()}this.nav_display_width=this.nav.width();this.current_index=0;this.current_image=false;this.current_description=false;this.in_transition=false;this.findImages();if(this.settings.display_next_and_prev){this.initNextAndPrev()}var nextimage_callback=function(callback){return context.nextImage(callback)};this.slideshow=new AdGallerySlideshow(nextimage_callback,this.settings.slideshow);this.controls.append(this.slideshow.create());if(this.settings.slideshow.enable){this.slideshow.enable()}else{this.slideshow.disable()}if(this.settings.display_back_and_forward){this.initBackAndForward()}if(this.settings.enable_keyboard_move){this.initKeyEvents()}var start_at=parseInt(this.settings.start_at_index,10);if(window.location.hash&&window.location.hash.indexOf("#ad-image")===0){start_at=window.location.hash.replace(/[^0-9]+/g,"");if((start_at*1)!=start_at){start_at=this.settings.start_at_index}}this.loading(true);this.showImage(start_at,function(){if(context.settings.slideshow.autostart){context.preloadImage(start_at+1);context.slideshow.start()}});this.fireCallback(this.settings.callbacks.init)},setupAnimations:function(){this.animations={"slide-vert":VerticalSlideAnimation,"slide-hori":HorizontalSlideAnimation,resize:ResizeAnimation,fade:FadeAnimation,none:NoneAnimation}},setupElements:function(){this.controls=this.wrapper.find(".ad-controls");this.gallery_info=$('<p class="ad-info"></p>');this.controls.append(this.gallery_info);this.image_wrapper=this.wrapper.find(".ad-image-wrapper");this.image_wrapper.empty();this.nav=this.wrapper.find(".ad-nav");this.thumbs_wrapper=this.nav.find(".ad-thumbs");
this.preloads=$('<div class="ad-preloads"></div>');this.loader=$('<img class="ad-loader" src="'+this.settings.loader_image+'">');this.image_wrapper.append(this.loader);this.loader.hide();$(document.body).append(this.preloads)},loading:function(bool){if(bool){this.loader.show()}else{this.loader.hide()}},addAnimation:function(name,fn){if($.isFunction(fn)){this.animations[name]=fn}},findImages:function(){var context=this;this.images=[];var thumb_wrapper_width=0;var thumbs_loaded=0;var thumbs=this.thumbs_wrapper.find("a");var thumb_count=thumbs.length;if(this.settings.thumb_opacity<1){thumbs.find("img").css("opacity",this.settings.thumb_opacity)}thumbs.each(function(i){var link=$(this);var image_src=link.attr("href");var thumb=link.find("img");if(!context.isImageLoaded(thumb[0])){thumb.load(function(){thumb_wrapper_width+=this.parentNode.parentNode.offsetWidth;thumbs_loaded++})}else{thumb_wrapper_width+=thumb[0].parentNode.parentNode.offsetWidth;thumbs_loaded++}link.addClass("ad-thumb"+i);link.click(function(){context.showImage(i);context.slideshow.stop();return false}).hover(function(){if(!$(this).is(".ad-active")&&context.settings.thumb_opacity<1){$(this).find("img").fadeTo(300,1)}context.preloadImage(i)},function(){if(!$(this).is(".ad-active")&&context.settings.thumb_opacity<1){$(this).find("img").fadeTo(300,context.settings.thumb_opacity)}});var link=false;if(thumb.data("ad-link")){link=thumb.data("ad-link")}else{if(thumb.attr("longdesc")&&thumb.attr("longdesc").length){link=thumb.attr("longdesc")}}var desc=false;if(thumb.data("ad-desc")){desc=thumb.data("ad-desc")}else{if(thumb.attr("alt")&&thumb.attr("alt").length){desc=thumb.attr("alt")}}var title=false;if(thumb.data("ad-title")){title=thumb.data("ad-title")}else{if(thumb.attr("title")&&thumb.attr("title").length){title=thumb.attr("title")}}context.images[i]={thumb:thumb.attr("src"),image:image_src,error:false,preloaded:false,desc:desc,title:title,size:false,link:link}});var inter=setInterval(function(){if(thumb_count==thumbs_loaded){if(context.settings.theme=="classic"){thumb_wrapper_width-=50;
var list=context.nav.find(".ad-thumb-list");list.css("width",thumb_wrapper_width+"px");var i=1;var last_height=list.height();while(i<201){list.css("width",(thumb_wrapper_width+i)+"px");if(last_height>list.height()+5){break}last_height=list.height();i++}}else{var list=context.nav.find(".ad-thumb-list");var width=0;list.find("li").each(function(){width+=$(this).outerWidth()});list.css("width",width+"px")}clearInterval(inter)}},100)},initKeyEvents:function(){var context=this;$(document).keydown(function(e){if(e.keyCode==39){context.nextImage();context.slideshow.stop()}else{if(e.keyCode==37){context.prevImage();context.slideshow.stop()}}})},initNextAndPrev:function(){this.next_link=$('<div class="ad-next" onmousedown="uw_mlrUtagByStr(\'photos\');"><div class="ad-next-image"></div></div>');this.prev_link=$('<div class="ad-prev" onmousedown="uw_mlrUtagByStr(\'photos\');"><div class="ad-prev-image"></div></div>');this.image_wrapper.append(this.next_link);this.image_wrapper.append(this.prev_link);var context=this;this.prev_link.add(this.next_link).mouseover(function(e){$(this).css("height",context.image_wrapper_height);$(this).find("div").show()}).mouseout(function(e){$(this).find("div").hide()}).click(function(){if($(this).is(".ad-next")){context.nextImage();context.slideshow.stop()}else{context.prevImage();context.slideshow.stop()}}).find("div").css("opacity",0.7)},initBackAndForward:function(){var context=this;this.scroll_forward=$('<div class="ad-forward"></div>');this.scroll_back=$('<div class="ad-back"></div>');this.nav.append(this.scroll_forward);this.nav.prepend(this.scroll_back);var has_scrolled=0;var thumbs_scroll_interval=false;$(this.scroll_back).add(this.scroll_forward).click(function(){var width=context.nav_display_width-50;if(context.settings.scroll_jump>0){var width=context.settings.scroll_jump}if($(this).is(".ad-forward")){var left=context.thumbs_wrapper.scrollLeft()+width}else{var left=context.thumbs_wrapper.scrollLeft()-width}if(context.settings.slideshow.stop_on_scroll){context.slideshow.stop()}context.thumbs_wrapper.animate({scrollLeft:left+"px"});
return false}).css("opacity",0.6).hover(function(){var direction="left";if($(this).is(".ad-forward")){direction="right"}thumbs_scroll_interval=setInterval(function(){has_scrolled++;if(has_scrolled>30&&context.settings.slideshow.stop_on_scroll){context.slideshow.stop()}var left=context.thumbs_wrapper.scrollLeft()+1;if(direction=="left"){left=context.thumbs_wrapper.scrollLeft()-1}context.thumbs_wrapper.scrollLeft(left)},10);$(this).css("opacity",1)},function(){has_scrolled=0;clearInterval(thumbs_scroll_interval);$(this).css("opacity",0.6)})},_afterShow:function(){this.gallery_info.html((this.current_index+1)+" / "+this.images.length);if(!this.settings.cycle){this.prev_link.show().css("height",this.image_wrapper_height);this.next_link.show().css("height",this.image_wrapper_height);if(this.current_index==(this.images.length-1)){this.next_link.hide()}if(this.current_index==0){this.prev_link.hide()}}this.fireCallback(this.settings.callbacks.afterImageVisible)},_getContainedImageSize:function(image_width,image_height){if(image_height>this.image_wrapper_height){var ratio=image_width/image_height;image_height=this.image_wrapper_height;image_width=this.image_wrapper_height*ratio}if(image_width>this.image_wrapper_width){var ratio=image_height/image_width;image_width=this.image_wrapper_width;image_height=this.image_wrapper_width*ratio}return{width:image_width,height:image_height}},_centerImage:function(img_container,image_width,image_height){img_container.css("top","0px");if(image_height<this.image_wrapper_height){var dif=this.image_wrapper_height-image_height;img_container.css("top",(dif/2)+"px")}img_container.css("left","0px");if(image_width<this.image_wrapper_width){var dif=this.image_wrapper_width-image_width;img_container.css("left",(dif/2)+"px")}},_getDescription:function(image){var desc=false;if(image.desc.length||image.title.length){var title="";if(image.title.length){title='<strong class="ad-description-title">'+image.title+"</strong>"}var desc="";desc=$('<p class="ad-image-description">'+title+desc+"</p>")}return desc
},showImage:function(index,callback){if(this.images[index]&&!this.in_transition){var context=this;var image=this.images[index];this.in_transition=true;if(!image.preloaded){this.loading(true);this.preloadImage(index,function(){context.loading(false);context._showWhenLoaded(index,callback)})}else{this._showWhenLoaded(index,callback)}}},_showWhenLoaded:function(index,callback){if(this.images[index]){var context=this;var image=this.images[index];var img_container=$(document.createElement("div")).addClass("ad-image");var img=$(new Image()).attr("src",image.image);if(image.link){var link=$('<a href="'+image.link+'" target="_blank"></a>');link.append(img);img_container.append(link)}else{img_container.append(img)}this.image_wrapper.prepend(img_container);var size=this._getContainedImageSize(image.size.width,image.size.height);img.attr("width",size.width);img.attr("height",size.height);img_container.css({width:size.width+"px",height:size.height+"px"});this._centerImage(img_container,size.width,size.height);var desc=this._getDescription(image,img_container);if(desc){if(!this.settings.description_wrapper){img_container.append(desc);var width=size.width-parseInt(desc.css("padding-left"),10)-parseInt(desc.css("padding-right"),10);desc.css("width",width+"px")}else{this.settings.description_wrapper.append(desc)}}this.highLightThumb(this.nav.find(".ad-thumb"+index));var direction="right";if(this.current_index<index){direction="left"}this.fireCallback(this.settings.callbacks.beforeImageVisible);if(this.current_image||this.settings.animate_first_image){var animation_speed=this.settings.animation_speed;var easing="swing";var animation=this.animations[this.settings.effect].call(this,img_container,direction,desc);if(typeof animation.speed!="undefined"){animation_speed=animation.speed}if(typeof animation.easing!="undefined"){easing=animation.easing}if(this.current_image){var old_image=this.current_image;var old_description=this.current_description;old_image.animate(animation.old_image,animation_speed,easing,function(){old_image.remove();
if(old_description){old_description.remove()}})}img_container.animate(animation.new_image,animation_speed,easing,function(){context.current_index=index;context.current_image=img_container;context.current_description=desc;context.in_transition=false;context._afterShow();context.fireCallback(callback)})}else{this.current_index=index;this.current_image=img_container;context.current_description=desc;this.in_transition=false;context._afterShow();this.fireCallback(callback)}}},nextIndex:function(){if(this.current_index==(this.images.length-1)){if(!this.settings.cycle){return false}var next=0}else{var next=this.current_index+1}return next},nextImage:function(callback){var next=this.nextIndex();if(next===false){return false}this.preloadImage(next+1);this.showImage(next,callback);return true},prevIndex:function(){if(this.current_index==0){if(!this.settings.cycle){return false}var prev=this.images.length-1}else{var prev=this.current_index-1}return prev},prevImage:function(callback){var prev=this.prevIndex();if(prev===false){return false}this.preloadImage(prev-1);this.showImage(prev,callback);return true},preloadAll:function(){var context=this;var i=0;function preloadNext(){if(i<context.images.length){i++;context.preloadImage(i,preloadNext)}}context.preloadImage(i,preloadNext)},preloadImage:function(index,callback){if(this.images[index]){var image=this.images[index];if(!this.images[index].preloaded){var img=$(new Image());img.attr("src",image.image);if(!this.isImageLoaded(img[0])){this.preloads.append(img);var context=this;img.load(function(){image.preloaded=true;image.size={width:this.width,height:this.height};context.fireCallback(callback)}).error(function(){image.error=true;image.preloaded=false;image.size=false})}else{image.preloaded=true;image.size={width:img[0].width,height:img[0].height};this.fireCallback(callback)}}else{this.fireCallback(callback)}}},isImageLoaded:function(img){if(typeof img.complete!="undefined"&&!img.complete){return false}if(typeof img.naturalWidth!="undefined"&&img.naturalWidth==0){return false}return true
},highLightThumb:function(thumb){this.thumbs_wrapper.find(".ad-active").removeClass("ad-active");thumb.addClass("ad-active");if(this.settings.thumb_opacity<1){this.thumbs_wrapper.find("a:not(.ad-active) img").fadeTo(300,this.settings.thumb_opacity);thumb.find("img").fadeTo(300,1)}var left=thumb[0].parentNode.offsetLeft;left-=(this.nav_display_width/2)-(thumb[0].offsetWidth/2);this.thumbs_wrapper.animate({scrollLeft:left+"px"})},fireCallback:function(fn){if($.isFunction(fn)){fn.call(this)}}};function AdGallerySlideshow(nextimage_callback,settings){this.init(nextimage_callback,settings)}AdGallerySlideshow.prototype={start_link:false,stop_link:false,countdown:false,controls:false,settings:false,nextimage_callback:false,enabled:false,running:false,countdown_interval:false,init:function(nextimage_callback,settings){var context=this;this.nextimage_callback=nextimage_callback;this.settings=settings},create:function(){this.start_link=$('<span class="ad-slideshow-start">'+this.settings.start_label+"</span>");this.stop_link=$('<span class="ad-slideshow-stop">'+this.settings.stop_label+"</span>");this.countdown=$('<span class="ad-slideshow-countdown"></span>');this.controls=$('<div class="ad-slideshow-controls"></div>');this.controls.append(this.start_link).append(this.stop_link).append(this.countdown);this.countdown.hide();var context=this;this.start_link.click(function(){context.start()});this.stop_link.click(function(){context.stop()});$(document).keydown(function(e){if(e.keyCode==83){if(context.running){context.stop()}else{context.start()}}});return this.controls},disable:function(){this.enabled=false;this.stop();this.controls.hide()},enable:function(){this.enabled=true;this.controls.show()},toggle:function(){if(this.enabled){this.disable()}else{this.enable()}},start:function(){if(this.running||!this.enabled){return false}var context=this;this.running=true;this.controls.addClass("ad-slideshow-running");this._next();this.fireCallback(this.settings.onStart);return true},stop:function(){if(!this.running){return false}this.running=false;
this.countdown.hide();this.controls.removeClass("ad-slideshow-running");clearInterval(this.countdown_interval);this.fireCallback(this.settings.onStop);return true},_next:function(){var context=this;var pre=this.settings.countdown_prefix;var su=this.settings.countdown_sufix;clearInterval(context.countdown_interval);this.countdown.show().html(pre+(this.settings.speed/1000)+su);var slide_timer=0;this.countdown_interval=setInterval(function(){slide_timer+=1000;if(slide_timer>=context.settings.speed){var whenNextIsShown=function(){if(context.running){context._next()}slide_timer=0};if(!context.nextimage_callback(whenNextIsShown)){context.stop()}slide_timer=0}var sec=parseInt(context.countdown.text().replace(/[^0-9]/g,""),10);sec--;if(sec>0){context.countdown.html(pre+sec+su)}},1000)},fireCallback:function(fn){if($.isFunction(fn)){fn.call(this)}}}})(jQuery);function initGallery(id,transition,speed,autoPlay,theme,loaderImg){var options={loader_image:loaderImg,start_at_index:0,description_wrapper:false,thumb_opacity:0.7,animate_first_image:true,animation_speed:speed,width:false,height:false,display_next_and_prev:true,display_back_and_forward:false,scroll_jump:0,slideshow:{enable:autoPlay,autostart:autoPlay,speed:speed,start_label:"Start",stop_label:"Stop",stop_on_scroll:true,countdown_prefix:"(",countdown_sufix:")",onStart:false,onStop:false},effect:transition,theme:theme,enable_keyboard_move:true,cycle:true,callbacks:{init:false,afterImageVisible:false,beforeImageVisible:false}};$("#"+id).adGallery(options)};
