var MoviePlayer = new Object();
var movieArray = new Array();
var productsArray = new Array();

MoviePlayer.Movie = function(movieName, movieStreamURL, movieDownloadURL, sizeWidth, sizeHeight, thumbnailImage, productArrayName)
{
	this.movieName = movieName;
	this.movieStreamURL = movieStreamURL;
	this.movieDownloadURL = movieDownloadURL;
	this.sizeWidth = sizeWidth;
	this.sizeHeight = sizeHeight;
	this.thumbnailImage = thumbnailImage;
	this.productArrayName = productArrayName;
}

//-----------------------------------------------------------------------------------------------------------------

MoviePlayer.Products = function(productName, productLink)
{
	this.productName = productName;
	this.productLink = productLink;
}

//-----------------------------------------------------------------------------------------------------------------

MoviePlayer.ListMovies = function(name)
{
	var writeOut = "";
	var imageURL = "/images/movie_player/";
	
	try{
		writeOut += "<table width=\"180\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n";
	
		if(movieArray[name].length > 0)
		{
			for(var i=0; i < movieArray[name].length; i++){
				writeOut += "<tr>\n";
				writeOut += "<td><a href=\"javascript:MoviePlayer.PlayMovie('"+ name +"',"+ i +");void (0)\"><img src=\"" + imageURL + movieArray[name][i].thumbnailImage + "\" class=\"videoThumbnails\" alt=\""+ movieArray[name][i].movieName +"\" width=\"85\" border=\"0\"></a></td>";
				writeOut += "<td><p class=\"smallVideoInfo\"><a class=\"smallVideoInfoLink\" href=\"javascript:MoviePlayer.PlayMovie('"+ name +"',"+ i +");void (0)\">"+ movieArray[name][i].movieName +"<br></a></p></td>";
				writeOut += "</tr>\n";
			}
		}else{
			writeOut += "<tr>\n";
				writeOut += "<td><p class=\"smallVideoInfo\"><br><br>There are no Videos at this time.</p></td>";
			writeOut += "</tr>\n";
		}
		
		writeOut += "</table>\n";	
	}
	catch(e){
	}
	document.getElementById("content").innerHTML = writeOut;
	Scroller.init();
}

//-----------------------------------------------------------------------------------------------------------------

MoviePlayer.PlayMovie = function(name, id)
{
	MoviePlayer.CreateMovieControl(movieArray[name][id],name,id,true);
}

//-----------------------------------------------------------------------------------------------------------------

MoviePlayer.PlayStartUpMovie = function(name, id)
{
	MoviePlayer.CreateMovieControl(movieArray[name][id],name,id,false);
}

//-----------------------------------------------------------------------------------------------------------------

MoviePlayer.CreateMovieControl = function(arrayobj, name, id, autostart)
{
	var movieControl = "";

	try{
	
		movieControl += "<OBJECT id=\'WMVMoviePlayer\' name=\"WMVMoviePlayer\" width=\"320\" height=\"285\" classid=\'CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95\' codebase=\'http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701\' standby=\'\' type=\'application/x-oleobject\'>";

		if(autostart){
			movieControl += "<param name=\'autoStart\' value=\"true\">";
		}else{
			movieControl += "<param name=\'autoStart\' value=\"false\">";
		}		
		
		movieControl += "<param name=\'fileName\' value=\'"+ arrayobj.movieStreamURL +"\'>";
		movieControl += "<param name=\'animationatStart\' value=\'true\'>";
		movieControl += "<param name=\'transparentatStart\' value=\'true\'>";
		
		movieControl += "<param name=\'showControls\' value=\"true\">";
		movieControl += "<param name=\'loop\' value=\"false\">";
		movieControl += "<EMBED type=\'application/x-mplayer2\' pluginspage=\'http://microsoft.com/windows/mediaplayer/en/download/\' id=\'WMVMoviePlayer\' name=\'WMVMoviePlayer\' autostart=\""+(autostart?"true":"false")+"\" displaysize=\'4\' autosize=\'-1\' bgcolor=\'darkblue\' showcontrols=\'true\' showtracker=\'-1\' showdisplay=\'0\' showstatusbar=\'-1\' videoborder3d=\'-1\' width=\"320\" height=\"285\" src=\""+ arrayobj.movieStreamURL +"\" designtimesp=\'5311\' loop=\"false\">";
		movieControl += "</EMBED>";
		movieControl += "</OBJECT>";
	
		movieControl += "<p class=\"loadedVideoTitle\">";
		movieControl += arrayobj.movieName + "";
		//movieControl += "<br /><a href=\"javascript:MoviePlayer.PlayMovie('"+ name +"',"+ id +");void (0)\">Streaming</a>  \// ";
		//movieControl += "<a href=\"http://glarp.atk.com/videos/" + arrayobj.movieDownloadURL + "\">Download as Windows Media</a>";
		movieControl += "</p>";
	}
	catch(e){
	}

	var obj = document.getElementById("mediaplayer");  
	obj.innerHTML = movieControl;
	movieControl = "";
	
	MoviePlayer.CreateProductDisplay(productsArray[arrayobj.productArrayName]);
}

