// All scripting hand-coded by JuiCe (j.ski@online.ie) 2002-2005

onload = initScripts;

imageCount = 22;

numCell = 13;
menuBG = "#FFFFFF";

MD = 0;
cX = 0;
cY = 0;

OOOStatus = false;
qFlag = false;

rndMsg = new Array();
rndMsg[0] = "Welcome to EQSource: Your complete EverQuest source!";
rndMsg[1] = "Check out <a href='http://snow.prohosting.com/eqsource/ttp' target='_blank'>Tic Tac PRO</a> - your answer to boredom ;)";
rndMsg[2] = "Submit screenshots for the front page of EQSource <a href='sshots.htm'>here</a>!";
rndMsg[3] = "Add yourself to my new matchmaker database: <a href='http://wind.prohosting.com/fux0r' target='_blank'>JHL</a>!";
rndMsg[4] = "EQSource is best viewed at <b>1024x768</b> resolution";
rndMsg[5] = "Behold the new power of the <a href='aditem.htm'>Advanced Item Lookup</a> with <b>QuickTips</b>!";
rndMsg[6] = "Ever want to just <a href='kbl.htm'>kill Bin Laden</a>?";
rndMsg[7] = "Questions / comments?  <a href='contact.htm'>Contact me</a>!";
rndMsg[8] = "You've got questions.  The <a href='http://www.pliner.net/appmb/everquest'>messageboard</a> has answers.";
rndMsg[9] = "I love fishes cuz they so delicious.";
rndMsg[10] = "If you appreciate my work, <a href='https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=j.ski@online.ie' target='_blank'><b>DONATE</b></a>!";
rndMsg[11] = "Have you tried <a href='down.htm'>AdminEQ 2004 Lite</a>?";

//document.oncontextmenu = new Function("return false");
window.onerror = killErr;

function killErr() {
	return true;
}

imgCap = new Array();

window.status = "EQSource";
baseURL = "http://everquest.mirrorz.com/";

curCell = 1;

function Sel(mNum) {
	while (curCell < numCell) {
		selMenu = "MenuTBL.Menu"+curCell;
		selMenu.backgroundColor = "#DDDDDD";
		curCell++;
	}
		mNum.style.backgroundColor = menuBG;
		curCell = 1;
}

function DeSel(mNum) {
	mNum.style.backgroundColor = "#DDDDDD";
}

function Alpha() {
	if (event.keyCode < 65 || event.keyCode > 122) {
		if (event.keyCode != 32) {
			event.keyCode = 0;
		}
	}
}

function dragOK(n) {
	MD = n;
	cX = event.offsetX;
	cY = event.offsetY;
}

function doDrag() {
	if (MD == 1) {
		mX = event.clientX;
		mY = event.clientY;
		stats.style.pixelLeft = mX-cX + document.body.scrollLeft; 		
		stats.style.pixelTop = mY-cY + document.body.scrollTop;
	}
}

function doRand() {
	n = Math.round(Math.random() * (rndMsg.length-1));
		if (n < 0) n = 0;
	Msg.innerHTML = rndMsg[n];
}

// Image handling
function getIMG(SRC) {
	HWND = window.open("","",config="scrollbars=no,titlebar=no,location=no,status=no,menubar=no,directories=no,resizable=no,toolbar=no,height=300,width=300");
	HWND.document.write("<div style='display:none'><noscript><body></body></noscript></div>\n");
	HWND.document.write("<html>\n");
	HWND.document.write("<head><title>Loading..</title>\n");
	HWND.document.write("<link rel='stylesheet' href='http://snow.prohosting.com/eqsource/src/JuiCe.css'>\n");
	HWND.document.write("<script>\n");
	HWND.document.write("<!--\n");
	HWND.document.write("document.oncontextmenu = new Function('return false');\n");
	HWND.document.write("onload = init;\n");
	HWND.document.write("function init() {\n");
	HWND.document.write("window.resizeTo(document.images[0].width+30,document.images[0].height+100);\n");
	HWND.document.write("document.title = 'EQSource';\n");
	HWND.document.write("}\n");
	HWND.document.write("//-->\n");
	HWND.document.write("</scr"+"ipt>\n");
	HWND.document.write("</head>\n");
	HWND.document.write("<table height='100%' width='100%' cellpadding='0' cellspacing='0'><tr><td align='center' valign='middle'>\n");
	HWND.document.write("<img src='img/"+SRC+".jpg' ondrag='return false' galleryimg='no'><br><a href='javascript:window.close()'>Close Window</a></td></tr></table></html>\n");
	HWND.document.close();
}

