

// DOM Check
if (!document.getElementById) {
 self.location.replace('/browserupgrade');
}

// IE 5.0
var ua = navigator.userAgent.toLowerCase();
var ieIndex = ua.indexOf("msie");
if (ieIndex != -1 && ua.indexOf("mac") == -1) {
    var ieVer = parseFloat(ua.substr(ieIndex + 5));
    if (ieVer < 5.5) {
        window.location.replace("/browserupgrade");
    }
}
function clearfix(classname) {
    if(navigator.appVersion.indexOf('Mac')!= -1 && document.all) {
        var divs = document.getElementsByTagName("DIV");
        for(var i = 0; i < divs.length; i++) {
            if(divs[i].className.indexOf(classname) != -1) {
                //divs[i].innerHTML += '<div class="mac-clearfix"> </div>';
                var clearDiv = document.createElement("div");
                clearDiv.className = "mac-clearfix";
                divs[i].appendChild(clearDiv);
            }
        }
    }
}
// Add it to window.onload event
addOnLoad(function() {clearfix("clearthis");});

/*
 * Adds a function into the onload event
 * Usage: addOnLoad(functionName)
 * Or, if you need to pass arguments in the
 * function:
 * addOnLoad(function() {functionName("argument")})
*/
function addOnLoad(newFunction) {
    var currentOnLoad = window.onload;
    if (typeof window.onload != "function") {
        window.onload = newFunction;
    }
    else {
        window.onload = function() {
            currentOnLoad();
            newFunction();
        }
    }
}

Flash = function(swf, width, height, version)
{
    this.swf = swf || "";
    this.width = width || "100%";
    this.height = height || "100%";
    this.requiredVersion = version || 6;
    this.id = "";
    this.params = new Object();
    this.variables = new Object();
};

Flash.hasVersion = function(requiredVersion)
{
    var hasVersion = false;
    if (navigator.plugins.length > 0 && navigator.plugins["Shockwave Flash"]) { // NS/Mozilla
        var description = navigator.plugins["Shockwave Flash"].description;
        var version = description.match(/\d{1,2}/);
        hasVersion = (version >= requiredVersion);
    }
    else if (window.ActiveXObject && window.execScript && navigator.userAgent.indexOf('Mac') == -1) { // Win IE
        Flash.hasActiveX = false;
        window.execScript("On error resume next: Flash.hasActiveX = IsObject(CreateObject('ShockwaveFlash.ShockwaveFlash." + requiredVersion + "'))", "VBScript");
        hasVersion = Flash.hasActiveX;
        delete Flash.hasActiveX;
    }
    return hasVersion;
};

Flash.resizeTo = function(id, w, h)
{
    var movie = document.getElementById(id);
    movie.width = w;
    movie.height = h;
};

Flash.prototype.getSWF = function()
{
    return this.swf;
};

Flash.prototype.setSWF = function(swf)
{
    this.swf = swf;
};

Flash.prototype.getWidth = function()
{
    return this.width;
};

Flash.prototype.setWidth = function(w)
{
    this.width = w;
};

Flash.prototype.getHeight = function()
{
    return this.height;
};

Flash.prototype.setHeight = function(h)
{
    this.height = h;
};

Flash.prototype.getRequiredVersion = function()
{
    return this.requiredVersion;
};

Flash.prototype.setRequiredVersion = function(v)
{
    this.requiredVersion = v;
};

Flash.prototype.getId = function()
{
    return this.id;
};

Flash.prototype.setId = function(id)
{
    this.id = id;
};

Flash.prototype.getParam = function(name)
{
    return this.params[name];
};

Flash.prototype.getParams = function()
{
    return this.params;
};

Flash.prototype.setParam = function(name, value)
{
    this.params[name] = value;
};

Flash.prototype.getVariable = function(name)
{
    return this.variables[name];
};

Flash.prototype.getVariables = function()
{
    return this.variables;
};

Flash.prototype.setVariable = function(name, value)
{
    this.variables[name] = value;
};

Flash.prototype.getVariablePairs = function()
{
    var variablePairs = new Array();
    for (var name in this.getVariables()) {
        variablePairs.push(name + "=" + escape(this.getVariable(name)));
    }
    if (variablePairs.length > 0) {
        return variablePairs.join("&");
    }
    else {
        return null;
    }
};

Flash.prototype.getParamTags = function()
{
    var paramTags = "";
    for (var param in this.getParams()) {
        paramTags += '<param name="' + param + '" value="' + this.getParam(param) + '" />';
    }
    if (paramTags == "") {
        paramTags = null;
    }
    return paramTags;
};

