var myposts = new post_db();
myposts.ResetPost();
var qdisplay = new qdisplay();
qdisplay.ResetPost();

function qdisplay() 
{
	var maxposts = 50;
	var postArr = new Array(maxposts);
	var postindex = 1;
	var postprefix=new Array("postshow","postbox");
	var ischecked = false;
	var dspposts = 0;

	this.SetPost = SetPost;
	this.ResetPost = ResetPost;
	this.DspToolBar = DspToolBar;
	this.DspPost = DspPost;
	this.DspID = DspID;

	function ResetPost() 
	{
//		alert('ResetPost');
		var x = 0;
		for (x = 0; x < maxposts; x++)  { 
			postArr[x] = -1;
		}
		postindex = 1;
		return;
	}

	function SetPost(status) 
	{
		if (status == 'new') {
			postArr[postindex] = 1;
		} else {
			postArr[postindex] = 0;
		}
		postindex++;
		return;
	} 
	function DspToolBar() 
	{
		var x=0; var y=0;
		var oldpost = 0;
		var newpost = 0;
		var totalposts = 0;
		var docwrite = '';
		for (x=1; x < maxposts; x++)  { 
			if (postArr[x] == '0') {
	//			alert('old post='+x);
				oldpost++;
			} else if (postArr[x] == '1') {
	//			alert('new post='+x);
				newpost++;
			} else {
	//			alert('null post='+x);
				break;
			}
		}
		totalposts = (x-1); x = '';
		dspposts = totalposts;
		//alert('newposts:'+newpost+' oldpost:'+oldpost+' totalposts:'+totalposts);
		
		var part1 = '';
		docwrite = '<div style="z-index:100; position: absolute; left: 0px; bottom: 0px;">';
		for (x=1; x <= totalposts; x++)  { 
			part1 = '<A href="javascript:qdisplay.DspPost(\'postbox'+x+'\',true)" onmouseover="qdisplay.DspPost(\'postbox'+x+'\',false);" onmouseout="qdisplay.DspPost(\'postbox'+x+'\',false);">';
			if (x != totalposts) {
				docwrite = docwrite+part1+x+'</A> ';
			} else {
				docwrite = docwrite+part1+x+'</A>';
			}
		} // end for
		docwrite = docwrite+'</div>';
		return docwrite;
	} // end func
	function hideallposts() {
		for (x=1; x <= dspposts; x++)  { 
			objname = postprefix[1]+x;
			objtmp = document.getElementById(objname);
			if (objtmp != null) { 
				objtmp.style.display = 'none';
			} else {
				alert('DspPost: Error! objtmp does not exist! ');
			}
		}
	}
	function DspPost(objname,markthis) {
		var obj = ''; var x = 0;
		obj = document.getElementById(objname);
		if (obj != null) { 
			if (markthis == false && ischecked == false) {	
				obj.style.display = (obj.style.display == 'none'?'block':'none');
			} else if (markthis == true && ischecked == false) {
				hideallposts();
				obj.style.display = 'block';
			} else if (markthis == true && ischecked == true) {
				hideallposts();
				obj.style.display = 'block';
			}
			if (markthis == true) {
				//alert('markthis:true ischecked:'+ischecked);
				ischecked = (ischecked == false?true:false);
			}
		} else {
			alert('DspPost: Error! objname does not exist! objname='+objname);
		}
		return;
	}
	function DspID(itemname) { // sets defaults for span tag
		//alert('dspid='+itemname+postindex);
		var docwrite = '';
		docwrite = '<div id="';
		if (itemname == postprefix[0]) { // postshow
			docwrite = docwrite+postprefix[0]+postindex+'" style="display: none;">';
		} else if (itemname == postprefix[1]) { // postbox
			docwrite = docwrite+postprefix[1]+postindex+'" style="display: none; border: 3px solid #FF0000;">';
		} else {
			alert('error! invalid itemname for func dspid');
		}
		return docwrite;
	}
} // end class