function bigIMG(SRC) {
	HWND = window.open("","",config="scrollbars=no,titlebar=no,location=no,status=no,menubar=no,directories=no,resizable=no,toolbar=no,height=300,width=300");
	HWND.document.write("<div style='display:none'><noscript><body></body></noscript></div>\n");
	HWND.document.write("<html>\n");
	HWND.document.write("<head><title>Loading..</title>\n");
	HWND.document.write("<link rel='stylesheet' href='http://snow.prohosting.com/eqsource/src/JuiCe.css'>\n");
	HWND.document.write("<script>\n");
	HWND.document.write("<!--\n");
	HWND.document.write("document.oncontextmenu = new Function('return false');\n");
	HWND.document.write("onload = init;\n");
	HWND.document.write("function init() {\n");
	HWND.document.write("window.resizeTo(document.images[0].width+30,document.images[0].height+100);\n");
	HWND.document.write("document.title = 'EQSource';\n");
	HWND.document.write("}\n");
	HWND.document.write("//-->\n");
	HWND.document.write("</scr"+"ipt>\n");
	HWND.document.write("</head>\n");
	HWND.document.write("<table height='100%' width='100%' cellpadding='0' cellspacing='0'><tr><td align='center' valign='middle'>\n");
	HWND.document.write("<img src='"+SRC+"' ondrag='return false' galleryimg='no'><br><a href='javascript:window.close()'>Close Window</a></td></tr></table></html>\n");
	HWND.document.close();
}

function cRes() {
	sH = screen.Height;
	sW = screen.Width;
		if ((sW < 1024) && (sH < 768)) {
			agree = confirm("I have detected that your screen resolution is "+sW+"x"+sH+". This website was designed for 1024x768 resolution. If you continue, the website may not appear correctly. Would you like to enter anyway?");
			if (!agree) history.go(-1);
		}
}

function ImgErr() {
	c = 0;
	nImg = document.images.length;
	if (nImg > 0) {
		while (c < nImg) {
			if ((document.images[c].width == 28) && (document.images[c].height == 30)) {
				document.images[c].src = "img/BrokenImg.jpg";
			}
				c++;
		}
	}
}

function findSS(eqPath,maxSS) {
	alert("Please allow this process up to 5 minutes, depending on the the speed of your computer and the number of screenshots you opted to show.");
	ss.innerHTML = "";
	eqPath = jsPath(eqPath);
	ss.innerHTML += "<br>";
		for (c=0; c<=maxSS; c++) {
			if (qFlag == true) {
				qFlag = false;
				window.status = "EQSource";
				break;
			}
			window.status = "Trying EQ"+nullify(c)+".bmp..";
			img = new Image();
			img.src = "file://"+eqPath+"/EQ"+nullify(c)+".bmp";
				if (img.width != 28) {
					remID = "<img src='file://"+eqPath+"/EQ"+nullify(c)+".bmp' alt='"+eqPath+"/EQ"+nullify(c)+".bmp' height='150' width='200' onerror='remImage(this)' style='cursor:hand' onClick='bigIMG(this.src)'> ";
				ss.innerHTML += remID;
				}
			window.status = "EQSource";
		}
	if (ss.innerHTML == "" || ss.innerHTML == "<BR>") {
		alert("No screenshots found");
	} else {
		alert("Done");
	}
}

function remImage(obj) {
	obj.style.display = "none";
}

function jsPath(eqPath) {
	newPath = eqPath.replace(/\\/g,"/");
	return newPath;
}

function nullify(n) {
	if ((n >= 0) && (n < 10)) {
		f = "00000"+n;
	} else if ((n >= 10) && (n < 100)) {
		f = "0000"+n;
	} else if ((n >= 100) && (n < 1000)) {
		f = "000"+n;
	} else if ((n >= 1000) && (n < 10000)) {
		f = "00"+n;
	}
return f;
}