Flash.prototype.getHTML = function()
{
    var flashHTML = "";
    if (window.ActiveXObject && navigator.userAgent.indexOf('Mac') == -1) { // PC IE
        flashHTML += '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="' + this.getWidth() + '" height="' + this.getHeight() + '" id="' + this.getId() + '">';
        flashHTML += '<param name="movie" value="' + this.getSWF() + '" />';
        if (this.getParamTags() != null) {
            flashHTML += this.getParamTags();
        }
        if (this.getVariablePairs() != null) {
            flashHTML += '<param name="flashVars" value="' + this.getVariablePairs() + '" />';
        }
        flashHTML += '</object>';
    }
    else { // Everyone else
        flashHTML += '<embed type="application/x-shockwave-flash" src="' + this.getSWF() + '" width="' + this.getWidth() + '" height="' + this.getHeight() + '" id="' + this.getId() + '"';
        for (var param in this.getParams()) {
            flashHTML += ' ' + param + '="' + this.getParam(param) + '"';
        }
        if (this.getVariablePairs() != null) {
            flashHTML += ' flashVars="' + this.getVariablePairs() + '"';
        }
        flashHTML += '></embed>';
    }
    
    return flashHTML;
};

Flash.prototype.render = function(elementId)
{
    if(Flash.hasVersion(this.getRequiredVersion())) {
        if (elementId) {
            document.getElementById(elementId).innerHTML = this.getHTML();
        }
        else {
            document.write(this.getHTML());
        }
    }
};

document.write('<OBJECT ID="IERPCtl" WIDTH=0 HEIGHT=0 CLASSID="CLSID:FDC7A535-4070-4B92-A0EA-D9994BCC0DC5"></OBJECT>');
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' || (navigator.plugins[i].name) == 'RealPlayer Version Plugin'){
					nPlayerInstalled=1;
					szPlayerVersion=navigator.plugins[i].description;
					break;
					}
					i++;
				}
			
				if ( nPlayerInstalled == 2 ){
					var nRPVersion = 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 LaunchRealChannel(page) {
		
		fullpage = page + '';
		//indexpage = page + '\\index.html';
		
		var agt=navigator.userAgent.toLowerCase();
		var
		is_aol = (agt.indexOf("aol") != -1);
		if (is_aol){
			window.location = (fullpage); // version for AOL browsers, was aol.html
		}
		else{
			var checkbrowser = isRealOne(); // here's where people with R1 will go
			if (checkbrowser == 'using') {
				 window.location = (fullpage);
			}
			if (checkbrowser == 'installed') {  // here's where people with R1 will go
				 window.location = (fullpage);
			}
			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 (navigator.userAgent.indexOf("Mac") != -1) {
		
			if (oldRealPlayer == 'true'){
				window.location = (fullpage);
			} else {
			window.open('http://transfer.go.com/cgi/transfer.pl?goto=http://www.real.com/partners/abcnews/?pcode=abc&cpath=R1R&rsrc=jslandingpage','r1popup','height=460,width=626,status=yes,toolbar=no,menubar=no,scrollbars=yes,resize=yes,location=yes');
			}
		}
		
		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';
			}
		}
			if (oldRealPlayer == 'true' || oldRealPlayerIE == 'true'){	
			window.location = (fullpage);
			} else {
			window.open('http://transfer.go.com/cgi/transfer.pl?goto=http://www.real.com/partners/abcnews/?pcode=abc&cpath=R1R&rsrc=jslandingpage','r1popup','height=460,width=626,status=yes,toolbar=no,menubar=no,scrollbars=yes,resize=yes,location=yes');
			}	 	
		}	
		
		
		else {if (navigator.userAgent.indexOf("Win") != -1) {
		
			if (checkbrowser =='undetermined' || checkbrowser =='notinstalled') {
				window.open('http://transfer.go.com/cgi/transfer.pl?goto=http://www.real.com/partners/abcnews/?pcode=abc&cpath=R1R&rsrc=jslandingpage','r1popup','height=460,width=626,status=yes,toolbar=no,menubar=no,scrollbars=yes,resize=yes,location=yes');
			}
			
		} else {
		
			window.open('http://transfer.go.com/cgi/transfer.pl?goto=http://www.real.com/partners/abcnews/?pcode=abc&cpath=R1R&rsrc=jslandingpage','r1popup','height=460,width=626,status=yes,toolbar=no,menubar=no,scrollbars=yes,resize=yes,location=yes');
		
		}
	}
	}
	}
}
function LaunchVideo(page) { 
		
		fullpage = page + '';
		//indexpage = page + '\\index.html';
		
		var agt=navigator.userAgent.toLowerCase();
		var
		is_aol = (agt.indexOf("aol") != -1);
		if (is_aol){
			window.location = (fullpage); // version for AOL browsers, was aol.html
		}
		else{
			var checkbrowser = isRealOne(); // here's where people with R1 will go
			if (checkbrowser == 'using') {
				 window.location = (fullpage);
			}
			if (checkbrowser == 'installed') {  // here's where people with R1 will go
				 window.location = (fullpage);
			}
			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 (navigator.userAgent.indexOf("Mac") != -1) {
		
			if (oldRealPlayer == 'true'){
				window.location = (fullpage);
			} else {
			window.open('http://transfer.go.com/cgi/transfer.pl?goto=http://www.real.com/partners/abcnews/?pcode=abc&cpath=R1R&rsrc=jslandingpage','r1popup','height=460,width=626,status=yes,toolbar=no,menubar=no,scrollbars=yes,resize=yes,location=yes');
			}
		}
		
		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';
			}
		}
			if (oldRealPlayer == 'true' || oldRealPlayerIE == 'true'){	
			window.location = (fullpage);
			} else {
			window.open('http://transfer.go.com/cgi/transfer.pl?goto=http://www.real.com/partners/abcnews/?pcode=abc&cpath=R1R&rsrc=jslandingpage','r1popup','height=460,width=626,status=yes,toolbar=no,menubar=no,scrollbars=yes,resize=yes,location=yes');
			}	 	
		}	
		
		
		else {if (navigator.userAgent.indexOf("Win") != -1) {
		
			if (checkbrowser =='undetermined' || checkbrowser =='notinstalled') {
				window.open('http://transfer.go.com/cgi/transfer.pl?goto=http://www.real.com/partners/abcnews/?pcode=abc&cpath=R1R&rsrc=jslandingpage','r1popup','height=460,width=626,status=yes,toolbar=no,menubar=no,scrollbars=yes,resize=yes,location=yes');
			}
			
		} else {
		
			window.open('http://transfer.go.com/cgi/transfer.pl?goto=http://www.real.com/partners/abcnews/?pcode=abc&cpath=R1R&rsrc=jslandingpage','r1popup','height=460,width=626,status=yes,toolbar=no,menubar=no,scrollbars=yes,resize=yes,location=yes');
		
		}
	}
	}
	}
}

