function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_popUpImage(c) {
  imageWindow = window.open('', 'window', 'width=600,height=675,scrollbars=yes,status=yes');
  imageWindow.document.write("<table align='center' background=" + c + " style='background-repeat:no-repeat; background-position:center;' width='550' height='550'><a href='javascript:window.close()'><tr><td width='550' height='600'></td></tr><tr><td><a href='javascript:window.close()'><center><font face='Arial, Helvetica' size='2'>Close Window</font></center></a></td></tr></a></table>");
}
  
function MM_parseSource(c) {
   var path = window.document.images[c].src;
   var pathArray;
   pathArray = path.split("/");
   path = pathArray[3] + "/" + pathArray[4] + "/550/" + pathArray[6];
   MM_popUpImage(path);
}
function showImage(url,name,options) {
  var ContextWindow = window.open(url,name,options);
  ContextWindow.focus();
  return false;
}

// Snow Lookup

var tooltip=function(){
	var id = 'tt';
	var top = -103;
	var left;
	var maxw = 365;
	var speed = 20;
	var timer = 20;
	var endalpha = 95;
	var alpha = 0;
	var tt,t,c,b,h;
	var ie = document.all ? true : false;
	return{
		show:function(v,type,xpos,imgWidth){
			// Made w = null (to get rid of issues with using it when we don't need it). -KJS 08/13/10
			var w = null;
			
			// Default the image width to 419 because Chrome is dumb and doesn't know the width until the image is 100% loaded... all other browsers get the correct width, though. -KJS 08/13/10
			if(imgWidth <= 0){
				imgWidth = 419;
			}

			// Checks whether to make it left or right, > than is right and < is left. -KJS 08/13/10
			if(xpos > imgWidth){
				left = -342;
			}else if(xpos <= imgWidth){
				left = 0;
			}else{
				left = 0;
			}
			
			// Recieves variable oem or oemam (whether aftermarket or oem) to decide how far from the top of the cursor to put the box (because aftermarket box is taller). -KJS 08/13/10
			if(type == 'oem'){
				top = -103;
			}else if (type = 'oemam'){
				top = -146;
			}else{
				top = -103;
			}
			
			if(tt == null){
				tt = document.createElement('div');
				tt.setAttribute('id',id);
				t = document.createElement('div');
				t.setAttribute('id',id + 'top');
				c = document.createElement('div');
				c.setAttribute('id',id + 'cont');
				b = document.createElement('div');
				b.setAttribute('id',id + 'bot');
				tt.appendChild(t);
				tt.appendChild(c);
				tt.appendChild(b);
				document.body.appendChild(tt);
				tt.style.opacity = 0;
				tt.style.filter = 'alpha(opacity=0)';
				document.onmousemove = this.pos;
			}
			tt.style.display = 'block';
			c.innerHTML = v;
			tt.style.width = w ? w + 'px' : 'auto';
			if(!w && ie){
				t.style.display = 'none';
				b.style.display = 'none';
				tt.style.width = tt.offsetWidth;
				t.style.display = 'block';
				b.style.display = 'block';
			}
			if(tt.offsetWidth > maxw){tt.style.width = maxw + 'px'}
			h = parseInt(tt.offsetHeight) + top;
			clearInterval(tt.timer);
			tt.timer = setInterval(function(){tooltip.fade(1)},timer);
		},
		pos:function(e){
			var u = ie ? event.clientY + document.documentElement.scrollTop : e.pageY;
			var l = ie ? event.clientX + document.documentElement.scrollLeft : e.pageX;
			tt.style.top = (u - h) + 'px';
			tt.style.left = (l + left) + 'px';
		},
		fade:function(d){
			var a = alpha;
			if((a != endalpha && d == 1) || (a != 0 && d == -1)){
				var i = speed;
				if(endalpha - a < speed && d == 1){
					i = endalpha - a;
				}else if(alpha < speed && d == -1){
					i = a;
				}
				alpha = a + (i * d);
				tt.style.opacity = alpha * .01;
				tt.style.filter = 'alpha(opacity=' + alpha + ')';
			}else{
				clearInterval(tt.timer);
				if(d == -1){tt.style.display = 'none'}
			}
		},
		hide:function(){
			clearInterval(tt.timer);
			tt.timer = setInterval(function(){tooltip.fade(-1)},timer);
		}
	};
}();

// Gets image size. -KJS 08/13/10

function getImgSize(imgSrc)
{
	var newImg = new Image();
	newImg.src = imgSrc;
	var width = newImg.width;
	// alert ('The image width is '+width);
	return width;
}