//-----------------------------------------------------------------------------------------------------------------

MoviePlayer.CreateProductDisplay = function(arrayobj)
{
	var contentDisplay = "";

	try{
		
		for(var i=0; i < arrayobj.length; i++){
			contentDisplay += "<p class=\"moviePlayerProduct\">";
				if(!arrayobj[i].productLink =="") {
					contentDisplay += "<a href=\"" + arrayobj[i].productLink + "\">" + arrayobj[i].productName + "</a>";
				}else{
					contentDisplay += arrayobj[i].productName;
				}
			contentDisplay += "</p>";
		}
		
	}
	catch(e){
	}

	var obj = document.getElementById("ProductInformationDisplay");  
	obj.innerHTML = contentDisplay;
	contentDisplay = "";
}

//-----------------------------------------------------------------------------------------------------------------

MoviePlayer.Init = function()
{
	document.getElementById("scrollbar").style.display = 'none';
	document.getElementById("scrollUp").style.display = 'none';
	document.getElementById("scrollDn").style.display = 'none';
	
	MoviePlayer.ListMovies('RCBS');
	MoviePlayer.PlayStartUpMovie('RCBS',0);

}

//-----------------------------------------------------------------------------------------------------------------

movieArray["RCBS"] = new Array(
	new MoviePlayer.Movie("Cleaning Cases","http://wst2.atk.com/anokastream/RCBS/2008/ShootingUSA/CasePreparation.wmv","RCBS/2007/download.aspx?movie=RASS_Final.wmv",320,240,"CasePreparation.jpg","CleaningCases"),
	new MoviePlayer.Movie("Sizer Die (Caliber Specific)","http://wst2.atk.com/anokastream/RCBS/2008/ShootingUSA/SizerDie.wmv","RCBS/2007/download.aspx?movie=RASSBenchSpot.wmv",320,240,"SizerDie.jpg","SizerDie"),
	new MoviePlayer.Movie("RCBS.Load","http://wst2.atk.com/anokastream/RCBS/2008/ShootingUSA/HandPriming.wmv","RCBS/2007/download.aspx?movie=RASSBenchSpot.wmv",320,240,"HandPriming.jpg","RCBSLoad"),
	new MoviePlayer.Movie("X-Die (Caliber Specific)","http://wst2.atk.com/anokastream/RCBS/2008/ShootingUSA/CaseMasterTool.wmv","RCBS/2007/download.aspx?movie=RASS_Final.wmv",320,240,"CaseMasterTool.jpg","XDie"),
	new MoviePlayer.Movie("Priming Cases","http://wst2.atk.com/anokastream/RCBS/2008/ShootingUSA/ChargeMaster.wmv","RCBS/2007/download.aspx?movie=RASS_Final.wmv",320,240,"ChargeMaster.jpg","PrimingCases"),
	new MoviePlayer.Movie("Powder Charging","http://wst2.atk.com/anokastream/RCBS/2008/ShootingUSA/HeadSpace.wmv","RCBS/2006/download.aspx?movie=RCBS_Scoutten001.wmv",320,240,"HeadSpace.jpg","HeadSpace"),
	new MoviePlayer.Movie("Flash Hole Deburring Tool","http://wst2.atk.com/anokastream/RCBS/2008/ShootingUSA/FlashHole.wmv","RCBS/2006/download.aspx?movie=RCBS_Scoutten001.wmv",320,240,"FlashHole.jpg","FlashHoleDeburringTool"),
	new MoviePlayer.Movie("How to Determine the Quality of Cases","http://wst2.atk.com/anokastream/RCBS/2008/ShootingUSA/CaseExtraction.wmv","RCBS/2006/download.aspx?movie=RCBS_Scoutten001.wmv",320,240,"CaseExtraction.jpg","QualityOfCases"),
	new MoviePlayer.Movie("Case Trimming","http://wst2.atk.com/anokastream/RCBS/2008/ShootingUSA/CaseTrimming.wmv","RCBS/2006/download.aspx?movie=RCBS_Scoutten001.wmv",320,240,"CaseTrimming.jpg","CaseTrimming"),
	new MoviePlayer.Movie("Case Neck Prep","http://wst2.atk.com/anokastream/RCBS/2008/ShootingUSA/CaseNeckPrep.wmv","RCBS/2005/download.aspx?movie=RCBS_Final.wmv",320,240,"CaseNeckPrep.jpg","CaseNeckPrep"),
	new MoviePlayer.Movie("Sizer Die 2 (Caliber Specific)","http://wst2.atk.com/anokastream/RCBS/2008/ShootingUSA/SizerDie_2.wmv","RCBS/2005/download.aspx?movie=RCBS_Final.wmv",320,240,"SizerDie_2.jpg","SizerDie2"),
	new MoviePlayer.Movie("Adjust Seater Die (Caliber Specific)","http://wst2.atk.com/anokastream/RCBS/2008/ShootingUSA/The_X_Die.wmv","RCBS/2005/download.aspx?movie=RCBS_Final.wmv",320,240,"The_X_Die.jpg","AdjustSeaterDie"),
	new MoviePlayer.Movie("Stuck Case","http://wst2.atk.com/anokastream/RCBS/2008/ShootingUSA/DotLoadSoftware.wmv","RCBS/2005/download.aspx?movie=RCBS_Final.wmv",320,240,"DotLoadSoftware.jpg","StuckCase")
);

