// variables for embeded player		
var ifilm_sap2_win = null;
var r1_error_win = null;
var add_var = "";
var is_input = document.URL.indexOf('?');
if (is_input != -1)	{ 
	var param = document.URL.substring(is_input+1, document.URL.length);
	var array1 = param.split("&");
	var itemcount = array1.length;
		if (itemcount < 3 ) {
			add_var = param;
		} else {
			add_var = "";
		}
} else {
	add_var = "";
}		
var cch;

// name - name of the cookie
// value - value of the cookie
// [expires] - expiration date of the cookie (defaults to end of current session)
// [path] - path for which the cookie is valid (defaults to path of calling document)
// [domain] - domain for which the cookie is valid (defaults to domain of calling document)
// [secure] - Boolean value indicating if the cookie transmission requires a secure transmission
// * an argument defaults when it is assigned null as a placeholder
// * a null placeholder is not required for trailing omitted arguments
function setCookie(name, value, expires, path, domain, secure) {
  var curCookie = name + "=" + escape(value) +
      ((expires) ? "; expires=" + expires.toGMTString() : "") +
      ((path) ? "; path=" + path : "") +
      ((domain) ? "; domain=" + domain : "") +
      ((secure) ? "; secure" : "");
  document.cookie = curCookie;
}

// name - name of the desired cookie
// * return string containing value of specified cookie or null if cookie does not exist
function getCookie(name) {
  var dc = document.cookie;
  var prefix = name + "=";
  var begin = dc.indexOf("; " + prefix);
  if (begin == -1) {
    begin = dc.indexOf(prefix);
    if (begin != 0) return null;
  } else
    begin += 2;
  var end = document.cookie.indexOf(";", begin);
  if (end == -1)
    end = dc.length;
  return unescape(dc.substring(begin + prefix.length, end));
}

// name - name of the cookie
// [path] - path of the cookie (must be same as path used to create cookie)
// [domain] - domain of the cookie (must be same as domain used to create cookie)
// * path and domain default if assigned null or omitted if no explicit argument proceeds
function deleteCookie(name, path, domain) {
  if (getCookie(name)) {
    document.cookie = name + "=" + 
    ((path) ? "; path=" + path : "") +
    ((domain) ? "; domain=" + domain : "") +
    "; expires=Thu, 01-Jan-70 00:00:01 GMT";
  }
}

// date - any instance of the Date object
// * hand all instances of the Date object to this function for "repairs"
function fixDate(date) {
  var base = new Date(0);
  var skew = base.getTime();
  if (skew > 0)
    date.setTime(date.getTime() - skew);
}

function launchPref() {
	//movieArgs = "/media/sap/sniffer/sniffer.jsp?pinfo=fid:" + fid + "|mt:" + mt + "|bw:" + bw + "|refsite:" + refsite + "|rcid:" + rcid + "|prn:" + prn + "|it:" + it + "|pop:" + pop + "|lid:" + lid + "|sid:" + sid + "|cid:" + cid + "|" + adVars;
	movieArgs = "/media/sapext/sniffer/sniffer.jsp?pinfo=fid:2400440|bw:200";

    var agt=navigator.userAgent.toLowerCase();
    var appVer = navigator.appVersion.toLowerCase();
    var is_major = parseInt(appVer); 
    var is_minor = parseFloat(appVer); 

    var is_mac    = (agt.indexOf("mac")!=-1);
	var is_win    = (agt.indexOf("win")!=-1);
    var is_ie    = (agt.indexOf("msie")!=-1);				
    var is_nav  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)
                && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1)
                && (agt.indexOf('webtv')==-1));				
	var is_aol   = (agt.indexOf("aol") != -1);
	var resizeable;		
	if (is_mac || is_nav || is_aol) {
		resizeable = "resizable=no"
	} else {
		resizeable = "resizable=yes"
	}
	// Exact Insides
	//var size = 'width=652,height=492';
			// SAP Extended
			if (is_win && is_nav && is_major == 4) {
				var size = 'width=670,height=410';
				var wndWidth = 670;
				var wndHeight = 410;				
			} else if (is_ie) {
				var size = 'width=670,height=412';
				var wndWidth = 670;
				var wndHeight = 412;								
			} else {
				var size = 'width=670,height=412';
				var wndWidth = 670;
				var wndHeight = 412;				
			}
	
	if (movieArgs != "") {
		if ( ifilm_sap2_win && !ifilm_sap2_win.closed ) {
			ifilm_sap2_win.location.href = movieArgs;
			setTimeout("ifilm_sap2_win.focus();",500);
		} else {
			ifilm_sap2_win = window.open(movieArgs,'IFILM_SAP2','menubar=no,' + resizeable + ',scrollbars=no,toolbar=no,' + size);
			setTimeout("ifilm_sap2_win.focus();",500);
		}
	}
}

