// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults

$(document).ready(function(){
	// alert('jQuery works!');

	/* NAV ROLLOVERS */
	$("a img.rollover").hover(
		function(){
			if($(this).attr("src").indexOf("_on") == -1) {
				var newSrc = $(this).attr("src").replace(".png","_on.png#hover");
				$(this).attr("src",newSrc);
			}
		},
		function(){
			if($(this).attr("src").indexOf("_on.png#hover") != -1) {
				var oldSrc = $(this).attr("src").replace("_on.png#hover",".png");
				$(this).attr("src",oldSrc);
			}
		}
	);

	/* LIGHTBOX */
	jQuery('#lightbox a').lightBox(); // Select all links in object with lightbox ID
	jQuery("a.lightbox").lightBox(); // Select all links with lightbox class

	// products' graphic story
	$('div#graphic_story_link a').click(function(){
		$('div#product_copy').hide();
		$('div#product_graphicstory').show();
		return false;
	});
	$('div#product_graphicstory a').click(function(){
		$('div#product_graphicstory').hide();
		$('div#product_copy').show();
		return false;
	});
	
	// support answer toggle
	$(".question").click(function(){
		// jQuery(this).siblings(".answer").toggle();
		$(".answer").hide();
		$(this).siblings(".answer").show();
	});
	
	// board product zoom toggle
	$('div#product_boards').click(function(){
		$('div#product_boards').fadeOut("fast");
		$('div#product_boards_zoom').fadeIn("fast")
		$('div#product_boards_zoom_close').fadeIn("fast");
		return false;
	});
	$('div#product_boards_zoom_close').click(function(){
		$('div#product_boards_zoom').fadeOut("fast");
		$('div#product_boards_zoom_close').fadeOut("fast");
		$('div#product_boards').fadeIn("fast");
		return false;
	});
	
	// boot, binder, helmet product zoom toggle
	$('div#product_nonboards').click(function(){
		$('div#product_nonboards').fadeOut("fast");
		$('div#product_nonboards_zoom').fadeIn("fast")
		$('div#product_nonboards_zoom_close').fadeIn("fast");
		return false;
	});
	$('div#product_nonboards_zoom_close').click(function(){
		$('div#product_nonboards_zoom').fadeOut("fast");
		$('div#product_nonboards_zoom_close').fadeOut("fast");
		$('div#product_nonboards').fadeIn("fast");
		return false;
	});


});

// tech details popup
function popTech() {
	window.open('/images/tech_bg.gif', 'techwin', 'menubar=no,width=750,height=483,toolbar=no');
}


// jQuery preload images
jQuery.preloadImages = function() {
	for(var i=0; i<arguments.length; i++) {
		$("<img>").attr("src", arguments[i]);
	}
}
