/* 
	Author: 		Mathew Ng
	Email:			illusion_shaker[at]yahoo[dot]com
	Written: 		18/02/2011
	Description:	initialise the scrolling effects 
*/

$(document).ready(function() {

	$(".modal").colorbox({width:"900px", height:"70%", iframe:true});

	//	Get the current filename
	
	var file_name = document.location.href;
	var end = (file_name.indexOf("?") == -1) ? file_name.length : file_name.indexOf("?");
	file_name = file_name.substring(file_name.lastIndexOf("/")+1, end);
	var parts = file_name.split("#");

	//	Define the global variables

	$.gtr = {} 
			
	//	Filename
			
	$.gtr.filename 	= parts[0].replace('http://test.greattransportrace.com.au/', '');
	$.gtr.hash 		= "#" + parts[1];
						
	//	Scroll duration
			
	$.gtr.duration 	= 800;
			
	// 	Reset the screen to (0,0)
	//	Safari and IE require a duration to be set
			
	if($.browser.msie) {
		$.scrollTo(0, 250);
	}
	else if($.browser.safari) {
		$.scrollTo(0, 1);
	}
	else {
		$.scrollTo(0,0);
	}
			
	//	Scroll to section if clicking from a different page
		
	if(parts.length >= 2) {
		
		//	Delay the scroll effect
		
		$(this).delay($.gtr.duration, function() {

			//	Scroll to the location on the page
			$.scrollTo($.gtr.hash, $.gtr.duration);
		
			return false;
		});
	}
			
	$.localScroll();
});