function launchSAP(strPage) {
	adVars = getAdVars();		

	var fid = "";
	var mt = "";
	var bw = "";
	var refsite = "";
	var rcid = "";
	var prn = "";
	var it = "";
	var pop = "";
	var lid = "";	
	var sid = "";
	var cid = "";
	var ec = "";
	var nLen = strPage.length
	var query = strPage.substring(strPage.indexOf("?") + 1,nLen);	
	if (query != "") {
		var lst = query.split("&");
		for (var x = 0; x < lst.length; x++) {
			var item1data = lst[x];
			var item1 = item1data.split("=");
			var itemValue = unescape(item1[1]);
			itemValue = itemValue.replace("+", " ");
			if (typeof itemValue == "undefined") 
				itemValue = "";
			eval("var " + item1[0] + " = '" + itemValue + "';");
		}
		if (ec == "") {	
			var allcookies = document.cookie;			
			if (allcookies.indexOf("ifilm_sap2_prefs=") == -1) {    
				// Go through the sniffer
				//movieArgs = "http://start.real.com/3rd?pid=ifilm_status&url=reallaunch.jsp&pinfo=fid:" + fid + "|mt:" + mt + "|bw:" + bw + "|refsite:" + refsite + "|rcid:" + rcid + "|prn:" + prn + "|it:" + it + "|pop:" + pop + "|lid:" + lid + "|sid:" + sid + "|cid:" + cid + "|" + adVars;
				movieArgs = "/media/sap/sniffer/sniffer.jsp?pinfo=fid:" + fid + "|mt:" + mt + "|bw:" + bw + "|refsite:" + refsite + "|rcid:" + rcid + "|prn:" + prn + "|it:" + it + "|pop:" + pop + "|lid:" + lid + "|sid:" + sid + "|cid:" + cid + "|" + adVars;
			} else {				
				// User has a preference, picky....
				var prefs = getCookie("ifilm_sap2_prefs");
				alert("prefPlayer:" + prefs);
				
				var arrPrefs = prefs.split("|");
				
				var arrPlayerPref = arrPrefs[0].split("=");
//				var arrBandwidthPref = arrPrefs[1].split("=");				
				
				prefPlayer = arrPlayerPref[1];
//				prefBandwidth = arrBandwidthPref[1];				
				
				if (prefPlayer == "ro") {
					// RealONE is the users Preferred Player
					//movieArgs = "";
					//window.location = "";
				} else {
					//movieArgs = "/iFilm/media/sap/sap_wmp.jsp?fid=" + fid + "&mt=" + mt + "&bw=" + bw + "&refsite=" + refsite + "&rcid=" + rcid + "&prn=" + prn + "&it=" + it + "&pop=" + pop + "&lid=" + lid + "&sid=" + sid + "&cid=" + cid + "&" + adVars;
					//movieArgs = "/media/sap/sap_wmp.jsp?fid=" + fid + "&mt=" + mt + "&bw=" + bw + "&refsite=" + refsite + "&rcid=" + rcid + "&prn=" + prn + "&it=" + it + "&pop=" + pop + "&lid=" + lid + "&sid=" + sid + "&cid=" + cid + "&" + adVars;
					var pinfo = "fid:" + fid + "|mt:" + prefPlayer + "|bw:" + bw + "|refsite:" + refsite + "|rcid:" + rcid + "|prn:" + prn + "|it:" + it + "|pop:" + pop + "|lid:" + lid + "|sid:" + sid + "|cid:" + cid + "|" + adVars;
					movieArgs = "/media/player3/showistream?ipt=sap&fid=" + fid + "&mt=" + prefPlayer + "&bw=" + bw + "&refsite=" + refsite + "&rcid=" + rcid + "&prn=" + prn + "&it=" + it + "&pop=" + pop + "&lid=" + lid + "&sid=" + sid + "&cid=" + cid + "&" + adVars + "&pinfo=" + pinfo;
				}				
			}

//			movieArgs = "/media/player3/showistream?ipt=sap&fid=" + fid + "&mt=" + mt + "&bw=" + bw + "&refsite=" + refsite + "&rcid=" + rcid + "&prn=" + prn + "&it=" + it + "&pop=" + pop + "&lid=" + lid + "&sid=" + sid + "&cid=" + cid + "&" + adVars;
			
		    var agt=navigator.userAgent.toLowerCase();
		    var appVer = navigator.appVersion.toLowerCase();
		    var is_major = parseInt(appVer); 
		    var is_minor = parseFloat(appVer); 

		    var is_mac    = (agt.indexOf("mac")!=-1);
			var is_win    = (agt.indexOf("win")!=-1);
		    var is_ie    = (agt.indexOf("msie")!=-1);				
		    var is_nav  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)
		                && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1)
		                && (agt.indexOf('webtv')==-1));				
			var is_aol   = (agt.indexOf("aol") != -1);
			var resizeable;		
			if (is_mac || is_nav || is_aol) {
				resizeable = "resizable=no"
			} else {
				resizeable = "resizable=yes"
			}
			// Exact Insides
			//var size = 'width=652,height=492';
			// Chrome Adjustments
			if (is_win && is_nav && is_major == 4) {
				var size = 'width=340,height=470';
				var reWidth = 340;
				var reHeight = 470;				
			} else if (is_ie) {
				var size = 'width=350,height=472';
				var reWidth = 350;
				var reHeight = 472;								
			} else {
				var size = 'width=340,height=472';
				var reWidth = 340;
				var reHeight = 472;				
			}
			
			if (movieArgs != "") {
				if ( ifilm_sap2_win && !ifilm_sap2_win.closed ) {
					ifilm_sap2_win.location.href = movieArgs;
					setTimeout("ifilm_sap2_win.focus();",500);
				} else {
					ifilm_sap2_win = window.open(movieArgs,'IFILM_SAP2','menubar=no,' + resizeable + ',scrollbars=no,toolbar=no,' + size);
					setTimeout("ifilm_sap2_win.focus();",500);
				}
			}

		}
	}		
}	

