// JavaScript Document

// EDIT THESE VALUES IF REQUIRED
var alertText = 'Are you sure you wish to perform this action' + "\n"; //DEFAULT TEXT DISPLAYED ON CONFIRM BUTTONS/LINKS WHEN NO ALT/TITLE
var newWindowLink = true; //OPEN EXTERNAL LINKS BY DEFAULT IN A NEW WINDOW (TRUE/FALSE)?


var woms = new Array(); //CREATE ARRAY OF FUNCTIONS TO LAUNCH ONLOAD

//ONLOAD MANAGER
function womOn(){
  window.onload = womGo;
}

function womGo(){
  for(var i = 0;i < woms.length;i++)
    eval(woms[i]);
}

function womAdd(func){
  woms[woms.length] = func;
}

function CreateBookmarkLink() {

	title = document.title;
	url = window.location.href;
	
	if (window.sidebar) { 
		window.sidebar.addPanel(title, url,"");
	} else if(window.external) {
		window.external.AddFavorite( url, title); 
	} else if(window.opera && window.print) {
		return true;
	}
	
}

function objToggle(obj) { 

	var obj = document.getElementById(obj);

	if(obj.style.display == "block") { 
		obj.style.display = "none";
	} else { 
		obj.style.display = "block";
	}

}

function memberTabs()
{
	
		
	var panelName = '';
	
	if($('.memberinfo .memberinfoinner').length > 0) {
		panelName = '.member';
	} else if($('.projectinfo .projectinfoinner').length > 0) {
		panelName = '.project';
	}
	
	$(panelName + 'info ' + panelName + 'infoinner').each(
		function (i) {
			
			if(i !== 0) $(this).hide();
			
		});
	
	if(location.hash.length > 0) {
		$(panelName + 'info ul li .chebs').each(
			function (e) {
				
				var tabid = $(this).attr("id");
				var tabid_clean = tabid;
				if("#"+tabid_clean == location.hash) {
					
					$(this).addClass("selected");
					$(panelName + 'info ' + panelName + 'infoinner').hide();
					$(panelName + 'info ' + panelName + 'infoinner:eq(' + e + ')').show();
					
				}
			});
	}
	
	if($(panelName + 'info ul li .chebs').hasClass("selected") == false) {
												   
		$(panelName + 'info ul li .chebs:first').addClass("selected");
		
	}
	
	$('ul li .chebs').click(
							
		function () {
			
			var currentTab = $(panelName + 'info ul li a.selected');
			var currentTabIndex = $(this).index(currentTab);
			var indexPos = $(panelName + 'info ul li a').index(this);

			if(currentTabIndex !== indexPos) {
				
				$(panelName + 'info ' + panelName + 'infoinner').hide();
				$(panelName + 'info ' + panelName + 'infoinner:eq(' + indexPos + ')').fadeIn(900);
				$(panelName + 'info .chebs').removeClass('selected');
				$(this).addClass('selected');
			
			}
			
			$(this).blur();
			
			if($("input[name='not_portfolio']").length > 0) {
				
				if(($(this).attr("id") == "multimedia-tab") || ($(this).attr("id") == "website-tab")) {
					
					return true;
					
				}
				
			}
			
			return false;
		
		});
	
}



$(document).ready(
	function () 
	{
		memberTabs();
		//externalLinks();
	});


//<![CDATA[

	function createMarker(point,html) {
		var marker = new GMarker(point);
		GEvent.addListener(marker, "click", function() {
			marker.openInfoWindowHtml(html);
		});
		return marker;
     }

    function load() {
      if (GBrowserIsCompatible()) {

	      var map = new GMap2(document.getElementById("map"));

		  // Display the map, with some controls and set the initial location 
		  var map = new GMap2(document.getElementById("map"));
		  map.addControl(new GSmallMapControl());
		  map.addControl(new GMapTypeControl());
	  
		  var point = new GLatLng(53.98576454175, -1.492263078689);
		  var start = new GLatLng(53.99368336665186, -1.51885986328125);
		  
		  map.setCenter(start,12);
		
		  // Set up three markers with info windows 

		  var marker = createMarker(point,'<div style="width:240px"><strong>9xb Limited</strong><br />38 Freemans Way<br />Harrogate Business Park<br />Wetherby Road<br />Harrogate<br />HG3 1DH</div>');
		  map.addOverlay(marker);

      }
    }
	
	
	function swapDepths(div, depth){
			document.getElementById(div).style.zIndex	=	depth;
	}

    //]]>