//---- Store the current visible section name
var visSecName='main';
var map;

function addJavascript(jsname,pos) 
{
	var th = document.getElementsByTagName(pos)[0];
	var s = document.createElement('script');
	s.setAttribute('type','text/javascript');
	s.setAttribute('src',jsname);
	th.appendChild(s);
}	//end function


//----- Manages Sections Visibility
function ManageSections(SectionName)
{
	try
	{
		document.getElementById(visSecName).style.visibility='hidden';
		document.getElementById(visSecName).style.display='none';
		
		visSecName = SectionName;
		
		document.getElementById(SectionName).style.visibility='visible';
		document.getElementById(SectionName).style.display='inline';
		
		//----- Show google maps
		if(SectionName=='ContactUsSec' && map==null)
			initialize();
	}//end try
	catch (e)
	{
		alert("Try again: "+e.toString())
	}//end catch
}//end function


function initialize() 
{
	try
	{
		//var myLatlng = new google.maps.LatLng(33.85748,35.48772);
		var myOptions = {
			zoom: 17,
			center: new google.maps.LatLng(33.85748,35.48772),
			disableDefaultUI: true,
			//backgroundColor: "#ff0000",		
			mapTypeId: google.maps.MapTypeId.HYBRID
		}
	  
		var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
	
		var infowindow = new google.maps.InfoWindow({
			content: '<p><b><font face="Arial, Helvetica, sans-serif" size="2" color="#4f77bc">We are here</font></b></p><p><font face="Arial, Helvetica, sans-serif" size="2" color="#999999">Jnah – Nadim Fakhry Bldg “South For Construction Bldg “ - 3rd Floor<br>P.O.Box 50219 Beirut-Lebanon<br>Tel / Fax: +961-1-834026/011</font></p>',
			//size: new google.maps.Size(250,260),
			maxWidth: 300
			//, position: myLatlng
		});
	  
		/*var shadow = new google.maps.MarkerImage('_img/icon-shadow.png',
			new google.maps.Size(34, 34),
			new google.maps.Point(0,0),
			new google.maps.Point(23, 30));  */
		
		var shape = {
			coord: [1, 1, 1, 20, 18, 20, 18 , 1],
			type: 'poly'
		};
		
		//var image = '_img/icon-on.png';
		var myLatLng = new google.maps.LatLng(33.85748,35.48772);
		var bbMarker = new google.maps.Marker({
			position: myLatLng,
			map: map,
			//icon: image,
			//shadow: shadow,
			shape: shape,		
			title:"Geo Vision Offices"
		});
		
		//var images = '_img/icon-off.png';
		/*var myLatLngs = new google.maps.LatLng(33.85748,35.48772);
		var bbMarkers = new google.maps.Marker({
			position: myLatLngs,
			map: map,
			icon: images,
			shadow: shadow,
			shape: shape,		
			title:"Geo Vision Offices"
		});*/
		
		/*google.maps.event.addListener(bbMarker, 'click', function() {*/
		infowindow.open(map,bbMarker);
			//map.set_zoom(18);
		//});
	  
		/*var controller = new CustomControllerBase(map);
			controller.setBackgroundImage('_img/nav-bg.png');
			controller.setWidth(959);
			controller.setHeight(32);
			controller.element.style.top = 328 + "px";;
			controller.alignContent('center');
	
		var pan = new CustomController('img', '_img/pan.png', 'mapPan');
		var slider = new CustomController('img', '_img/slider.png', 'mapSlider');
		var zoomIn = new CustomController('img', '_img/zoom-in.png', 'mapZoomIn');
		var zoomOut = new CustomController('img', '_img/zoom-out.png', 'mapZoomOut');
		var roadmap = new CustomController('img', '_img/map.png', 'mapType');
		var satellite = new CustomController('img', '_img/satellite.png', 'mapType');
		var terrain = new CustomController('img', '_img/terrain.png', 'mapType');
		var finish = new CustomController('img', '_img/finish.png', 'mapIconOn');
		/*var progress = new CustomController('img', '_img/progress.png', 'mapIconOff');	
		var closebtn = new CustomController('img', '_img/close.png', 'closebtn');	*/
	
		/*controller.addZoomDecreaser(pan);
		controller.addZoomIncreaser(zoomIn);
		controller.addElement(slider);	
		
		controller.addElement(roadmap, 'click', function() {
			controller.setMapTypeId(google.maps.MapTypeId.HYBRID);	});
		controller.addElement(satellite, 'click', function() {
			controller.setMapTypeId(google.maps.MapTypeId.SATELLITE); });
		controller.addElement(terrain, 'click', function() {
			controller.setMapTypeId(google.maps.MapTypeId.TERRAIN); });*/
	
		/*controller.addElement(finish);
		controller.addElement(progress);
		controller.addElement(closebtn);
		
		controller.draw();*/
	}//end try
	catch (e)
	{
		alert("Try again: "+e.toString())
	}//end catch
}
