﻿// JScript File
// execute your scripts when the DOM is ready. this is mostly a good habit
$(function() {
	
	// Slide Image	
	
	// initialize scrollable
	$(".scrollable").scrollable();
	
	$(".items img").click(function() {

		// see if same thumb is being clicked
		if ($(this).hasClass("active")) { return; }
	
		// calclulate large image's URL based on the thumbnail URL (flickr specific)
		var url = $(this).attr("src").replace("50", "200");
		var urlLarge = url.replace("200", "500");
		$("#ProductLargeImgDiv").find("img").attr("src", urlLarge);

		
		// get Product Image Title
		var urlAry = $(this).attr("src").split('/');
		var LastElementIndex = urlAry.length - 1;
		var ProductImageTitle = urlAry[LastElementIndex];
		ProductImageTitle = ProductImageTitle.substr(0,ProductImageTitle.indexOf('_'));
		ProductImageTitle = ProductImageTitle.replace(/-/g, " "); // replace all '-' with ' '
		
		$('#ProductImgTitle').html(ProductImageTitle);
	
		// get handle to element that wraps the image and make it semi-transparent
		var wrap = $("#image_wrap").fadeTo("medium", 0.5);
	
		// the large image from www.flickr.com
		var img = new Image();
	
	
		// call this function after it's loaded
		img.onload = function() {
	
			// make wrapper fully visible
			wrap.fadeTo("fast", 1);
	
			// change the image
			wrap.find("img").attr("src", url);

		};
	
		// begin loading the image from www.flickr.com
		img.src = url;
	
		// activate item
		$(".items img").removeClass("active");
		$(this).addClass("active");
	
		// when page loads simulate a "click" on the first image
	}).filter(":first").click();
	
	
	// Tab
	// setup ul.tabs to work as tabs for each div directly under div.panes
	$("ul.tabs").tabs("div.panes > div");
	
	
	// Apple overlay effect
	$("#ProductVideoTriggers img[rel]").overlay({effect: 'apple'});
	$("#EnlargePicTriggers img[rel]").overlay({ effect: 'apple' });

	// Video overlay effect (TrainingVideos.aspx)
	$(".video-box img[rel]").overlay({ effect: 'apple' });
	$(".video-box-no-dot img[rel]").overlay({ effect: 'apple' });

	// Video overlay effect (Video.aspx)
	//$("#tv-img-wrap img[rel]").overlay({ effect: 'apple' });
	$(".tv-img-wrap img[rel]").overlay({ effect: 'apple' });

	// Training Video overlay effect (TrainingVideos.aspx)
	$(".video-box-training img[rel]").overlay({ effect: 'apple' });
	$(".video-box-training-no-dot img[rel]").overlay({ effect: 'apple' });

    
});

function ClickTab(tArr,tabID) {			// Product Page Tab
	for (var i=0; i<tArr.length; i++) {
		document.getElementById(tArr[i]+"Tab").className = "button-unselected";
		document.getElementById(tArr[i]+"Div").style.display = "none";
	}
	document.getElementById(tabID+"Tab").className = "button-selected";
	document.getElementById(tabID+"Div").style.display = "block";
}