file = new Array();
file[0] = "AEQ2003.zip";
file[1] = "EQInside.zip";
file[2] = "EQWindows.zip";
file[3] = "BazaarMate.zip";
file[4] = "EQRosterizer.zip";
file[5] = "MyMQ2.zip";
file[6] = "MagelorizeR.zip";
file[7] = "AEQ2_Lite.zip";

function dl(n) {
baseDLS = "http://e.toolz.tripod.com/dls/";
	if (OOOStatus == true) {
		alert("Sorry, downloads are currently out of order.\n\nPlease try back later.");
	} else {
		if (navigator.appName != "Netscape") {
			window.open(baseDLS+file[n]);
		} else {
			alert("Sorry, downloads do not work with FireFox/Netscape at the moment.");
		}
	}
}

function getMiniQ() {
	if (OOOStatus == true) {
		alert("Sorry, downloads are currently out of order.\n\nPlease try back later.");
	} else {
		window.open("http://e.toolz.tripod.com/MiniQ/MiniQ.zip");
	}
}

mods = new Array();
mods[0] = "javascript:alert('This download no longer exists.');";
mods[1] = "PWMod1.zip";

function getMOD(n) {
	if (OOOStatus == true) {
		alert("Sorry, downloads are currently out of order.\n\nPlease try back later.");
	} else {
		modBase = "http://e.toolz.tripod.com/dls/";
		window.open(modBase+mods[n]);
	}
}

function initScripts() {
	doRand();
	ImgErr();
}

function randImg() {
	n = Math.round(Math.random() * (imageCount));
		if (n <= 0) {
			setTimeout("randImg()",10);
		} else {
			BlockIMG.style.backgroundImage = "url(usr/EQs"+n+".jpg)";
		}
}

function selText(tBox) {
	range = tBox.createTextRange();
	range.select();
}

function goHome() {
	window.location = "http://everquest.mirrorz.com";
}

function cF() {
	if (itemName.value == "") {
		alert("Enter an item");
		itemName.focus();
	} else {
		is.submit();
	}
}

function Poll() {	window.open("http://everquest.mirrorz.com/EQSpoll.htm","EQSPOLL",config="scrollbars=no,height=400,width=300,resizable=no,location=no,directories=no,status=no,titlebar=no,menubar=no");
}

function doApprove(n,iNum) {
	if (n == 0) {
		document.forms['is'].auth.value = "decline";
	} else if (n == 1) {
		document.forms['is'].auth.value = "approve";
	}
		document.forms['is'].img.value = iNum;
		document.forms['is'].submit();
}

function doGallery() {
	document.forms['is'].action = "http://snow.prohosting.com/eqsource/cgi-bin/gallery.pl";
	document.forms['is'].submit();
}

function doWin(movie,height,width,bgcolor) {
	pageData = "about:<html><head><title>JuiCe</title><script src='src/JuiCe.js'></script><link rel='stylesheet' href='src/JuiCe.css'></head><body><table height='100%' width='100%'><tr><td align='center' valign='middle'><OBJECT classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0' WIDTH="+width+" HEIGHT="+height+"><PARAM NAME=menu VALUE=false><PARAM NAME=quality VALUE=autohigh><PARAM NAME=scale VALUE=noborder><PARAM NAME=wmode VALUE=opaque><PARAM NAME=bgcolor VALUE="+bgcolor+"><PARAM NAME=movie VALUE='flash/"+movie+".swf'><EMBED src='flash/"+movie+".swf' menu=false quality=autohigh scale=noborder wmode=opaque bgcolor="+bgcolor+" WIDTH="+width+" HEIGHT="+height+" TYPE='application/x-shockwave-flash' PLUGINSPAGE='http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash'></EMBED></OBJECT>";
	wHeight = height + 50;
	wWidth = width + 50;
window.open(pageData,"f745H",config="toolbar=no,menubar=no,scrollbars=no,status=no,directories=no,location=no,resizable=no,height="+wHeight+",width="+wWidth);
}

function inString(targetString,searchString,caseSensitive) {
	if ((caseSensitive == 0) || (caseSensitive == null)) {
		targetString = targetString.toLowerCase();
		searchString = searchString.toLowerCase();
	}
		if (targetString.indexOf(searchString) != -1) return 1;
		
		return 0;
}

