$(document).ready(function(){
	
	/*
		** ClientName Specific Components
	*/
	
	$("a.inline-link").click(
		function()
		{
			href = $(this).attr("href").replace("#", "");
			$("#"+href).removeClass("hidden");
			$("#"+href).addClass("showing");
			$(this).addClass("hidden");
			return false;
		}
	);
	$("div.stage").hover(
		function(){
			$(this).addClass("hover");
		},
		function(){
			$(this).removeClass("hover");
		}
	);
	
	/*$(".siteplan div").hover(
		function(){
			$(this).addClass("hover");
		},
		function(){
			$(this).removeClass("hover");
		}
	);*/
	
	/*if(document.getElementById("simpleCarousel"))
	{
		$('#simpleCarousel').jcarousel({
			itemScroll: 1,
			scrollAnimation: "normal",
			wrap: true,
			wrapPrev: true,
			autoScroll: 4,
			itemVisible: 1
		});
		
	}
	*/
	/*if(document.getElementById("cnCarousel"))
	{
		$('#cnCarousel').jcarousel({
			itemScroll: 1,
			scrollAnimation: "normal",
			wrap: false,
			wrapPrev: false,
			autoScroll: 0,
			itemVisible: 5
		});
		
		$("#cnCarousel li").hover(
			function()
			{
				$(this).addClass("hover");
			},
			function()
			{
				$(this).removeClass("hover");
			}
			
		);
	}*/
	
	if(document.getElementById("shadowbox-holder"))
	{
		Shadowbox.init(
			{
				loadingImage: "global/img/shadowbox/loading.gif"
			}			   
		);
		//grouped boxes
		links = [];
		$(".shadowbox-gallery").each(
			function(i)
			{
				links[i] = this;
			}
		);
		if(links.length>0)
		{
			Shadowbox.setup(links, {
				gallery: "Image gallery",
				continuous:	true
			});
		}
		
		links = [];
		$(".shadowbox-gallery-two").each(
			function(i)
			{
				links[i] = this;
			}
		);
		if(links.length>0)
		{
			Shadowbox.setup(links, {
				gallery: "Image gallery Two",
				continuous:	true
			});
		}
		
		//individual box, draggable on large images
		links = [];
		$(".shadowbox-draglargeimage").each(
			function(i)
			{
				links[i] = this;
			}
		);
		if (links.length>0){
			Shadowbox.setup(links, {
				handleLgImages:'drag'
			});	
		}
				
		//individual shadow boxes with default settings
		links = [];
		$(".shadowbox").each(
			function(i)
			{
				links[i] = this;
			}
		);
		if(links.length>0)
		{
			Shadowbox.setup(links, {});
		}
	}
	
	if($(".gmap").length>0) {
		$("#gmap-locs li a").click(
			function()
			{	
				if($(this).attr("class") == "show-all")
				{
					$("#map1").googleMap(-28.148292, 153.468361, 5, 
					{
						controls: ["GSmallMapControl", "GMapTypeControl"],
						markers: $(".geo")
					});
				}
				else
				{
					//get the office clicked on
					var office = $(this).attr('href');
					hashIndex = office.indexOf("#");
					office = office.substring(hashIndex,office.length).replace("#", "");
					
					var longitude;
					var latitude;
					var officeName;
					$("div.geo").each(function() {
						if(office == $(this).attr('id'))
						{
							officeName = $(this).attr('title');
							//get the children of the div
							//var kids = $(this).children('.latitude');
							latitude = parseFloat($(this).children('.latitude').attr('title'));
							longitude = parseFloat($(this).children('.longitude').attr('title'));
							//get the lat
							//latitude = parseFloat(kids.attr('title'));
							//get the long
							//longitude = parseFloat(kids.next().attr('title')); 
						}
					});
					$("#map1").googleMapZoomIn(latitude, longitude, officeName, {	controls: ["GSmallMapControl", "GMapTypeControl"],	markers: $(".geo")	});	
					
				}
				
				return false;
			}
		)};
						   
});

/*
	** Global functions
*/

function enableJSClass()
{
	document.body.className = "jsEnabled";
}






