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;");xmltmp=xmltmp.concat('<field name="'+$(this).attr("name")+'" required="'+isRequired(this)+'" value="'+value+'" />')}});$("#"+e+" textarea").each(function(){var value=$(this).val().replace(/\"/g,"&quot;");xmltmp=xmltmp.concat('<field name="'+$(this).attr("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);if(msg==""){if($("html").attr("lang")=="fr"){msg=(err?"Le service n'est pas disponible pour l'instant.":"Le courriel été envoyé.")}else{msg=(err?"Service unavailable. Please try again later.":"Email sent.")}}feedbackEmailUs(msg,err)}function successSendToFriend(response){var err=isError(response);var msg=gatherText(response);if(msg==""){if($("html").attr("lang")=="fr"){msg=(err?"Le service n'est pas disponible pour l'instant.":"Le courriel été envoyé.")}else{msg=(err?"Service unavailable. Please try again later.":"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}}}})})};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("<img src='"+pushpinUrl+"'>");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+="<h4><img src='"+A_ico+"'>"+jQuery("#txtStart_"+global_direction_ctr).val()+"</h4>";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+="<h4><img src='"+B_ico+"'>"+jQuery("#txtEnd_"+global_direction_ctr).val()+"</h4>";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());if(jQuery("#useLatLongForDirections_"+global_direction_ctr).val()=="true"){var latitude=jQuery("#latitude_"+global_direction_ctr).val();var longitude=jQuery("#longitude_"+global_direction_ctr).val();
var latLong=new VELatLong(latitude,longitude);locations.push(latLong)}else{locations.push(jQuery("#txtEnd_"+global_direction_ctr).val())}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(A_ico);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("<img src='"+poi_via+"'>");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(B_ico);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("<img src='"+poi_via+"'>");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(index){$("#directionsBox_"+index).hide()});$('div[id^="mapDiv"]').each(function(index){lati=$("#mer_address_"+index+"_lati").attr("value");longi=$("#mer_address_"+index+"_longi").attr("value");InitMap($(this).attr("id"),index,lati,longi)})}function InitMap(mapDivId,indx,lati,longi){g_mapManager.Debug=false;g_mapManager.GetMap(mapDivId,lati,longi,15,null);mapList[indx]=g_mapManager.MapInstance;
pin=new VEShape(VEShapeType.Pushpin,new VELatLong(lati,longi));pin.SetCustomIcon("<img src='"+pushpinUrl+"'>");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)})};
