// JavaScript Document

// Global Vars
var $home,
	$scroller;

jQuery(document).ready(function(){
	$home = jQuery("#home-div div");		// ---  Define Global Vars
	$scroller = jQuery("#scroll");
	
	//Caption Sliding (Partially Hidden to Visible)
	jQuery('.boxgrid.caption').hover(function(){
		jQuery(".cover", this).stop().animate({top:'15px'},{queue:false,duration:160});
	}, function() {
		jQuery(".cover", this).stop().animate({top:'220px'},{queue:false,duration:160});
	});
	
	jQuery("#home-div").fadeIn(1000);		// ---  Fade In Main Content
	
	$videoDialog = jQuery("#videoDialog");
	var m_parameters = {
			autoOpen: false, 
			resizable: true, 
			height: 500,
			width: 600,
			modal: true,
			title: '',
			dialogClass: 'start',
			bgiframe: true,
			closeOnEscape: true,
			draggable: true,
			hide: 'fadeOut(fast)',
			position: ['center', 40],
			focus: null,
			buttons: {
				Close: function () {
					jQuery(this).dialog("close");
				}
			}
		};
	
	$videoDialog.dialog(m_parameters);
	
	jQuery.preloadCssImages();				// ---  PreLoad Images
});

function displayVideo(){
	var strVideoSCR = '<object width="500" height="405"><param name="movie" value="http://www.youtube.com/v/hmhPfxxnhAM&hl=en&fs=1&rel=0&color1=0x3a3a3a&color2=0x999999&border=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/hmhPfxxnhAM&hl=en&fs=1&rel=0&color1=0x3a3a3a&color2=0x999999&border=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="500" height="405"></embed></object>';
	$videoDialog.dialog("open");
	$videoDialog.dialog('option', 'height', '500');
	$videoDialog.html('<div class="inner-video-div">' + strVideoSCR + '</div>');
}

function hideHOME(){
	if($home.css("display") != "none"){
		$home.fadeOut("fast");
	};
};
function showHOME(){
	if($home.css("display") == "none"){
		showContent(false);
		$home.fadeIn("slow");
	};	
};

function show_CJ(){
	hideHOME();
	loadCobragallery();
}
function show_Raptor(){
	hideHOME();
	loadRaptorGallery();
}
function show_Boss(){
	hideHOME();
	loadBossGallery();
}
function show_Packs(){
	hideHOME();
	loadPacksGallery();
}

function showContent(isVisible){
	if(($scroller.css("display") == "none") || (isVisible == true)){
		$scroller.fadeIn("slow");
	}else{
		$scroller.fadeOut("fast");
	}
}

function controlContent(contentID){
	showContent(true);
	var $container = jQuery("#scroll-container");

	var target = ((parseInt(contentID)-1)*800);
	var currentX = Math.abs(parseInt($container.css("left")));
	
	if(target > currentX){				// Move the Container Right
		var xVal = target - currentX;
		$container.animate({"left": "-=" + xVal + "px"}, "slow");
	}else if(target < currentX){		// Move the Container Left
		var xVal = currentX - target;
		$container.animate({"left": "+=" + xVal + "px"}, "slow");
	}else{
		//alert('you are retarded');
	}
	
}


/***********************************************
* Simple Controls Gallery- (c) Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for this script and 100s more
***********************************************/
function loadCobragallery() {
	var cobragallery = new simpleGallery({
		wrapperid: "simplegallery1", 	//ID of main gallery container,
		dimensions: [694, 405], 		//width/height of gallery in pixels. Should reflect dimensions of the images exactly
		imagearray: [
			["images/tattoo-gal-img-6.jpg", "../mustang/herocard11.asp", "", ""],
			["images/cj-gal-img-1.jpg", "../mustang/herocard11.asp", "", ""],
			["images/cj-gal-img-2.jpg", "../mustang/herocard11.asp", "", ""],
			["images/cj-gal-img-3.jpg", "../mustang/herocard11.asp", "", ""],
			["images/cj-gal-img-4.jpg", "../mustang/herocard11.asp", "", ""],
			["images/cj-gal-img-5.jpg", "../mustang/herocard11.asp", "", ""],
			["images/cj-gal-img-6.jpg", "../mustang/herocard11.asp", "", ""],
			["images/cj-gal-img-7.jpg", "../mustang/herocard11.asp", "", ""],
			["images/cj-gal-img-8.jpg", "../mustang/herocard11.asp", "", ""],
			["images/cj-gal-img-9.jpg", "../mustang/herocard11.asp", "", ""],
			["images/cj-gal-img-10.jpg", "../mustang/herocard11.asp", "", ""]
		],
		autoplay: [true, 3000, 20], 	//[auto_play_boolean, delay_btw_slide_millisec, cycles_before_stopping_int]
		persist: false, 			//remember last viewed slide and recall within same session?
		fadeduration: 1000, 			//transition duration (milliseconds)
		oninit:function(){ 			//event that fires when gallery has initialized/ ready to run
			controlContent(1);						//Keyword "this": references current gallery instance (ie: try this.navigate("play/pause"))
		},
		onslide:function(curslide, i){ 	//event that fires after each slide is shown
										//Keyword "this": references current gallery instance
										//curslide: returns DOM reference to current slide's DIV (ie: try alert(curslide.innerHTML)
										//i: integer reflecting current image within collection being shown (0=1st image, 1=2nd etc)
		}
	})
}
function loadRaptorGallery(){
	var raptorgallery = new simpleGallery({
		wrapperid: "simplegallery2", 	//ID of main gallery container,
		dimensions: [694, 405], 		//width/height of gallery in pixels. Should reflect dimensions of the images exactly
		imagearray: [
			["images/tattoo-gal-img-2.jpg", "../announcements/news97.asp", "", ""],
			["images/raptor-gal-img-11.jpg", "../announcements/news97.asp", "", ""],
			["images/raptor-gal-img-12.jpg", "../announcements/news97.asp", "", ""],
			["images/raptor-gal-img-1.jpg", "../announcements/news97.asp", "", ""],
			["images/raptor-gal-img-2.jpg", "../announcements/news97.asp", "", ""],
			["images/raptor-gal-img-3.jpg", "../announcements/news97.asp", "", ""],
			["images/raptor-gal-img-4.jpg", "../announcements/news97.asp", "", ""],
			["images/raptor-gal-img-5.jpg", "../announcements/news97.asp", "", ""],
			["images/raptor-gal-img-6.jpg", "../announcements/news97.asp", "", ""],
			["images/raptor-gal-img-7.jpg", "../announcements/news97.asp", "", ""],
			["images/raptor-gal-img-8.jpg", "../announcements/news97.asp", "", ""],
			["images/raptor-gal-img-9.jpg", "../announcements/news97.asp", "", ""],
			["images/raptor-gal-img-10.jpg", "../announcements/news97.asp", "", ""],
			["images/raptor-gal-img-13.jpg", "../announcements/news97.asp", "", ""],
			["images/raptor-gal-img-14.jpg", "../announcements/news97.asp", "", ""],
			["images/raptor-gal-img-15.jpg", "../announcements/news97.asp", "", ""]
		],
		autoplay: [true, 3000, 20], 	//[auto_play_boolean, delay_btw_slide_millisec, cycles_before_stopping_int]
		persist: false, 			//remember last viewed slide and recall within same session?
		fadeduration: 1000, 			//transition duration (milliseconds)
		oninit:function(){ 			//event that fires when gallery has initialized/ ready to run
			controlContent(2);						//Keyword "this": references current gallery instance (ie: try this.navigate("play/pause"))
		},
		onslide:function(curslide, i){ 	//event that fires after each slide is shown
										//Keyword "this": references current gallery instance
										//curslide: returns DOM reference to current slide's DIV (ie: try alert(curslide.innerHTML)
										//i: integer reflecting current image within collection being shown (0=1st image, 1=2nd etc)
		}
	})
}

