	var map,timer;
	var categories=[];
	var currentcategory="null";
	var gmarkers=[];
	var markerloaded=false;
	var categoryloaded=false;
	var getdirectionspage = false;
	var wikipedialink = "";
	var layers = [];
	
	var StreetViewclient=null;
	var myPano = null;
	var guymarker = null;
	var panopoint=null;
	var svOverlay = null;
	var guyIcon;
	var chosen = [];
	var filename = '';

function fisheyebind(){
//jQuery('#fisheye2').Fisheye(
//				{
//					maxWidth: 60,
//					items: 'a',
//					itemsText: 'span',
//					container: '.fisheyeContainter',
//					itemWidth: 40,
//					proximity: 80,
//					alignment : 'left',
//					valign: 'bottom',
//					halign : 'center'
//				}
//			)
}
function bindtabevents(language){
jQuery("li")
    .filter("#images")
	  .click(function(){
		jQuery("#tabcontent").slideUp("slow");
		loadtab('images',linkid);
		jQuery("#tabcontent").slideDown('slow',function callback() {
  fisheyebind();
});
     })
   .end()
   .filter("#multimedia")
     .click(function(){
		jQuery("#tabcontent").slideUp("slow");
		loadtab('multimedia',linkid);
		jQuery("#tabcontent").slideDown('slow',function callback() {
  fisheyebind();
});
     })
   .end()
      .filter("#panorama")
     .click(function(){
		jQuery("#tabcontent").slideUp("slow");
		loadtab('panorama',linkid);
		jQuery("#tabcontent").slideDown('slow',function callback() {
  fisheyebind();
});
     })
   .end()
    .filter("#msmap")
     .click(function(){
		jQuery.getScript("http://dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6.1&mkt="+language, function(){
			jQuery("#tabcontent").slideUp("slow");
			loadtab('msmap',linkid);
				jQuery("#tabcontent").slideDown('slow',function callback() {
					fisheyebind();
				});
		});
     })
   .end()
   ;
}
function bindtabeventspopup(language){
jQuery("li")
    .filter("#images")
	  .click(function(){
		jQuery("#tabcontent").slideUp("slow");
		loadtab('images',linkid);
		jQuery("#tabcontent").slideDown('slow',function callback() {
  
});
     })
   .end()
   .filter("#multimedia")
     .click(function(){
		jQuery("#tabcontent").slideUp("slow");
		loadtab('multimedia',linkid);
		jQuery("#tabcontent").slideDown('slow',function callback() {
  
});
     })
   .end()
      .filter("#panorama")
     .click(function(){
		jQuery("#tabcontent").slideUp("slow");
		loadtab('panorama',linkid);
		jQuery("#tabcontent").slideDown('slow',function callback() {
  
});
     })
   .end()
    .filter("#msmap")
     .click(function(){
		jQuery.getScript("http://dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6.1&mkt="+language, function(){
			jQuery("#tabcontent").slideUp("slow");
			loadtab('msmap',linkid);
				jQuery("#tabcontent").slideDown('slow',function callback() {
					
				});
		});
     })
   .end()
   ;
}
function dhtmlLoadScript(url){
   var e = document.createElement("script");
   e.src = url;
   e.type="text/javascript";
   document.getElementsByTagName("head")[0].appendChild(e);
}

function loadtab(tabname,lid) {
setcurrenttab(tabname);

if (tabname=='images'){
	xajax_loadimages(lid);
	return true;
}
if (tabname=='multimedia'){
	xajax_loadmultimedia(lid);
	return true;
}
if (tabname=='panorama'){
	xajax_loadpanorama(lid);
	return true;
}
if (tabname=='msmap'){
	xajax_loadmsmap(lid);
	return true;
}
return false;
}