function cssRollover(obj, posX, posY) {
    if (typeof obj == "string") {
        obj = document.getElementById(obj);
    }
    obj.style.backgroundPosition = posX + "px " + posY + "px";
}

function extLinkTarget() {
    var links = document.getElementsByTagName("a");
    for (var i = 0; i < links.length; i++) {
        var currentLink = links[i];
        if ((currentLink.href.indexOf("go.com") == -1) && (currentLink.href.indexOf("abcnews.com") == -1) && (currentLink.href.indexOf("blogs.com") == -1) && (currentLink.href.indexOf("start.real.com") == -1) && (currentLink.href.indexOf("mfile.akamai.com") == -1) && (currentLink.href.indexOf("dig.com") == -1) && (currentLink.href.indexOf("newspreview") == -1) && (currentLink.href.indexOf("javascript") == -1) && (currentLink.href.indexOf("dyn.onthesnow.com") == -1)) {
      	    currentLink.target = "_blank"; 
  	    } 
  	    else if (currentLink.href.indexOf("espn.go.com") != -1) {
  	        currentLink.target = "_blank"; 
  	        }
    }
}

addOnLoad(extLinkTarget);

function openPopup(url, name, width, height, features) {
    adjH = ((!document.all)&&(height<635))?20:0;
    var winFeatures = (features) ? "," + features : "";
    var xPos = (screen.availWidth) / 2 - (width / 2);
    var yPos = (screen.availHeight / 2) - (height / 2);
    var winAttribs = "width=" + width + ",height=" + (height+adjH) + ",left=" + xPos + ",top=" + yPos + winFeatures;
    var popup = window.open(url, name, winAttribs);
    popup.focus();
}

// search query
function URLencode(sStr) {
    return escape(sStr).
             replace(/\+/g, '%2B').
                replace(/\"/g,'%22').
                   replace(/\'/g, '%27').
                     replace(/\//g,'%2F');
}
 
function tgSearch(tg) {
    var query = '';
    var type = 'feature'
    searchQuery = tg.searchtext.value;
    query = 'http://abcnews.go.com/search?searchtext=' + URLencode(searchQuery) + '&type=' + type;
    if (query != '') {
        window.location.href = query;
    }
    return false;
}
