function switchControl() {}
  switchControl.prototype = new GControl();
  switchControl.prototype.initialize = function(map) {
  var container = document.createElement("div");
 
    
    var myform = document.createElement("form");
   myform.setAttribute("name","switchformx");
   //myform.setAttribute("id","placeswitch");
    
	
   var oSelect=document.createElement("select");
   oSelect.setAttribute("name", "switchviewx");
     
   oSelect.onchange = function() { moveMap(oSelect.value); };
    
   myform.appendChild(oSelect);
    
   var oOption = document.createElement("option");
   var t0 = document.createTextNode("Area Selector");
   oOption.setAttribute("value", 0);
   oOption.appendChild(t0);
   oSelect.appendChild(oOption);
   
 
	var oOption1 = document.createElement("option");
	var t1 = document.createTextNode("Arnisdale");
	oOption1.setAttribute("value", 1);
	oOption1.appendChild(t1);
	oSelect.appendChild(oOption1);
	
	var oOption2 = document.createElement("option");
	var t2 = document.createTextNode("Dornie");
	oOption2.setAttribute("value", 2);
	oOption2.appendChild(t2);
	oSelect.appendChild(oOption2);
    
   var oOption3 = document.createElement("option");
	var t3 = document.createTextNode("Glenelg");
	oOption3.setAttribute("value", 3);
	oOption3.appendChild(t3);
	oSelect.appendChild(oOption3);

    var oOption12 = document.createElement("option");
	var t12 = document.createTextNode("Kintail");
	oOption12.setAttribute("value", 12);
	oOption12.appendChild(t12);
	oSelect.appendChild(oOption12);
	
	var oOption13 = document.createElement("option");
	var t13 = document.createTextNode("Kyleakin");
	oOption13.setAttribute("value", 13);
	oOption13.appendChild(t13);
	oSelect.appendChild(oOption13);

    var oOption6 = document.createElement("option");
	var t6 = document.createTextNode("Kyle of Lochalsh");
	oOption6.setAttribute("value", 6);
	oOption6.appendChild(t6);
	oSelect.appendChild(oOption6);
	
	var oOption7 = document.createElement("option");
	var t7 = document.createTextNode("Sandaig");
	oOption7.setAttribute("value", 7);
	oOption7.appendChild(t7);
	oSelect.appendChild(oOption7);
	
	var oOption8 = document.createElement("option");
	var t8 = document.createTextNode("Skye Ferry");
	oOption8.setAttribute("value", 8);
	oOption8.appendChild(t8);
	oSelect.appendChild(oOption8);
    
    container.appendChild(myform);
    map.getContainer().appendChild(container);
    return container;
    }

    // By default, the control will appear in the top left corner of the
    // map with 7 pixels of padding.
    switchControl.prototype.getDefaultPosition = function() {
      return new GControlPosition(G_ANCHOR_TOP_RIGHT, new GSize(230, 7));
    }

var docpath = new String(window.location);//Convert document location to a string
var docpathlength = docpath.length;
var firstslash = docpath.lastIndexOf('/');

var pointofinterest = docpath.substring(firstslash+1,docpathlength-5);




var getxmlfile = docpath.substring(0,firstslash);
var secondslash = getxmlfile.lastIndexOf('/');
var thexmlfile = docpath.substring(secondslash+1,firstslash);

var districtpath = docpath.substring(0,secondslash);
var thirdslash = districtpath.lastIndexOf('/');
var district = docpath.substring(thirdslash+1,secondslash);


//alert (district);
//alert (thexmlfile);


 
       var district = docpath.substring(thirdslash+1,secondslash);

  
        
      
      
     if(district =="arnisdale"){
     // move map to view arnisdale
     moveMap(1);
     }
     else if(district =="dornie"){
     // move map to view dornie
     moveMap(2);
     }
       else if(district =="glenelg"){
     // move map to view glenelg
     moveMap(3);
     }
     
     else if(district =="kyleoflochalsh"){
     // move map to view kyle of lochalsh
     moveMap(6);
     }
     
     else if(district =="sandaig"){
     // move map to view sandaig
     moveMap(7);
     }
	 
	  else if(district =="skyeferry"){
     // move map to view sandaig
     moveMap(8);
     }
	 
	 else if(district =="kintail"){
     // move map to view kintail
     moveMap(12);
     }
	 
	  else if(district =="kyleakin"){
     // move map to view kyleakin
     moveMap(13);
     }
	 
     else{
      //Default Country View
      moveMap(0);
     }


 //Switch box functions to move on different sections of the map  
      
function moveMap(section)
{ 
   if (section == "0") 
   {
   //Set map to Country View  
   map.setCenter(new GLatLng(57.200457, -5.528869), 10);
   } 
   else if (section == "1") 
   {
    //Set map to Arnisdale
     map.setCenter(new GLatLng(57.133151,-5.575542), 13);
    }
      
     else if (section == "2")
   {
    //Set map to Dornie
   map.setCenter(new GLatLng(57.278439,-5.519591), 14);
   
   }  
   
    else if (section == "3")
   {
    //Set map to Glenelg
   map.setCenter(new GLatLng(57.211966,-5.62509), 14);
   } 

    else if (section == "6") 
   {
    //Set map to Kyle of Lochalsh
     map.setCenter(new GLatLng(57.282661,-5.714393), 15);
    }
 
else if (section == "7")
   {
    //Set map to Sandaig
   map.setCenter(new GLatLng(57.168928,-5.688891), 14);
   } 
   
   else if (section == "8")
   {
    //Set map to Skye Ferry
   map.setCenter(new GLatLng(57.228633,-5.660577), 14);
   } 
   
   else if (section == "12")
   {
    //Set map to Kintail
   map.setCenter(new GLatLng(57.230341,-5.414800), 13);
   } 
   
    else if (section == "13")
   {
    //Set map to Kyleakin
   map.setCenter(new GLatLng(57.276893,-5.732502), 15);
   } 
   
//  return error;
}