function loadedittab(tabname,lid) {
setcurrenttab(tabname);
//alert(tabname);
//alert(lid);
if (tabname=="images"){
	xajax_loadimagesedit(lid);
	
}
if (tabname=="multimedia"){
	xajax_loadmultimediaedit(lid);
	
}
if (tabname=='panorama'){
	xajax_loadpanoramaedit(lid);
	
}
if (tabname=='mapinfo'){
	xajax_loadgmap(lid);
	
}
return false;
}
function updatemaploc(loc,showsublocations) {
	showloading();
if(showsublocations==true){
	xajax_loadsublocationarea(loc);
	}
	xajax_updatearea(loc);

	return true;
}
function setcurrenttab(tabname){
	jQuery("#"+currenttab).addClass("tab");
	currenttab=tabname;
	jQuery("#"+currenttab).removeClass("tab");	
	jQuery("#"+currenttab).addClass("selectedtab");	
}
function checkstring(string,field) {
var check = string.indexOf("'");
if(check>-1){
	if(field=="adress_el" || field=="adress_eng" || field=="description_el" || field=="description_eng" || field=="description_eli" || field=="description_engl" || field=="keywords_el" || field=="keywords_eng" ){string=string.replace(/'/,'&#39;')}
	
else{
	string=string.replace(/'/,'')
	}
document.getElementById(field).value=string;
//alert(string+'sdfsd');
//return string;
}

}	

function loadmap(lat,lon,zoom,type) {
	 
	if (getdirectionspage==true){
		map = new GMap2(document.getElementById("mainmap"), {draggableCursor:"crosshair"}); 
		map.enableContinuousZoom();

	  }
	  else {		
	  map = new GMap2(document.getElementById("mainmap"));
	  layers = [
			 { name: "Pano", obj: new GLayer("com.panoramio.all") },
			 { name: "Wiki", obj: new GLayer(""+wikipedialink+"") },
			 { name: "Streetview", obj: new GLayer("") }
		];
	  }
	  

		document.getElementById("mainmap").style.backgroundColor = "transparent";
		// set the controls
		
		var mapControl = new GHierarchicalMapTypeControl();
		mapControl.addRelationship(G_SATELLITE_MAP, G_HYBRID_MAP, "Labels", true);
		mapControl.addRelationship(G_NORMAL_MAP, G_PHYSICAL_MAP, "Terrain", false);
		map.addControl(new GLargeMapControl());
        //map.addControl(new GMapTypeControl());	//add terrain 
		map.addMapType(G_PHYSICAL_MAP);
		map.addMapType(G_SATELLITE_3D_MAP);
		
		map.addControl(mapControl);
		map.setCenter(new GLatLng(lat,lon), zoom);
		map.setMapType(type);
		map.checkResize();
		map.enableDoubleClickZoom();
		
	if (getdirectionspage==false){
		// ajout fleches de controle
		map.addControl(new MoreControl());
		map.addControl(new BoxControl());

		guyIcon = new GIcon(G_DEFAULT_ICON);
					guyIcon.image = "http://maps.google.com/intl/en_us/mapfiles/cb/man_arrow-0.png";
					  guyIcon.transparent = "http://maps.google.com/intl/en_us/mapfiles/cb/man-pick.png";
					  guyIcon.imageMap = [
							26,13, 30,14, 32,28, 27,28, 28,36, 18,35, 18,27, 16,26,
							16,20, 16,14, 19,13, 22,8
						 ];
					  guyIcon.iconSize = new GSize(49, 52);
					  guyIcon.iconAnchor = new GPoint(25, 35);  // near base of guy's feet
					  guyIcon.infoWindowAnchor = new GPoint(25, 5);  // top of guy's head
		
		StreetViewclient = new GStreetviewClient();
		//svOverlay = new GStreetviewOverlay();
		//map.addOverlay(svOverlay);

		GEvent.addListener(map,"click", function(overlay,latlng) {
			if(svOverlay !=null && !overlay){	
			StreetViewclient.getNearestPanoramaLatLng(latlng, NearestPan); 
			}				
		});
	
		}		
	return map;
	}
//check if there is a panorama
	function NearestPan(inPoint) {
               if (inPoint != null) 
				{
					  if(guymarker){map.removeOverlay(guymarker);}

					  guymarker = new GMarker(inPoint, {icon: guyIcon, draggable: false});
					  map.addOverlay(guymarker);
					  //GEvent.addListener(guymarker, "dragend", onDragEnd);
					  GEvent.addListener(guymarker, "click", openPanoramaBubble());
                }
				else {if(guymarker){map.removeOverlay(guymarker);}}
        } 
function openPanoramaBubble() {
	
   var contentNode = document.createElement('div');
  contentNode.style.textAlign = 'center';
  contentNode.style.width = '500px';
  contentNode.style.height = '300px';
  contentNode.innerHTML = 'Loading panorama';

  var smallNode = document.createElement('div');
  smallNode.style.width = '500px';
  smallNode.style.height = '300px';
  smallNode.id = 'pano';
  guymarker.openInfoWindow(smallNode); 

  myPano = new GStreetviewPanorama(smallNode);
  myPano.setLocationAndPOV(guymarker.getLatLng(), null);
  GEvent.addListener(myPano, "error", handleNoFlash);
 
  GEvent.addListener(myPano, "initialized", function(call) {
	panopoint = call.latlng;
	onNewLocation(call.latlng);
  });
  //GEvent.addListener(myPano, "newpano", onNewLocation);
  GEvent.addListener(myPano, "yawchanged", onYawChange);
   /* var iw = map.getInfoWindow();
  GEvent.addListener(iw, "maximizeend", function() {
    myPano.setContainer(contentNode);  
    window.setTimeout("myPano.checkResize()", 5);
  });  */
}
function onYawChange(newYaw) {
  var GUY_NUM_ICONS = 16;
  var GUY_ANGULAR_RES = 360/GUY_NUM_ICONS;
  if (newYaw < 0) {
    newYaw += 360;
  }
  guyImageNum = Math.round(newYaw/GUY_ANGULAR_RES) % GUY_NUM_ICONS;
  guyImageUrl = "http://maps.google.com/intl/en_us/mapfiles/cb/man_arrow-" + guyImageNum + ".png";
  guymarker.setImage(guyImageUrl);
}
function onNewLocation(point) {
  guymarker.setLatLng(new GLatLng(point.y,point.x));
}

//toggle streetview
function toggleOverlay() {
	if (!svOverlay) {
		svOverlay = new GStreetviewOverlay();
		map.addOverlay(svOverlay);
	 } 
	else {
		map.removeOverlay(svOverlay);
		svOverlay = null;
		if(guymarker){
			map.removeOverlay(guymarker);
		}
		
	}
}
//if the angle change

 function handleNoFlash(errorCode) {
      if (errorCode == 603) {
        alert("Error: Flash doesn't appear to be supported by your browser");
        return;
      }
    }  

	function updatemap(lat,lon,zoom,type) {

        map.setCenter(new GLatLng(lat,lon), zoom);
		//map.setMapType(type);
	}
	
	function loadsubmitmap(lat,lon,zoom,type) {
	
	loadmap(lat,lon,zoom,type);

	
	var marker = new GMarker(new GLatLng(lat,lon),{draggable:true});
	map.addOverlay(marker,{draggable:true});
	
	// listener for when dragging the marker
	GEvent.addListener(marker, "dragend", function(overlay, point){
	map.panTo(marker.getPoint());
	document.getElementById("lat").value = marker.getPoint().lat();
	document.getElementById("lon").value = marker.getPoint().lng();});
	
	//listener for when clicking on the map
	GEvent.addListener(map, "click", function(overlay, point){
	map.clearOverlays();	
	if (point) {
	var marker = new GMarker(new GLatLng(point.y,point.x),{draggable:true});
	marker.lat = point.y;
	marker.lon = point.x;	
	map.addOverlay(marker);			
	GEvent.addListener(marker, "dragend", function(){
	map.panTo(marker.getPoint());
	document.getElementById("lat").value = marker.getPoint().lat();
	document.getElementById("lon").value = marker.getPoint().lng();	});
	map.panTo(marker.getPoint());
	document.getElementById("lat").value = marker.lat;
	document.getElementById("lon").value = marker.lon;
	document.getElementById("zoom").value = map.getZoom();}	});
	
	
	//event for when zooming the map
	GEvent.addListener(map, "zoomend", function(overlay, marker){
	document.getElementById("zoom").value = map.getZoom();});
	
	return map;
	}
	
	function toggleMarker(catid,location) {

if (location=='null' || location==null || location=='' ){	
  
   if (document.getElementById(catid).checked==false) { // hide the marker
      for (var i=0;i<gmarkers.length;i++) {
         if (gmarkers[i].cid==catid || gmarkers[i].pid==catid )  {
		
      map.removeOverlay(gmarkers[i]);
         }
      }
   } 
   else { // show the marker again
      for (var i=0;i<gmarkers.length;i++) {
         if (gmarkers[i].cid==catid || gmarkers[i].pid==catid )  {
             map.addOverlay(gmarkers[i]);
         }
      }
   }
   }
 else {
 if (document.getElementById(catid).checked==false) { // hide the marker
      for (var i=0;i<gmarkers.length;i++) {
         if (gmarkers[i].cid==catid || gmarkers[i].pid==catid)  {
			
			if (gmarkers[i].locid==location)  {   map.removeOverlay(gmarkers[i]);}
         }
      }
   } 
   else { // show the marker again
      for (var i=0;i<gmarkers.length;i++) {
         if (gmarkers[i].cid==catid || gmarkers[i].pid==catid)  {
             if (gmarkers[i].locid==location)  {   map.addOverlay(gmarkers[i]);}
         }
      }
   }
 }  
   
}
	
	function toggleMarkers(catid,location,checked) {
	 if (location=='null' || location==null || location=='' ){	
  //map.getInfoWindow().hide() 
   if (checked==false) { // hide the marker
      for (var i=0;i<gmarkers.length;i++) {
         if (gmarkers[i].cid==catid || gmarkers[i].pid==catid )  {
		
      map.removeOverlay(gmarkers[i]);
         }
      }
   } else { // show the marker again
      for (var i=0;i<gmarkers.length;i++) {
         if (gmarkers[i].cid==catid || gmarkers[i].pid==catid )  {
             map.addOverlay(gmarkers[i]);
         }
      }
   }
   }
 else {
 if (checked==false) { // hide the marker
      for (var i=0;i<gmarkers.length;i++) {
         if (gmarkers[i].cid==catid || gmarkers[i].pid==catid)  {
			if (gmarkers[i].locid==location || gmarkers[i].locpid==location)  {   map.removeOverlay(gmarkers[i]);}
			
         }
      }
   } else { // show the marker again
      for (var i=0;i<gmarkers.length;i++) {
         if (gmarkers[i].cid==catid || gmarkers[i].pid==catid)  {
             if (gmarkers[i].locid==location || gmarkers[i].locpid==location)  {   map.addOverlay(gmarkers[i]);}
         }
      }
   }
 }  
   
}
	function toggleoneCat(catid,location,checked) {
	 if (location=='null' || location==null || location=='' ){	
  //map.getInfoWindow().hide() 
   if (checked==false) { // hide the marker
      for (var i=0;i<gmarkers.length;i++) {
         if (gmarkers[i].cid==catid  )  {
		
      map.removeOverlay(gmarkers[i]);
         }
      }
   } else { // show the marker again
      for (var i=0;i<gmarkers.length;i++) {
         if (gmarkers[i].cid==catid )  {
             map.addOverlay(gmarkers[i]);
         }
      }
   }
   }
 else {
 if (checked==false) { // hide the marker
      for (var i=0;i<gmarkers.length;i++) {
         if (gmarkers[i].cid==catid )  {
			if (gmarkers[i].locid==location || gmarkers[i].locpid==location)  {   map.removeOverlay(gmarkers[i]);}
			
         }
      }
   } else { // show the marker again
      for (var i=0;i<gmarkers.length;i++) {
         if (gmarkers[i].cid==catid )  {
             if (gmarkers[i].locid==location || gmarkers[i].locpid==location)  {   map.addOverlay(gmarkers[i]);}
         }
      }
   }
 }  
   
}	
	function toggleMarkerOn(id) {

      for (var i=0;i<gmarkers.length;i++) {
		 if (gmarkers[i].lid==id)  {
			map.addOverlay(gmarkers[i]);}
         
      }
   } 
	
	function toggleMarkerOff(id) {

      for (var i=0;i<gmarkers.length;i++) {
		 if (gmarkers[i].lid==id)  {
			map.removeOverlay(gmarkers[i]);}
         
      }
   } 
	
	function createMarkers(lat,lon,cid,pid,lid,tooltip,img,locid,locpid) {
		if(checkmarkersarray(lid)==false){
				var icon = new GIcon();
				icon.image = img;
				//icon.shadow = "";
				icon.iconSize = new GSize(30, 30);
				icon.shadowSize = new GSize(29, 30);
				icon.iconAnchor = new GPoint(30, 29);
				icon.infoWindowAnchor = new GPoint(30, 18);
				 
			// creation marker
			
		   	var marker = new GMarker(new GLatLng(lat,lon),{icon:icon, title:tooltip});
 
			marker.cid = cid; 
			marker.pid = pid; 
			marker.lid = lid; 
			marker.locid = locid; 
			marker.locpid = locpid; 
			GEvent.addListener(marker,"click", function() {
			filename = location.href.substring(location.href.lastIndexOf('/')+1);
			//alert(filename); 
			if(filename == "service.php")
				location.href="/modules/addresses/popup.php?cid="+marker.cid+"&lid="+marker.lid;	
			else 
				location.href="/modules/addresses/visit.php?cid="+marker.cid+"&lid="+marker.lid;
			});  
		
		gmarkers.push(marker);
		return marker;
		}
		
	else{
	return false;
	}

     }
	 
	 
	function loadsmallmap(lat,lon,zoom,type) {
	     map = new GMap2(document.getElementById("smallmap"));

		// keybord listener

		 new GKeyboardHandler(map);
		
		//add terrain 
		map.addMapType(G_PHYSICAL_MAP);
      	// ajout type de controle
		var mapControl = new GHierarchicalMapTypeControl();
		map.addControl(mapControl);
		
		// ajout fleches de controle

		map.addControl(new GSmallMapControl());

		map.setCenter(new GLatLng(lat,lon),zoom,type);

		map.setMapType(type);

		map.checkResize();

		// activation continous zoom

		map.enableContinuousZoom();

		// double click zoom

		map.enableDoubleClickZoom();
	return map;
	}
	 
    function clearallMarkers() {
	 
	 for (var i=0;i<gmarkers.length;i++) {
	
		map.removeOverlay(gmarkers[i]);
			 
      }
	 //gmarkers=[];
	 // return gmarkers;
	}

	function savelocation(location){
	if (location=='null'){
	locid = null;
	}
	else {
	locid = location;
	}
	}	
	
	function savecategory(categoryid){
	if (categoryid!='null'){
	
	checkCategoriesArray(categoryid);
	
		if (categoryloaded==false){
			categories.push(categoryid);
			}
	}

}

	function savecurrentcategory(categoryid){
	  currentcategory=categoryid;
}

	function checkmarkersarray(lid){
	
		for(q=0;q<gmarkers.length;q++){
			
			if (gmarkers[q].lid == lid){return true;
			break;}
		}
	return false;
}
  
	function checkCategoriesArray(catid){
	for (var i=0;i<categories.length;i++) {
		if (catid != categories[i]){
		categoryloaded=false;
		}
		else if (catid != categories[i] || catid==null){
		categoryloaded=true;
		}
	}
  }
  
	function visitCat(locid,cat,showthis,check){
	
	clearallMarkers();
	currentcategory=cat;
	categories=[];
	
	if(showthis==0 && cat=='null' && check==false){
	
	xajax_loadcategory(locid,null);
	//xajax.request( xajax_loadcategorymarkers(locid,cat,1,check), {mode:'asynchronous'});

	}
	else{

	xajax_loadcategory(locid,cat);
	xajax_loadonecategorymarkers(locid,cat,showthis,check);

}
 }
 
	function visitsubLocation(locid,cat,showthis,check){
		showloading();
		clearallMarkers();

	xajax_loadarea(locid);
	if(currentcategory!="null"){
	xajax_loadonecategorymarkers(locid,currentcategory,showthis,true);
}
	for (var i=0;i<categories.length;i++) {
			if (document.getElementById(categories[i]).checked==true){
				xajax_loadcategorymarkers(locid,categories[i],showthis,true);
		}
		else {
		toggleMarkers(categories[i],locid,false);
		}
	} 
	  return true;
}
	function visitmainLocation(locid,showthis,check){
	
	clearallMarkers();
	xajax_loadarea(locid);
	xajax_loadsubareas(locid);
	if(currentcategory!="null"){
	xajax_loadonecategorymarkers(locid,currentcategory,showthis,true);
}
	for (var i=0;i<categories.length;i++) {
			if (document.getElementById(categories[i]).checked==true){
				xajax_loadcategorymarkers(locid,categories[i],showthis,true);
		}
		else {
		toggleMarkers(categories[i],locid,false);
		}
	} 
	

		  return true;
}
  
function loadCatmarkers(loc,cat,showthis,check){
xajax_loadcategorymarkers(loc,cat,showthis,check);
}	
function showloading(){
	var oLMsg = document.getElementById('loading');

oLMsg.style.display='block';

	var oLMsg = document.getElementById('loading');
	//oLMsg.style.display = '';
	oLMsg.style.left = document.getElementById('mainmap').offsetLeft + (document.getElementById('mainmap').clientWidth / 2) - (oLMsg.clientWidth / 2) + 'px';
	oLMsg.style.top = document.getElementById('mainmap').offsetTop + (document.getElementById('mainmap').clientHeight / 2) - (oLMsg.clientHeight / 2) + 'px';
	oLMsg.style.filter="alpha(opacity=70)";

	
return true;
}
function hideloading(){
document.getElementById("loading").style.display="none";
//xajax.$('loading').style.display='none';
return true;
}
//functions for wiki and panoramio
function hideAll() {

 var boxes = document.getElementsByName("mark");

 for(var i = 0; i < boxes.length; i++) {
  if(boxes[i].checked) {
   boxes[i].checked = false;
   switchLayer(false, layers[i].obj);
   chosen.push(i);
  }
 }
 
}
function checkChecked() {

 /* Returns true if a checkbox is still checked
 *  otherwise false
 */
 var boxes = document.getElementsByName("mark");
 for(var i = 0; i < boxes.length; i++) {
  if(boxes[i].checked) return true;
 }
 return false;
}


function switchLayer(checked, layer) {

 /* Function was originally borrowed from Esa:
 *  http://esa.ilmari.googlepages.com/dropdownmenu.htm
 */
 var box = document.getElementById("box");
 var boxlink = document.getElementById("boxlink");
 var button = document.getElementById("more_button");

 if(checked) {
	 if (layer==layers[2].obj){
		svOverlay = new GStreetviewOverlay();
		map.addOverlay(svOverlay);
	 }
	 else{
		map.addOverlay(layer);
     }
   // Reset chosen array
   chosen.length = 0;
   /* Highlight the link and
   *  make the button font bold.
   */
   boxlink.className ="highlight";
   box.className ="highlight";
   button.className ="highlight";
	 
 }
 else {
	 if (layer==layers[2].obj){
		map.removeOverlay(svOverlay);
		svOverlay = null;
		if(guymarker){
			map.removeOverlay(guymarker);
		}
	 }
	 else{
		map.removeOverlay(layer);
	 }
   /*  Reset the link and the button
    * if all checkboxes were unchecked.
   */
   if(!checkChecked()) {
    boxlink.blur();
    boxlink.className ="";
    box.className ="";
    button.className ="";
   }
 }
}


function showBox() {

 if(window.timer) clearTimeout(timer);
 document.getElementById("box").style.display ="block";
}


function hideBox(element) {

 element.style.display = "none";
}


function setClose(e) {

 if(!e) e = window.event;
 var element = document.getElementById("box");

 if(checkMouseLeave(element, e))
  timer = setTimeout("hideBox(document.getElementById('box'))", 400);
}


function checkMouseLeave(element, evt) {

 /* Avoid firing a mouseout event
 *  when the mouse moves over a child element.
 *  Borrowed from:
 *  http://www.faqts.com/knowledge_base/view.phtml/aid/1606/fid/145
 */
 if(element.contains && evt.toElement) {
   return !element.contains(evt.toElement);
 }
 else if(evt.relatedTarget) {
   return !containsDOM(element, evt.relatedTarget);
 }
}


function containsDOM(container, containee) {

 var isParent = false;
 do {
  if((isParent = container == containee))
   break;
   containee = containee.parentNode;
 }
 while(containee != null);
 return isParent;
}


function MoreControl(){};
MoreControl.prototype = new GControl();
MoreControl.prototype.initialize = function(map) {

 var more = document.createElement("div");
 more.id = "more_button";
 this.assignClickEvent_(more);
 more.title= "More Layers";
 more.appendChild(document.createTextNode("More..."));
 more.onmouseover = showBox;
 more.onmouseout = setClose;
 map.getContainer().appendChild(more);
 return more;
}

MoreControl.prototype.assignClickEvent_ = function(button) {

 GEvent.addDomListener(button, "click", function() {

  if(chosen.length > 0 ) {

    /* Make an independent copy of chosen array since switchLayer()
    *  resets the chosen array, which may not be useful here.
    */
    var copy = chosen.slice();

    for(var i = 0; i < copy.length; i++) {
     var index = parseInt(copy[i]);
     switchLayer(true, layers[index].obj);
     document.getElementsByName("mark")[index].checked = true;
    }
  }
  else {
    hideAll();
  }
 });
}
MoreControl.prototype.getDefaultPosition = function() {
 return new GControlPosition(G_ANCHOR_TOP_RIGHT, new GSize(500, 7));
}


function BoxControl(){};
BoxControl.prototype = new GControl();
BoxControl.prototype.initialize = function(map) {
 var box = document.getElementById("box");
	 if( box!=null ){
		 box.onmouseout = setClose;
		 map.getContainer().appendChild(box);
		 return box;
	 }
}
BoxControl.prototype.getDefaultPosition = function() {
 return new GControlPosition(G_ANCHOR_TOP_RIGHT, new GSize(450, 25));
}

