// JavaScript Document
<!--//

var aigVideoFO;
var win = window;
var vidPath = "#";
var vidTitle = 'Sample Video';
var prodDataList;

function loadAigVideo(url) {
   aigVideoFO.addVariable("videoUrl", url);
   aigVideoFO.writeWithWin("popupVideoDiv", win);
}

function callBack() {
   loadAigVideo(vidPath, win);
   win.document.title = vidTitle;
   win.document.getElementById('videoTitle').innerHTML = vidTitle;
   
   var products = new Array(
		//win.document.getElementById('product1'),
		//win.document.getElementById('product2'),
		//win.document.getElementById('product3')
	);
   
   for (var i = 0; i < products.length; ++i) {
		var newa=document.createElement('a');
		newa.className=previewlinkclass;
		var newimg=document.createElement('img');
		newimg.src=previewimage;
		newimg.alt=previewalternative;
		newimg.className=previewimageclass;
		newa.appendChild(newimg);
		newa.href="#";
   }
}

function openVideo(_title, videoPath, storeRoot, prodList, frameDoc, studyGuide, templateName) { // Answers in Genesis
   openVideoWithSize(_title, videoPath, storeRoot, prodList, frameDoc, studyGuide, templateName, 400, 300);
}

function openVideoWithSize(_title, videoPath, storeRoot, prodList, frameDoc, studyGuide, templateName, playWidth, playHeight) { // Answers in Genesis
   vidPath = 'http://media.answersingenesis.org/video/' + videoPath;
   vidTitle = _title;
   
   var fileUrl = storeRoot + '/include/onDemandTemplates/' + templateName + '/newVideoWin.asp';

   fileUrl += '?frameDoc=' + 'html/ondemand/' + templateName + '/' + frameDoc;
   fileUrl += '&templateName=' + templateName;
   fileUrl += '&videoUrl=' + vidPath;
   fileUrl += '&playWidth=' + playWidth;
   fileUrl += '&playHeight=' + playHeight;
   if (studyGuide.indexOf('.pdf') != -1) {
      fileUrl += '&studyGuide=' + 'pdf/ondemand/' + templateName + '/' + studyGuide;
   } else {
   	  fileUrl += '&studyGuide=' + studyGuide;
   }
   if (prodList.length > 0) {
     fileUrl += '&sku1=' + prodList[0][0] + '&sku2=' + prodList[1][0] + '&sku3=' + prodList[2][0];
     fileUrl += '&cid1=' + prodList[0][1] + '&cid2=' + prodList[1][1] + '&cid3=' + prodList[2][1];
   }
   //alert(fileUrl);
   
   win = vWindow = window.open(fileUrl, 'Feature','scrollbars=1,resizable=1,width=' + (930) + ',height=' + (700));
   aigVideoFO = new FlashObject("http://www.answersingenesis.org/include/FlashMovies/aigVideo.swf", "popupVideo", playWidth, playHeight + 70, 7, "#CC0000", "true");
   aigVideoFO.addParam("allowScriptAccess", "always");
   aigVideoFO.addParam("SWLIVECONNECT", "true");
   aigVideoFO.addParam("wmode", "transparent");
   aigVideoFO.addVariable("videoUrl");
   aigVideoFO.addVariable("playWidth", playWidth);
   aigVideoFO.addVariable("playHeight", playHeight);
   aigVideoFO.addVariable("showIntro", 0);
   aigVideoFO.addVariable("autoHide", 0);
   aigVideoFO.addVariable("playAutomatically", 0);			// don't use with "loadAutomatically."
   aigVideoFO.addVariable("loadAutomatically", 1);			// start pre-loading the video
   aigVideoFO.addVariable("showSplashScreen", 1);		// when combined with "loadAutomatically", disables "Click here..."
   
   //aigVideoFO.writeWithWin("aigVideoDiv", vWindow);
   //loadAigVideo(videoPath);
   
   // if callbacks don't work, we can't set the title, so just directly load window now without callback
   //if (win.document.getElementById('videoTitle') == null) {
   //  loadAigVideo(videoPath);
   //}
   
   vWindow.document.close();
}

function openLibraryVideo(videoData) {
	prodDataList = videoData;
	var templateName = videoData[5];
	if(templateName == null) templateName = "default";
	var storeRoot = videoData[6];
	if(storeRoot == null) storeRoot = "";
	openVideo(videoData[0], videoData[1], storeRoot, videoData[4], videoData[2], videoData[3], templateName);
}

-->