$(document).ready(function(){
	/*
		JCAROUSEL
		Requires: jquery, jcarousel
	*/
	/*Simple carousel*/
	if(document.getElementById("jcarousel"))
	{		
		$(".simpleCarousel").each(
			function()
			{
				id = $(this).attr("id");
				time = $(this).attr("rel");
				var count = 0;
				$("#"+id+" .jcarousel-list li").each(function() {
					count++;
				});
				$("#"+id).parents(".body").next().children(".pages").children(".total").html(count);
				
				$(this).jcarousel({
					itemVisible: 1,
					scrollAnimation: "normal",
					autoScroll: 0,
					wrap: true,
					carouselid: id,
					carouselItemCounterEnabled: true
				});
			}
		);
			
	}
	/*Vertical Carousel*/
	if(document.getElementById("jcarouselVertical"))
	{
		$('#verticalCarousel').jcarousel({
			orientation: "vertical",
			itemVisible: 4,
			carouselid: "jcarouselVertical"
		});
	}
	/*Auto scrolling Carousel*/
	if(document.getElementById("jcarouselAutoscroll"))
	{
	    id = $(this).attr("id");
		$('#simpleCarousel').jcarousel({
			itemScroll: 1,
			scrollAnimation: "fast",
			autoScroll: 4,
			wrap: false,
			autoScrollStopOnInteract: false,
			autoScrollStopOnMouseover:  false,
			autoScrollResumeOnMouseout: false,
			carouselid: "jcarouselAutoscroll"
		});
	}
	/*Custom Controls Carousel*/
	/*
		CAROUSEL WITH CUSTOM CONTROLS
		Usage: Used when other controls are needed for the carousel besides the previous and next button
		Requires: jquery, jcarousel-w-customcontrols
		
		Short fall: At present jcarousel-w-customcontrols cannot be used in conjuntion with a normal carousel
	*/
	/*if(document.getElementById("jcarouselControls"))
	{
		//creates all of the controls
		var count = 0;
		$(".jcarousel-list li").each(function() {
			count++;
		});
		$("div.pages span#total").html(count);
		
		//put in the carousel
		$('#projectCarousel').jcarousel({
			itemVisible: 1,
			itemFirstInHandler: itemFirstInHandlerCustomControls
		});
		
	}*/
	/*SWF OBJECT*/

	if(document.getElementById("flashcontent"))
	{
		var so = new SWFObject("/racing_global/flash/swfobject/flv_player.swf", "vidplayer", "303", "187", "9", "#000000");
		//so.addParam("wmode", "transparent");
		path=$("#flashcontent").attr("rel");
		so.addVariable("flvPath", path);
		so.write("flashcontent");
	}
	
});
	
	
	/*
		SWFOBJECT
		Inserting a swf object into the page;
		Requires: swfobject
	*/

	function updateFlashVid(path) {
		if(document.getElementById("flashcontent"))
		{
			var so = new SWFObject("/racing_global/flash/swfobject/flv_player.swf", "vidplayer", "303", "187", "9", "#000000");
			//so.addParam("wmode", "transparent");
			so.addVariable("flvPath", path);
			so.write("flashcontent");
		}
	}

function enableJSClass()
{
	document.body.className = "jsEnabled";
}

function printPage() { 
	if (window.print) { 
		window.print() ; 
	} else { 
		var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>'; 
		document.body.insertAdjacentHTML('beforeEnd', WebBrowser); 
		WebBrowser1.ExecWB(6, 2);//Use a 1 vs. a 2 for a prompting dialog box WebBrowser1.outerHTML = ""; 
	}
}
