top.calendarEvents=new Array(); top.calendarMonths=new Array(31,28,31,30,31,30,31,31,30,31,30,31);

function navigationChange(mode) { var theOutput=""; 
	if(mode=="members") { theOutput+=" [<a href=index.php?view=memberlist>Member List</a>] [<a href=index.php?view=zoneaccess>Zone Access</a>] [Relic List]"; }
	document.getElementById("navigation_Span").innerHTML=theOutput;
}

function loadCalendar(firstday,lastday,today,total,month,lasttotal,monthnumber,yearnumber) { var theDates=""; var theFirst=firstday; var nextMonth=0;

	if(firstday==0) { firstday=7; } var prevMonth=(monthnumber-1); prevYear=yearnumber; if(prevMonth==0) { prevMonth=12; prevYear--; } if(prevMonth<10) { prevMonth="0"+prevMonth; }
	for(var a=firstday; a>1; a--) {
		theDates+="<td class='calendarPrevNextMonth' valign=middle>"+(lasttotal-(a-2))+"<span id='"+(lasttotal-(a-2))+"-"+prevMonth+"-"+prevYear+"'></span></td>";
	}
	for(var i=0; i<total; i++) { var thePlus="";
		if(theFirst==6 || theFirst==7) { thePlus=" weekendDate"; } else if(theFirst==1) { theDates+="<tr>"; } var theDay=(i+1); if(theDay<10) { theDay="0"+theDay; }
		theDates+="<td class='calendarCurrentMonth"+thePlus+"' valign=top><a href=index.php?view=events&date="+theDay+"-"+monthnumber+"-"+yearnumber+"&month="+monthnumber+"&year="+yearnumber+">"+(i+1)+"</a><p><span id='"+theDay+"-"+monthnumber+"-"+yearnumber+"'></span></td>";
		if(theFirst==7 || theFirst==0) { theFirst=0; theDates+="</tr>"; }
		theFirst++;
	}
	var theLast=lastday; if(theLast==0) { theLast=7; } var foreMonth=(parseInt(monthnumber)+1); foreYear=parseInt(yearnumber); if(foreMonth==13) { foreMonth=1; foreYear++; } if(foreMonth<10) { foreMonth="0"+foreMonth; }
	for(var b=theLast; b<=6; b++) { nextMonth++; theNextMonth=nextMonth; if(theNextMonth<10) { theNextMonth="0"+theNextMonth; }
		theDates+="<td class='calendarPrevNextMonth' valign=middle>"+nextMonth+"<span id='"+(theNextMonth)+"-"+foreMonth+"-"+foreYear+"'></span></td>";
	}

	var lastMonth=parseInt(monthnumber,10)-1; var lastYear=parseInt(yearnumber,10); if(lastMonth==0) { lastMonth=12; lastYear=parseInt(yearnumber,10)-1; }
	var nextMonth=parseInt(monthnumber,10)+1; var nextYear=parseInt(yearnumber,10); if(nextMonth>=13) { nextMonth=1; nextYear=parseInt(yearnumber,10)+1; }

	var theOutput="<table cellpadding=0 cellspacing=3 align=center>\
		<tr><th colspan=7 style='border:1px solid black'><a href=index.php?view=events&month="+lastMonth+"&year="+lastYear+">«</a> "+month+", "+yearnumber+" <a href=index.php?view=events&month="+nextMonth+"&year="+nextYear+">»</a></th></tr>\
		<tr><th width=100 style='border:1px solid black'>Monday</th><th width=100 style='border:1px solid black'>Tuesday</th><th width=100 style='border:1px solid black'>Wednesday</th><th width=100 style='border:1px solid black'>Thursday</th><th width=100 style='border:1px solid black'>Friday</th><th width=100 style='border:1px solid black'>Saturday</th><th width=100 style='border:1px solid black'>Sunday</th></tr>\
		<tr>"+theDates+"</tr>\
		<tr><th width=100 style='border:1px solid black'>Monday</th><th width=100 style='border:1px solid black'>Tuesday</th><th width=100 style='border:1px solid black'>Wednesday</th><th width=100 style='border:1px solid black'>Thursday</th><th width=100 style='border:1px solid black'>Friday</th><th width=100 style='border:1px solid black'>Saturday</th><th width=100 style='border:1px solid black'>Sunday</th></tr>\
	</table>";
	eval("document.getElementById('s_Calendar').innerHTML=\""+theOutput+"\";");

	var theArray=calendarEvents;
	for(var i=0; i<theArray.length; i++) {
		var theExplode=theArray[i].split("|"); var furtherExplode=theExplode[0].split("-");
		eval("document.getElementById(\""+theExplode[0]+"\").innerHTML+=\"<div><a href=index.php?view=events&month="+monthnumber+"&year="+yearnumber+"&date="+theExplode[0]+"&id="+theExplode[2]+"><font size=2>"+theExplode[1]+"</font></a></div>\";");
	}
}