// Need to modify to get parameters and call new playVideo
function getMovieQueryString() {
	var value = "";
	var query = location.search.substring(1);
	var pos = query.indexOf("movie=");
	if (pos != -1) {
		// path of movie args
		var moviePath = query.substr(6);
				
		var fid = "";
		var mt = "";
		var bw = "";
		var refsite = "";
		var rcid = "";
		var prn = "";
		var it = "";
		var pop = "";
		var lid = "";	
		var sid = "";
		var cid = "";
		var ec = "";
		var nLen = moviePath.length
		var query = moviePath.substring(moviePath.indexOf("?") + 1,nLen);	
		if (query != "") {
			var lst = query.split("&");
			for (var x = 0; x < lst.length; x++) {
				var item1data = lst[x];
				var item1 = item1data.split("=");
				var itemValue = unescape(item1[1]);
				itemValue = itemValue.replace("+", " ");
				if (typeof itemValue == "undefined") 
					itemValue = "";
				eval("var " + item1[0] + " = '" + itemValue + "';");
			}				
		}
				
		// popup emebeded player
		if ( moviePath != "" ) {
			// Default to unsecure, general content
//			playVideo(fid, bw, "no", "", 1, refsite);
			ipt = "sapext";
			var pinfo = "ipt:" + ipt + "|fid:" + fid + "|mt:" + mt + "|bw:" + bw + "|refsite:" + refsite + "|rcid:" + rcid + "|prn:" + prn + "|it:" + it + "|pop:" + pop + "|lid:" + lid + "|sid:" + sid + "|cid:" + cid + "|" + adVars;
			movieArgs = "/media/setpref?hidUserPrefPlayer=" + mt + "&fid=" + fid + "&mt=" + mt + "&bw=" + bw + "&refsite=" + refsite + "&rcid=" + rcid + "&prn=" + prn + "&it=" + it + "&pop=" + pop + "&lid=" + lid + "&sid=" + sid + "&cid=" + cid + "&" + adVars + "&pinfo=" + pinfo;

		    var agt=navigator.userAgent.toLowerCase();
		    var appVer = navigator.appVersion.toLowerCase();
		    var is_major = parseInt(appVer); 
		    var is_minor = parseFloat(appVer); 
	
		    var is_mac    = (agt.indexOf("mac")!=-1);
			var is_win    = (agt.indexOf("win")!=-1);
		    var is_ie    = (agt.indexOf("msie")!=-1);				
		    var is_nav  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)
		                && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1)
		                && (agt.indexOf('webtv')==-1));				
			var is_aol   = (agt.indexOf("aol") != -1);
			var resizeable;		
			if (is_mac || is_nav || is_aol) {
				resizeable = "resizable=no"
			} else {
				resizeable = "resizable=yes"
			}
			// SAP Extended
			if (is_win && is_nav && is_major == 4) {
				var size = 'width=670,height=410';
				var wndWidth = 670;
				var wndHeight = 410;				
			} else if (is_ie) {
				var size = 'width=670,height=412';
				var wndWidth = 670;
				var wndHeight = 412;								
			} else {
				var size = 'width=670,height=412';
				var wndWidth = 670;
				var wndHeight = 412;				
			}			
			
			if (movieArgs != "") {
				if ( ifilm_sap2_win && !ifilm_sap2_win.closed ) {
					ifilm_sap2_win.location.href = movieArgs;
					setTimeout("ifilm_sap2_win.focus();",500);
				} else {
					ifilm_sap2_win = window.open(movieArgs,'IFILM_SAP2','menubar=no,' + resizeable + ',scrollbars=no,toolbar=no,' + size);
					setTimeout("ifilm_sap2_win.focus();",500);
				}
			}
		}					
	}		
}	

