// openMovie - just starts the script
function openMovie(movieURL)
{	
	if (isQTInstalled) {gup('url',movieURL);}			
		
	properties = "";	

	var newwindow = window.open('','movie',properties);	
	newwindow.document.write("<html>");
	newwindow.document.write("<title>Missing QuickTime Player Plug-in</title><body>");
	newwindow.document.write("<a href=\"http://www.apple.com/quicktime/?returnURL="+movieURL+"\"><img src=\"Images/QTlogo.jpg\" /></a>");
	newwindow.document.write("<br /><p>Either your QuickTime Plug-in is not turned on or not installed!</p>");		
	newwindow.document.write("<h4>Please, <a href=\"http://www.apple.com/quicktime/?returnURL="+movieURL+"\">download</a> Quicktime to view video.</h4>");
	newwindow.document.write("</body></html>");

	if (window.focus) {newwindow.focus();}		
	return false;				
}

// check if QuickTime is installed
function isQTInstalled() {
	var qtInstalled = false;
	qtObj = false;
	if (navigator.plugins && navigator.plugins.length) {
		for (var i=0; i < navigator.plugins.length; i++ ) {
         var plugin = navigator.plugins[i];
         if (plugin.name.indexOf("QuickTime") > -1) {
			qtInstalled = true;
         }
      }
	} else {
		execScript('on error resume next: qtObj = IsObject(CreateObject("QuickTimeCheckObject.QuickTimeCheck.1"))','VBScript');
		qtInstalled = qtObj;
	}
	return qtInstalled;
}

// get the movie file from the URL parameter
function gup(name,movieURL)
{  
	name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
	var regexS = "[\\?&]"+name+"=([^&#]*)";
	var regex = new RegExp( regexS );
	var results = regex.exec( movieURL );	
	
	if( results == null ) {
		return "";
	} else {
		//return results[1]; // original purposes
		//alert(results[1]); // testing purposes
		return urlLink(results[1]);
	}
}

// open the popup window with the populated movie
function urlLink(url)
{	
	properties = "width=323,height=259,left=450,top=250";	
	
	var newwindow = window.open('','movie',properties);	
	newwindow.document.write("<html style=\"margin:0;padding:0;\">");
	newwindow.document.write("<title>"+url+"</title><body style=\"margin:0;padding:0;\">");
	newwindow.document.write("<object style=\"margin:0;padding:0;\" width=\"323\" height=\"259\"");
	newwindow.document.write(" classid=\"clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B\" codebase=\"http://www.apple.com/qtactivex/qtplugin.cab\">");
	newwindow.document.write("<embed style=\"margin:0;padding:0;\" src=\""+url+"\" width=\"323\" height=\"259\" style=\"position:relative;margin:30px;\" ");
	newwindow.document.write(" type=\"video/quicktime\" pluginspage=\"http://www.apple.com/quicktime/download/\">");
	newwindow.document.write("</embed>");
	newwindow.document.write("</object>");
	newwindow.document.write("</body></html>");

	if (window.focus) {newwindow.focus();}
	
	return false;
	
}