function correctIt(x,y) {
	if(x=="Name") { document.getElementById("correct"+x).innerHTML="<input type=text class=inputText name=correctName size=20 maxlength=255 value=\""+document.getElementById('correct'+x).innerHTML+"\";"; }
	else if(x=="Time") {
		var theExplode=y.split("-");
		var theHours=""; for(var a=0; a<24; a++) { var theTemp=a; theSelect=""; if(theTemp<10) { theTemp="0"+theTemp; } if(theTemp==theExplode[3]) { theSelect=" selected"; } theHours+="<option value="+a+theSelect+">"+theTemp+"</option>"; }
		var theMinutes=""; for(var a=0; a<60; a++) { var theTemp=a; theSelect=""; if(theTemp<10) { theTemp="0"+theTemp; } if(theTemp==theExplode[4]) { theSelect=" selected"; } theMinutes+="<option value="+a+theSelect+">"+theTemp+"</option>"; }

		document.getElementById("correct"+x).innerHTML="<select class=inputText name=correctTimeH>"+theHours+"</select> <select class=inputText name=correctTimeM>"+theMinutes+"</select>";
	}
	else if(x=="Description") {
		document.getElementById("correct"+x).innerHTML="<textarea class=inputText name=correctDescription>"+document.getElementById("correct"+x).innerHTML+"</textarea>";
	}
	document.getElementById("correct"+x+"X").innerHTML="[X]"; document.getElementById("correctSubmit").innerHTML="<input type=submit class=activeSubmit value=Submit>"; 
}

function changeJob(x,y) {
	document.getElementById(x).innerHTML="<input type=text class=inputText name=\""+x+"-job\" id=\""+x+"-job\" value=\""+y+"\" style='width:20px;height:20px' maxlength=2>";
	document.getElementById('submitJob').innerHTML="<input type=submit class=activeSubmit value=Submit>"; 
}
function toggleIt(x) {
	if(document.getElementById(x+'relic').style.display=="none") { document.getElementById(x+'relic').style.display='block'; }
	else { document.getElementById(x+'relic').style.display="none"; }
}
function upgradeRelic(w,x,y,z) { var theCurrency=""; tempCurrency=y.split("x"); tempCurrency=tempCurrency[1];
	if(y.charAt(0)=="s") { theCurrency="Ordelle's Bronzepieces"; } else if(y.charAt(0)=="b") { theCurrency="Byne Bills"; } else { theCurrency="Tukuku Whiteshells"; }
	while(w.replace("_"," ")!=w) { w=w.replace("_"," "); } while(x.replace("_"," ")!=x) { x=x.replace("_"," "); }
	document.getElementById("upgradeItem").innerHTML="<table style='border:1px solid #9A9A9A;width:800px'><tr><td width=780><input type=hidden name=item value=\""+z+"\">Upgrade "+w+" for "+tempCurrency+" "+theCurrency+" and a "+x+" at <input type=text class=inputText size=4 maxlength=6 name=craft style='border-top:0px;border-left:0px;border-right:0px;height:18px;'> <input type=submit class=activeSubmit value=Submit></td><td><a href=# onClick=\"document.getElementById('upgradeItem').innerHTML=''\"><img src=images/exitButton.gif height=15 width=15 border=0></a></td></tr></table><p>&nbsp;";
}