getMovieQueryString();

function isRealOne() {
	RealOneInst = 'undetermined';
	var agt=navigator.userAgent.toLowerCase();
	var is_nav  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)
					&& (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1)
					&& (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1));
	if (is_nav) {
		IERPCtl = 0;
	}
	
	if (navigator.plugins) {
		if ((navigator.userAgent.charAt(8)) >= ('3')) {
			var nPlayerInstalled=2;
			var i=0;
			while (navigator.plugins[i]){
				if ((navigator.plugins[i].name) == 'RealOne Player Version Plugin'){
					nPlayerInstalled=1;
					szPlayerVersion=navigator.plugins[i].description;
					break;
				}
				i++;
			}
			
			if ( nPlayerInstalled == 2 ){
				var nRPVersion = document.IERPCtl.RealPlayerVersion;
				if ( nRPVersion == null ){
					nPlayerInstalled=2;
				} else {
					nPlayerInstalled=1;
				}
			}
		}       
		if (nPlayerInstalled == 1){
			RealOneInst = 'installed';  
		} 
		if (nPlayerInstalled == 2){
			RealOneInst = 'notinstalled';
		}
	} else {
		RealOneInst = 'undetermined';
	}
	if (RealOneInst == 'installed') {
		if (agt.indexOf("(r1 ") != -1) {
				RealOneInst = 'using';
		}
	}
	return RealOneInst;     
}