function makeImages(tagOpen,tagClosed,imgWidth,imgHeight,altText) {
	imgStart = document.body.innerHTML.indexOf(tagOpen);
		while (imgStart != -1) {
			HTML = document.body.innerHTML;
			bodyLen = HTML.length;
			imgStart = HTML.indexOf(tagOpen);
			bodyStart = HTML.substr(0,imgStart);
				if (imgStart != -1) {
					imgStart = imgStart + tagOpen.length;
				}
 			imgHTML = HTML.substr(imgStart,bodyLen);
			imgEnd = imgHTML.indexOf(tagClosed);
			img = HTML.substr(imgStart,imgEnd)
				if ((inString(link,"onclick=",0) == 1) || (inString(link,"ondblclick=",0) == 1) || (inString(link,"onmousemove=",0) == 1) || (inString(link,"onmouseover=",0) == 1) || (inString(link,"onmouseup=",0) == 1) || (inString(link,"onmousedown=",0) == 1) || (inString(link,"onunload=",0) == 1) || (inString(link,"onload=",0) == 1) || (inString(link,"onblur=",0) == 1) || (inString(link,"onfocus=",0) == 1) || (inString(link,"onselect=",0) == 1) || (inString(link,"onbeforeunload=",0) == 1) || (inString(link,"onchange=",0) == 1) || (inString(link,"onkeydown=",0) == 1) || (inString(link,"onkeyup=",0) == 1) || (inString(link,"onmouseout=",0) == 1) || (inString(link,"onerror=",0) == 1) || (inString(link,"javascript:",0) == 1)) {
					break;
				}
			bodyEnd = imgHTML.substr(imgEnd+tagClosed.length,bodyLen);
				if (bodyStart != "") {
					newBody = bodyStart;
					newBody += '<img src="'+img+'"';
				   if ((imgWidth != "") && (imgWidth != null)) {
					newBody += ' width="'+imgWidth+'"';
				   }
				   if ((imgHeight != "") && (imgHeight != null)) {
					newBody += ' height="'+imgHeight+'"';
				   }
				   if ((altText != "") && (altText != null)) { 
 					newBody += ' alt="'+altText+'">';
				   }
					newBody += bodyEnd;
					document.body.innerHTML = newBody;
				}
		}
}

function makeLinks(tagOpen,tagClosed,target) {
	linkStart = document.body.innerHTML.indexOf(tagOpen);
		while (linkStart != -1) {
			HTML = document.body.innerHTML;
			bodyLen = HTML.length;
			linkStart = HTML.indexOf(tagOpen);
			bodyStart = HTML.substr(0,linkStart);
				if (linkStart != -1) {
					linkStart = linkStart + tagOpen.length;
				}
 			linkHTML = HTML.substr(linkStart,bodyLen);
			linkEnd = linkHTML.indexOf(tagClosed);
			link = HTML.substr(linkStart,linkEnd)
				if ((inString(link,"onclick=",0) == 1) || (inString(link,"ondblclick=",0) == 1) || (inString(link,"onmousemove=",0) == 1) || (inString(link,"onmouseover=",0) == 1) || (inString(link,"onmouseup=",0) == 1) || (inString(link,"onmousedown=",0) == 1) || (inString(link,"onunload=",0) == 1) || (inString(link,"onload=",0) == 1) || (inString(link,"onblur=",0) == 1) || (inString(link,"onfocus=",0) == 1) || (inString(link,"onselect=",0) == 1) || (inString(link,"onbeforeunload=",0) == 1) || (inString(link,"onchange=",0) == 1) || (inString(link,"onkeydown=",0) == 1) || (inString(link,"onkeyup=",0) == 1) || (inString(link,"onmouseout=",0) == 1) || (inString(link,"onerror=",0) == 1) || (inString(link,"javascript:",0) == 1)) {
					break;
				}
			bodyEnd = linkHTML.substr(linkEnd+tagClosed.length,bodyLen);
				if (bodyStart != "") {
					newBody = bodyStart;
					newBody += '<a href="'+link+'" target="'+target+'">'+link+'</a>';
					newBody += bodyEnd;
					document.body.innerHTML = newBody;
				}
		}
}

