/*2 CE ID 2360292 generated by espn/Collection.tea on March 8, 2006 6:23:13 PM PST from Production/Production/Javascript */

Object.extend = function(destination, source)/* From  Prototype JavaScript framework, version 1.4.0 (c) 2005 Sam Stephenson <sam@conio.net>*/
{
	for (property in source)
	{
		destination[property] = source[property];
	}
	return destination;
}

var Class = { /* From  Prototype JavaScript framework, version 1.4.0 (c) 2005 Sam Stephenson <sam@conio.net>*/
	create: function()
	{
		return function()
		{
			this.initialize.apply(this, arguments);
		}
	}
}

Class.inherits = function(parentClass)
{
	return function()
	{
		for(var prop in parentClass.prototype)
		{
			if(!this[prop])
			{
				this[prop] = parentClass.prototype[prop];
			}
		}
		this.uber = parentClass.prototype;
		parentClass.prototype.initialize.apply(this, arguments);
		this.initialize.apply(this, arguments);
	}
}

window.onloadListeners = new Array();
window.addOnloadListener = function(listener,context)
{
	window.onloadListeners[onloadListeners.length] = new com.espn.listeners.WindowListener(listener,context);
}
window.onload = function()
{
	for(var i=0; i<window.onloadListeners.length; i++)
	{
		if(window.onloadListeners[i].context)
		{
			var func = window.onloadListeners[i].listener;
			func.call(window.onloadListeners[i].context);
		}
		else
		{
			var func = window.onloadListeners[i].listener;
			func.call();
		}
	}
}


/*Begin ESPN.com core*/
var com = {
	espn:{
		env:{},
		listeners:{}
	}
};

com.espn.env.av = navigator.appVersion;
com.espn.env.ua = navigator.userAgent;

com.espn.listeners.Listener = Class.create();

com.espn.listeners.Listener.prototype = {
	initialize: function(listener,context)
	{
		this.context = context;
		this.listener = listener;
	}
};

com.espn.listeners.WindowListener = Class.inherits(com.espn.listeners.Listener);

com.espn.listeners.WindowListener.prototype = {
	initialize: function(){}
}

com.espn.resolve = function(packageString)
{
	var packages = packageString.split(',');
	for(var i=0; i<packages.length; i++)
	{
		com.espn.resolvePackage(packages[i]);
	}
}

com.espn.resolvePackage = function(objectName,originalTry)
{
	if(objectName.indexOf('*') != -1 || objectName == '' || !objectName)
	{
		return;
	}
	try
	{
		var dummy = eval(objectName);
	}
	catch(e)
	{
		var lastDot = objectName.lastIndexOf('.');
		var originalTry = originalTry ? originalTry : objectName;
		objectName = objectName.substring(0,lastDot);
		com.espn.resolvePackage(objectName,originalTry);
	}
	
	if(!eval(objectName))
	{
		var lastDot = objectName.lastIndexOf('.');
		var originalTry = originalTry ? originalTry : objectName;
		objectName = objectName.substring(0,lastDot);
		com.espn.resolvePackage(objectName,originalTry);
	}
	var left = originalTry.replace(objectName + '.','');
	var objectNames = left.split('.');
	var objStr = objectName;
	for(var i = 0; i < objectNames.length; i++)
	{
		eval(objStr)[objectNames[i]] = {};
		objStr = objectName + '.' + objectNames[i];
	}
}




com.espn.resolve('');
function getElem(name)
{
	if (document.getElementById)
	{
		return document.getElementById(name);
	}
	else if (document.all)
	{
		return document.all[name];
	}
	else if (document.layers)
	{
		return document.layers[name];
	}
	else
	{
		return null;
	}
}
var g_ajax_debug = false;
var RequestFactory = {
	'requests':new Object(),
	'createRequest':function(url,id,func,argObj,abortable,abortOthers,query,type)
	{
		if(abortOthers)
		{
			RequestFactory.abortAll();
		}
		
		if(!RequestFactory.requests[id])
		{
			RequestFactory.requests[id] = new CustomRequest(url,id,func,argObj,abortable,query,type);
		}
		
		RequestFactory.requests[id].init(id);
		return RequestFactory.requests[id];
	},
	'abortAll':function()
	{
		for(var i in RequestFactory.requests)
		{
			RequestFactory.requests[i].abort();
		}
	},
	'getRequest':function(id)
	{
		return RequestFactory.requests[id];
	}
};

function CustomRequest(url,id,func,argObj,abortable,query,type)
{
	this.id = id;
	this.req = null;
	this.type = type;
	this.url = url;
	this.query = query;
	this.argObj = argObj;
	this.func = func;
	this.abortable = null;

	if(typeof abortable == 'undefined' || abortable == null)
	{
		this.abortable = true;
	}
	else
	{
		this.abortable = abortable;
	}
	
	this.abort = function()
	{
		if(this.req && this.abortable)
		{
			this.req.abort();
		}
	}
	
	this.init = function(id)
	{
		if(!this.type)
		{
			this.type = 'GET';
		}
		
		if(!this.argObj)
		{
			this.argObj = new Object();
		}
		
		if(!this.query)
		{
			this.query = '';
		}
		
		if(this.req == null)
		{
			if(window.XMLHttpRequest)
			{
				try
				{
					this.req = new XMLHttpRequest();
				} 
				catch(e)
				{
					this.req = null;
				}
			}
			else if(window.ActiveXObject)
			{
				try
				{
					this.req = new ActiveXObject("Msxml2.XMLHTTP");
				}
				catch(e)
				{
					try
					{
						this.req = new ActiveXObject("Microsoft.XMLHTTP");
					}
					catch(e)
					{
						this.req = null;
					}
				}
			}
		}
		
		if(this.req)
		{
			this.req.onreadystatechange = function()
			{
				var localReq = RequestFactory.getRequest(id);
				if (localReq.req.readyState == 4)
				{
					if (localReq.req.status == 200 || g_ajax_debug)
					{
						localReq.argObj['responseXML'] = localReq.req.responseXML;
						localReq.func(localReq.argObj);
					}
				}
			}
			
			this.req.open(this.type,this.url, true);
			if(this.type == 'POST')
			{
				this.req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
			}
			this.req.send(this.query);
		}
	}
}