function playVideo(fid, bw, secure, lid, cr, refsite) {
	// Advars
	adVars = getAdVars();
//	var cch = "";
//	var fid = "";
	var mt = "";
//	var bw = "";
	var rcid = "";
	var prn = "";
	var it = "";
	var pop = "";
//	var lid = "";	
	var sid = "";
	var cid = "";
	var ec = "";

	var strUrl = "";

	if (typeof refsite == "undefined") {
		refsite = "";
	}
	
	
	var query = "";
	var strPage = location.toString();
	var nLen = strPage.length;
	if (strPage.indexOf("?") != -1) {
		query = strPage.substring(strPage.indexOf("?") + 1,nLen);	
	}	
	if (query != "") {
		var lst = query.split("&");
		for (var x = 0; x < lst.length; x++) {
			var item1data = lst[x];
			var item1 = item1data.split("=");
			var itemValue = unescape(item1[1]);
			itemValue = itemValue.replace("+", " ");
			if (typeof itemValue == "undefined") 
				itemValue = "";
			eval("var " + item1[0] + " = '" + itemValue + "';");
		}
	}	
	
	var agt=navigator.userAgent.toLowerCase(); 
	var is_aol = (agt.indexOf("aol") != -1);
	var is_mac = (agt.indexOf("mac")!=-1);
	var is_win = (agt.indexOf("win")!=-1);
	var is_ie = (agt.indexOf("msie")!=-1);	

	var checkbrowser = isRealOne(); 
	if (secure == 'yes') {
		if (is_aol){
//			window.location="/media/sap/sniffer/error/aol.html" // version for AOL browsers
			r1_error_win = window.open("/media/sap/sniffer/error/aol.html",'r1popup','width=250,height=300,toolbar=no,scrollbars=no,resizable=no,directories=no,location=no,status=no,menubar=no');
			setTimeout("r1_error_win.focus();",500);
		} else {	
			if (bw == "56" || bw == "200") {
				bw = "MULTI";
			}
			strUrl = "/media/getmetafile.ram?fid=" + fid + "&bw=" + bw;
			strUrl += "&cch=" + cch;
			var strUrl;
			if (secure == "yes") {
				secure = "yes";
				strUrl += "&mt=ros";
			} else {
				secure = "no";
				strUrl += "&mt=ro";
			}
			strUrl += "&mft=metafile";
			if (lid != "" && lid != "undefined") {
				strUrl += "&lid=" + lid;
			}	
			if (cr != "" && cr != "undefined") {
				strUrl += "&cr=" + cr;
			}

			if (checkbrowser == 'using') {
				 window.location = (strUrl);  // here's where people using R1 will go
			}
			if (checkbrowser == 'installed') {  // here's where people with R1 will go
				 window.location = (strUrl);
			}
			if (checkbrowser =='undetermined' || checkbrowser =='notinstalled') {
				// now the tricky part : people we're not sure about yet
				numPlugins = navigator.plugins.length;
				oldRealPlayer = 'false';
				for (i = 0; i < numPlugins; i++) {
					plugin = navigator.plugins[i];
					if (plugin.name.substring(0,10)=="RealPlayer") {
						oldRealPlayer = 'true';
					}
				}	
			}		
			if (is_mac) {
				// Need to expand sniffing for OSX since 
				// they now have a working RealONE player
	//			window.open('/media/sap/sniffer/error/premium.html','r1popup','width=250,height=300,toolbar=no,scrollbars=no,resizable=no,directories=no,location=no,status=no,menubar=no');
				if (oldRealPlayer == 'true'){
					window.location = (strUrl);
				} else {
					if (secure == 'yes') {
						r1_error_win = window.open('/media/sap/sniffer/error/ifilmplus.jsp','r1popup','width=400,height=320,toolbar=no,scrollbars=no,resizable=no,directories=no,location=no,status=no,menubar=no');
						setTimeout("r1_error_win.focus();",500);
					}
					if (secure == 'no') {
						r1_error_win = window.open('/media/sap/sniffer/error/free.html','r1popup','width=250,height=300,toolbar=no,scrollbars=no,resizable=no,directories=no,location=no,status=no,menubar=no');
						setTimeout("r1_error_win.focus();",500);
					}
				}
			} else {
				if (navigator.userAgent.indexOf("95") != -1) {
					oldRealPlayer = 'false';
					document.writeln('<script language="VBscript">');
					document.writeln('on error resume next');
					document.writeln('RealPlayerG2 = not IsNull(CreateObject("rmocx.RealPlayer G2 Control"))');
					document.writeln('if (RealPlayerG2) then');
					document.writeln('oldRealPlayerIE=\"true\"');
					document.writeln('else');
					document.writeln('oldRealPlayerIE=\"false\"');
					document.writeln('end if');
					document.writeln('</scr' + 'ipt>');
				
					numPlugins = navigator.plugins.length;
					for (i = 0; i < numPlugins; i++) {
						plugin = navigator.plugins[i];
						if (plugin.name.substring(0,10)=="RealPlayer") {
							oldRealPlayer = 'true';
						}
					}
	
	//				window.open('/media/sap/sniffer/error/premium.html','r1popup','width=250,height=300,toolbar=no,scrollbars=no,resizable=no,directories=no,location=no,status=no,menubar=no');
					
					if (oldRealPlayer == 'true' || oldRealPlayerIE == 'true'){	
						// Popup the install RealOne error
						if (secure == 'yes') {
							//window.open('/media/sap/sniffer/error/premium.html','r1popup','width=250,height=300,toolbar=no,scrollbars=no,resizable=no,directories=no,location=no,status=no,menubar=no');
							r1_error_win = window.open('/media/sap/sniffer/error/ifilmplus.jsp','r1popup','width=400,height=320,toolbar=no,scrollbars=no,resizable=no,directories=no,location=no,status=no,menubar=no');
							setTimeout("r1_error_win.focus();",500);
						}
						if (secure == 'no') {
							r1_error_win = window.open('/media/sap/sniffer/error/free.html','r1popup','width=250,height=300,toolbar=no,scrollbars=no,resizable=no,directories=no,location=no,status=no,menubar=no');
							setTimeout("r1_error_win.focus();",500);						}	
	
						// window.location = (strUrl);
					} else {
						if (secure == 'yes') {
							r1_error_win = window.open('/media/sap/sniffer/error/ifilmplus.jsp','r1popup','width=400,height=320,toolbar=no,scrollbars=no,resizable=no,directories=no,location=no,status=no,menubar=no');
							setTimeout("r1_error_win.focus();",500);
						}	
						if (secure == 'no') {
							r1_error_win = window.open('/media/sap/sniffer/error/free.html','r1popup','width=250,height=300,toolbar=no,scrollbars=no,resizable=no,directories=no,location=no,status=no,menubar=no');
							setTimeout("r1_error_win.focus();",500);
						}
					}	 	
				} else {
					// Windows (non Windows 95)
					if (is_win) {
						if (checkbrowser == 'using' || checkbrowser =='installed') {
							window.location = (strUrl);
						} else {
	//						window.open('/media/sap/sniffer/error/premium.html','r1popup','width=250,height=300,toolbar=no,scrollbars=no,resizable=no,directories=no,location=no,status=no,menubar=no');
							if (secure == 'yes') {
								r1_error_win = window.open('/media/sap/sniffer/error/ifilmplus.jsp','r1popup','width=400,height=320,toolbar=no,scrollbars=no,resizable=no,directories=no,location=no,status=no,menubar=no');
								setTimeout("r1_error_win.focus();",500);
							}
							if (secure == 'no') {
								r1_error_win = window.open('/media/sap/sniffer/error/free.html','r1popup','width=250,height=300,toolbar=no,scrollbars=no,resizable=no,directories=no,location=no,status=no,menubar=no');
								setTimeout("r1_error_win.focus();",500);
							}
						} 
					} else {
						r1_error_win = window.open('/media/sap/sniffer/error/otherOS.html','r1popup','width=250,height=160,toolbar=no,scrollbars=no,resizable=no,directories=no,location=no,status=no,menubar=no');	
						setTimeout("r1_error_win.focus();",500);
					}
				}
			}
		}	
	} else {
		// Free content
		if (checkbrowser == 'using') {
			if (bw == "56" || bw == "200") {
				bw = "MULTI";
			}
			strUrl = "/media/getmetafile.ram?fid=" + fid + "&bw=" + bw;
			strUrl += "&cch=" + cch;
			var strUrl;
			if (secure == "yes") {
				secure = "yes";
				strUrl += "&mt=ros";
			} else {
				secure = "no";
				strUrl += "&mt=ro";
			}
			strUrl += "&mft=metafile";
			if (lid != "" && lid != "undefined") {
				strUrl += "&lid=" + lid;
			}	
			if (cr != "" && cr != "undefined") {
				strUrl += "&cr=" + cr;
			}
			window.location = (strUrl);  // here's where people using R1 will go
		} else {
		
	// 		Upsell RealONE here? 
	//		if (upsell == "yes") {
	//			redirect to RealMedia
	//		} else {
	//			continue to popup IFILM player
	//		}
			// Check User Preferences
			var allcookies = document.cookie;
			if (allcookies.indexOf("ifilm_sap2_prefs=") == -1) {    
				// Go through the sniffer
				//movieArgs = "http://start.real.com/3rd?pid=ifilm_status&url=reallaunch.jsp&pinfo=fid:" + fid + "|mt:" + mt + "|bw:" + bw + "|refsite:" + refsite + "|rcid:" + rcid + "|prn:" + prn + "|it:" + it + "|pop:" + pop + "|lid:" + lid + "|sid:" + sid + "|cid:" + cid + "|" + adVars;
				movieArgs = "/media/sapext/sniffer/sniffer.jsp?pinfo=fid:" + fid + "|mt:" + mt + "|bw:" + bw + "|refsite:" + refsite + "|rcid:" + rcid + "|prn:" + prn + "|it:" + it + "|pop:" + pop + "|lid:" + lid + "|sid:" + sid + "|cid:" + cid + "|" + adVars;
			} else {				
				// User has a preference, picky....
				var prefs = getCookie("ifilm_sap2_prefs");

				var arrPrefs = prefs.split("|");
				
				var arrPlayerPref = arrPrefs[0].split("=");
				prefPlayer = arrPlayerPref[1];
				
				if (arrPrefs.length > 1) {
					var arrPlayerType = arrPrefs[1].split("=");
					ipt = arrPlayerType[1];
				} else {
					ipt = "sapext";
				}
	
				if ((prefPlayer == "ro" || prefPlayer == "rm") && (bw == "56" || bw == "200")) {
					bw = "MULTI";
				}
				
				if (prefPlayer == "ro") {
					// RealONE is the users Preferred Player
					strUrl = "/media/getmetafile.ram?fid=" + fid + "&bw=" + bw;
					strUrl += "&cch=" + cch;
					var strUrl;
					if (secure == "yes") {
						secure = "yes";
						strUrl += "&mt=ros";
					} else {
						secure = "no";
						strUrl += "&mt=ro";
					}
					strUrl += "&mft=metafile";
					if (lid != "" && lid != "undefined") {
						strUrl += "&lid=" + lid;
					}	
					if (cr != "" && cr != "undefined") {
						strUrl += "&cr=" + cr;
					}				
					
					movieArgs = "";
					window.location = strUrl;
				} else {
					var pinfo = "ipt:" + ipt + "|fid:" + fid + "|mt:" + prefPlayer + "|bw:" + bw + "|refsite:" + refsite + "|rcid:" + rcid + "|prn:" + prn + "|it:" + it + "|pop:" + pop + "|lid:" + lid + "|sid:" + sid + "|cid:" + cid + "|" + adVars;
					movieArgs = "/media/player3/showistream?fid=" + fid + "&mt=" + prefPlayer + "&bw=" + bw + "&refsite=" + refsite + "&rcid=" + rcid + "&prn=" + prn + "&it=" + it + "&pop=" + pop + "&lid=" + lid + "&sid=" + sid + "&cid=" + cid + "&" + adVars + "&pinfo=" + pinfo;
				}				
			}
			
		    var agt=navigator.userAgent.toLowerCase();
		    var appVer = navigator.appVersion.toLowerCase();
		    var is_major = parseInt(appVer); 
		    var is_minor = parseFloat(appVer); 
	
		    var is_mac    = (agt.indexOf("mac")!=-1);
			var is_win    = (agt.indexOf("win")!=-1);
		    var is_ie    = (agt.indexOf("msie")!=-1);				
		    var is_nav  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)
		                && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1)
		                && (agt.indexOf('webtv')==-1));				
			var is_aol   = (agt.indexOf("aol") != -1);
			var resizeable;		
			if (is_mac || is_nav || is_aol) {
				resizeable = "resizable=no"
			} else {
				resizeable = "resizable=yes"
			}
			// Exact Insides
			// Chrome Adjustments