//-----------------------------------------------------------------------------------------------------------------

productsArray["StuckCase"] = new Array(
	new MoviePlayer.Products("#9355 Stuck Case Remover-2 Kit","https://shop.rcbs.com/WebConnect/MainServlet?storeId=webconnect&catalogId=webconnect&langId=en_US&action=ProductDisplay&screenlabel=index&productId=3160&route=C15J030")
);

productsArray["FlashHoleDeburringTool"] = new Array(
	new MoviePlayer.Products("Flash Hole Deburring Tool","https://shop.rcbs.com/WebConnect/MainServlet?action=CatalogSearch&langId=en_US&storeId=webconnect&catalogId=webconnect&screenlabel=index&pageSize=15&beginIndex=0&resultType=3&orderBy=1&searchType=0&searchDescription=flash"),
	new MoviePlayer.Products("#90375 Trim Mate Case Prep Center 110 VAC","https://shop.rcbs.com/WebConnect/MainServlet?storeId=webconnect&catalogId=webconnect&langId=en_US&action=ProductDisplay&screenlabel=index&productId=3170")
);

productsArray["RCBSLoad"] = new Array(
	new MoviePlayer.Products("#99915 RCBS.Load Reloading Software","https://shop.rcbs.com/WebConnect/MainServlet?storeId=webconnect&catalogId=webconnect&langId=en_US&action=ProductDisplay&screenlabel=index&productId=3672")
);

productsArray["HeadSpace"] = new Array(
	new MoviePlayer.Products("#98923 ChargeMaster Combo","https://shop.rcbs.com/WebConnect/MainServlet?storeId=webconnect&catalogId=webconnect&langId=en_US&action=ProductDisplay&screenlabel=index&productId=2964"),
	new MoviePlayer.Products("#7109515 Speer Reloading Manual #14","")
);

