var helper_path = 'http://www.atlasct.com/helper/v.2.1/base/';
﻿var reletive_path;
if (isset("helper_path"))
	reletive_path = helper_path;
if(!isset("graphic_path"))
	var graphic_path = reletive_path + "../../";
var add_sdk = eed("atlasmap['sdk']",true);
var map_mode = eed("atlasmap['mode']","");
if (map_mode == "part")
	map_mode = "weather";
function include_dom(script_filename) {
	var html_doc = document.getElementsByTagName('head').item(0);
	var js = document.createElement('script');
	js.setAttribute('language', 'javascript');
	js.setAttribute('type', 'text/javascript');
	js.setAttribute('charset', 'utf-8');
	js.setAttribute('src', script_filename);
	html_doc.appendChild(js);
	return false;
}
var included_files = new Array();
var included_css_files = new Array();
function include_once(_script_filename) {
	if(empty(_script_filename))
		return;
	var script_filename = "";
	if (strtolower(_script_filename.substring(0,4)) == "http")
		script_filename = _script_filename;
	else
		script_filename = reletive_path + _script_filename;
	if (!in_array(script_filename, included_files)) {
		included_files[included_files.length] = script_filename;
		include_dom(script_filename);
	}
}
function in_array(needle, haystack) {
	for (var i = 0; i < haystack.length; i++) {
		if (haystack[i] == needle) {
			return true;
		}
	}
	return false;
}
function include_css(_css_filename,plain) {
	if(empty(_css_filename))
		return;
		
	if (in_array(css_filename, included_css_files)) {
		return;
	}
	var css_filename = "";
	if(!empty(plain) && plain == true){
		css_filename = _css_filename;
	}
	else{
		if (strtolower(_css_filename.substring(0,4)) == "http")
			css_filename = _css_filename;
		else
			css_filename = graphic_path + _css_filename;
	}
	included_css_files[included_css_files.length] = css_filename;
	var headID = document.getElementsByTagName("head")[0];
	var cssNode = document.createElement('link');
	cssNode.type = 'text/css';
	cssNode.rel = 'stylesheet';
	cssNode.href = css_filename;//'FireFox.css';
	cssNode.media = 'screen';
	headID.appendChild(cssNode);
}
function isset(varname)  {
	if(typeof( window[ varname ] ) != "undefined") return true;
	else return false;
}
function is_array(mixed_var){
	var key='';
	if(!mixed_var){
		return false;
	}
	this.php_js=this.php_js||{};
	this.php_js.ini=this.php_js.ini||{};
	if(typeof mixed_var==='object'){
		if(this.php_js.ini['phpjs.objectsAsArrays']&&((this.php_js.ini['phpjs.objectsAsArrays'].local_value.toLowerCase&&this.php_js.ini['phpjs.objectsAsArrays'].local_value.toLowerCase()==='off')||parseInt(this.php_js.ini['phpjs.objectsAsArrays'].local_value,10)===0)){
			return mixed_var.hasOwnProperty('length')&&!mixed_var.propertyIsEnumerable('length')&&mixed_var.constructor.name!=='String';
		}
		if(mixed_var.hasOwnProperty){
			for(key in mixed_var){
				if(false===mixed_var.hasOwnProperty(key)){
					return false;
				}
			}
		}
		return true;
	}
	return false;
}
function empty(obj){
	//if (obj != null && typeof(obj) != "undefined")
	if (obj == null || obj == "" || typeof(obj) == "undefined")
		return true;
	else
		return false;
}
/*** try to eval(str) and check if empty */
function ee(str){
	try{
		var obj = eval(str);
		if(obj === 0){
			return 0;
		}
		if(obj === false){
			return false;
		}
		else
			return empty(obj);
	}
	catch(e){
		return true;
	}
}
/** if empty eval(str) returns def value
 * 	if not returns eval(str) */
