if (document.getElementById) {
	// Prefs
	document.write('<link rel="stylesheet" type="text/css" href="css/default.css" />');
	
	mac = (navigator.appVersion.indexOf("Mac")>-1) ? true : false; // Mac
	ie = (document.all && !window.opera) ? true : false; // IE
	safari = (navigator.appVersion.indexOf("Safari")>-1) ? true : false; // Safari
	gecko = (navigator.userAgent.indexOf("Gecko/") > -1)? true : false; // Gecko
	
	
	menuMargin = (mac && ie) ?16:1; // Menu Margin (px)
	popupmenu = null; // Object Name
	overlay = null; // Object Name
	sel = false; // Disk Selected
	z = 1; // Z-Index
	obj = null;
	ttl = false;
	f = 0;
	window.onload = init;
}

function init() {
	document.ondragstart = document.onselectstart = new Function("return false");
	

	d = document.getElementById("main").getElementsByTagName("div");
	for (i=0; i<d.length; i++) {
		//if (d[i].className && (d[i].className == "dskimg" || d[i].className == "ovl")) {
		if (d[i].className && d[i].className == "thumbnail") {
			d[i].style.cursor = "pointer";
			d[i].oncontextmenu = new Function("return false");
			d[i].getElementsByTagName("img")[0].setAttribute("alt","");
			
			as= d[i].getElementsByTagName("A");
			for(j=0; j<as.length; j++) {
				as[j].onfocus = mBlur;
			}
		}
	}

	bodyObj = (ie && mac) ? document.body : document.documentElement;
	
	window.onscroll = hideMenu;
	document.onmouseup = docMouseUp;
	document.onmousedown = docMouseDown;

	if (ie && !mac) window.onfocus = reloadImgs;
	// Patch: Add Title Attribute
	if (ttl) {
		d = document.getElementById("main").getElementsByTagName("div");
		for (i=0; i<d.length; i++) {
			if (d[i].className && d[i].className=="thumbnail") {
				t = new String(d[i].getElementsByTagName("p")[0].innerHTML);
				t = (!gecko) ? t.replace(/<br>/gi,"\r"):t.replace(/<br>/gi," ") ;
				t = t.replace(/ {2,}/gi," ");
				t = t.replace(/&amp;/gi,"&");
				t = (!gecko) ? t.replace(/\n/gi,""): t.replace(/[\r\n]/gi,"");
				t = t.replace(/<(\/{0,})([a-zA-Z]+)>/gi,"");
				d[i].getElementsByTagName("img")[0].setAttribute("title",t);
			}
		}
	}
	
	// Patch: View Screen Shot with New Window
	d = document.getElementById("main").getElementsByTagName("a");
	for (i=0; i<d.length; i++) {
		if (d[i].className && d[i].className == "view") {
			d[i].onclick= new Function("newWindow(this); return false");
		}
	}
}


function docMouseDown(e) {
	obj = (ie) ? event.srcElement: e.target;
	while (obj.parentNode) {
		if ((obj.className && obj.className == "thumbnail") || (obj.className && obj.className == "menu")) break;
		else obj = obj.parentNode;
	}

	if (obj.className == "thumbnail" && !overlay && !popupmenu) {
		overlay = obj.getElementsByTagName("p")[0];
		overlay.style.visibility = "visible";
		obj.onmouseover = mOver;
		overlay.onmouseout = mOut;
		
		sel = true;
	} else if (obj.className != "menu") {
		hideMenu();
	}
	return false;
}

function mOver() {
	if (overlay && sel) overlay.style.visibility = "visible";
}

function mOut() {
	if (overlay && sel) overlay.style.visibility = "hidden";
}