function post_db()
{
	var maxposts = 50;
	var postArr = new Array(maxposts);
	var postindex = 1;
	var overidedsp = -1;
	var postprefix=new Array("postshow","postbox");
	
	this.SetPost = SetPost;
	this.ShowPost = DisplayPost;
	this.ResetPost = ResetPost;
	this.dspid = dspid;
	this.dsptogglepost = dsptogglepost;
	this.dspallposts = dspallposts;
	this.HidePosts = HidePosts;

	function SetPost(status) 
	{
		if (status == 'new') {
			postArr[postindex] = 1;
		} else {
			postArr[postindex] = 0;
		}
		postindex++;
		return;
	}
	function DisplayPost(index)
	{
		return ((postArr[index] == null || postArr[index] == -1)?-1:postArr[index]);
	}
	function ResetPost() 
	{
//		alert('ResetPost');
		var x = 0;
		for (x = 0; x < maxposts; x++)  { 
			postArr[x] = -1;
		}
		postindex = 1;
		return;
	}
	function dspid(itemname) { // sets defaults for span tag
		//alert('dspid='+itemname+postindex);
		var docwrite = '';
		docwrite = '<SPAN id="';
		if (itemname == postprefix[0]) { // postshow
			docwrite = docwrite+postprefix[0]+postindex+'" style="display: none;">';;
		} else if (itemname == postprefix[1]) { // postbox
			docwrite = docwrite+postprefix[1]+postindex+'" style="display: none;">';;
		} else {
			alert('error! invalid itemname for func dspid');
		}
		return docwrite;
	}
	function dsptogglepost(linkname) {
		var docwrite = '';
		docwrite = '<A href="javascript:';
		docwrite = docwrite+ 'myposts.HidePosts(\''+postprefix[0]+postindex+'\',\''+postprefix[1]+postindex+'\',0)"';
		docwrite = docwrite+'>'+linkname+'</A>';
		return docwrite;
	}
	function HidePosts(obj1, obj2, y) {
		var pshow = '';
		var pbox = '';
		pshow = document.getElementById(obj1);
		pbox = document.getElementById(obj2);
		if (pshow != null && pbox != null) { 
			if ((overidedsp == 1 || (postArr[y] == '1' && overidedsp == 2)) && y != 0) { // display all
				pshow.style.display = 'none';
				pbox.style.display = 'block';
			} else if ((overidedsp == 0 || (postArr[y] == '0' && overidedsp == 2)) && y != 0) {
				pshow.style.display = 'block';
				pbox.style.display = 'none';
			} else {
				pshow.style.display = (pshow.style.display == 'none'?'block':'none');
				pbox.style.display = (pbox.style.display == 'none'?'block':'none');
			}
		} else {
			alert('HidePosts: Error! objectid does not exist! pshow='+pshow+' pbox='+pbox);
		}
		return;
	}

	function dspallposts() {
		var x=0; var y=0;
		var oldpost = 0;
		var newpost = 0;
		var totalposts = 0;
		for (x=1; x < maxposts; x++)  { 
			if (postArr[x] == '0') {
	//			alert('old post='+x);
				oldpost++;
			} else if (postArr[x] == '1') {
	//			alert('new post='+x);
				newpost++;
			} else {
	//			alert('null post='+x);
				break;
			}
		}
		totalposts = (x-1); x = '';
		if ((oldpost == totalposts || oldpost == 0) && overidedsp == -1) {
			overidedsp = 1;
		} else if (oldpost != totalposts && overidedsp == -1) {
			overidedsp = 2;
		}
//alert('overidedsp='+overidedsp);
		if (totalposts > 0) {
			for (y=1; y <= totalposts; y++)  { 
				HidePosts(postprefix[0]+y, postprefix[1]+y,y);
			}
		}
		if (overidedsp == 2) {
			overidedsp = 0;
		} else {
			overidedsp++;
		}
		return;
	}
} // end class

//==============
function closeme() {
	self.close();
}
function closewin() {
	opener.location.reload();parent.close()
}
function autoclosewin() {
	self.setTimeout('closewin()', 1000)
}
function resizewin(w,h) {
	leftwin = (screen.width - w) / 2;
	topwin = (screen.height - h) / 2;
	w = w + 10;
	h = h + 50;
	if (navigator.appName=="Netscape") {
		resizeTo(w,h);
		moveTo(leftwin,topwin);
	} else {
		top.resizeTo(w,h);
		top.moveTo(leftwin,topwin);
	}
}
function fillScreen() {
		moveTo(0,0);
		//windowWidth = screen.width;
		windowWidth = screen.availWidth;
		//windowHeight = screen.height;
		windowHeight = screen.availHeight;
		if (navigator.appName=="Netscape") {
			resizeTo(windowWidth,windowHeight);
		} else {
			top.resizeTo(windowWidth,windowHeight);
		}
}
function findLivePageHeight() {
	if (window.innerHeight) {
		//alert ('uses Inner');
		return window.innerHeight;
		}
	if (document.body.clientHeight) {
		//alert ('uses Client');
		return document.body.clientHeight;
		}
	return (null);
}

