/*
CRITCHLOW OPENLAYERS INTERFACE (critchlowOpenlayers.js)

Created by:
Jeremy Husmann
Barry Boyed
Ian Downey

Current formal release V3 @ 19 May 2009
*/

//LINKS ALL CRITCLOW JS FILES
	function init()
	{   
		var jsfiles = new Array(
			"critchlowJS/critchlowYUI.js",
			"critchlowJS/critchlowGeocode.js",
			"critchlowJS/critchlowRouting.js",
			"critchlowJS/critchlowGPS.js",
			"critchlowJS/critchlowVector.js"
		);
	    	    
		var agent = navigator.userAgent;
		var host = window.location;
	    
		var docWrite = (agent.match("MSIE") || agent.match("Safari"));
		if(docWrite) {
			var allScriptTags = new Array(jsfiles.length);
		}
	
		for (var i=0, len=jsfiles.length; i<len; i++) 
		{
			if (docWrite) 
			{
				allScriptTags[i] = "<script src='" + host + jsfiles[i] + "'></script>"; 
			} 
			else 
			{
				var s = document.createElement("script");
				s.src = host + jsfiles[i];
				var h = document.getElementsByTagName("head").length ? document.getElementsByTagName("head")[0] : document.body;
				h.appendChild(s);
			}
		}
		
		if (docWrite) 
		{
			document.write(allScriptTags.join(""));
	
		}
		
		mapInit();
	}
	
	
//Global Variables
        var map, streetview, directionsPanel, directions, vectorLayer, routeVectorLayer, pointVectorLayer, gpsTimer, selectControl ;
        
            
//Openlayers stlyes for vector objects	    









/*Map Initialise
Sets all the map options to surround NZ

*/
        function mapInit() 
	{
	
		var nzBounds = new OpenLayers.Bounds(165, -47, 180, -34.5).transform((new OpenLayers.Projection("EPSG:4326")), (new OpenLayers.Projection("EPSG:900913")));
		
		//var kmlBounds = (17950267,-5930235,20454956,-4107977);
		//var nzBounds = new OpenLayers.Bounds(17950267,-5930235,20454956,-4107977);
                 
		var options = 
		{
		projection: new OpenLayers.Projection("EPSG:900913"),
                displayProjection: new OpenLayers.Projection("EPSG:4326"),
                units: "m",
                maxResolution: "auto",
		minResolution: 10.39,
                maxExtent: nzBounds,
						 
		numZoomLevels: 10, 


		
		controls: [
                        new OpenLayers.Control.Navigation(),
                        new OpenLayers.Control.LayerSwitcher({'ascending':false}),
			new OpenLayers.Control.PanZoomBar({zoomWorldIcon:true})
			 
			
            
			]
		};
            
                map = new OpenLayers.Map('map', options);


	        base = new OpenLayers.Layer("",{isBaseLayer: true, displayInLayerSwitcher:false});
		map.addLayers([base]); 
		
		map.zoomToExtent(nzBounds);  
		
                //map.addControl(new OpenLayers.Control.MousePosition());

		addKML();

 var termsOfUse = document.createElement("div");

 
 
         
	    termsOfUse.innerHTML = "<b>Copyright notice:</b> Maps contain Crown and Critchlow Limited Copyright Data.<br/><b>Disclaimer:</b> Region boundaries are indicative ";
	      //this.map.layerContainerDiv.appendChild(termsOfUse);
	       

  termsOfUse.className = "olCritchlowNotes";
  this.map.viewPortDiv.appendChild(termsOfUse);
	
 //termsOfUse.style. = "1100";
            //termsOfUse.style.display = this.div.style.display;
           	      
	    //termsOfUse.style.right = "2px";
            //termsOfUse.style.bottom = "2px";
	    termsOfUse.style.top = "715px";
	    
	    
            //termsOfUse.className = "olLayerGoogleCopyright";
	    
	    
	    
              //  this.map.viewPortDiv.appendChild(termsOfUse);
           
              
           
	    
	    
 //this.map.layerContainerDiv.appendChild(termsOfUse);
 
 
 
 
	}
	    
	     
	    
	    
	    
	

       

       
       
     
       

       
      
       
       
        
       
        









    
    
    

