$(document).ready(function(){
	
	/*
		** ClientName Specific Components
	*/
	
	$(".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();
		
		var links = [];
		$(".shadowbox-single").each(
			function(i)
			{
				links[i] = this;
			}
		);
		if (links.length>0){
			Shadowbox.setup(links, {});
		}

		//individual box, draggable on large images
		links = [];
		$(".shadowbox-draglargeimage").each(
			function(i)
			{
				links[i] = this;
			}
		);
		if (links.length>0){
			Shadowbox.setup(links, {
				handleLgImages:'drag'
			});	
		}
	}
	
	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")	});	
					/*$("ul.office-info li").each(
						function()
						{
							var compare = $(this).attr('class').replace('hide', '').replace(' ', '');
							if(office == compare)
							{
								$(this).removeClass('hide');
							}
							else
							{
								$(this).addClass('hide');
							}
						}
					);*/
				}
				
				return false;
			}
		)};
						   
});

/*
	** Global functions
*/

function enableJSClass()
{
	document.body.className = "jsEnabled";
}







