﻿/*
'--------------------------------------------------------------------------------------------------
' Title			: Lisensed Products VIEW PRODUCT JavaScript
' Description	: JavaScript functions and declarations for the Licensed Product View Product page
'--------------------------------------------------------------------------------------------------
' History
' 11/11/2008	: DPE - Created Page
' 05/13/2009	: DPE - Copied from bows-viewProduct.js for Licensed Products
'--------------------------------------------------------------------------------------------------
*/

var swfPlayerReady = false;

function initImgRotator() {
	
	$("#largeImgBox").html('<div class="imgwrap"></div><p style="display:block;">Hover over image to pause transitions.</p>');

	largeImgs	= new Array(); // Array to hold the LARGE preloaded images
	
	$("#imgNav li a img").each(function(i){
		var largeImgSrc		= $(this).attr("src").replace(/w70/,"w365");
		largeImgSrc			= largeImgSrc.replace(/_sq/,"");
		largeImgs[i]		= new Image;
		largeImgs[i].src	= largeImgSrc;
		largeImgs[i].alt	= $(this).attr("alt")
		$(".imgwrap").append(largeImgs[i]);
		$(".imgwrap").cycle({
			fx:	'scrollRight',
			timeout: 3000,
			pause: 1 //Pauses the rotation on hover
		});
	});	
}

function initSwitchVid() {
	$("#vidNav li a").click(function(){
		
		// Turn off any rotating images...
		$(".imgwrap").cycle('pause');
		$("#largeImgBox").hide();
		
		var videoObj	= document.getElementById("videoPlayer");
		var flvInfo		= $(this).attr("rel");
		var strUrl		= "/site/layouts/products/ajax/setVideoObject.asp";
		
		$.ajax({
			url: strUrl,
			data: "flvInfo=" + flvInfo + "",
     		error: function (xhr, desc, exceptionobj) {
				alert(xhr.responseText);
				$("#videoPlayerBox").append('<p><a href="#gallery">Close the video player</a></p>');
			},
			success: function(output){
				if(output.error) {
					alert(output.error);
					return;
				}
				$("#videoPlayerBox").html(output)
		   }
		 });		 				
	});
}

function closeVidPlayer() {
 	$("#videoPlayerBox").html("");
	$("#largeImgBox").show();
	$(".imgwrap").cycle('resume');
}

function initSifr(){
	if(typeof sIFR == "function"){ // Fancy Text for the page title...
		if($("body").hasClass("Monster") || $("body").hasClass("MonsterXLR8")){
			sIFR.replaceElement("h1", named({sFlashSrc:"/site/swf/sifr-myriadProCond.swf",sColor:"#E72A11",sBgColor:"#08000a",sWmode:"opaque"}));
		} else {
			sIFR.replaceElement("h1", named({sFlashSrc:"/site/swf/sifr-myriadProCond.swf",sColor:"#a97c25",sWmode:"opaque"}));
		}
	};
}

// Replaces tradtional body onLoad="" functionality throughout the site
$(document).ready(function(){
	initImgRotator();	// Sets up and starts gallery image rotation
	initSwitchVid();	// initiates video switching on the gallery tab
	initSifr();			// initiates the Flash text replacement for the page title
	//$("#gallery .jqzoom").jqueryzoom({xzoom:400,yzoom:400,offset:0,position:"left",preload:0}); // Initiates the magnifier/close-up image functions
	//$("#testimonials .jqzoom").jqueryzoom({xzoom:365,yzoom:220,offset:2,position:"left",preload:0}); // Initiates the magnifier/close-up image functions

});
