// (c) 2010 CodeGen International

var wts_list="";var tts_list="";var ttd_list="";var main_list="";var wts_count=1;var tts_count=1;var ttd_count=1;var path_attr_list=[];var viaCitiesArray=[];var viaCitiesMarkersArray=[];var clickCount=0;var isShowHideClicked=true;var startCityTid=0;var endCityTid=0;var start_point_as_a_string="";var end_point_as_a_string="";var status_viacity=true;var cityNamesNotLoaded=true;var suggestedRouteAttrSet=false;function drawPath(city1,city2){GDownloadUrl(cg_pathfinder_path+"ajax_genpathxml.php?city1="+city1+"&city2="+city2,function(data){var xml=GXml.parse(data);var lines=xml.documentElement.getElementsByTagName("line");for(var a=0;a<lines.length;a++){var colour=lines[a].getAttribute("colour");var width=parseFloat(lines[a].getAttribute("width"));var points=lines[a].getElementsByTagName("point");var pts=[];for(var i=0;i<points.length;i++){pts[i]=new GLatLng(parseFloat(points[i].getAttribute("lat")),parseFloat(points[i].getAttribute("lng")));}
map.addOverlay(new GPolyline(pts,colour,width));}});}
function check_path_attr_exists(node_nid){var exists=false;for(var idx in path_attr_list){if(idx==node_nid){exists=true;break;}}
return exists;}
function get_dir_entry_style(cur_entry_id){if(!empty(cur_entry_id)){if(parseInt(cur_entry_id,10)%2===0){return'tblDirEntry2';}else{return'tblDirEntry1';}}else{return'tblDirEntry1';}}
function show_hide_path_load_img(show_img){var obj_loading_div=document.getElementById('path_loading_image');if(!empty(obj_loading_div)){if(show_img===true){obj_loading_div.style.display='inline';obj_loading_div.style.zIndex=100;}else{obj_loading_div.style.display='none';obj_loading_div.style.zIndex=1;}}}
function get_turn_dir_img_key(turn_dir){var dir_string="";switch(turn_dir){case'Turn Right':dir_string='turn_right';break;case'Turn Left':dir_string='turn_left';break;case'Go Straight':dir_string='straight';break;default:dir_string='default';break;}
return dir_string;}
function create_path_attr_mkr(node_type,node_tid,node_name,node_image,node_content,node_nid,marker_icon,node_pt_lat,node_pt_lon,htl_facilities,htl_frm_price,distance_colombo,star_content,nearest_city,logger_row_id,body_images,phone,email,prod_sys_code,prod_city_code){var marker_point=new GLatLng(node_pt_lat,node_pt_lon);var marker_lable=new ELabel(marker_point,""+node_name,"style2");var marker=new GMarker(marker_point,{icon:marker_icon,title:node_name});var markerObj=marker;var info_window_tab3="<table width='400' border='0' cellspacing='0' cellpadding='0'>"+"<tr>"+"<td class='infoBg'>"+"<div class='infoLeft'></div>"+"<div class='hotName'>Gallery</div>"+"<div class='infoRight'></div>"+"</td>"+"</tr>"+"<tr>"+"<td class='infoCage'>"+"<table width='100%' border='0' cellspacing='0' cellpadding='5'>"+"<tr>"+"<td>"+
body_images+"</td>"+"</tr>"+"</table>"+"</td>"+"</tr>"+"</table>";switch(node_type){case"accommodation":var contact_str="";contact_str+="<table>";if(!empty(phone)){contact_str+="<tr><td><img src='"+cg_pathfinder_path+"/icons/phone.png' width=20 height=18 /></td><td>"+phone+"</td>";}
if(!empty(email)){contact_str+="<tr><td><img src='"+cg_pathfinder_path+"/icons/email.png' width=20 height=18 /></td><td><a href='mailto:"+email+"' />"+email+"</td>";}
contact_str+="</table>";GEvent.addListener(marker,'click',function(){node_tid=4;var temp=node_name;var info_window_tab1="<table width='400' border='0' cellspacing='0' cellpadding='0'>"+"<tr>"+"<td class='infoBg'>"+"<div class='infoLeft'></div>"+"<div class='hotName'>"+trim_name(node_name)+"</div>"+
star_content+"<div class='infoRight'></div>"+"<div class='price'>"+htl_frm_price+"</div>"+"</td>"+"</tr>"+"<tr>"+"<td class='infoCage'>"+"<table width='100%' border='0' cellspacing='0' cellpadding='5' >"+"<tr>"+"<td width='120' valign='top'>"+"<div class='itinImg'><img src='"+node_image+"' width='116' height='100'></div></td>"+"<td valign='top' class='desc'>"+node_content+generateMoreLinkValue(node_nid)+
contact_str+"</tr>"+"<!--tr>"+"<td align='right' valign='top' class='details'></td>"+"<td valign='top' class='details'>"+distance_colombo+"</td>"+"</tr-->"+
nearest_city+"</table>"+"</td>"+"</tr>"+"</table>"+showBookNowHTML(prod_sys_code,trim_name(node_name),prod_city_code);var info_window_tab2="";if(empty(htl_facilities)){info_window_tab2="Facilities not specified.";}
info_window_tab2="<table width='400' border='0' cellspacing='0' cellpadding='0'>"+"<tr>"+"<td class='infoBg'>"+"<div class='infoLeft'></div>"+"<div class='hotName'>Facilities</div>"+"<div class='infoRight'></div>"+"</td>"+"</tr>"+"<tr>"+"<td class='infoCage'>"+"<table width='100%' border='0' cellspacing='0' cellpadding='5' >"+"<tr>"+"<td width='120' valign='top'>"+"</td>"+"<td valign='top' class='desc'>"+htl_facilities+" </td>"+"</tr>"+"<tr>"+"<td align='right' valign='top' class='details'></td>"+"<td valign='top'></td>"+"</tr>"+"</table>"+"</td>"+"</tr>"+"</table>"+"<table width='400' border='0' cellspacing='0' cellpadding='0'>"+"<tr>"+"<td height='40' align='right'>"+" </td></tr></table>";marker.openInfoWindowTabsHtml([new GInfoWindowTab("Info",info_window_tab1),new GInfoWindowTab("Facilities",info_window_tab2),new GInfoWindowTab("Gallary",info_window_tab3)]);});GEvent.addListener(marker,"mouseover",function(){marker.setImage(markerHighlightIconArray[node_tid]);marker.zIndexProcess=100;if(!empty(document.getElementById('ptattr_wts_lst'))){if(document.getElementById('ptattr_wts_lst').style.display=='table-row'){if(!empty(document.getElementById(logger_row_id))&&(document.getElementById(logger_row_id).className=="trblock")){document.getElementById(logger_row_id).className="trhighlight";}}}
if(!empty(document.getElementById('itinearary_'+node_nid))){document.getElementById('itinearary_'+node_nid).className="sourcelihl";}});GEvent.addListener(marker,"infowindowopen",function(){var mkrPoint=this.getLatLng();var center=map.getCenter();var winW;var winH;if(navigator.appName=="Netscape"){winW=window.innerWidth-16;winH=window.innerHeight-16;}
if(navigator.appName.indexOf("Microsoft")!=-1){winW=document.body.offsetWidth-20;winH=document.body.offsetHeight-20;}
if((winW<=2000)&&(winH<=768))
{var bound=map.getBounds();if(bound.containsLatLng(mkrPoint)){var sw=bound.getSouthWest();var nea=bound.getNorthEast();var boundCenter=bound.getCenter();var boundCenter_lng=boundCenter.lng();var boundCenter_lat=boundCenter.lat();var sw_lng=sw.lng();if(mkrPoint.lat()>boundCenter_lat){map.panTo(new GLatLng(nea.lat(),mkrPoint.lng()));}
else{map.panTo(new GLatLng(boundCenter_lat,mkrPoint.lng()));}}
else{map.setCenter(mkrPoint);bound=map.getBounds();var neb=bound.getNorthEast();var ne_lng=neb.lng();map.panTo(new GLatLng(neb.lat(),mkrPoint.lng()));}}
else
{map.panTo(new GLatLng(mkrPoint.lat(),mkrPoint.lng()));}});GEvent.addListener(marker,"mouseout",function(){marker.setImage(markerIconArray[node_tid]);if(!empty(document.getElementById(logger_row_id))){if(document.getElementById(logger_row_id).className=="trblockhide"){document.getElementById(logger_row_id).className="trblockhide";}
else{document.getElementById(logger_row_id).className="trblock";}}
if(!empty(document.getElementById('itinearary_'+node_nid))){document.getElementById('itinearary_'+node_nid).className="sourceli";}});break;case"things_to_do":GEvent.addListener(marker,'click',function(){node_tid=3;var info_window_tab1="<table width='400' border='0' cellspacing='0' cellpadding='0'>"+"<tr>"+"<td class='infoBg'>"+"<div class='infoLeft'></div>"+"<div class='hotName'>"+trim_name(node_name)+"</div>"+"<div class='infoRight'></div>"+"</td>"+"</tr>"+"<tr>"+"<td class='infoCage'>"+"<table width='100%' border='0' cellspacing='0' cellpadding='5' >"+"<tr>"+"<td width='120' valign='top'>"+"<div class='itinImg'><img src='"+node_image+"' width='116' height='100'></div></td>"+"<td valign='top' class='desc'>"+node_content+generateMoreLinkValue(node_nid)+"</td>"+"</tr>"+"<tr>"+"<td align='right' valign='top' class='details'></td>"+"<td valign='top'></td>"+"</tr>"+nearest_city+"</table>"+"</td>"+"</tr>"+"</table>"+showBookNowHTML(prod_sys_code,trim_name(node_name),prod_city_code);this.openInfoWindowTabsHtml([new GInfoWindowTab("Info",info_window_tab1),new GInfoWindowTab("Gallary",info_window_tab3)]);});GEvent.addListener(marker,"mouseover",function(){marker.setImage(markerHighlightIconArray[node_tid]);marker.zIndexProcess=100;if(!empty(document.getElementById('ptattr_ttd_lst'))){if(document.getElementById('ptattr_ttd_lst').style.display=='table-row'){if(document.getElementById(logger_row_id).className=="trblock"){document.getElementById(logger_row_id).className="trhighlight";}}}
if(!empty(document.getElementById('itinearary_'+node_nid))){document.getElementById('itinearary_'+node_nid).className="sourcelihl";}});GEvent.addListener(marker,"infowindowopen",function(){var mkrPoint=this.getLatLng();var center=map.getCenter();var winW;var winH;if(navigator.appName=="Netscape"){winW=window.innerWidth-16;winH=window.innerHeight-16;}
if(navigator.appName.indexOf("Microsoft")!=-1){winW=document.body.offsetWidth-20;winH=document.body.offsetHeight-20;}
if((winW<=2000)&&(winH<=768))
{var bound=map.getBounds();var ne;var sw;if(bound.containsLatLng(mkrPoint)){sw=bound.getSouthWest();ne=bound.getNorthEast();var boundCenter=bound.getCenter();var boundCenter_lng=boundCenter.lng();var boundCenter_lat=boundCenter.lat();var sw_lng=sw.lng();if(mkrPoint.lat()>boundCenter_lat){map.panTo(new GLatLng(ne.lat(),mkrPoint.lng()));}
else{map.panTo(new GLatLng(boundCenter_lat,mkrPoint.lng()));}}
else{map.setCenter(mkrPoint);bound=map.getBounds();ne=bound.getNorthEast();var ne_lng=ne.lng();map.panTo(new GLatLng(ne.lat(),mkrPoint.lng()));}}
else
{map.panTo(new GLatLng(mkrPoint.lat(),mkrPoint.lng()));}});GEvent.addListener(marker,"mouseout",function(){marker.setImage(markerIconArray[node_tid]);if(!empty(document.getElementById(logger_row_id))){if(document.getElementById(logger_row_id).className=="trblockhide"){document.getElementById(logger_row_id).className="trblockhide";}
else{document.getElementById(logger_row_id).className="trblock";}}
if(!empty(document.getElementById('itinearary_'+node_nid))){document.getElementById('itinearary_'+node_nid).className="sourceli";}});break;case"things_to_see":GEvent.addListener(marker,'click',function(){node_tid=2;var info_window_tab1="<table width='400' border='0' cellspacing='0' cellpadding='0'>"+"<tr>"+"<td class='infoBg'>"+"<div class='infoLeft'></div>"+"<div class='hotName'>"+trim_name(node_name)+"</div>"+"<div class='infoRight'></div>"+"</td>"+"</tr>"+"<tr>"+"<td class='infoCage'>"+"<table width='100%' border='0' cellspacing='0' cellpadding='5' >"+"<tr>"+"<td width='120' valign='top'>"+"<div class='itinImg'><img src='"+node_image+"' width='116' height='100'></div></td>"+"<td valign='top' class='desc'>"+node_content+generateMoreLinkValue(node_nid)+"</td>"+"</tr>"+"<tr>"+"<td align='right' valign='top' class='details'></td>"+"<td valign='top'></td>"+"</tr>"+nearest_city+"</table>"+"</td>"+"</tr>"+"</table>"+showBookNowHTML(prod_sys_code,trim_name(node_name),prod_city_code);this.openInfoWindowTabsHtml([new GInfoWindowTab("Info",info_window_tab1),new GInfoWindowTab("Gallary",info_window_tab3)]);});GEvent.addListener(marker,"mouseover",function(){marker.setImage(markerHighlightIconArray[node_tid]);marker.zIndexProcess=100;if(!empty(document.getElementById('ptattr_tts_lst'))){if(document.getElementById('ptattr_tts_lst').style.display=='table-row'){if(document.getElementById(logger_row_id).className=="trblock"){document.getElementById(logger_row_id).className="trhighlight";}}}
if(!empty(document.getElementById('itinearary_'+node_nid))){document.getElementById('itinearary_'+node_nid).className="sourcelihl";}});GEvent.addListener(marker,"infowindowopen",function(){var mkrPoint=this.getLatLng();var center=map.getCenter();var winW;var winH;if(navigator.appName=="Netscape"){winW=window.innerWidth-16;winH=window.innerHeight-16;}
if(navigator.appName.indexOf("Microsoft")!=-1){winW=document.body.offsetWidth-20;winH=document.body.offsetHeight-20;}
if((winW<=2000)&&(winH<=768))
{var bound=map.getBounds();var ne;var sw;if(bound.containsLatLng(mkrPoint)){sw=bound.getSouthWest();ne=bound.getNorthEast();var boundCenter=bound.getCenter();var boundCenter_lng=boundCenter.lng();var boundCenter_lat=boundCenter.lat();var sw_lng=sw.lng();if(mkrPoint.lat()>boundCenter_lat){map.panTo(new GLatLng(ne.lat(),mkrPoint.lng()));}
else{map.panTo(new GLatLng(boundCenter_lat,mkrPoint.lng()));}}
else{map.setCenter(mkrPoint);bound=map.getBounds();ne=bound.getNorthEast();var ne_lng=ne.lng();map.panTo(new GLatLng(ne.lat(),mkrPoint.lng()));}}
else
{map.panTo(new GLatLng(mkrPoint.lat(),mkrPoint.lng()));}});GEvent.addListener(marker,"mouseout",function(){marker.setImage(markerIconArray[node_tid]);if(!empty(document.getElementById(logger_row_id))){if(document.getElementById(logger_row_id).className=="trblockhide"){document.getElementById(logger_row_id).className="trblockhide";}
else{document.getElementById(logger_row_id).className="trblock";}}
if(!empty(document.getElementById('itinearary_'+node_nid))){document.getElementById('itinearary_'+node_nid).className="sourceli";}});break;}
return marker;}
function show_path_attractions(attr_list){if(!empty(attr_list)){var node_nid;var node_tid;var node_name;var node_image;var node_type;var htl_url;var htl_str_rate;var htl_frm_price;var htl_facilities;var distance_colombo;var body_images;var phone;var email;var nearest_city;var nearest_city_link;var star_content;var star_content2;var attr_type_main;var attr_type_arr;var attr_type;var prod_sys_code;var prod_city_code;for(var i=0;i<attr_list.length;i++){node_nid="";node_tid=0;node_name="";node_image="";node_type="";htl_url="";htl_str_rate="";htl_frm_price="";htl_facilities="";distance_colombo="";body_images="";phone="";email="";nearest_city="";nearest_city_link="";star_content="";star_content2="";attr_type="";prod_sys_code="";prod_city_code="";node_nid=attr_list[i].getAttribute("nid");node_name=attr_list[i].getAttribute("name");node_image=attr_list[i].getAttribute("image");node_type=attr_list[i].getAttribute("type");node_content=attr_list[i].getAttribute("tcontent");nearest_city_tid=attr_list[i].getAttribute("nearest_city");node_pt_lat=parseFloat(attr_list[i].getAttribute("lat"));node_pt_lon=parseFloat(attr_list[i].getAttribute("lng"));if(!empty(node_name)){if(check_path_attr_exists(node_nid)){continue;}
if(nearest_city_tid!==0&&!empty(nearest_city_tid)){nearest_city_link="<a href='javascript:drawAttractions("+nearest_city_tid+")' >Show the nearest city</a>";nearest_city="<tr>"+"<td align='right' valign='top' class='details'></td>"+"<td valign='top'><div align='right' style='padding-bottom:10px; padding-right:5px;font-weight:bold;'>"+
nearest_city_link+"</div></td>"+"</tr>";}
attr_type_main=attr_list[i].getElementsByTagName("attr_terms");if(!empty(attr_type_main)){for(var a=0;a<attr_type_main.length;a++){attr_type_arr=attr_type_main[a].getElementsByTagName("term");}
if(!empty(attr_type_arr)){for(var l=0;l<attr_type_arr.length;l++){if(attr_type.length>0){attr_type+=' ,';attr_type+=attr_type_arr[l].getAttribute("term_name");}else{attr_type=attr_type_arr[l].getAttribute("term_name");}}}}
body_images=attr_list[i].getAttribute("body_images");var body_images_div="";if(!empty(body_images)){var body_imagesArr=body_images.split(",");for(var j=0;j<body_imagesArr.length;j++){if(j<4){if(!empty(body_imagesArr[j])){var item_str="[";for(var k=0;k<body_imagesArr.length;k++){var image_info_arr=body_imagesArr[k].split("|");if(k<4){if(k>0){item_str+=",";}
item_str+="[\""+image_info_arr[0]+"\",\""+image_info_arr[1]+" "+"\",\"350 350\"]";}}
item_str+="],"+j;var final_image_info=body_imagesArr[j].split("|");body_images_div+="<div class='galThumb' align='center' ><a href='javascript:;' onclick='Mediabox.open("+item_str+")' ><img src='"+final_image_info[0]+"' width='100' height='59' title='"+final_image_info[1]+"'/></a></div>";}}
else{break;}}}
else{body_images_div="No Images available...";}
switch(node_type){case"accommodation":node_tid=4;htl_url=attr_list[i].getAttribute("node_url");htl_str_rate=attr_list[i].getAttribute("star_rating");htl_frm_price=attr_list[i].getAttribute("from_price");htl_facilities=attr_list[i].getAttribute("accom_facilities");distance_colombo=attr_list[i].getAttribute("distance");phone=attr_list[i].getAttribute("phone");email=attr_list[i].getAttribute("email");prod_sys_code=attr_list[i].getAttribute("prod_sys_code");prod_city_code=attr_list[i].getAttribute("prod_city_code");for(var m=0;m<parseInt(htl_str_rate,10);m++){star_content=star_content+"<div class='star'><img src='"+cg_pathfinder_path+"/images/star.png' width='16' height='15' /></div>";star_content2=star_content2+"<img src='"+cg_pathfinder_path+"/images/star.png' width='8' height='8' alt='"+htl_str_rate+"' title='"+htl_frm_price+"' />";}
if(empty(htl_url)){htl_url="";}
if(empty(htl_str_rate)){htl_str_rate="";}
if(empty(htl_frm_price)){htl_frm_price="";}
if(empty(htl_facilities)){htl_facilities="Facilities not specified.";}
if(empty(distance_colombo)){distance_colombo="";}
var row_id='pthattr_wts_'+wts_count;var marker_icon=hotel_icon;marker_icon.infoWindowAnchor=new GPoint(9,1);var marker=create_path_attr_mkr(node_type,node_tid,node_name,node_image,node_content,node_nid,marker_icon,node_pt_lat,node_pt_lon,htl_facilities,htl_frm_price,distance_colombo,star_content,nearest_city,row_id,body_images_div,phone,email,prod_sys_code,prod_city_code);wts_list+='<tr id="'+row_id+'" title="'+attr_type+'" class="trblock"  onMouseOver="path_attr_list['+node_nid+'].setImage(\''+markerHighlightIconArray[node_tid]+'\');this.className=\'trhighlight\';" '+'onMouseOut="path_attr_list['+node_nid+'].setImage(\''+markerIconArray[node_tid]+'\');if(this.className != \'trblockhide\' ){ this.className = \'trblock\';}"'+'onClick="javascript:GEvent.trigger(path_attr_list['+node_nid+'], \'click\')" ><td>'+
wts_count+'.&nbsp;</td><td class="tdDashboard">'+node_name+'</td><td>'+star_content2+'</td></tr>';wts_count++;break;case"things_to_do":node_tid=3;row_id='pthattr_ttd_'+ttd_count;marker_icon=do_icon;marker_icon.infoWindowAnchor=new GPoint(9,1);marker=create_path_attr_mkr(node_type,node_tid,node_name,node_image,node_content,node_nid,marker_icon,node_pt_lat,node_pt_lon,htl_facilities,htl_frm_price,distance_colombo,star_content,nearest_city,row_id,body_images_div,"","","",prod_sys_code,prod_city_code);ttd_list+='<tr id="'+row_id+'" title="'+attr_type+'" class="trblock"  onMouseOver="path_attr_list['+node_nid+'].setImage(\''+markerHighlightIconArray[node_tid]+'\');this.className=\'trhighlight\';" '+'onMouseOut="path_attr_list['+node_nid+'].setImage(\''+markerIconArray[node_tid]+'\');if(this.className != \'trblockhide\' ){ this.className = \'trblock\';}"'+'onClick="javascript:GEvent.trigger(path_attr_list['+node_nid+'], \'click\')" ><td>'+
ttd_count+'.&nbsp;</td><td class="tdDashboard">'+node_name+'</td></tr>';ttd_count++;break;case"things_to_see":node_tid=2;marker_icon=see_icon;row_id='pthattr_tts_'+tts_count;marker_icon.infoWindowAnchor=new GPoint(9,1);marker=create_path_attr_mkr(node_type,node_tid,node_name,node_image,node_content,node_nid,marker_icon,node_pt_lat,node_pt_lon,htl_facilities,htl_frm_price,distance_colombo,star_content,nearest_city,row_id,body_images_div,"","","",prod_sys_code,prod_city_code);tts_list+='<tr id="'+row_id+'" title="'+attr_type+'" class="trblock"  onMouseOver="path_attr_list['+node_nid+'].setImage(\''+markerHighlightIconArray[node_tid]+'\');this.className=\'trhighlight\';" '+'onMouseOut="path_attr_list['+node_nid+'].setImage(\''+markerIconArray[node_tid]+'\');if(this.className != \'trblockhide\' ){ this.className = \'trblock\';}"'+'onClick="javascript:GEvent.trigger(path_attr_list['+node_nid+'], \'click\')" ><td>'+
tts_count+'.&nbsp;</td><td class="tdDashboard">'+node_name+'</td></tr>';tts_count++;break;}
path_attr_list[node_nid]=marker;minimapMarkerAdding(marker);itineraryMarkerUpdate(node_nid,0,marker);map.addOverlay(marker);}}}}
function remove_path(){if(!empty(startAndEndMarkersHidden)&&!empty(cityMarkerList)){for(var p in startAndEndMarkersHidden){if(document.getElementById(startAndEndMarkersHidden[p])){if(!empty(cityMarkerList[startAndEndMarkersHidden[p]])){var objPoly=cityMarkerList[startAndEndMarkersHidden[p]];var cityIconUrl=cg_pathfinder_path+'/icons/city_marker.png';objPoly[0].centerMarker.setImage(cityIconUrl);}}}}
clearSuggestedRouteMarkers();if(!empty(path_poly_arr)){for(var i=0;i<path_poly_arr.length;i++){map.removeOverlay(path_poly_arr[i]);}}
if(!empty(dir_entry_marker_list)){for(var k in dir_entry_marker_list){if(!empty(dir_entry_marker_list[k])){map.removeOverlay(dir_entry_marker_list[k]);}}}
var show_attr=false;var obj_chk_show_attr=document.getElementById('chk_dir_path_attr');if(!empty(obj_chk_show_attr)){if(obj_chk_show_attr.checked===true){show_attr=true;}}
if(!empty(path_attr_list)){for(var j in path_attr_list){if(!empty(path_attr_list[j])){minimapMarkerRemoving(path_attr_list[j]);map.removeOverlay(path_attr_list[j]);}}
if(logger_directions_id>0){previousItem();logger_array.splice(logger_directions_id,2);title_logger.splice(logger_directions_id,2);title_index=title_logger.length-1;current_index=logger_array.length-1;logger_directions_id=-1;if(suggestedRouteAttrSet){suggestedRouteAttrSet=false;}}}else if(show_attr){if(logger_directions_id>0){previousItem();logger_array.splice(logger_directions_id,2);title_logger.splice(logger_directions_id,2);title_index=title_logger.length-1;current_index=logger_array.length-1;logger_directions_id=-1;if(suggestedRouteAttrSet){suggestedRouteAttrSet=false;}}}else{if(logger_directions_id>0&&suggestedRouteAttrSet){previousItem();logger_array.splice(logger_directions_id,2);title_logger.splice(logger_directions_id,2);title_index=title_logger.length-1;current_index=logger_array.length-1;logger_directions_id=-1;suggestedRouteAttrSet=false;}else if(logger_directions_id>0){previousItem();logger_array.splice(logger_directions_id,2);title_logger.splice(logger_directions_id,2);title_index=title_logger.length-1;current_index=logger_array.length-1;logger_directions_id=-1;suggestedRouteAttrSet=false;}else if(logger_directions_id>0){previousItem();logger_array.splice(logger_directions_id,1);title_logger.splice(logger_directions_id,1);title_index=title_logger.length-1;current_index=logger_array.length-1;logger_directions_id=-1;}}
document.getElementById('mainTabContainer').innerHTML=logger_array[logger_array.length-1].content;document.getElementById('dash_title').innerHTML=title_logger[logger_array.length-1];}
function show_directions(xml_doc,end_location){if(!empty(xml_doc)){var dir_main=xml_doc.documentElement.getElementsByTagName("directions");if(!empty(dir_main)){dir_main=dir_main[0];var dir_entries=dir_main.getElementsByTagName("dir_entry");var tot_length_km=dir_main.getAttribute('distance_km');var tot_time_hrs=dir_main.getAttribute('time_hrs');var tot_entries=parseInt(dir_main.getAttribute('total_entries'),10);var dir_start_pt=dir_main.getAttribute('start_point');var dir_end_pt=dir_main.getAttribute('end_point');if(!empty(dir_entries)){var dir_html='';var dir_summary_html='<table align="center" border="1" style="padding:1px;" class="tborderDirectionsSummary">';var cur_entry='';var cur_entry_id=0;var cur_entry_icon='';var cur_direction='';var cur_distance=0;var cur_time=0;var cur_turn='';var cur_road_name='';var cur_start_city;var cur_end_city;var cur_start_point;var cur_end_point;var dir_start_city=dir_entries[0].getElementsByTagName('start_city');dir_start_city=dir_start_city[0].getAttribute("city_name");var dir_end_city=dir_entries[dir_entries.length-1].getElementsByTagName('end_city');dir_end_city=dir_end_city[0].getAttribute("city_name");var dir_start_road=dir_entries[0].getElementsByTagName('road_name');var dir_end_road=dir_entries[dir_entries.length-1].getElementsByTagName('road_name');var travelDistanceTotal=0;var travelledSoFar=0;var travelTimeTotal=0;var viaCitiesIsSelected=false;var cityNames="";if(dir_main.getAttribute('via_cities')){viaCitiesIsSelected=true;cityNames=dir_main.getAttribute('via_cities').split(",");}
var textToBePrinted="";if(viaCitiesIsSelected){textToBePrinted=" Via ";var seperator="";for(var p=0;p<cityNames.length;p++){var j=p;if(j+1!=cityNames.length){seperator="-";}else{seperator="";}
textToBePrinted=textToBePrinted+cityNames[p]+seperator;}}
var dir_start_entry="";var dir_end_entry="";if(!empty(dir_start_city)&&!empty(end_location)){dir_start_entry=dir_start_city;dir_end_entry=end_location;}
else if(!empty(dir_start_city)&&!empty(dir_end_city)){dir_start_entry=dir_start_city;dir_end_entry=dir_end_city;}else if(!empty(dir_start_road)&&!empty(dir_end_road)){dir_start_entry=dir_start_road+' Road ';dir_end_entry=dir_end_road+' Road ';}
else{dir_start_entry=dir_start_pt;dir_end_entry=dir_end_pt;}
dir_html='<table align="center" border="1" style="padding:0;" class="tborderDirections" width="200px" cellpadding="1px" cellspacing="1px">';dir_html+='<tr><td colspan="4" class="tblrowDirHeading">Directions from '+
dir_start_entry+'<br> to '+dir_end_entry+textToBePrinted+'</td></tr>';dir_html+='<tr><td colspan="4" class="tblrowDirSubHeading">Total Distance : '+
tot_length_km+'km <br>(Aprox. time : '+tot_time_hrs+' Hours)</td></tr>';var cur_entry_style_no=1;var cur_link_id=1;var cur_link_str='';var cur_entry_style=get_dir_entry_style(cur_link_id);for(var i=0;i<dir_entries.length;i++){cur_entry_id=parseInt(dir_entries[i].getAttribute('entry_id'),10);cur_direction=dir_entries[i].getAttribute('heading_dir');cur_distance=dir_entries[i].getAttribute('length_km');cur_time=dir_entries[i].getAttribute('time_hrs');cur_turn=dir_entries[i].getAttribute('turn_dir');cur_road_name=dir_entries[i].getAttribute('road_name');cur_start_city=dir_entries[i].getElementsByTagName('start_city');cur_start_city=cur_start_city[0];cur_end_city=dir_entries[i].getElementsByTagName('end_city');cur_end_city=cur_end_city[0];cur_start_point=dir_entries[i].getElementsByTagName('start_point');cur_start_point=cur_start_point[0];cur_end_point=dir_entries[i].getElementsByTagName('end_point');cur_end_point=cur_end_point[0];next_entry_road='';cur_entry_icon='';if(!empty(cur_entry_id)){cur_entry_string='';cur_entry_style=get_dir_entry_style(cur_link_id);if(cur_entry_id==1){cur_link_str='javascript:show_direction_entry('+cur_start_point.getAttribute('lat')+','+cur_start_point.getAttribute('lon')+','+cur_link_id+')';cur_entry_icon=dir_icons.start;cur_entry_string='<tr class="'+cur_entry_style+'">';cur_entry_string+='<td class="'+cur_entry_style+'" width="5px"><a href=\''+cur_link_str+'\'>'+cur_link_id+'</a></td>';cur_entry_string+='<td class="'+cur_entry_style+'" width="20px"><img width="20" height="20" src="'+cur_entry_icon+'"/></td>';cur_entry_string+='<td class="'+cur_entry_style+'" width="120px">Head '+cur_direction+' on '+cur_road_name+'road.</td>';cur_entry_string+='<td class="'+cur_entry_style+'" width="50px">';if(!empty(cur_start_city)){cur_entry_string+='Nearest City:'+cur_start_city.getAttribute("city_name")+'<br/>Distance : 0km';travelDistanceTotal=travelDistanceTotal+parseInt(cur_distance,10);}else{cur_entry_string+='Distance: 0km';travelDistanceTotal=travelDistanceTotal+parseInt(cur_distance,10);}
cur_entry_string+='</td>';cur_entry_string+='</tr>';cur_link_id++;if(tot_entries==1){cur_entry_icon=dir_icons.end;cur_entry_style=get_dir_entry_style(cur_link_id);cur_link_str='javascript:show_direction_entry('+cur_end_point.getAttribute('lat')+','+cur_end_point.getAttribute('lon')+','+cur_link_id+')';cur_entry_string+='<tr class="'+cur_entry_style+'">';cur_entry_string+='<td class="'+cur_entry_style+'" width="5px"><a href=\''+cur_link_str+'\'>'+cur_link_id+'</a></td>';cur_entry_string+='<td class="'+cur_entry_style+'" width="20px"><img width="20" height="20" src="'+cur_entry_icon+'"/></td>';cur_entry_string+='<td class="'+cur_entry_style+'" width="120px">Head '+cur_direction+' on '+cur_road_name+' road and arive at Destination!</td>';cur_entry_string+='<td class="'+cur_entry_style+'" width="50px">';if(!empty(cur_end_city)){cur_entry_string+='Nearest City:'+cur_end_city.getAttribute("city_name")+'<br/>Travel Distance : '+cur_distance+'km';travelDistanceTotal=travelDistanceTotal+parseInt(cur_distance,10);}else{cur_entry_string+='Travel Distance: '+cur_distance+'km';travelDistanceTotal=travelDistanceTotal+parseInt(cur_distance,10);}
cur_entry_string+='</td>';cur_entry_string+='</tr>';cur_link_id++;}else{next_entry_road=dir_entries[i+1].getAttribute('road_name');if(empty(next_entry_road)){next_entry_road='next';}
cur_entry_icon=dir_icons[get_turn_dir_img_key(cur_turn)];cur_entry_style=get_dir_entry_style(cur_link_id);cur_link_str='javascript:show_direction_entry('+cur_end_point.getAttribute('lat')+','+cur_end_point.getAttribute('lon')+','+cur_link_id+')';cur_entry_string+='<tr class="'+cur_entry_style+'">';cur_entry_string+='<td class="'+cur_entry_style+'" width="5px"><a href=\''+cur_link_str+'\'>'+cur_link_id+'</a></td>';cur_entry_string+='<td class="'+cur_entry_style+'" width="20px"><img width="20" height="20" src="'+cur_entry_icon+'"/></td>';cur_entry_string+='<td class="'+cur_entry_style+'" width="120px">'+cur_turn+' to '+next_entry_road+' road.</td>';cur_entry_string+='<td class="'+cur_entry_style+'" width="50px">';if(!empty(cur_end_city)){cur_entry_string+='Nearest City:'+cur_end_city.getAttribute("city_name")+'<br/>Travel Distance : '+cur_distance+'km';travelDistanceTotal=travelDistanceTotal+parseInt(cur_distance,10);}else{cur_entry_string+='Travel Distance: '+cur_distance+'km';travelDistanceTotal=travelDistanceTotal+parseInt(cur_distance,10);}
cur_entry_string+='</td>';cur_entry_string+='</tr>';cur_link_id++;}}else if(cur_entry_id==tot_entries){cur_entry_icon=dir_icons.end;cur_entry_style=get_dir_entry_style(cur_link_id);cur_link_str='javascript:show_direction_entry('+cur_end_point.getAttribute('lat')+','+cur_end_point.getAttribute('lon')+','+cur_link_id+')';cur_entry_string+='<tr class="'+cur_entry_style+'">';cur_entry_string+='<td class="'+cur_entry_style+'" width="5px"><a href=\''+cur_link_str+'\'>'+cur_link_id+'</a></td>';cur_entry_string+='<td class="'+cur_entry_style+'" width="20px"><img width="20" height="20" src="'+cur_entry_icon+'"/></td>';cur_entry_string+='<td class="'+cur_entry_style+'" width="120px">Destination!</td>';cur_entry_string+='<td class="'+cur_entry_style+'" width="50px">';if(!empty(cur_end_city)){cur_entry_string+='Nearest City:'+cur_end_city.getAttribute("city_name")+'<br/>Travel Distance : '+cur_distance+'km';travelDistanceTotal=travelDistanceTotal+parseInt(cur_distance,10);}else{cur_entry_string+='Distance: '+cur_distance+'km';travelDistanceTotal=travelDistanceTotal+parseInt(cur_distance,10);}
cur_entry_string+='</td>';cur_entry_string+='</tr>';cur_link_id++;}else{cur_entry_icon=dir_icons["default"];cur_entry_style=get_dir_entry_style(cur_link_id);cur_link_str='javascript:show_direction_entry('+cur_start_point.getAttribute('lat')+','+cur_start_point.getAttribute('lon')+','+cur_link_id+')';cur_entry_string+='<tr class="'+cur_entry_style+'">';cur_entry_string+='<td class="'+cur_entry_style+'" width="5px"><a href=\''+cur_link_str+'\'>'+cur_link_id+'</a></td>';cur_entry_string+='<td class="'+cur_entry_style+'" width="20px"><img width="20" height="20" src="'+cur_entry_icon+'"/></td>';cur_entry_string+='<td class="'+cur_entry_style+'" width="120px">Head '+cur_direction+' on '+cur_road_name+' road.</td>';cur_entry_string+='<td class="'+cur_entry_style+'" width="50px">';if(!empty(cur_start_city)){cur_entry_string+='Nearest City:'+cur_start_city.getAttribute("city_name")+'<br/>Travel Distance : 0km';travelDistanceTotal=travelDistanceTotal+parseInt(cur_distance,10);}else{cur_entry_string+='Travel Distance: 0km';travelDistanceTotal=travelDistanceTotal+parseInt(cur_distance,10);}
cur_entry_string+='</td>';cur_entry_string+='</tr>';cur_link_id++;var arrivedText="";var via_ico=dir_icons.end;var viaCitiesSelected=false;var viacityNames="";if(dir_main.getAttribute('via_cities')){viaCitiesSelected=true;viacityNames=dir_main.getAttribute('via_cities').split(",");}
if(viaCitiesSelected){for(var x=0;x<viacityNames.length;x++){if(cur_turn==viacityNames[x]){arrivedText+='<tr class="tblrowDirSubHeading">';arrivedText+='<td class="tblrowDirSubHeading" width="5px">&nbsp;</td>';arrivedText+='<td class="tblrowDirSubHeading" width="20px"><img width="20" height="20" align="left" src='+via_ico+'></td>';arrivedText+='<td class="tblrowDirSubHeading" colspan="2" width="120px">Arrived at '+cur_turn+'. <br />Total Distance Travelled: '+travelDistanceTotal+' kms. <br />Total Approximate Time: '+parseFloat(travelDistanceTotal/50.0)+' hrs</td>';arrivedText+='</td>';arrivedText+='</tr>';cur_entry_string+=arrivedText;}}}
next_entry_road=dir_entries[i+1].getAttribute('road_name');if(empty(next_entry_road)){next_entry_road='next';}
cur_entry_icon=dir_icons[get_turn_dir_img_key(cur_turn)];cur_entry_style=get_dir_entry_style(cur_link_id);cur_link_str='javascript:show_direction_entry('+cur_end_point.getAttribute('lat')+','+cur_end_point.getAttribute('lon')+','+cur_link_id+');';cur_entry_string+='<tr class="'+cur_entry_style+'">';cur_entry_string+='<td class="'+cur_entry_style+'" width="5px"><a href=\''+cur_link_str+'\'>'+cur_link_id+'</a></td>';cur_entry_string+='<td class="'+cur_entry_style+'" width="20px"><img width="20" height="20" src="'+cur_entry_icon+'"/></td>';cur_entry_string+='<td class="'+cur_entry_style+'" width="120px">'+cur_turn+' to '+next_entry_road+' road</td>';cur_entry_string+='<td class="'+cur_entry_style+'" width="50px">';if(!empty(cur_end_city)){cur_entry_string+='Nearest City:'+cur_end_city.getAttribute("city_name")+'<br/>Travel Distance : '+cur_distance+'km';}else{cur_entry_string+='Travel Distance: '+cur_distance+'km';}
cur_entry_string+='</td>';cur_entry_string+='</tr>';cur_link_id++;}
dir_html+=cur_entry_string;}}
dir_html+='</table>';var logger_content;if(is_IE===true){logger_content='<div class="coner_round" style="overflow:auto; margin-top:10px; height:240px; padding-left:0px!important; padding-right:0px!important;">';}else{logger_content='<div class="coner_round" style="overflow:auto; margin-top:10px; ">';}
logger_content+=dir_html;logger_content+='</div>';if(logger_directions_id>0){logger_array.splice(logger_directions_id,1);title_logger.splice(logger_directions_id,1);}
var loggerObj=new logger(logger_content,-1);logger_array[logger_array.length]=loggerObj;title_logger[title_logger.length]="Directions";logger_directions_id=logger_array.length-1;title_index=title_logger.length-1;current_index=logger_array.length-1;document.getElementById('mainTabContainer').innerHTML=logger_array[logger_array.length-1].content;document.getElementById('dash_title').innerHTML=title_logger[title_logger.length-1];}}else{}}else{}}
function show_path(xml_doc,end_location,showAttractions){if(!empty(xml_doc)){show_hide_path_load_img(true);var lines_main=xml_doc.documentElement.getElementsByTagName("polylines");var show_attr=false;var obj_chk_show_attr=document.getElementById('chk_dir_path_attr');if(!empty(obj_chk_show_attr)){if(obj_chk_show_attr.checked===true||showPathAttrWithSugstddRoutes===true){show_attr=true;showPathAttrWithSugstddRoutes=false;if(showAttractions!="undefined"){if(showAttractions===false&&obj_chk_show_attr.checked===true){show_attr=false;}}}}
if(!empty(lines_main)){var polylines=lines_main[0].getElementsByTagName("polyline");var GPointArr=[];var line_color="#000000";var line_width=3;var line_opacity=0.5;line_color=lines_main[0].getAttribute("colour");line_width=parseInt(lines_main[0].getAttribute("width"),10);line_opacity=parseFloat(lines_main[0].getAttribute("opacity"));remove_path();path_poly_arr=[];path_poly_mini_arr=[];path_poly_point_arr=[];GPointMiniArr=[];main_list="<table class='tableDashboard'>";tts_list="<table class='corner_round'>";ttd_list="<table class='corner_round'>";wts_list="<table class='corner_round'>";wts_count=1;tts_count=1;ttd_count=1;path_attr_list=[];for(var i=0;i<polylines.length;i++){var points=polylines[i].getElementsByTagName("point");GPointArr=[];for(var j=0;j<points.length;j++){GPointArr.push(new GLatLng(parseFloat(points[j].getAttribute("lat")),parseFloat(points[j].getAttribute("lon"))));}
if(!empty(GPointArr)){var poly_line=new GPolyline(GPointArr,line_color,line_width,line_opacity);path_poly_arr.push(poly_line);map.addOverlay(poly_line);}else{}
if(show_attr===true){var attr_main=polylines[i].getElementsByTagName("path_attr");if(!empty(attr_main)){for(var g=0;g<attr_main.length;g++){var attr_list=attr_main[g].getElementsByTagName("attraction");show_path_attractions(attr_list);}}}}
show_directions(xml_doc,end_location);if(show_attr===true){wts_list+="</table>";tts_list+="</table>";ttd_list+="</table>";main_list+='<tr onClick="javascript:toggle_path_attr_logger_header(\'wts\')"  ><td class="tdPathAttrWTSHeading" width="200px">Places To Stay</td></tr>';main_list+='<tr id="ptattr_wts_lst" style="display:none;"><td>'+wts_list+'</td></tr>';main_list+='<tr onClick="javascript:toggle_path_attr_logger_header(\'tts\')"  ><td class="tdPathAttrTTSHeading" width="200px">Things To See</td></tr>';main_list+='<tr id="ptattr_tts_lst" style="display:none;"><td>'+tts_list+'</td></tr>';main_list+='<tr onClick="javascript:toggle_path_attr_logger_header(\'ttd\')"  ><td class="tdPathAttrTTDHeading" width="200px">Things To Do</td></tr>';main_list+='<tr id="ptattr_ttd_lst" style="display:none;"><td>'+ttd_list+'</td></tr>';main_list+="</table>";var div_content="<div class='coner_round'>"+main_list+"</div>";var logger_obj=new logger(div_content,0);logger_array[logger_array.length]=logger_obj;logger_pathattr_id=logger_array.length-1;title_logger[title_logger.length]="Path Attractions";current_index=logger_array.length-1;title_index=title_logger.length-1;document.getElementById('mainTabContainer').innerHTML=logger_array[logger_array.length-1].content;document.getElementById('dash_title').innerHTML=title_logger[title_logger.length-1];}}}}
function isArray(obj){return(obj.constructor.toString().indexOf("Array")!=-1);}
function get_path(){var xml_doc;if(!empty(path_start_point)&&!empty(path_end_point)){remove_path();show_hide_path_load_img(true);var start_point_str=path_start_point.lat()+","+path_start_point.lng();var end_point_str=path_end_point.lat()+","+path_end_point.lng();var zoom_level=map.getZoom();if(start_pt_zoom<end_pt_zoom){zoom_level=start_pt_zoom;}else{zoom_level=end_pt_zoom;}
var obj_chk_show_attr=document.getElementById('chk_dir_path_attr');var show_attr=0;if(!empty(obj_chk_show_attr)){if(obj_chk_show_attr.checked===true){show_attr=1;}}
var obj_chk_avoid_unclassi=document.getElementById('chk_avoid_unclassified');var avoid_unclassi=0;if(!empty(obj_chk_avoid_unclassi)){if(obj_chk_avoid_unclassi.checked===true){avoid_unclassi=1;}}
if(start_point_as_a_string!==null&&start_point_as_a_string!=start_point_str){if(!empty(path_start_marker)){map.removeOverlay(path_start_marker);}
path_start_marker=new GMarker(path_start_point,{icon:start_marker_ico,title:"Start of the Current Path",draggable:true});GEvent.addListener(path_start_marker,"dragend",function(latlng){path_start_point=latlng;start_pt_zoom=map.getZoom();get_path();});map.addOverlay(path_start_marker);start_pt_zoom=map.getZoom();}
if(end_point_as_a_string!==null&&end_point_as_a_string!=end_point_str){if(!empty(path_end_marker)){map.removeOverlay(path_end_marker);}
path_end_marker=new GMarker(path_end_point,{icon:end_marker_ico,title:"End of the Current Path",draggable:true});GEvent.addListener(path_end_marker,"dragend",function(latlng){path_end_point=latlng;end_pt_zoom=map.getZoom();get_path();});map.addOverlay(path_end_marker);end_pt_zoom=map.getZoom();endCityChaged=true;}
var dwnld_url=base_path+"path_marker_wl/"+start_point_str+"/"+end_point_str+"/"+zoom_level+"/"+show_attr;var viaCitiesRadioButtonIsSelected=0;var viaCitiesSelectedCityList="";var viaCityTempList="";if(document.getElementById('rd_dir_via_cities')){if(document.getElementById('rd_dir_via_cities').checked){if(document.getElementById('facebook-list')){var elem=document.getElementById('facebook-list');var elems=getElementsByClassName(elem,"li","bit-box");for(var x=0;x<elems.length;x++){if(elems[x].hasChildNodes()){var textValue=elems[x].childNodes[0].nodeValue;viaCityTempList=viaCityTempList+","+textValue;}}
viaCityTempList=viaCityTempList.substr(1);viaCityTempList=viaCityTempList.split(",");}
if(isArray(viaCityTempList)){if(viaCityTempList.length>0&&viaCityTempList[0]!=""){for(var i=0;i<viaCityTempList.length;i++){for(var j in viaCitiesArray){if(viaCitiesArray[j]==viaCityTempList[i].trim()){viaCitiesSelectedCityList=viaCitiesSelectedCityList+","+j;}}}
viaCitiesRadioButtonIsSelected=1;viaCitiesSelectedCityList=viaCitiesSelectedCityList.substr(1);dwnld_url=dwnld_url+"/"+viaCitiesRadioButtonIsSelected+","+viaCitiesSelectedCityList+"/"+avoid_unclassi;showViaCitiesMarkers();}else{dwnld_url=dwnld_url+"/"+0+"/"+avoid_unclassi;}}else{dwnld_url=dwnld_url+"/"+0+"/"+avoid_unclassi;}}else{dwnld_url=dwnld_url+"/"+viaCitiesRadioButtonIsSelected+"/"+avoid_unclassi;}}
viaCityRequestNotArrived=true;timerObj=window.setTimeout('checkViaCityTimeTaken()',30000);GDownloadUrl(dwnld_url,function(data){if(viaCityRequestNotArrived){if(!empty(data)){viaCityRequestNotArrived=false;xml_doc=GXml.parse(data);show_path(xml_doc);clearViaCityTimer();show_hide_path_load_img(false);viaCityRequestNotArrived=true;}else{remove_path();document.getElementById('mainTabContainer').innerHTML=logger_array[logger_array.length-1].content;document.getElementById('dash_title').innerHTML=title_logger[title_logger.length-1];current_index=logger_array.length-1;title_index=title_logger.length-1;alert("Could not identify a path between two locations. Please try again!");}}
clearViaCityTimer();show_hide_path_load_img(false);viaCityRequestNotArrived=true;});}}
function toggle_path_attr_logger_header(clicked_header){obj_wts_header=document.getElementById('ptattr_wts_lst');obj_tts_header=document.getElementById('ptattr_tts_lst');obj_ttd_header=document.getElementById('ptattr_ttd_lst');if(!empty(obj_wts_header)&&!empty(obj_tts_header)&&!empty(obj_ttd_header)){switch(clicked_header){case"wts":if(obj_wts_header.style.display=='none'){obj_wts_header.style.display='table-row';obj_tts_header.style.display='none';obj_ttd_header.style.display='none';}else{obj_wts_header.style.display='none';}
break;case"tts":if(obj_tts_header.style.display=='none'){obj_wts_header.style.display='none';obj_tts_header.style.display='table-row';obj_ttd_header.style.display='none';}else{obj_tts_header.style.display='none';}
break;case"ttd":if(obj_ttd_header.style.display=='none'){obj_wts_header.style.display='none';obj_tts_header.style.display='none';obj_ttd_header.style.display='table-row';}else{obj_ttd_header.style.display='none';}
break;}}}
function show_direction_entry(dir_point_lat,dir_point_lon,dir_entry_id){if(!empty(dir_entry_id)){var idx=dir_entry_marker_list.indexOf(dir_entry_id);if(idx!=-1){map.removeOverlay(dir_entry_marker_list[dir_entry_id]);}
var entry_icon_url=cg_pathfinder_path+'/icons/dir_entry_'+dir_entry_id+'.png';var entry_icon=new GIcon(icon);entry_icon.image=entry_icon_url;entry_icon.iconSize=new GSize(18,24);entry_icon.iconAnchor=new GPoint(10,24);entry_icon.infoWindowAnchor=new GPoint(10,1);var entry_title='Directions entry '+dir_entry_id;var marker_point=new GLatLng(parseFloat(dir_point_lat),parseFloat(dir_point_lon));var dir_marker=new GMarker(marker_point,{icon:entry_icon,title:entry_title});map.addOverlay(dir_marker);dir_entry_marker_list[dir_entry_id]=dir_marker;GEvent.addListener(dir_marker,'click',function(){var map_type=map.getCurrentMapType();dir_marker.showMapBlowup({zoomLevel:12,mapType:map_type});});GEvent.trigger(dir_marker,'click');}}
function get_tile_image_url(point_Glatlng,zoom_level){if((zoom_level<map_min_zoom)||(zoom_level>map_max_zoom)){return cg_pathfinder_path+"/SLTILES/blank.png";}else{var mercator=new GMercatorProjection(map_max_zoom+1);var map_bounds=new GLatLngBounds(map_SE_bound_latlng,map_NW_bound_latlng);var point_pixel=mercator.fromLatLngToPixel(point_Glatlng,zoom_level);var tile_coord=new GPoint();tile_coord.x=Math.floor(point_pixel.x/256);tile_coord.y=Math.floor(point_pixel.y/256);var tile_bounds=new GLatLngBounds(mercator.fromPixelToLatLng(new GPoint((tile_coord.x)*256,(tile_coord.y+1)*256),zoom_level),mercator.fromPixelToLatLng(new GPoint((tile_coord.x+1)*256,(tile_coord.y)*256),zoom_level));var ymax;ymax=1<<zoom_level;var y=ymax-tile_coord.y-1;if(map_bounds.intersects(tile_bounds)){return cg_pathfinder_path+"/SLTILES/"+zoom_level+"/"+tile_coord.x+"/"+y+".png";}else{return cg_pathfinder_path+"/SLTILES/blank.png";}}}
function checkStartAndEndLocationsInViaCities(){var startOrEndIsInViaCities=false;if(viaCitiesArray!==null&&viaCitiesArray.length>0){var startLocation=document.getElementById('sel_directions_from');var endLocation=document.getElementById('sel_directions_to');if(!empty(startLocation)&&!empty(endLocation)){var start_city_tid=startLocation.value;var end_city_tid=endLocation.value;var startCityName=document.getElementById('select-from-loc').value;var endCityName=document.getElementById('select-to-loc').value;for(var key in viaCitiesArray){if(key==start_city_tid||key==end_city_tid){startOrEndIsInViaCities=true;map.removeOverlay(viaCitiesMarkersArray[key]);delete viaCitiesMarkersArray[key];if(document.getElementById('facebook-list')){var elem=document.getElementById('facebook-list');var elems=getElementsByClassName(elem,"li","bit-box");for(var x=0;x<elems.length;x++){if(elems[x].hasChildNodes()){var textValue=elems[x].childNodes[0].nodeValue;if(startCityName==textValue||endCityName==textValue){elems[x].parentNode.removeChild(elems[x]);if(itemCountInViaCityList>0){itemCountInViaCityList--;}}}}}
return startOrEndIsInViaCities;}}}}
return startOrEndIsInViaCities;}
function hideViaCitiesLable(){if(document.getElementById('dir_opt_city_list')){document.getElementById('dir_opt_city_list').innerHTML="";document.getElementById('dir_opt_city_list').style.display="none";}}
function removeInnerHTMLFromLabel(city_name){if(document.getElementById('dir_opt_city_list')){var currentTextInLabelArray=document.getElementById('dir_opt_city_list').innerHTML.split(",");var newTextOfLabel="";var seperator=", ";for(var i=0;i<currentTextInLabelArray.length;i++){if(currentTextInLabelArray[i].trim()==city_name||currentTextInLabelArray[i].trim()==""){continue;}else{newTextOfLabel=currentTextInLabelArray[i].trim()+seperator+newTextOfLabel;newTextOfLabel=newTextOfLabel.split(",").reverse().toString();if(newTextOfLabel.charAt[0]==","){newTextOfLabel=newTextOfLabel.charAt[0]=" ";}
if(newTextOfLabel.charAt[newTextOfLabel.length-1]==","){newTextOfLabel=newTextOfLabel.charAt[0]=" ";}
newTextOfLabel=newTextOfLabel.replace(/, /i," ");newTextOfLabel=newTextOfLabel.replace(/ ,/i," ");}}
document.getElementById('dir_opt_city_list').innerHTML=newTextOfLabel;}}
function checkStartCityChange(){var startCityChaged=false;var startLocation=document.getElementById('sel_directions_from');if(!empty(startLocation)){var currentStartCity=startLocation.value;if(startCityTid!=currentStartCity){startCityTid=currentStartCity;startCityChaged=true;}
if(!empty(path_start_point)){var start_point_str=path_start_point.lat()+","+path_start_point.lng();if(start_point_str!=start_point_as_a_string){startCityChaged=true;}}}
return startCityChaged;}
function checkEndCityChange(){var endCityChaged=false;var endLocation=document.getElementById('sel_directions_from');if(!empty(endLocation)){var currentEndCity=endLocation.value;if(endCityTid!=currentEndCity){endCityTid=currentEndCity;endCityChaged=true;}
if(!empty(path_end_point)){var end_point_str=path_end_point.lat()+","+path_end_point.lng();if(end_point_str!=end_point_as_a_string){endCityChaged=true;}}}
return endCityChaged;}
function closeComboCityList(){if(document.getElementById('combo-city-list')){var combo_city_list=document.getElementById('combo-city-list');if(combo_city_list.className=='expand'){combo_city_list.className='checklist cl2';document.getElementById('item-one').className='checklist cl1';}}}
function set_dir_start_point(){if(!checkStartAndEndLocationsInViaCities()){if(checkStartCityChange()){var obj_sel_dir_from=document.getElementById('sel_directions_from');var xml_doc;var startLocName="";if(document.getElementById('select-from-loc')){startLocName=document.getElementById('select-from-loc').value;}
show_hide_path_load_img(true);if(!empty(obj_sel_dir_from)){var start_city_tid=obj_sel_dir_from.value;if(!empty(start_city_tid)){remove_path();var dwnld_url=base_path+"get_city_geocode_wl/"+start_city_tid;GDownloadUrl(dwnld_url,function(data){if(!empty(data)){xml_doc=GXml.parse(data);var city_info_node=xml_doc.documentElement.getElementsByTagName("city_info");if(!empty(city_info_node)){path_start_point=new GLatLng(parseFloat(city_info_node[0].getAttribute("city_pt_lat")),parseFloat(city_info_node[0].getAttribute("city_pt_lon")));start_point_as_a_string=parseFloat(city_info_node[0].getAttribute("city_pt_lat"))+","+parseFloat(city_info_node[0].getAttribute("city_pt_lon"));var city_name=city_info_node[0].getAttribute("city_name");if(!empty(path_start_marker)){map.removeOverlay(path_start_marker);}
path_start_marker=new GMarker(path_start_point,{icon:start_marker_ico,title:startLocName,draggable:true});GEvent.addListener(path_start_marker,"dragend",function(latlng){path_start_point=latlng;start_pt_zoom=map.getZoom();get_path();});map.addOverlay(path_start_marker);start_pt_zoom=map.getZoom();}else{alert('Location data currently unavailable.');}}else{alert('Could not identify start city location. Please select a different start city!');}
show_hide_path_load_img(false);});}}}}else{var startLocation=document.getElementById('sel_directions_from');if(!empty(startLocation)){var start_tid=startLocation.value;var start_location_name=viaCitiesArray[start_tid];clickCount--;removeInnerHTMLFromLabel(start_location_name);delete viaCitiesArray[start_tid];var path_id="path-"+start_tid;if(document.getElementById(path_id)&&document.getElementById(path_id).checked){document.getElementById(path_id).checked=false;}
if(clickCount===0){hideViaCitiesLable();closeComboCityList();isShowHideClicked=true;}}
alert("Start city was in via cities list. Via cities list updated.");var sel_dir_from=document.getElementById('sel_directions_from');var downl_xml_doc;var startingLocName="";if(document.getElementById('select-from-loc')){startingLocName=document.getElementById('select-from-loc').value;}
if(!empty(sel_dir_from)){var start_ct_tid=sel_dir_from.value;if(!empty(start_ct_tid)){remove_path();var download_url=base_path+"get_city_geocode_wl/"+start_ct_tid;GDownloadUrl(download_url,function(data){if(!empty(data)){downl_xml_doc=GXml.parse(data);var city_info_node=downl_xml_doc.documentElement.getElementsByTagName("city_info");if(!empty(city_info_node)){path_start_point=new GLatLng(parseFloat(city_info_node[0].getAttribute("city_pt_lat")),parseFloat(city_info_node[0].getAttribute("city_pt_lon")));var city_name=city_info_node[0].getAttribute("city_name");if(!empty(path_start_marker)){map.removeOverlay(path_start_marker);}
path_start_marker=new GMarker(path_start_point,{icon:start_marker_ico,title:startingLocName,draggable:true});GEvent.addListener(path_start_marker,"dragend",function(latlng){path_start_point=latlng;start_pt_zoom=map.getZoom();get_path();});map.addOverlay(path_start_marker);start_pt_zoom=map.getZoom();}else{alert('Location data currently unavailable.');}}else{alert('Could not identify start city location. Please select a different start city!');}});}}}}
function setPathStartPointIfNotSet(){if(checkStartCityChange()){var obj_sel_dir_from=document.getElementById('sel_directions_from');var xml_doc;var startingLocName="";if(document.getElementById('select-from-loc')){startingLocName=document.getElementById('select-from-loc').value;}
if(!empty(obj_sel_dir_from)){var start_city_tid=obj_sel_dir_from.value;if(!empty(start_city_tid)){remove_path();var dwnld_url=base_path+"get_city_geocode_wl/"+start_city_tid;GDownloadUrl(dwnld_url,function(data){if(!empty(data)){xml_doc=GXml.parse(data);var city_info_node=xml_doc.documentElement.getElementsByTagName("city_info");if(!empty(city_info_node)){path_start_point=new GLatLng(parseFloat(city_info_node[0].getAttribute("city_pt_lat")),parseFloat(city_info_node[0].getAttribute("city_pt_lon")));start_point_as_a_string=parseFloat(city_info_node[0].getAttribute("city_pt_lat"))+","+parseFloat(city_info_node[0].getAttribute("city_pt_lon"));var city_name=city_info_node[0].getAttribute("city_name");if(!empty(path_start_marker)){map.removeOverlay(path_start_marker);}
path_start_marker=new GMarker(path_start_point,{icon:start_marker_ico,title:startingLocName,draggable:true});GEvent.addListener(path_start_marker,"dragend",function(latlng){path_start_point=latlng;start_pt_zoom=map.getZoom();get_path();});map.addOverlay(path_start_marker);start_pt_zoom=map.getZoom();}else{alert('Location data currently unavailable.');}}else{alert('Could not identify start city location. Please select a different start city!');}});}}}}
function checkEndtCityChange(){var endCityChaged=false;var endLocation=document.getElementById('sel_directions_to');if(!empty(endLocation)){var currentEndCity=endLocation.value;if(endCityTid!=currentEndCity){endCityTid=currentEndCity;endCityChaged=true;}
if(!empty(path_end_point)){var end_point_str=path_end_point.lat()+","+path_end_point.lng();if(end_point_str!=end_point_as_a_string){endCityChaged=true;}}}
return endCityChaged;}
function set_dir_end_point(){if(!checkStartAndEndLocationsInViaCities()){if(checkEndtCityChange()){var obj_sel_dir_to=document.getElementById('sel_directions_to');var xml_doc;var endLocName="";if(document.getElementById('select-to-loc')){endLocName=document.getElementById('select-to-loc').value;}
if(!empty(obj_sel_dir_to)){var end_city_tid=obj_sel_dir_to.value;if(!empty(end_city_tid)){remove_path();var dwnld_url=base_path+"get_city_geocode_wl/"+end_city_tid;GDownloadUrl(dwnld_url,function(data){if(!empty(data)){xml_doc=GXml.parse(data);var city_info_node=xml_doc.documentElement.getElementsByTagName("city_info");if(!empty(city_info_node)){path_end_point=new GLatLng(parseFloat(city_info_node[0].getAttribute("city_pt_lat")),parseFloat(city_info_node[0].getAttribute("city_pt_lon")));end_point_as_a_string=parseFloat(city_info_node[0].getAttribute("city_pt_lat"))+","+parseFloat(city_info_node[0].getAttribute("city_pt_lon"));if(!empty(path_end_marker)){map.removeOverlay(path_end_marker);}
path_end_marker=new GMarker(path_end_point,{icon:end_marker_ico,title:endLocName,draggable:true});GEvent.addListener(path_end_marker,"dragend",function(latlng){path_end_point=latlng;end_pt_zoom=map.getZoom();get_path();});map.addOverlay(path_end_marker);end_pt_zoom=map.getZoom();}else{alert('Location data currently unavailable.');}}else{alert('Could not identify end city location. Please select a different end city!');}
show_hide_path_load_img(false);});}}}}else{var endLocation=document.getElementById('sel_directions_to');if(!empty(endLocation)){var end_tid=endLocation.value;var end_location_name=viaCitiesArray[end_tid];clickCount--;removeInnerHTMLFromLabel(end_location_name);delete viaCitiesArray[end_tid];var path_id="path-"+end_tid;if(document.getElementById(path_id)&&document.getElementById(path_id).checked){document.getElementById(path_id).checked=false;}
if(clickCount===0){hideViaCitiesLable();closeComboCityList();isShowHideClicked=true;}}
alert("End city was in via cities list. Via cities list updated.");var sel_dir_to=document.getElementById('sel_directions_to');var show_xml_doc;var endingLocName="";if(document.getElementById('select-to-loc')){endingLocName=document.getElementById('select-to-loc').value;}
if(!empty(sel_dir_to)){var end_ct_tid=sel_dir_to.value;if(!empty(end_ct_tid)){remove_path();var download_url=base_path+"get_city_geocode_wl/"+end_ct_tid;GDownloadUrl(download_url,function(data){if(!empty(data)){show_xml_doc=GXml.parse(data);var city_info_node=show_xml_doc.documentElement.getElementsByTagName("city_info");if(!empty(city_info_node)){path_end_point=new GLatLng(parseFloat(city_info_node[0].getAttribute("city_pt_lat")),parseFloat(city_info_node[0].getAttribute("city_pt_lon")));if(!empty(path_end_marker)){map.removeOverlay(path_end_marker);}
path_end_marker=new GMarker(path_end_point,{icon:end_marker_ico,title:endingLocName,draggable:true});GEvent.addListener(path_end_marker,"dragend",function(latlng){path_end_point=latlng;end_pt_zoom=map.getZoom();get_path();});map.addOverlay(path_end_marker);end_pt_zoom=map.getZoom();}else{alert('Location data currently unavailable.');}}else{alert('Could not identify end city location. Please select a different end city!');}});}}}}
function get_directions_wl(){var obj_sel_dir_from=document.getElementById('sel_directions_from');var obj_sel_dir_to=document.getElementById('sel_directions_to');var xml_doc;show_hide_path_load_img(true);if(!empty(obj_sel_dir_from)&&!empty(obj_sel_dir_to)){var start_city_tid=obj_sel_dir_from.value;var end_city_tid=obj_sel_dir_to.value;var zoom_level=map.getZoom();if(!empty(start_city_tid)&&!empty(end_city_tid)){if(start_city_tid!=end_city_tid){var obj_chk_show_attr=document.getElementById('chk_dir_path_attr');var show_attr=0;if(!empty(obj_chk_show_attr)){if(obj_chk_show_attr.checked===true){show_attr=1;}}
var obj_chk_avoid_unclassi=document.getElementById('chk_avoid_unclassified');var avoid_unclassi=0;if(!empty(obj_chk_avoid_unclassi)){if(obj_chk_avoid_unclassi.checked===true){avoid_unclassi=1;}}
var dwnld_url=base_path+"get_directions_wl/"+start_city_tid+"/"+end_city_tid+"/"+zoom_level+"/"+show_attr;var viaCitiesRadioButtonIsSelected=0;var viaCitiesSelectedCityList="";var viaCityTempList="";if(document.getElementById('rd_dir_via_cities')){if(document.getElementById('rd_dir_via_cities').checked){if(document.getElementById('facebook-list')){var elem=document.getElementById('facebook-list');var elems=getElementsByClassName(elem,"li","bit-box");for(var x=0;x<elems.length;x++){if(elems[x].hasChildNodes()){var textValue=elems[x].childNodes[0].nodeValue;viaCityTempList=viaCityTempList+","+textValue;}}
viaCityTempList=viaCityTempList.substr(1);viaCityTempList=viaCityTempList.split(",");}
if(isArray(viaCityTempList)){if(viaCityTempList.length>0&&viaCityTempList[0]!=""){for(var i=0;i<viaCityTempList.length;i++){for(var j in viaCitiesArray){if(viaCitiesArray[j]==viaCityTempList[i].trim()){viaCitiesSelectedCityList=viaCitiesSelectedCityList+","+j;}}}
viaCitiesRadioButtonIsSelected=1;viaCitiesSelectedCityList=viaCitiesSelectedCityList.substr(1);dwnld_url=dwnld_url+"/"+viaCitiesRadioButtonIsSelected+","+viaCitiesSelectedCityList+"/"+avoid_unclassi;showViaCitiesMarkers();}else{dwnld_url=dwnld_url+"/"+0+"/"+avoid_unclassi;}}else{dwnld_url=dwnld_url+"/"+0+"/"+avoid_unclassi;}}else{dwnld_url=dwnld_url+"/"+viaCitiesRadioButtonIsSelected+"/"+avoid_unclassi;}}
viaCityRequestNotArrived=true;timerObj=window.setTimeout('checkViaCityTimeTaken()',30000);GDownloadUrl(dwnld_url,function(data){if(viaCityRequestNotArrived){if(!empty(data)){viaCityRequestNotArrived=false;xml_doc=GXml.parse(data);var loct_node=xml_doc.documentElement.getElementsByTagName("locations");if(!empty(loct_node)){var start_pt_node=loct_node[0].getElementsByTagName("start_point");if(!empty(start_pt_node)){path_start_point=new GLatLng(parseFloat(start_pt_node[0].getAttribute("lat")),parseFloat(start_pt_node[0].getAttribute("lon")));if(!empty(path_start_marker)){map.removeOverlay(path_start_marker);}
path_start_marker=new GMarker(path_start_point,{icon:start_marker_ico,title:obj_sel_dir_from.text,draggable:true});GEvent.addListener(path_start_marker,"dragend",function(latlng){path_start_point=latlng;start_pt_zoom=map.getZoom();get_path();});map.addOverlay(path_start_marker);start_pt_zoom=map.getZoom();}
var end_pt_node=loct_node[0].getElementsByTagName("end_point");if(!empty(end_pt_node)){path_end_point=new GLatLng(parseFloat(end_pt_node[0].getAttribute("lat")),parseFloat(end_pt_node[0].getAttribute("lon")));if(!empty(path_end_marker)){map.removeOverlay(path_end_marker);}
path_end_marker=new GMarker(path_end_point,{icon:end_marker_ico,title:obj_sel_dir_to.text,draggable:true});GEvent.addListener(path_end_marker,"dragend",function(latlng){path_end_point=latlng;end_pt_zoom=map.getZoom();get_path();});map.addOverlay(path_end_marker);end_pt_zoom=map.getZoom();}}
show_path(xml_doc);clearViaCityTimer();show_hide_path_load_img(false);viaCityRequestNotArrived=true;}else{alert('Could not identify a path between two destinations. Please try again!');}}
clearViaCityTimer();show_hide_path_load_img(false);viaCityRequestNotArrived=true;});}else{alert('Cannot get directions for same city. Please select different cities to get directions.');show_hide_path_load_img(false);}}else{alert("Start and end locations cannot be empty. Please select correct start and end locations.");show_hide_path_load_img(false);}}}
String.prototype.trim=function(){return this.replace(/^\s*/,"").replace(/\s*$/,"");};function generateMarkerForViaCity(tid,cityname){var name=cityname+": Click to see attractions";var dwnld_url=base_path+"get_city_geocode_wl/"+tid;GDownloadUrl(dwnld_url,function(data){if(!empty(data)){xml_doc=GXml.parse(data);var city_info_node=xml_doc.documentElement.getElementsByTagName("city_info");if(!empty(city_info_node)){var cms_tid=0;for(var a=0;a<tokensArray[0].length;a++){if(tid==tokensArray[0][a][2]){if(tokensArray[0][a][3]!==null){cms_tid=tokensArray[0][a][3];}}}
var point=new GLatLng(parseFloat(city_info_node[0].getAttribute("city_pt_lat")),parseFloat(city_info_node[0].getAttribute("city_pt_lon")));var ico=viacityicon;ico.infoWindowAnchor=new GPoint(5,2);var marker;if(cms_tid!==0){marker=new GMarker(point,{icon:ico,title:name});map.addOverlay(marker);GEvent.addListener(marker,'click',function(){if(document.getElementById(cms_tid)){document.getElementById(cms_tid).checked=true;getCity(cms_tid);var cityElementArr=cityMarkerList[cms_tid];if(!empty(cityElementArr)){marker.hide();}}});var label=null;GEvent.addListener(marker,"mouseover",function(){label=new ELabel(new GLatLng(parseFloat(city_info_node[0].getAttribute("city_pt_lat")),parseFloat(city_info_node[0].getAttribute("city_pt_lon"))),cityname+": Click to see attractions","elableStyle");label.pixelOffset=new GSize(5,5);map.addOverlay(label);});GEvent.addListener(marker,"mouseout",function(){if(label!==null){map.removeOverlay(label);label=null;}});}else{marker=new GMarker(point,{icon:ico,title:cityname});map.addOverlay(marker);}
viaCitiesMarkersArray[tid]=marker;}else{alert('Location data currently unavailable.');var pathtid="path-"+tid;if(document.getElementById(pathtid)){document.getElementById(pathtid).checked=false;}
clickCount--;removeInnerHTMLFromLabel(cityname);delete viaCitiesArray[tid];if(clickCount===0){hideViaCitiesLable();closeComboCityList();isShowHideClicked=true;}}}else{alert('Could not identify city location. Please select a different city!');}});}
function openComboCityList(){if(document.getElementById('combo-city-list')){var combo_city_list=document.getElementById('combo-city-list');combo_city_list.className='expand';}}
function toggleCityListOnRadioButtonSelect(){if(document.getElementById("rd_dir_via_cities").checked){if(document.getElementById('facebook-list')){document.getElementById('facebook-list').style.display="";document.getElementById('facebook-list').style.listStyle="none";}
showViaCitiesMarkers();}else{if(document.getElementById('facebook-list')){document.getElementById('facebook-list').style.display="none";document.getElementById('facebook-list').style.listStyle="none";}
hideViaCitiesMarkers();}}
function showViaCitiesLable(city_name){if(document.getElementById('dir_opt_city_list')){var currentTextInLabel=document.getElementById('dir_opt_city_list').innerHTML;var seperator="";var numOfCommas=currentTextInLabel.split(",",currentTextInLabel);if(clickCount!=1){seperator=", ";}
var newTextOfLabel=currentTextInLabel+seperator+city_name;document.getElementById('dir_opt_city_list').innerHTML=newTextOfLabel;document.getElementById('dir_opt_city_list').style.display="";}}
function populateSelectedCities(tid,city_name){var pathtid="path-"+tid;var proceedOrNot=false;if(document.getElementById(pathtid)&&document.getElementById(pathtid).checked){var startLocation=document.getElementById('sel_directions_from');var endLocation=document.getElementById('sel_directions_to');if(!empty(startLocation)&&!empty(endLocation)){var start_city_tid=startLocation.value;var end_city_tid=endLocation.value;if(start_city_tid==tid||end_city_tid==tid){document.getElementById(pathtid).checked=false;alert("Please select a city other than start city or end city.");}else{proceedOrNot=true;}
if(proceedOrNot){if(clickCount!=3){clickCount++;viaCitiesArray[tid]=city_name;showViaCitiesLable(city_name);generateMarkerForViaCity(tid,city_name);}else{document.getElementById(pathtid).checked=false;alert("You can select only three additional cities.");}}}}else{clickCount--;removeInnerHTMLFromLabel(city_name);delete viaCitiesArray[tid];for(var key in viaCitiesMarkersArray){if(key==tid){map.removeOverlay(viaCitiesMarkersArray[tid]);delete viaCitiesMarkersArray[tid];}}
if(clickCount===0){hideViaCitiesLable();closeComboCityList();isShowHideClicked=true;}}}
function onClickShowHideViaCitiesList(){if(isShowHideClicked){openComboCityList();isShowHideClicked=false;}else{closeComboCityList();isShowHideClicked=true;}}
function populateDirectionsData(showLoading){if(cityNamesNotLoaded){cityNamesNotLoaded=false;var dwnld_url=base_path+"get_city_json_wl";show_hide_path_load_img(showLoading);GDownloadUrl(dwnld_url,function(data){if(!empty(data)){tokensArray.push(eval('('+data+')'));var el=$('select-from-loc');var completer1;completer1=new Autocompleter.Local(el,tokensArray[0],{'width':200,'delay':100,'filterTokens':function(){var regex=new RegExp('^'+this.queryValue.escapeRegExp(),'i');return this.tokensArray[0].filter(function(token){return(regex.test(token[0])||regex.test(token[1]));});},'injectChoice':function(choice){var textinput="";if(choice[1].trim().length>3){textinput=choice[1];}
var el=new Element('li').set({'html':this.markQueryValue(choice[0]),id:"st"+choice[2]}).adopt(new Element('span',{'class':'example-info'}).set('html',this.markQueryValue(textinput)));el.inputValue=choice[0];this.addChoiceEvents(el).injectInside(this.choices);},'onDemand':function(selected){setStartHiddenField(selected);}});var el2=$('select-to-loc');var completer2=new Autocompleter.Local(el2,tokensArray[0],{'width':200,'delay':100,'filterTokens':function(){var regex=new RegExp('^'+this.queryValue.escapeRegExp(),'i');return this.tokensArray[0].filter(function(token){return(regex.test(token[0])||regex.test(token[1]));});},'injectChoice':function(choice){var textinp="";if(choice[1].trim().length>3){textinp=choice[1];}
var el3=new Element('li').set({'html':this.markQueryValue(choice[0]),id:"end"+choice[2]}).adopt(new Element('span',{'class':'example-info'}).set('html',this.markQueryValue(textinp)));el3.inputValue=choice[0];this.addChoiceEvents(el3).injectInside(this.choices);},'onDemand':function(selected){setEndHiddenField(selected);}});if(document.getElementById("select-from-loc")){var startLocText=document.getElementById("select-from-loc");document.getElementById("select-from-loc").value="Select start location";startLocText.setAttribute("title","Type a city name to select start location");startLocText.setAttribute("alt","Type a city name to select start location");startLocText.removeAttribute("readOnly");}
if(document.getElementById("select-to-loc")){var endLocText=document.getElementById("select-to-loc");document.getElementById("select-to-loc").value="Select end location";endLocText.setAttribute("title","Type a city name to select end location");endLocText.setAttribute("alt","Type a city name to select end location");endLocText.removeAttribute("readOnly");}
if(showLoading){show_hide_path_load_img(false);}}});}}
function clearStartCityNameOnFocus(){if(document.getElementById('select-from-loc')){var startLocValue=document.getElementById('select-from-loc').value;if(startLocValue=="Select start location"){document.getElementById('select-from-loc').value="";if(document.getElementById('sel_directions_from')){document.getElementById('sel_directions_from').value="";}}}}
function clearEndCityNameOnFocus(){if(document.getElementById('select-to-loc')){var endLocValue=document.getElementById('select-to-loc').value;if(endLocValue=="Select end location"){document.getElementById('select-to-loc').value="";if(document.getElementById('sel_directions_to')){document.getElementById('sel_directions_to').value="";}}}}
