function isIE() {
	var agt=navigator.userAgent.toLowerCase();
	return ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
}

function isNetscape() {
	var agt=navigator.userAgent.toLowerCase();
	return ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)
                && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1)
                && (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1));
}

function openWindow(imagename, winwidth, winheight) {
	var str = new String(imagename);
	winheight += 20;
	winwidth += 20;
	var winObj;
	if (!isNetscape()) 
		winObj = window.open("", "mywindow", "width=" + winwidth + ",height=" + winheight + ",left=" +Math.round(screen.width/2 - winwidth/2) + ",top=" + Math.round(screen.height/2 - winheight/2) + ",resizable=no")
	else if (isNetscape()) 
		winObj = window.open("", "mywindow", "width=" + winwidth + ",height=" + winheight + ",screenX=" +Math.round(screen.width/2 - winwidth/2) + ",screenY=" + Math.round(screen.height/2 - winheight/2) + ",resizable=no");
	winObj.document.open();
	winObj.document.write("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"><html xmlns=\"http://www.w3.org/1999/xhtml\"><head><title>"+ str.substr(str.lastIndexOf("/")+1, str.lastIndexOf(".")-str.lastIndexOf("/")-1) +"</title></head><body><img src="+ imagename +" border=\"0\"/></body></html>");
}

function openFlash(videoname, description, width, height) {
	var winObj;
	var text;
	var winheight = height + 30;
	if (!isNetscape()) 
		winObj = window.open("", "mywindow", "width=" + width + ",height=" + winheight + ",left=" +Math.round(screen.width/2 - width/2) + ",top=" + Math.round(screen.height/2 - winheight/2) + ",resizable=no")
	else if (isNetscape()) 
		winObj = window.open("", "mywindow", "width=" + width + ",height=" + winheight + ",screenX=" +Math.round(screen.width/2 - width/2) + ",screenY=" + Math.round(screen.height/2 - winheight/2) + ",resizable=no");
	winObj.document.open();
	text = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"><html xmlns=\"http://www.w3.org/1999/xhtml\"><head><title>"+ description +"</title></head><body>";
	text += "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0\" width=\""+ width +"\" height=\""+ height +"\" id=\"FLVPlayer\">";
	text += "<param name=\"movie\" value=\"FLVPlayer_Progressive.swf\" />";
	text += "<param name=\"salign\" value=\"lt\" />";
	text += "<param name=\"quality\" value=\"high\" />";
	text += "<param name=\"scale\" value=\"noscale\" />";
	text += "<param name=\"FlashVars\" value=\"&MM_ComponentVersion=1&skinName=Corona_Skin_3&streamName=" + videoname + "&autoPlay=true&autoRewind=false\" />";
	text += "<embed src=\"FLVPlayer_Progressive.swf\" flashvars=\"&MM_ComponentVersion=1&skinName=Corona_Skin_3&streamName=" + videoname +"&autoPlay=true&autoRewind=false\" quality=\"high\" scale=\"noscale\" width=\""+ width +"\" height=\""+ height +"\" name=\"FLVPlayer\" salign=\"LT\" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" />";
	text += "</object>";
	text += "</body></html>";
	winObj.document.write(text);
}

