// (c) 2010 CodeGen International

function createContextMenu(map)
{contextmenu=document.createElement("div");contextmenu.style.visibility="hidden";contextmenu.style.background="#eff5fb";contextmenu.style.border="1px solid #8888FF";contextmenu.className="coner_round";contextmenu.innerHTML="<a href='javascript:centreMapHere()' style='text-decoration:none;'>  <div class='context'>  Centre map </div></a>"+"<a href='javascript:StartPath()' style='text-decoration:none;'>  <div class='context'>  Path Start  </div></a>"+"<a href='javascript:EndPath()' style='text-decoration:none;'>  <div class='context'>  Path End  </div></a>"+"<a href='javascript:clearPath()' style='text-decoration:none;'>  <div class='context'>  Clear Path  </div></a>"+"<a href='javascript:clearMap()' style='text-decoration:none;'>  <div class='context'>  Clean Map  </div></a>";map.getContainer().appendChild(contextmenu);GEvent.addListener(map,"singlerightclick",function(pixel,tile)
{clickedPixel=pixel;var x=pixel.x;var y=pixel.y;if(x>map.getSize().width-120)
{x=map.getSize().width-120;}
if(y>map.getSize().height-100)
{y=map.getSize().height-100;}
var pos=new GControlPosition(G_ANCHOR_TOP_LEFT,new GSize(x,y));pos.apply(contextmenu);contextmenu.style.visibility="visible";});GEvent.addListener(map,"click",function()
{contextmenu.style.visibility="hidden";});}
function zoomIn()
{map.zoomIn();contextmenu.style.visibility="hidden";}
function zoomOut()
{map.zoomOut();contextmenu.style.visibility="hidden";}
function zoomInHere()
{var point=map.fromContainerPixelToLatLng(clickedPixel);map.zoomIn(point,true);contextmenu.style.visibility="hidden";}
function zoomOutHere()
{var point=map.fromContainerPixelToLatLng(clickedPixel);map.setCenter(point,map.getZoom()-1);contextmenu.style.visibility="hidden";}
function centreMapHere()
{map.setCenter(new GLatLng(7.8688232820198305,80.66162109375));minimap.setCenter(map.getCenter());drawminiPolygon(minimap.getCenter());drawExtents(minimap.getCenter());contextmenu.style.visibility="hidden";}
function StartPath()
{remove_path();var ref_point=map.fromContainerPixelToLatLng(clickedPixel);path_start_point=ref_point;contextmenu.style.visibility="hidden";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 curent 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();get_path();}
function EndPath()
{remove_path();var ref_point=map.fromContainerPixelToLatLng(clickedPixel);path_end_point=ref_point;contextmenu.style.visibility="hidden";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 curent 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();get_path();}
function clearMap()
{map.clearOverlays();minimap.clearOverlays();drawminiPolygon(minimap.getCenter());contextmenu.style.visibility="hidden";city_ledgen_status=null;city_ledgen_status=[];miniMarkerArray=null;miniMarkerArray=[];miniArray=null;miniArray=[];accomNodeList=null;accomNodeList=[];otherMarkerList=null;otherMarkerList=[];cityNodeList=null;cityNodeList=[];cityMarkerList=null;cityMarkerList=[];path_attr_list=null;path_attr_list=[];itineraryMarkerArr=null;itineraryMarkerArr=[];viaCitiesArray=null;viaCitiesArray=[];viaCitiesMarkersArray=null;viaCitiesMarkersArray=[];clickCount=0;valuesArray=null;valuesArray=[];itemCountInViaCityList=0;status_viacity=true;clickCount=0;startAndEndMarkersHidden=null;startAndEndMarkersHidden=[];document.getElementById('mainTabContainer').innerHTML=logger_array[0].content;document.getElementById('dash_title').innerHTML=title_logger[0];logger_array.length=1;title_logger.length=1;current_index=0;title_index=0;for(var i=0,check=document.getElementsByTagName('input');i<check.length;i++){if(check[i].type=='checkbox'){if(check[i].id=='chk_dir_path_attr'){continue;}
check[i].checked=false;}}
for(var j in accomNodeList){if(!empty($('accom'+j))){var ck=$('accom'+j);ck.checked=false;}}
for(var k in otherMarkerList){if(!empty($(k))){var ckb=$(k);ckb.checked=false;delete otherMarkerList[k];}}
for(var checkItem=0;checkItem<checkBoxArr.length;checkItem++){if(!empty($(checkBoxArr[checkItem]))){if(!empty(document.getElementById('sub_'+checkBoxArr[checkItem]))){var nsub=document.getElementById('sub_'+checkBoxArr[checkItem]);nsub.className='hidden';document.getElementById(checkBoxArr[checkItem]).innerHTML="+";}
var checkedItem=$(checkBoxArr[checkItem]);checkedItem.checked=false;delete checkBoxArr[checkItem];}}
if(document.getElementById('dir_opt_city_list')){document.getElementById('dir_opt_city_list').innerHTML="";document.getElementById('dir_opt_city_list').style.display="none";}
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()){elems[x].parentNode.removeChild(elems[x]);}}}
closeComboCityList();isShowHideClicked=true;if(document.getElementById('select-from-loc')){document.getElementById('select-from-loc').value="";}
if(document.getElementById('select-to-loc')){document.getElementById('select-to-loc').value="";}
if(document.getElementById('sel_directions_to')){document.getElementById('sel_directions_to').value="";}
if(document.getElementById('sel_directions_from')){document.getElementById('sel_directions_from').value="";}
path_start_point=null;path_end_point=null;startCityTid=0;endCityTid=0;show_hide_path_load_img(false);}
function CheckUncheckAllCheckBoxes(objID,checkedValue){if(!empty(document.getElementById(objID))){document.getElementById(objID).checked=false;}}
function keyPressHandler(event){var keyId=event.keyCode;if(keyId==27){contextmenu.style.visibility="hidden";}}
function clearPath(){contextmenu.style.visibility="hidden";remove_path();if(!empty(path_start_marker)){map.removeOverlay(path_start_marker);}
if(!empty(path_end_marker)){map.removeOverlay(path_end_marker);}
if(!empty(viaCitiesMarkersArray)){for(var key in viaCitiesMarkersArray){if(/^\d*$/.test(key)){viaCitiesMarkersArray[key].hide();}}}
if(document.getElementById('select-from-loc')){document.getElementById('select-from-loc').value="";}
if(document.getElementById('select-to-loc')){document.getElementById('select-to-loc').value="";}
if(document.getElementById('sel_directions_to')){document.getElementById('sel_directions_to').value="";}
if(document.getElementById('sel_directions_from')){document.getElementById('sel_directions_from').value="";}
path_start_point=null;path_end_point=null;startCityTid=0;endCityTid=0;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()){elems[x].parentNode.removeChild(elems[x]);}}}
path_attr_list=null;path_attr_list=[];itineraryMarkerArr=null;itineraryMarkerArr=[];viaCitiesArray=null;viaCitiesArray=[];viaCitiesMarkersArray=null;viaCitiesMarkersArray=[];clickCount=0;valuesArray=null;valuesArray=[];itemCountInViaCityList=0;status_viacity=true;startAndEndMarkersHidden=null;startAndEndMarkersHidden=[];cityIdsOfClickedCities=null;cityIdsOfClickedCities=[];}