function loadBossGallery(){
	var bossgallery = new simpleGallery({
		wrapperid: "simplegallery3", 	//ID of main gallery container,
		dimensions: [694, 405], 		//width/height of gallery in pixels. Should reflect dimensions of the images exactly
		imagearray: [
			["images/tattoo-gal-img-5.jpg", "../parts/search.asp?q=M-6010-BOSS351", "", ""],
			["images/BOSS-gal-img-3.jpg", "../parts/search.asp?q=M-6010-BOSS351", "", ""],
			["images/BOSS-gal-img-7.jpg", "../parts/search.asp?q=M-6010-BOSS351", "", ""],
			["images/BOSS-gal-img-5.jpg", "../parts/search.asp?q=M-6010-BOSS351", "", ""],
			["images/BOSS-gal-img-6.jpg", "../parts/search.asp?q=M-6010-BOSS351", "", ""],
			["images/BOSS-gal-img-4.jpg", "../parts/search.asp?q=M-6010-BOSS351", "", ""],
			["images/BOSS-gal-img-8.jpg", "../parts/search.asp?q=M-6010-BOSS351", "", ""]
		],
		autoplay: [true, 3000, 20], 	//[auto_play_boolean, delay_btw_slide_millisec, cycles_before_stopping_int]
		persist: false, 			//remember last viewed slide and recall within same session?
		fadeduration: 1000, 			//transition duration (milliseconds)
		oninit:function(){ 			//event that fires when gallery has initialized/ ready to run
			controlContent(3);						//Keyword "this": references current gallery instance (ie: try this.navigate("play/pause"))
		},
		onslide:function(curslide, i){ 	//event that fires after each slide is shown
										//Keyword "this": references current gallery instance
										//curslide: returns DOM reference to current slide's DIV (ie: try alert(curslide.innerHTML)
										//i: integer reflecting current image within collection being shown (0=1st image, 1=2nd etc)
		}
	})
}

function loadPacksGallery(){
	var packsgallery = new simpleGallery({
		wrapperid: "simplegallery4", 	//ID of main gallery container,
		dimensions: [694, 405], 		//width/height of gallery in pixels. Should reflect dimensions of the images exactly
		imagearray: [
			["images/tattoo-gal-img-1.jpg", "../mustang/performancepacks.asp", "", ""],
			["images/packs-gal-img-1.jpg", "../mustang/performancepacks.asp", "", ""],
			["images/packs-gal-img-4.jpg", "../mustang/performancepacks.asp", "", ""],
			["images/packs-gal-img-2.jpg", "../mustang/performancepacks.asp", "", ""],
			["images/packs-gal-img-5.jpg", "../mustang/performancepacks.asp", "", ""],
			["images/packs-gal-img-3.jpg", "../mustang/performancepacks.asp", "", ""]
	
		],
		autoplay: [true, 3000, 20], 	//[auto_play_boolean, delay_btw_slide_millisec, cycles_before_stopping_int]
		persist: false, 			//remember last viewed slide and recall within same session?
		fadeduration: 1000, 			//transition duration (milliseconds)
		oninit:function(){ 			//event that fires when gallery has initialized/ ready to run
			controlContent(4);						//Keyword "this": references current gallery instance (ie: try this.navigate("play/pause"))
		},
		onslide:function(curslide, i){ 	//event that fires after each slide is shown
										//Keyword "this": references current gallery instance
										//curslide: returns DOM reference to current slide's DIV (ie: try alert(curslide.innerHTML)
										//i: integer reflecting current image within collection being shown (0=1st image, 1=2nd etc)
		}
	})
}