//			if (is_win && is_nav && is_major == 4) {
//				var size = 'width=340,height=470';
//				var reWidth = 340;
//				var reHeight = 470;				
//			} else if (is_ie) {
//				var size = 'width=350,height=472';
//				var reWidth = 350;
//				var reHeight = 472;								
//			} else {
//				var size = 'width=340,height=472';
//				var reWidth = 340;
//				var reHeight = 472;				
//			}
			// SAP Extended
			if (is_win && is_nav && is_major == 4) {
				var size = 'width=670,height=410';
				var wndWidth = 670;
				var wndHeight = 410;				
			} else if (is_ie) {
				var size = 'width=670,height=412';
				var wndWidth = 670;
				var wndHeight = 412;								
			} else {
				var size = 'width=670,height=412';
				var wndWidth = 670;
				var wndHeight = 412;				
			}			
			
			if (movieArgs != "") {
				if ( ifilm_sap2_win && !ifilm_sap2_win.closed ) {
					ifilm_sap2_win.location.href = movieArgs;
					setTimeout("ifilm_sap2_win.focus();",500);
				} else {
					ifilm_sap2_win = window.open(movieArgs,'IFILM_SAP2','menubar=no,' + resizeable + ',scrollbars=no,toolbar=no,' + size);
					setTimeout("ifilm_sap2_win.focus();",500);
				}
			}
		}
	}		
}	