function findLivePageWidth() {
	if (window.innerWidth)
		return window.innerWidth;
	if (document.body.clientWidth)
		return document.body.clientWidth;
	return (null);
}
function pageDim() {
	livePageHeight = findLivePageHeight();
	livePageWidth = findLivePageWidth();
	//alert ('Visible Page Width: ' + livePageWidth + 'px; Visible Page Height: ' + livePageHeight + 'px');
}


function findWidth(objectID) {
	var object = document.getElementById(objectID);
	if (object.offsetWidth)
		return object.offsetWidth;
	return (null);
}

function findHeight(objectID) {
	var object = document.getElementById(objectID);
	if (object.offsetHeight)
		return object.offsetHeight;
	return (null);
}
function moveObject(objectID,objw,objh) { // v1.0
	var object = document.getElementById(objectID);
	var w = findLivePageWidth();
	var h = findLivePageHeight();
	//objw = objw / 2; objh = objh / 2;
	h = (h - objh) / 2;
	w = (w - objw) / 2;
	object.style.top = h + 'px';
	object.style.left = w +'px';

	//alert("width "+w+" px");
	//alert("height "+h+" px");
}
function moveObject2(objectID) { // v2.1
	var object = document.getElementById(objectID);
	var objh = findHeight(objectID);
	var objw = findWidth(objectID);
	var screenHeight = screen.height;
	var screenWidth = screen.width;
	var w = findLivePageWidth();
	var h = findLivePageHeight();
	
	if (screenHeight > objh) {
		h = (h - objh) / 2;
		object.style.top = h + 'px';
	}
	w = (w - objw) / 2;
	object.style.left = w +'px';
}
function popUp(URL, w, h) { // main
	day = new Date();
	id = day.getTime();
	var leftwin = (screen.width - w) / 2;
	var topwin = (screen.height - h) / 2;
	eval("page2 = window.open(URL, 'mywin2', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=' + w + ',height=' + h + ',left = ' + leftwin + ',top =' + topwin);");
	//self.close();
}
function popUpmicro(URL) {
	eval("page = window.open(URL, 'mywin', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0');");
	//self.close();
}
//==================
function dateMsg() { // Daylong, Month DD, YYYY
	var dayarray=new Array("Sunday","Monday",
						   "Tuesday","Wednesday",
						   "Thursday","Friday",
						   "Saturday");
	var months = new Array("","January", "February",
						   "March", "April", "May", 
						   "June", "July", "August",
						   "September", "October",
						   "November", "December");
	var today = new Date(); // today
	var mon = months[today.getMonth() + 1]; // month
	var day = today.getDate(); // day
	var dayindex=today.getDay();
	var daytxt=dayarray[dayindex]; // day long txt
	var year = y2k(today.getYear()); // year
	return(daytxt + ", " + mon + " " + day + ", " + year); 
}
function todaytxt() { // MM/DD/YYYY
   var Today=new Date();
   return Today.getMonth()+1+"/"+Today.getDate()+"/"+Today.getFullYear();
}
function y2k(year) {
	if (year < 2000)
	year = year + 1900;
	return year;
}

function swapLayer(objectID,showid,hideid) {
	var object = document.getElementById(objectID);
	var showobj = document.getElementById(showid);
	var hideobj = document.getElementById(hideid);
	if (object.style.display == 'block') {
	//alert("off");
		object.style.display = 'none';
		showobj.style.display = 'block';
		hideobj.style.display = 'none';
	} else {
		//alert("on");
		object.style.display = 'block';
		showobj.style.display = 'none';
		hideobj.style.display = 'block';
	}
	object = '';
	showobj = '';
	hideobj = '';
	return;
}
function fjumpgo(targ,selObj,restore){ //v3.0
  eval(targ+".location='forumdisplay.php?f="+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}
function clearPreloadPage() { //DOM
	if (document.getElementById){
		document.getElementById('prepage').style.visibility='hidden';
	} else{
		if (document.layers){ //NS4
			document.prepage.visibility = 'hidden';
		} else { //IE4
			document.all.prepage.style.visibility = 'hidden';
		}
	}
}
function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
//  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
   for (i=0; i<(args.length-1); i+=2) eval("window.location='"+args[i+1]+"'");
}