function openMediaPlayer(videoname, description, width, height) {
	var winObj;
	var text;
	var winheight = height + 60;
	if (!isNetscape()) 
		winObj = window.open("", "mywindow", "width=" + width + ",height=" + winheight + ",left=" +Math.round(screen.width/2 - width/2) + ",top=" + Math.round(screen.height/2 - winheight/2) + ",resizable=no")
	else if (isNetscape()) 
		winObj = window.open("", "mywindow", "width=" + width + ",height=" + winheight + ",screenX=" +Math.round(screen.width/2 - width/2) + ",screenY=" + Math.round(screen.height/2 - winheight/2) + ",resizable=no");
	winObj.document.open();
	text = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"><html xmlns=\"http://www.w3.org/1999/xhtml\"><head><title>"+ description +"</title></head><body>";
	text += "<object classid=\"clsid:05589FA1-C356-11CE-BF01-00AA0055595A\" id=\"Control1\">";
	text += "<param name=\"Appearance\" value=\"0\">";
	text += "<param name=\"AutoStart\" value=\"-1\">";
	text += "<param name=\"AllowChangeDisplayMode\" value=\"-1\">";
	text += "<param name=\"AllowHideDisplay\" value=\"0\">";
	text += "<param name=\"AllowHideControls\" value=\"-1\">";
	text += "<param name=\"AutoRewind\" value=\"-1\">";
	text += "<param name=\"Balance\" value=\"0\">";
	text += "<param name=\"CurrentPosition\" value=\"0\">";
	text += "<param name=\"DisplayBackColor\" value=\"0\">";
	text += "<param name=\"DisplayForeColor\" value=\"16777215\">";
	text += "<param name=\"DisplayMode\" value=\"0\">";
	text += "<param name=\"Enabled\" value=\"-1\">";
	text += "<param name=\"EnableContextMenu\" value=\"-1\">";
	text += "<param name=\"EnablePositionControls\" value=\"-1\">";
	text += "<param name=\"EnableSelectionControls\" value=\"0\">";
	text += "<param name=\"EnableTracker\" value=\"-1\">";
	text += "<param name=\"Filename\" valuetype=\"ref\" value=\""+ videoname +"\">";
	text += "<param name=\"FullScreenMode\" value=\"-1\">";
	text += "<param name=\"MovieWindowSize\" value=\"0\">";
	text += "<param name=\"PlayCount\" value=\"1\">";
	text += "<param name=\"Rate\" value=\"1\">";
	text += "<param name=\"SelectionStart\" value=\"-1\">";
	text += "<param name=\"SelectionEnd\" value=\"-1\">";
	text += "<param name=\"ShowControls\" value=\"-1\">";
	text += "<param name=\"ShowDisplay\" value=\"-1\">";
	text += "<param name=\"ShowPositionControls\" value=\"0\">";
	text += "<param name=\"ShowTracker\" value=\"-1\">";
	text += "<param name=\"Volume\" value=\"-600\">";
	text += "<param name=\"URL\" value>";
	text += "<param name=\"balance\" value=\"0\">";
	text += "<param name=\"defaultFrame\" value>";
	text += "<param name=\"currentMarker\" value=\"0\">";
	text += "<param name=\"invokeURLs\" value=\"-1\">";
	text += "<param name=\"baseURL\" value>";
	text += "<param name=\"mute\" value=\"0\">";
	text += "<param name=\"uiMode\" value=\"full\">";
	text += "<param name=\"stretchToFit\" value=\"-1\">";
	text += "<param name=\"windowlessVideo\" value=\"0\">";
	text += "<param name=\"SAMIStyle\" value>";
	text += "<param name=\"SAMILang\" value>";
	text += "<param name=\"SAMIFilename\" value>";
	text += "<param name=\"captioningID\" value>";
	text += "<param name=\"enableErrorDialogs\" value=\"0\">";
	text += "</object>";
	text += "</body></html>";
	winObj.document.write(text);
}

function MM_CheckFlashVersion(reqVerStr,msg){
  with(navigator){
    var isIE  = (appVersion.indexOf("MSIE") != -1 && userAgent.indexOf("Opera") == -1);
    var isWin = (appVersion.toLowerCase().indexOf("win") != -1);
    if (!isIE || !isWin){  
      var flashVer = -1;
      if (plugins && plugins.length > 0){
        var desc = plugins["Shockwave Flash"] ? plugins["Shockwave Flash"].description : "";
        desc = plugins["Shockwave Flash 2.0"] ? plugins["Shockwave Flash 2.0"].description : desc;
        if (desc == "") flashVer = -1;
        else{
          var descArr = desc.split(" ");
          var tempArrMajor = descArr[2].split(".");
          var verMajor = tempArrMajor[0];
          var tempArrMinor = (descArr[3] != "") ? descArr[3].split("r") : descArr[4].split("r");
          var verMinor = (tempArrMinor[1] > 0) ? tempArrMinor[1] : 0;
          flashVer =  parseFloat(verMajor + "." + verMinor);
        }
      }
      // WebTV has Flash Player 4 or lower -- too low for video
      else if (userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 4.0;

      var verArr = reqVerStr.split(",");
      var reqVer = parseFloat(verArr[0] + "." + verArr[2]);
  
      if (flashVer < reqVer){
        if (confirm(msg))
          window.location = "http://www.macromedia.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash";
      }
    }
  } 
}