function eed(str,def){
	if(ee(str)){
		return def;
	}
	else{
		return eval(str);
	}
}
function is_http(txt){
	return strtolower(txt.substring(0,4)) == "http";
}
function gup( name )
{
	name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
	var regexS = "[\\?&]"+name+"=([^&#]*)";
	var regex = new RegExp( regexS , "i");
	var results = regex.exec( window.location.href );
	if( results == null )
		return "";
	else
		return results[1];
};
function get_obj(obj_id){
	return document.getElementById(obj_id);
}
//include_css("css/gen.css");
include_css("css/general.css");
add_helper_scripts(map_mode);
//var scripts = document.getElementsByTagName('script');dmp(scripts,3);//document.styleSheets
function strtolower( str ) {
	return (str+'').toLowerCase();
}
function getfileextension(filename)
{
	//var fileinput = document.getElementById("foo");
	// if(!fileinput ) return "";
	// var filename = fileinput.value;
	if( filename.length == 0 ) return "";
	var dot = filename.lastIndexOf(".");
	if( dot == -1 ) return "";
	var extension = filename.substr(dot+1,filename.length);
	return extension;
}
function helper(){
	this.lang = "he";
	this.map = null;
	this.route = null;
	this.create_map = true;
	this.pj = "LatLong";
	this.set_map = function(map){
		this.map = map;
	}
	this.get_map = function(){
		return this.map;
	}
	this.set_route = function(route){
		this.route = route;
	}
	this.get_route = function(){
		return this.route;
	}
	this.menu_on_map = true;
	this.writeMap = function(pour_map){
		var mo_dis = "display:none;";
		//if(empty(eed('atlasmap_menu["on_map"]',true)))
		if(!this.menu_on_map)
			mo_dis = "";
		//var on_map = eed('atlasmap_menu["on_map"]',true);
		//on_map
		//alert(mo_dis);

		var as_txt = "";
		if(pour_map){
			as_txt = '<div id=containerDiv style="z-index: 1050; position: absolute;float:right;"><div id="objid" style="overflow: hidden; direction: rtl; position: absolute; top: -1px; left: 0px; height: 0px; background-color: rgb(255, 255, 255);z-index:1060;border:#65AAEF 1px solid;"></div></div>';
		}
		document.write("<div id='helper_main'><div><span id='map_wrapper'><span id='map_overlays' style='"+mo_dis+"'></span><div id='main_map'>");
		if(pour_map){
			document.write("<div>");
			this.map.writeMap();
			document.write("</div>");
			}
		document.write("<div id=map_rights></div></div><span id='messages_layer'></span></span></div></div><div id=hdebug></div><div style='float:left;height:1px;overflow_:hidden;'>"+as_txt+"<div id=wrapper></div></div>");
		if(this.print_mode)
			document.write("<div id='print_box'></div>");
	}
	this.get_print_html = function(){
		var rHtml;
		if(translate.getInst().isHebrew()){
		rHtml =
			'<div class="NonPrintable">'+
			'<hr width="560px;" />'+
			'	<button style="width: 100px;" id="close_btn" onclick="window.close()"><span dir="rtl">'+this.translate("Close")+'</span></button>'+
			'	&nbsp;	&nbsp;	&nbsp;	&nbsp;'+
			'	<button style="width: 100px;" id="print_btn" onclick="print_page()"><span dir="rtl">'+this.translate("Print")+'</span></button>'+
			'<hr width="560px;" />'+
			'</div>'+
			'<div style="margin:20px;">'+
			'	<div  id="origin"></div><div id="dest"></div>'+
			'</div>'+
			'<div id="routeDescDiv"></div>';
		}
		else{
		rHtml =
			'<div class="NonPrintable">'+
			'<hr width="560px;" />'+
			'	<button style="width: 100px;" id="print_btn" onclick="print_page()"><span dir="rtl">'+this.translate("Print")+'</span></button>'+
			'	&nbsp;	&nbsp;	&nbsp;	&nbsp;'+
			'	<button style="width: 100px;" id="close_btn" onclick="window.close()"><span dir="rtl">'+this.translate("Close")+'</span></button>'+
			'<hr width="560px;" />'+
			'</div>'+
			'<div style="margin:20px;">'+
			'	<div  id="origin"></div><div id="dest"></div>'+
			'</div>'+
			'<div id="routeDescDiv"></div>';
		}
		return rHtml;
	}
	this.get_lang = function(){
		return translate.getInstance().get_lang();
	}
	this.set_lang = function(lang){
		return translate.getInstance().set_lang(lang);
	}
	this.translate = function(txt){
		return translate.getInst().get(txt);
	}
	this.get_rights = function(){
		if(!this.create_map) return "";
		var map = this.get_map();
		var rights;
		var width = map.width;
		if(translate.getInst().isHebrew()){
			rights = '<table  class="center_" id=rights border="0" dir=rtl cellpadding="0" cellspacing="0" Width="'+width+'">'+
			'<tr>'+
			'<td width="10"></td>'+
			'<td id="tdLnk1" class="textD">&nbsp‏<a href="http://www.abmaps.co.il" class="links" target="_blank" title="מפות">מפות</a>&nbsp;©&nbsp;<a href="http://www.atlasct.co.il" class="links" target="_blank">אטלס סי.טי.</a> בע"מ.</td>'+			
			'<td id="tdLnk2" class="textD" height="21" width="64" style="display_:none;">&copy;&nbsp;<a href=\'http://www.gisrael.co.il\' class=\'links\' target="_blank" style="color:#5b8bd5">&#1502;&#1508;&#1492;</a> &#1489;&#1506;"&#1502;. </td>'+
			'<Td style="width:2px"></Td>'+
			//'<td id="tdLnk1" class="textD" width="100" style="display_:none;">&copy;&nbsp;<a href="http://www.atlasct.co.il" id="lnkAtlas" class="links" target="_blank" style="color:#5b8bd5">&#8207;&#1488;&#1496;&#1500;&#1505;.&#1505;&#1497;.&#1496;&#1497;</a> &#1489;&#1506;"&#1502;. &nbsp; </td>'+
			'<td id="space1" width="'+(width-370)+'" style="xdisplay:none"></td>'+
			'<Td style="width:2px"></Td>'+
			'<td align="left" class="textD" width="23"><a href="http://www.atlasct.co.il/legend/" onclick="return openTermsOfUseWindow(this, \'Legend\',220,480,\'\')" class="links" style="color:#5b8bd5">&#8207;&#1502;&#1511;&#1512;&#1488;</a></td>'+
			'<td style="width:10px" align="center" valign="middle" style="font-size:8px;vertical-align:middle;margin:auto;padding-top:5px;"><div style="width:1px;height:10px;background-color:black;margin-top:5px;"></div></Td>'+
			'<td align="right" style="xpadding-left:3px" class="textD" width="100"><a href="http://www.atlasct.co.il/TermsOfUse.html" id="lnkTermsOfUse" class="links" onClick="return openTermsOfUseWindow(this, \'TermsOfUse\',800,480,\'scrollbars=yes,\')" style="color:#5b8bd5">&#1514;&#1504;&#1488;&#1497; &#1513;&#1497;&#1502;&#1493;&#1513; - &#1502;&#1508;&#1493;&#1514;</a></td>'+
			'<td id="space2" width="1" style="xdisplay:none"></td>'+
			'<td width="10"></td>'+
			'</tr>'+
			'</table>';
		}
		else{
			rights = '<table  class="center_" id=rights border="0" dir=ltr cellpadding="0" cellspacing="0" Width="'+width+'">'+
			'<tr>'+
			'<td width="10"></td>'+
			'<td id="tdLnk1" class="textD" width="101">&nbsp‏<a class="links" id="lnkAtlas" href="http://www.abmaps.co.il" class="links" target="_blank" title="Maps" style="color:#5b8bd5">Maps</a>&nbsp;©&nbsp;<a href="http://www.atlasct.com" id="lnkAtlas" class="links" target="_blank" style="color:#5b8bd5">AtlasCT</a> Ltd.&nbsp </td>'+			

			//'<td id="tdLnk1" class="textD" width="81">&copy; <a href="http://www.atlasct.com" id="lnkAtlas" class="links" target="_blank" style="color:#5b8bd5">AtlasCT</a> Ltd.&nbsp </td>'+
			'<td id="tdLnk2" class="textD" height="21" width="84">&copy; <a href=\'http://www.navteq.com/\' class=\'links\' target="_blank" style="color:#5b8bd5">NAVTEQ</a> Ltd.&nbsp </td>'+
			//'<td id="tdLnk2" class="textD" height="21" width="64">&copy; <a href=\'http://www.gisrael.co.il/eng/\' class=\'links\' target="_blank" style="color:#5b8bd5">Mapa</a> Ltd.&nbsp </td>'+
			'<Td style="width:2px"></Td>'+
			'<td id="space1" width="'+(width-370)+'" style="xdisplay:none"></td>'+
			'<Td style="width:2px"></Td>'+
			'<td align="right" class="textD" width="17" style="color:#5b8bd5;border:#000 0px solid;padding:0px;text-align:right!important;"><a href="http://www.atlasct.com/legend/" onclick="return openTermsOfUseWindow(this, \'Legend\',220,480,\'\')" class="linksss" style="color:#5b8bd5;border:#000 0px solid;float:right;margin:0px;">Legend</a></td>'+
			'<td style="width:10px" align="center" valign="middle" style="font-size:8px;" height="5px"><div style="width:1px;height:10px;background-color:black;margin-top:5px;"></div></Td>'+
			//'<td align="left" style_="__xpadding-leftd:3px;border:#000 0px solid;" class="textD" width="120px" style="padding-left:0px!important;padding-left:6px;"><a href="http://www.atlasct.co.il/TermsOfUse.html" id="lnkTermsOfUse" class="links" onClick="return openTermsOfUseWindow(this, \'TermsOfUse\',800,480,\'scrollbars=yes,\')" style="color:#5b8bd5;">Maps - terms of use</a></td>'+
			'<td align="left" style_="__xpadding-leftd:3px;border:#000 0px solid;" class="textD" width="120px" style="padding-left:0px!important;padding-left:6px;"><a href="http://www.atlasct.com/Terms_of_Service.html" id="lnkTermsOfUse" class="links" onClick="return openTermsOfUseWindow(this, \'TermsOfUse\',800,480,\'scrollbars=yes,\')" style="color:#5b8bd5;">Maps - terms of use</a></td>'+
			'<td id="space2" width="1" style="xdisplay:none"></td>'+
			'<td width="10"></td>'+
			'</tr>'+
			'</table>';
		}
		return rights;
	}
	//encodeURI(URI)
	//decodeURI(encodedURI)
	this.menus_start = false;
	this.print_mode = false;
	this.menus = function(type,skin){
	var lang = "eng";
	if (isset("atlasmap")){
		if(!empty(atlasmap["lang"])){
			lang = atlasmap["lang"];
		}
	}
	if(!empty(atlasmap["settingsRequest"])){
		translate.getInst().settingsRequest = atlasmap["settingsRequest"];
	}
		if(!empty(atlasmap["menu_width"])){
			menus.getInst().menu_width = parseInt(atlasmap["menu_width"]);
		}
		var uri_lang = null;
		if(empty( map_mode)){
			var uri_inst = uri.getInst();
			if (!empty(uri.getInst().get("lang")))
				lang = uri.getInst().get("lang");
			var uri_lang = uri_inst.get("lang");
		}
		if(empty(uri_lang))
			uri_lang = lang;
		uri_lang = lang;
		//alert(444);
		////###if(empty( map_mode)){}
		//alert(uri_lang);
		translate.getInst().set_lang(uri_lang);


		var x,y,sp,nav_type;
		var drag_x,drag_y;
		nav_type=eed('atlasmap["nav_bar"]["type"]',1)
		var uri_inst = uri.getInst();
		var map = this.get_map();
		var trans = translate.getInst();
		var isHeb = trans.isHebrew();
		var menu_inst = menus.getInst();
		menu_inst.sla = true;
		if(isHeb){
			x = eed('atlasmap["nav_bar"]["x"]',0);
			y = eed('atlasmap["nav_bar"]["y"]',5);
			drag_x = eed('atlasmap["drag_bar"]["x"]',80);
			drag_y = eed('atlasmap["drag_bar"]["y"]',30);
		}
		else{
			x = eed('atlasmap["nav_bar"]["x"]',map.width-80);
			y = eed('atlasmap["nav_bar"]["y"]',5);
			drag_x = eed('atlasmap["drag_bar"]["x"]',map.width-140);
			drag_y = eed("atlasmap['drag_bar']['y']",30);
		}
		sp = new ScreenPoint(x,y);
				if(!ee('atlasmap["nav_bar"]["src"]')){
					map.addFlashOverlayToScreen(x, y, atlasmap["nav_bar"]["src"]);
					map.addListener("ModeChanged", function onModeChanged(sender,mode){
										  switch (mode.toLowerCase()){
												case "drag":
													map.setMode(Map.MODE_PAN)
												break;
												case "zoom":
													map.setMode(Map.MODE_ZOOM_IN)
												break;
												case "measure":
													map.setMode(Map.MODE_MEASURE_EX)
													var layersManager = map.getLayersManager();
													layersManager.clearMeasureEx();
												break;
										  }
									  });
				}
				else{
					switch(nav_type+""){
						case "1":
							map.addAdvancedNavigationBar(sp);
							break
						case "2":map.addDefaultNavigationBar(sp);
							break
						default:
							break;
					}
		}
		if(!ee('atlasmap["drag_bar"]')){
			map.addDragBar(new ScreenPoint(drag_x,drag_y));
		}
		var address_sla = false;
		if(isset("helpers_address_sla"))
			address_sla=helpers_address_sla;
		else{
			if (uri_inst.get("sla"))
				address_sla = true;
			else
				address_sla = false;
		}

		/*
		if(isset("atlasmap_menu_on_map"))
			menu_inst.on_map = atlasmap_menu_on_map;//true;
		menu_inst.on_map = eed('atlasmap_menu["on_map"]',menu_inst.on_map);
		if(map_mode == "weather")
			menu_inst.on_map = false;
		*/

		menu_inst.on_map = this.menu_on_map;
		//fix_uri
		menu_inst.fix_uri = eed('atlasmap["fix_uri"]',menu_inst.fix_uri);
		menu_inst.fix_uri = eed('atlasmap_menu["fix_uri"]',menu_inst.fix_uri);
		//alert(menu_inst.on_map);
		menu_inst.collapse_button = menu_inst.on_map;
		//this.menu_on_map = false;// menu_inst.on_map;
		if(isset("atlasmap_collapse_button"))
			menu_inst.collapse_button = atlasmap_collapse_button;//true;
		address_sla = true;
		menu_inst.sla = address_sla;

		if(isset("atlasmap_address")){
			var address_inst = address_menu.getInst();
			address_inst.collapse_button = menu_inst.collapse_button;
			address_inst.add_address_search(atlasmap_address);
		}
		if(isset("atlasmap_route")){
			var route_menu_inst = route_menu.getInst();
			route_menu_inst.add_address_search(atlasmap_route);
		}

		if(!ee('atlasmap_poi'))
			poi.getInst().add(atlasmap_poi);
		if(!empty(uri_inst.get("more")))
			menu_inst.add_menu_item_html("<div><img src='http://www.abmaps.co.il/Images/Top/trips_off_over.he.png' />"+
				"<img src='http://www.abmaps.co.il/Images/Top/maps_on.he.png' /></div>"+
				"<img src='http://www.abmaps.co.il/Images/Top/friends_off_over.he.png' /></div>");
		if(isset("helper_logo_location"))
			if(!empty(helper_logo_location))
				add_logo(helper_logo_location,helper_logo_pos_x,helper_logo_pos_y,helper_logo_link,helper_logo_title);
		if(isset("helper_target_icon"))
			if(!empty(helper_target_icon))
				home.getInst().change_icon(helper_target_icon);
		//var icon_url = "images/ajax-loader_circle.gif";
		get_obj("map_rights").innerHTML = help_inst.get_rights();
		if(this.print_mode)
			get_obj("print_box").innerHTML = help_inst.get_print_html();
		//map.addAdvancedNavigationBar(new ScreenPoint(10,0));
		// onload section
		if (isset("on_init_helper"))
			on_init_helper();
		if(!ee('atlasmap["onload"]')){
		//alert(atlasmap["onload"]);
			var atm_onload = atlasmap["onload"];
			var func;
			if(typeof(atm_onload) == "string"){
					func = atm_onload;
					if(func.indexOf("(") == -1)
						func += '()';
					try{
						eval(func);
					}
					catch(e){
					}
			}
			else{
				for (var i in atm_onload ){
					func = atm_onload[i];
					if(func.indexOf("(") == -1)
						func += '()';
					try{
						eval(func);
					}
					catch(e){
					}
				}
			}
		}
		if(this.print_mode){
			var pinst=print_map.getInst();
			pinst.start__();
		}
	// skin: blue
	// types: basic addvanced
		/**/
		//alert(3);
		if(map_mode != "weather")
			setTimeout("on_load.getInst().start();",100);
			//setTimeout("on_load.getInst().apply_uri();",100);
			//on_load.getInstance().apply_uri();
		/**/

	}
};
/* singleton */
helper.instance = null;
helper.getInst = function() {
	if (helper.instance == null) {
		helper.instance = new helper();
	}
	return helper.instance;
}
helper.getInstance = helper.getInst;
/* singleton */
helper.start = function(__map){
	var help_inst = this.getInst();
	include_once("js/sdk/NewRemoteVectorLayer.js");
	if(map_mode != "weather"){	
		var divi = document.createElement("div");
		var inpt = document.createElement("input");
		var citySAutoSuggest_null_ = new hprAutoSuggest(inpt,null,divi);
	}
	var uri_css = "";
	if(empty(map_mode)){
		uri_css = gup("css")
	}
	if(!empty(uri_css)){
		//alert(reletive_path+uri_css);
		include_css(uri_css);
		}
	else
	{
		if(isset("helper_css_link"))
			include_css(helper_css_link);
		if(isset("atlasmap_css"))
			include_css(atlasmap_css);
	}
	var width=700;
	var height=400;
	var map;
	if(isset("atlasmap")){
		if(!empty(atlasmap["width"])){
			width = parseInt(atlasmap["width"]);
		}
		//if(empty(eed('atlasmap["on_map"]',true)))
		help_inst.menu_on_map = eed('atlasmap["on_map"]',true);
		if(isset("atlasmap_menu_on_map"))
			help_inst.menu_on_map = atlasmap_menu_on_map;//true;
		help_inst.menu_on_map = eed('atlasmap_menu["on_map"]',help_inst.menu_on_map);

		//alert(map_mode);
		if(map_mode == "weather")
			help_inst.menu_on_map = false;

		//if(!this.menu_on_map)

		//alert(eed('atlasmap["on_map"]',true))

		if(!empty(atlasmap["skin"])){
			include_css("css/themes/"+atlasmap["skin"]+".css");
			//include_css("css/themes/pink.css");
			//width = parseInt(atlasmap["skin"]);
		}

		if(!empty(atlasmap["height"])){
			height = parseInt(atlasmap["height"]);
		}
	}
	var pour_map = false;
	if(empty(__map)){
		if (isset("helper_map_width"))
			width = helper_map_width;
		if (isset("helper_map_height"))
			height = helper_map_height;
		map = new Map(width,height);
		pour_map = true;
		help_inst.create_map = true;
	}
	else{
		help_inst.create_map = false;
		map = __map;
	}
	if(isset("atlasmap_print_mode")){
		//if(atlasmap_print)
		help_inst.print_mode = true;
	}
	if(!empty(atlasmap["pj"])){
		help_inst.pj = atlasmap["pj"];
	}
	help_inst.set_map(map);
	help_inst.writeMap(pour_map);
	this.getInstance().set_map(map);
	var route = this.getInst().get_route();
	if(empty(route)){
		route = new Route();
		this.getInst().set_route(route);
	}
	if(pour_map){
		//alert(3);
		map.addListener(Flash.EVENT_FLASH_INITIALIZE,helper.onmapload,map);
		//setTimeout("helper.onmapload();",5000);
		}
	else
		setTimeout("helper.onmapload();",1000);
	map.addListener(Map.EVENT_GEO_RESULT,helper.ongeocode,map);
	route.addListener(Route.EVENT_ROUTE_RESULT,helper.onroute,route);
};
helper.onmapload = function(event){
	if(!isset("poi")){/** /setTimeout("helper.onmapload();",500);	return;	/**/}
	if(empty(get_obj("map_rights"))){/** /setTimeout("helper.onmapload();",500);	return; /**/}
	if(!isset("NewRemoteVectorLayer")){/**/setTimeout("helper.onmapload();",500);	return;	/**/}
	if(!isset("autoSuggestFlash")){/** /setTimeout("helper.onmapload();",500); return;	/**/}
	//AutoSuggest.class_type
	//if (dmode())		alert(poi);
	//help_inst = helper.getInst();
	help_inst = helper.getInst();
	if(help_inst.menus_start) 
		return;
	help_inst.menus_start = true;
	var uri_inst = uri.getInst();
	var map = help_inst.get_map();
	/*
	if(map_mode != "weather")
		on_load.getInstance().apply_uri();
	*/
	//menus.getInstance().apply_menus();
	if (!empty(uri_inst.get("kml")))
		kml.getInst().load(uri_inst.get("kml"));
	if(isset("atlasmap_target_icon"))
		if(!empty(atlasmap_target_icon)){
			if(!empty(atlasmap_target_icon["url"])){
				var x_offset = -(parseInt(atlasmap_target_icon["width"])/2);
				var y_offset = -(parseInt(atlasmap_target_icon["height"])/2);
				home.getInst().change_icon(atlasmap_target_icon["url"],x_offset,y_offset);
			}
		}
	if(isset("helper_weather"))
		if(!empty(helper_weather)){
			map.addListener(Map.EVENT_MAP_SMOOTH_ZOOM,add_weather_js,map);
			map.addListener(Map.EVENT_MAP_DRAG_END,add_drag_weather,map);
		}
	try{
		addCSS(
		  {
		  ".route_length":"display:none;"
		  //,		  "#abc":"border:#000 1px solid;"
		  }
		);
	}
	catch(e){
		document.styleSheets[0].addRule(".route_length","display:none;");
	}
	help_inst.menus(1,"blue");
};
helper.ongeocode = function(map,geo){
	if(map_mode == "weather")
		return;
	//menus.getInstance().ongeocode(map,geo);
	address_menu.getInstance().ongeocode(map,geo);
};
helper.onroute = function(route,r){
	if(map_mode == "weather")
		return;
	route_menu.getInst().onroute(route);
}
function pour_sdk(){
	var key = "";
	if (isset("atlasmap_key")) key = atlasmap_key;
	if (isset("helper_map_key")) key = helper_map_key;
	if(!empty(gup("map_key"))) key = gup("map_key");
	var lang,param_lang;
	lang = eed("atlasmap['lang']","");
	if(empty(lang))
		param_lang = "";
	else
		param_lang = "&GuiLang="+lang;
	if(!ee("sdk_params")) param_lang += sdk_params;
	var sdk_loc = "http://api.atlasct.co.il/sdk_v3_2/";
	if(!ee("sdk_lib")) sdk_loc = sdk_lib;
	//alert(eed("atlasmap['lang']",""));
	//document.write("<script type=\"text/javascript\" src=\"http://api.atlasct.co.il/sdk_v3_2/?key="+key+param_lang+"\"></script>");
	//alert(sdk_loc+"?key="+key+param_lang);
	document.write("\r\n<script type=\"text/javascript\" src=\""+sdk_loc+"?key="+key+param_lang+"\"></script>\r\n");
	//document.write("\r\n<script type=\"text/javascript\" src=\""+sdk_loc+"?key="+key+param_lang+"\"></script>\r\n");
	var helper_as = reletive_path+"js/sdk/AutoSuggest.js";
	document.write("<script type=\"text/javascript\" src=\""+helper_as+"\"></script>");
	//include_once("js/sdk/AutoSuggest.js");AutoSuggest.class_type
};
function add_helper_scripts(map_mode){
	var helper_files = reletive_path+"js/append.php";
	if(!empty(map_mode))
		helper_files += "?type="+map_mode;
	//include_once(helper_files);
	document.write("<script type=\"text/javascript\" src=\""+helper_files+"\"></script>");
};
//document.write ("\r\n<head>\r\n");
if(add_sdk)	pour_sdk();
//document.write ("\r\n</head>\r\n<body></body>\r\n");