
CHE.roll = function() {
	return {
		orgUrl: "",
		setId: "",

		//binds handler to A tag
		handler: function(domId)
		{
			var self = this;
			if(document.getElementById(domId).parentNode.tagName == "A") 
			{
				var pN = document.getElementById(domId).parentNode;
				pN.onmouseover = function(e)
				{
					self.over(pN.childNodes[0].id);
				}
				pN.onmouseout = function(e)
				{
					self.out(pN.childNodes[0].id);
				}
			}
		},
		
		over: function(domId)
		{
			if(window[domId + "_roll"]) {
				document.getElementById(domId).src = window[domId + "_roll"].src;
			}
		},
		
		out: function(domId)
		{
			if(window[domId]) {
				document.getElementById(domId).src = window[domId].src;
			}
		},
		
		//set img state w/ no binding events
		set: function(o)
		{
			this.setId = o.domId;
			document.getElementById(o.domId).src = o.onUrl;
		},
		
		preload: function(domId,url)
		{
			window[domId] = new Image();
			window[domId].src = url;
		},
		
		init: function(o)
		{
			if(this.setId != o.domId && document.getElementById(o.domId)) //dont bind if we accidentally initialized "domId" and set "setId"
			{
				this.handler(o.domId);
				this.orgUrl = o.orgUrl;
				this.preload(o.domId, o.orgUrl);
				this.preload(o.domId+"_roll", o.rollUrl);
			}
		}
 	};
} ();



