/*this is the new vlaunch*/

/*remove this after 9-11*/
var the_date = new Date();
var the_day = the_date.getDate();
var the_month = parseInt(the_date.getMonth()+1);
var the_year = the_date.getFullYear();
/*end remove this after 9-11*/

var ns4,ns6,ie4,ie5,ie6,aol,opera,icab,omniWeb,linux;
var nUser=navigator.userAgent.toLowerCase();
var bname = navigator.appName.toLowerCase();
var ver = navigator.appVersion;
var int_ver = parseInt(ver);
if (nUser.indexOf('konqueror')!=-1){linux = true;}
if (nUser.indexOf('omniWeb')!=-1){omniWeb = true;}
if (nUser.indexOf('opera')!=-1){opera = true;}
if (nUser.indexOf('icab')!=-1){icab = true;}
if (nUser.indexOf('aol')!=-1){aol = true;}
if (bname.indexOf("netscape") >= 0 && int_ver == 4) ns4 = true;/*netscape 4 +*/
if (nUser.indexOf("gecko") != -1){ns6 = true;}/*netscape 6*/
if (nUser.indexOf('msie 4') >0){ie4 = 1;}/*internet explorer 4*/
if (nUser.indexOf('msie 5') >0){ie5 = 1;}/*internet explorer 5*/
if (nUser.indexOf('msie 6') >0){ie6 = 1;}/*internet explorer 6*/
var Mac = ver.indexOf('Mac') != -1 ? true : false;
			var RealMode=0;
	        var RealPlayer7=0;
        	var RealPlayer8=0;
	        var RealPlayerG2=0;

	        if (navigator.userAgent.indexOf("MSIE")<0 )
        	{
        		numPlugins = navigator.plugins.length;
	        	for (i = 0; i < numPlugins; i++)
        		{
                		plugin = navigator.plugins[i];
                		if (plugin.name.substring(0,10)=="RealPlayer")
	                	{
        	                	RealMode=1;
                		}
	        	}
        	}
	        document.write('<SCRIPT LANGUAGE=VBScript\> \n');
        	document.write('on error resume next \n');
	        document.write('RealPlayerG2 = (NOT IsNull(CreateObject("rmocx.RealPlayer G2 Control")))\n');
        	//document.write('RealPlayer7 = (NOT IsNull(CreateObject("RealPlayer.RealPlayer(tm) ActiveX Control (32-bit)")))\n');
	        //document.write('RealPlayer8 = (NOT IsNull(CreateObject("RealVideo.RealVideo(tm) ActiveX Control (32-bit)")))\n');
        	document.write("</SCRIPT\> \n");
			/*test to see if user has real or not*/
	        if ( Mac || RealPlayerG2 )/*|| RealPlayer8  || RealPlayer7*/
        	{
	        	/*alert();*/
				isReal="yes";
			}
			else if ( RealMode )
			{
				isReal="yes";
			}
			else 
	   		{
	   			isReal="no";
			}
			/*this functin returns one of three player types old, new, and help*/
function vlaunch(file){
	/*var vfile = "clip=20011009/rather_cbs_01100918rumsfeld&title=Dan$@$Rather$@$Reports";*/

  var params = file.split("&");
  var clip = "";
  var title = "";
  var castNum = ""
  var date = "";
  var isLive = false;
  for (var i=0; i<params.length; i++)
  {
    var param = params[0].split("=");
    if (param[0] == "clip") {
      if (param[1].indexOf("LiveWebCast") != -1)
      {
        var numb = param[1].split("t");
        castNum = numb[1];
        title = "LiveWebCast";
        isLive = true;
      }
      else
      {
        var fileparts = param[1].split('.');
        clip = fileparts[0];
        var dateparts = clip.split('/');
        date = dateparts[2] + dateparts[3] + dateparts[4];
      }
    } else if (param[0] == "title") {
      if (param[1].indexOf("LiveWebCast") != -1)
      {
        var numb = param[1].split("t");
        castNum = numb[1];
        title = "LiveWebCast";
        isLive = true;
      }
      else
      {
        var titles = param[1].split('$@$');
        title = titles[0];
        for (var j=1; j<titles.length; j++) {
          title = title + " " + titles[j];
        }
      }
    }
  }

	var old_date = "20020225";
	var	templ0="http://www.cbsnews.com/htdocs/videoplayer/newVid/framesource_old.html?"+file;
	var	templ1="http://www.cbsnews.com/htdocs/videoplayer/newVid/framesource2.html?clip="+clip;//obj+"&title="+title;
	var	templ2="http://www.cbsnews.com/htdocs/videoplayer/newVid/framesource_help.html";
	var templ3="http://www.cbsnews.com/htdocs/videoplayer/newVid/framesource2.html?clip=LiveWebCast" + castNum;
	
	/*
	if(the_year == '2002' && the_day == '11' && the_month == '9')
	{
		var templ3="http://www.cbsnews.com/htdocs/videoplayer/newVid/framesource_webcast_911.html?clip=LiveWebCast" + castNum;
	}
	else
	{
		var templ3="http://www.cbsnews.com/htdocs/videoplayer/newVid/framesource2.html?clip=LiveWebCast" + castNum;
	}
	*/
	
	
	var player = isReal
	if(player == "no"){
		var nWin = templ2;
	}else if(isLive){
		var nWin = templ3;
	}else if((date <= old_date) && player == "yes"){
		var nWin = templ0;
	}else if((date > old_date) && player == "yes"){
		var nWin = templ1;
	}	
	//alert(nWin);
	if(ie4||ie5||ie6||ns4||ns6||aol||opera)
	{	
		//alert(Mac);
		//alert("this is:" + bname);
		//if(ns6 && nUser.toLowerCase().indexOf("gecko") != -1){alert("Your Browser is: "+ bname +"\n Your Version is:  " + ver + "\n Code Name: "+ codename + "\n User Agent: "+ nUser);}
		//alert(nWin);
		nWindow = window.open(nWin, 'vvviewer', 'width=540,height=400,scrollbars=0,location=0,menubar=0,resizable=0');
		nWindow.focus();
	}
	else
	{
		alert("We\'re sorry, the CBS video player requires a version 4 broswer\nClick ok to continue to our browser download page\n Hit cancel to return");
		window.open('http://www.microsoft.com/windows/ie/download/ie55sp1.htm?FinishURL=%2Fdownloads%2Frelease%2Easp%3FReleaseID%3D25479%26redirect%3Dno', '', '');
	}
}