productsArray["SizerDie"] = new Array(
	new MoviePlayer.Products("Sizer Die (Caliber Specific)","https://shop.rcbs.com/WebConnect/MainServlet?storeId=webconnect&catalogId=webconnect&langId=en_US&screenlabel=index&action=CategoryDisplay&categoryId=C09")
);

productsArray["SizerDie2"] = new Array(
	new MoviePlayer.Products("Precision Mic (Caliber Specific)","https://shop.rcbs.com/WebConnect/MainServlet?storeId=webconnect&catalogId=webconnect&langId=en_US&screenlabel=index&action=CategoryDisplay&categoryId=C11J149&route=C11"),
	new MoviePlayer.Products("Sizer Die (Caliber Specific)","https://shop.rcbs.com/WebConnect/MainServlet?storeId=webconnect&catalogId=webconnect&langId=en_US&screenlabel=index&action=CategoryDisplay&categoryId=C09")
);

productsArray["XDie"] = new Array(
	new MoviePlayer.Products("X-Die (Caliber Specific)","https://shop.rcbs.com/WebConnect/MainServlet?storeId=webconnect&catalogId=webconnect&langId=en_US&screenlabel=index&action=CategoryDisplay&categoryId=C09J049&route=C09")
);

productsArray["QualityOfCases"] = new Array(
	new MoviePlayer.Products("#87310 CaseMaster Gauging Tool","https://shop.rcbs.com/WebConnect/MainServlet?storeId=webconnect&catalogId=webconnect&langId=en_US&action=ProductDisplay&screenlabel=index&productId=3180")
);

productsArray["AdjustSeaterDie"] = new Array(
	new MoviePlayer.Products("Seater Die (Caliber Specific)","https://shop.rcbs.com/WebConnect/MainServlet?storeId=webconnect&catalogId=webconnect&langId=en_US&screenlabel=index&action=CategoryDisplay&categoryId=C09"),
	new MoviePlayer.Products("Precision Mic (Caliber Specific)","https://shop.rcbs.com/WebConnect/MainServlet?storeId=webconnect&catalogId=webconnect&langId=en_US&screenlabel=index&action=CategoryDisplay&categoryId=C11J149&route=C11")
);

productsArray["CaseNeckPrep"] = new Array(
	new MoviePlayer.Products("#90355 Trim Pro Manual Case Trimmer Kit","https://shop.rcbs.com/WebConnect/MainServlet?storeId=webconnect&catalogId=webconnect&langId=en_US&action=ProductDisplay&screenlabel=index&productId=3571"),
	new MoviePlayer.Products("#90350 Trim Pro Power Case Trimmer Kit","https://shop.rcbs.com/WebConnect/MainServlet?storeId=webconnect&catalogId=webconnect&langId=en_US&action=ProductDisplay&screenlabel=index&productId=3569")
);

productsArray["CleaningCases"] = new Array(
	new MoviePlayer.Products("#87088 Vibratory Case Cleaner","https://shop.rcbs.com/WebConnect/MainServlet?storeId=webconnect&catalogId=webconnect&langId=en_US&action=ProductDisplay&screenlabel=index&productId=3168")
);

productsArray["CaseTrimming"] = new Array(
	new MoviePlayer.Products("Trim Pro 3-Way Cutter (Caliber Specific)","https://shop.rcbs.com/WebConnect/MainServlet?storeId=webconnect&catalogId=webconnect&langId=en_US&screenlabel=index&action=CategoryDisplay&categoryId=C13J036N024&route=C13J036"),
	new MoviePlayer.Products("#7109515 Speer Reloading Manual #14","")
);

productsArray["PrimingCases"] = new Array(
	new MoviePlayer.Products("#90201 Universal Hand Priming Tool","https://shop.rcbs.com/WebConnect/MainServlet?storeId=webconnect&catalogId=webconnect&langId=en_US&action=ProductDisplay&screenlabel=index&productId=2885"),
	new MoviePlayer.Products("#7109515 Speer Reloading Manual #14","")
);
//-----------------------------------------------------------------------------------------------------------------

window.onload = function() { MoviePlayer.Init(); }