function docMouseUp(e) {
	sel = false;
	if (obj) obj.onmouseover = null;
	if (overlay) overlay.onmouseout = null;
	obj = (ie) ? event.srcElement: e.target;
	

	while (obj.parentNode) {
		if ((obj.className && obj.className == "thumbnail") || (obj.tagName && obj.tagName == "BODY")) break;
		else obj = obj.parentNode;
	}
	
	// Hide Popup Menu
	if (popupmenu) {
		if (gecko) setTimeout("hideMenu()",0);
		else hideMenu();
	}
	// Show Popup Menu
	else {
		// Get Scroll Offset
		scrollW = (ie) ? bodyObj.scrollLeft : window.pageXOffset;
		scrollH = (ie) ? bodyObj.scrollTop : window.pageYOffset;
		
		// Get Mouse Loc
		mouseX = (ie) ? event.clientX + scrollW : (safari) ? e.clientX : e.clientX + scrollW;
		mouseY = (ie) ? event.clientY + scrollH : (safari) ? e.clientY : e.clientY + scrollH;
		
		// Get Screen Size
		screenW = (ie) ? bodyObj.clientWidth + scrollW : window.innerWidth + scrollW;
		screenW = Math.min(bodyObj.offsetWidth+scrollW ,screenW);
		screenH = (ie) ? bodyObj.clientHeight + scrollH : window.innerHeight + scrollH;
		
		// Download Menu
		if (obj.className == "thumbnail" && (overlay && overlay.style.visibility == "visible")) {
			
			obj.style.zIndex = z;
			popupmenu = obj.getElementsByTagName("ul")[0];
			offSetX = obj.offsetLeft + (obj.parentNode.offsetLeft);
			offSetY = obj.offsetTop + (obj.parentNode.offsetTop);
		}
		
		// Show
		if (popupmenu) {
			// Safari Hover Redraw Patch
			if (safari) {
				popupmenu.innerHTML = popupmenu.innerHTML;
				d = popupmenu.getElementsByTagName("a");
				for (i=0; i<d.length; i++) {
					if (d[i].className && d[i].className == "view") {
						d[i].onclick= new Function("newWindow(this); return false");
					}
				}
			}
			
			z++;
			popupmenu.style.visibility = "hidden";
			popupmenu.style.display = "block";
			
			menuX = Math.min(mouseX - offSetX, screenW - popupmenu.offsetWidth - menuMargin - offSetX);
			menuY = Math.min(mouseY - offSetY, screenH - popupmenu.offsetHeight - menuMargin - offSetY);
		
			popupmenu.style.left = menuX +"px";
			popupmenu.style.top = menuY +"px";
			popupmenu.style.zIndex = z;
			popupmenu.style.visibility = "visible";
			
		}
		// Do Nothing
		else {
			overlay = null;
		}
		
	}

}

function hideMenu() {
	if (popupmenu) {
		popupmenu.style.display = "none";
		popupmenu = null;
	}
	if (overlay) {
		overlay.style.visibility = "hidden";
		overlay = null;
	}
}

function newWindow(o) {
	nw = window.open(o.getAttribute("href"),"_blanK","width=640,height=480,status=1,resizable=1,scrollbars=1");
	nw.focus();
}

function reloadImgs() {
	d = document.getElementById("main").getElementsByTagName("div");
	for (i=0; i<d.length; i++) {
		if (d[i].className && d[i].className=="thumbnail") {
			d[i].getElementsByTagName("p")[0].style.backgroundImage = d[i].getElementsByTagName("p")[0].currentStyle.backgroundImage;
		}
		//alert(d[i].getElementsByTagName("p")[0].style.backgroundImage)
	}

}

function mBlur(e) {
	if (event.srcElement || e) {
		eObj = (ie)?event.srcElement:e.target;
		while (eObj.tagName != "A") {
			eObj = eObj.parentNode;
		}
		eObj.blur();
	}
}

function showMe(o) {
	o.parentNode.parentNode.style.visibility = "visible";
}

function extremeTracking() {
	//return;
	EXs = screen;
	EXw = EXs.width;
	navigator.appName!="Netscape"?EXb=EXs.colorDepth:EXb=EXs.pixelDepth;
	var EXlogin='9031fdl' // Login
	var EXvsrv='s9' // VServer
	navigator.javaEnabled()==1?EXjv="y":EXjv="n";
	EXd = document;
	EXw?"":EXw="na";
	EXb?"":EXb="na";
	EXd.write('<img src="http://e0.extreme-dm.com/' + EXvsrv + '.g?login=' + EXlogin + '&amp;','jv=' + EXjv + '&amp;j=y&amp;srw=' + EXw + '&amp;srb=' + EXb + '&amp;','l=' + escape(EXd.referrer) + '" height="1" width="1" />');

}