var defaultSize		= 12;
var resizeCounter	= 0;
var increment		= 2;
var maxsize			= 18;
var minsize			= 8;
var currentID		= "";
var oldText			= "";
var currentImg		= 1;
var preloadImages	= new Array();
var currentImages	= new Array();
var rotateDiv		= 'rightColumn';
var fadeDiv			= 'fadeImage';
var currentDiv		= '';
var startOpacity	= .0;
var startFade		= 0;
var outOpacity		= 1;
var inOpacity		= 0;
var player			= null; 
var mailSubmit		= false;
var pageData		= new Array();
//var	pageReq			= new Array();
var galleryNum		= 0;
var buttonChecked	= '';

///////////////////// Beyond here be functions ////////////////

function toggle(ID)
{
	if(ID == currentID)
	{
		min(ID);
	}
	else
	{
		if(currentID != "")
		{
			min(currentID);
		}
		max(ID);
	}
	return false;
}

function panorama(panFile, divID)
{	var flashvars = 
	{
		xmlFile: panFile
	}
	var params = 
	{
		quality: "high",
		menu: "false",
		loop: "false",
		allowscriptaccess:"samedomain"
	}
	var attributes =
	{
	}
	swfobject.embedSWF("/scripts/Panview3.swf", divID, "700", "450", "9", "/scripts/expressInstall.swf", flashvars, params, attributes);
	playerReady();
}

function playerReady()
{
	player = window.document['mpl'];
}

function min(categoryID)
{
	var obj		= $(categoryID);
	obj.style.display = 'none';
	currentID	= "";
}

function max (categoryID)
{
	var obj		= $(categoryID);
	obj.style.display = 'block';
	currentID	= categoryID;
}

function bookNow(url)
{
	var viewWin	= window.open(url, 'viewWin', 'status = 1, height = 680, width = 1030, left = 150, top = 150, resize = 1, scrollbars = 1, menubar = 1, toolbar = 1, directories = 1, location = 1');
	if(window.focus){viewWin.focus();}

}

function verifyForm(pgForm)
{
	var errMsgs		= new Array();
	var reqMsgSet	= false;
	for(var i = 0; i < pgForm.elements.length; i++)
	{
		if(pgForm.elements[i].name == 'user_name')
		{
			if((pgForm.elements[i].value.length < 6)||(pgForm.elements[i].value.length > 12))
			{
				if(!alertMsg){var alertMsg	= "User names must be 6 - 12 characters long.";}
				else{alertMsg = alertMsg+"\nUser names must be 6 - 12 characters long.";}
				errMsgs.push(pgForm.elements[i].name);
			}
		}
		if(pgForm.elements[i].name == 'email')
		{
			if(isValidEmail(pgForm.elements[i].value) == false)
			{
				if(!alertMsg){var alertMsg	= "A valid Email address is required!";}
				else{alertMsg = alertMsg+"\nA valid Email address is required!";}
				errMsgs.push(pgForm.elements[i].name);
			}
			var priEmail	= pgForm.elements[i].value;
		}
		if(pgForm.elements[i].name == 'user_pass')
		{
			if(isValidPass(pgForm.elements[i].value) == false)
			{
				if(!alertMsg){var alertMsg	= "A password is required and may contain only Numbers, letters and these characters; @#$!%&";}
				else{alertMsg = alertMsg+"\nA password is required may contain only Numbers, letters and these characters; @#$!%&";}
				errMsgs.push(pgForm.elements[i].name);
				
			}else{
				var userPass	= pgForm.elements[i].value;
			}
		}
		if(pgForm.elements[i].name == 'verify_pass')
		{
			if(pgForm.elements[i].value != userPass)
			{
				if(!alertMsg){var alertMsg	= "Passwords do not match!";}
				else{alertMsg = alertMsg+"\nPasswords do not match!";}
				errMsgs.push(pgForm.elements[i].name);
			}
		}
		if(pgForm.elements[i].className == 'required')
		{
			if(pgForm.elements[i].value == '')
			{
				if(!reqMsgSet)
				{
					if(!alertMsg){var alertMsg	= "Required Field(s) blank.";}
					else{alertMsg = alertMsg+"\nRequired Field(s) blank.";};
					reqMsgSet	= 1
				}
				if(pgForm.elements[i].type != 'radio')
				{
					errMsgs.push(pgForm.elements[i].name);
				}
			}
		}
	}
	if(errMsgs.length > 0)
	{
		var errSpan	= $('error');
		alert(alertMsg+'\nPlease correct highlighted fields.');
		for(var j = 0; j < errMsgs.length; j++)
		{
			var fieldName	= errMsgs[j];
			pgForm.elements[fieldName].style.background = '#fff3c8';
		}
		return false;
	}
	return true;
}

function randomString(strLen) {
	var chars		= "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";
	var randomStr	= '';
	for(var i = 0; i < strLen; i++)
	{
		var rnum = Math.floor(Math.random() * chars.length);
		randomStr += chars.substring(rnum,rnum+1);
	}
	return randomStr;
}

function galleryDisp(img, imgWidth, imgHeight, caption, media)
{
	var overLay		= $('overLay');
	var imgDisplay	= $('imgDisplay');
	var	winWidth	= getWidth();
	var winHeight	= getHeight();

	if(imgWidth > (winWidth * .8))
	{
		var oldWidth	= imgWidth;
		imgWidth		= winWidth * .8;
		var adjFactor	= imgWidth/oldWidth;
		imgHeight		= imgHeight * adjFactor;
	}
	if(imgHeight > (winHeight * .8))
	{
		var oldHeight	= imgHeight;
		imgHeight		= winHeight * .8;
		var hghtFactor	= imgHeight/oldHeight;
		imgWidth		= imgWidth * hghtFactor;
	}
	var leftPos		= imgWidth/2;
	var topPos		= (imgHeight/2)+25;
	var divHeight	= (topPos*2);
	var imgUnderTop	= (imgHeight/1)+2;
	overHeight		= document.body.scrollHeight;
	overWidth		= document.body.scrollWidth;
	caption			= caption.replace(/\[/g, "<");
	caption			= caption.replace(/\]/g, " />");
	overLay.style.position		= 'absolute';
	overLay.style.top			= '0';
	overLay.style.left			= '0';
	overLay.style.width			= '100%';
	overLay.style.height		= overHeight+'px';
	overLay.style.opacity		= '.85';
	overLay.style.background	= '#ffffff';
	overLay.style.filter		= 'alpha(opacity:'+85+')';
	overLay.style.display		= 'block';
	
	overLay.onclick = function()
	{
		closeOver();
	}
	var topOffset				= window.pageYOffset;
	imgDisplay.style.position	= 'absolute';
	imgDisplay.style.top		= '50%';
	imgDisplay.style.left		= '50%';
	if(typeof( window.pageYOffset ) == 'number')
	{
		var topOffset	= window.pageYOffset;
		var leftOffset	= window.pageXOffset;
	}
	else if( document.body && (document.body.scrollTop))
	{
		var topOffset	= document.body.scrollTop;
		var leftOffset	= document.body.scrollLeft;
	}
	else if( document.documentElement && (document.documentElement.scrollTop))
	{
		var topOffset	= document.documentElement.scrollTop;
		var leftOffset	= document.documentElement.scrollLeft;
	}

	if(topOffset > 0)
	{
		var topMargin	= topPos*-1 + parseInt(topOffset);
	}else{
		var topMargin	= topPos*-1;
	}
	if(leftOffset > 0)
	{
		var leftMargin	= leftPos*-1 - parseInt(leftOffset);
	}else{
		var leftMargin = leftPos*-1;
	}
	imgDisplay.style.margin		= topMargin+'px 0px 0px '+leftMargin+'px';
	imgDisplay.style.width		= imgWidth+'px';
	imgDisplay.style.height		= divHeight+'px';
	imgDisplay.style.minHeight	= divHeight+'px';
	imgDisplay.style.display	= 'block';
	imgDisplay.style.border		= '3px solid #dcddde';
	imgDisplay.style.background	= "#ffffff url(\'/graphics/loading.gif\') center center no-repeat";
	var capWidth				= (imgWidth*1)-105;
	if(media == 'vid')
	{
		imgDisplay.innerHTML = "<div id=\"videoPlay\"></div><div id=\"imgUnder\" style=\"position: absolute; top: "+imgUnderTop+"px; left: 0px; width: "+imgWidth+"px\"><img id=\"closeButton\" src=\"http://"+location.host+"/graphics/close.png\" height=\"20\" width=\"64\" style=\"float:right; margin: 8px 12px 0px 8px;\" /><div id=\"caption\" style=\"width:"+capWidth+"px; padding: 5px;\">"+caption+"</div></div>";
		loadVideo('videoPlay', img, imgWidth, imgHeight);
		videoReady();
	}else{
		imgDisplay.innerHTML = "<img src=\""+img+"\" width=\""+imgWidth+"\" height=\""+imgHeight+"\" alt=\"\" /><div id=\"imgUnder\" style=\"position: absolute; top: "+imgUnderTop+"px; left: 0px; width: "+imgWidth+"px\"><img id=\"closeButton\" src=\"http://"+location.host+"/graphics/close.png\" height=\"20\" width=\"64\" style=\"float:right; margin: 8px 12px 0px 8px;\" /><div id=\"caption\" style=\"width:"+capWidth+"px; padding: 5px;\">"+caption+"</div></div>";
	}
	
	$('closeButton').onclick = function()
	{
		closeOver();
	}
	function closeOver()
	{
		imgDisplay.style.position	= 'static';
		imgDisplay.style.width		= '0px';
		imgDisplay.style.height		= '0px';
		imgDisplay.style.display	= 'none';
		imgDisplay.innerHTML		= "";
		
		overLay.style.position		= 'static';
		overLay.style.width			= '0px';
		overLay.style.height		= '0px';
		overLay.style.display		= 'none';
		return false;
	}
	return false;
}

function boxDisplay(scriptURL, media, trgtDiv, boxWidth, boxHeight, caption)
{
	var overLay		= $('overLay');
	var imgDisplay	= $(trgtDiv);
	var	winWidth	= getWidth();
	var winHeight	= getHeight();

	if(boxWidth > (winWidth * .8))
	{
		var oldWidth	= boxWidth;
		boxWidth		= winWidth * .8;
		var adjFactor	= boxWidth/oldWidth;
		boxHeight		= boxHeight * adjFactor;
	}
	if(boxHeight > (winHeight * .8))
	{
		var oldHeight	= boxHeight;
		boxHeight		= winHeight * .8;
		var hghtFactor	= boxHeight/oldHeight;
		boxWidth		= boxWidth * hghtFactor;
	}
	var leftPos		= boxWidth/2;
	var topPos		= (boxHeight/2)+25;
	var divHeight	= (topPos*2);
	var imgUnderTop	= (boxHeight/1)+2;
	overHeight		= document.body.scrollHeight;
	overWidth		= document.body.scrollWidth;
	
	overLay.style.position		= 'absolute';
	overLay.style.top			= '0';
	overLay.style.left			= '0';
	overLay.style.width			= '100%';
	overLay.style.height		= overHeight+'px';
	overLay.style.opacity		= '.85';
	overLay.style.background	= '#ffffff';
	overLay.style.filter		= 'alpha(opacity:'+85+')';
	overLay.style.display		= 'block';
	
	var topOffset				= window.pageYOffset;
	imgDisplay.style.position	= 'absolute';
	imgDisplay.style.top		= '50%';
	imgDisplay.style.left		= '50%';
	if(typeof( window.pageYOffset ) == 'number')
	{
		var topOffset	= window.pageYOffset;
		var leftOffset	= window.pageXOffset;
	}
	else if( document.body && (document.body.scrollTop))
	{
		var topOffset	= document.body.scrollTop;
		var leftOffset	= document.body.scrollLeft;
	}
	else if( document.documentElement && (document.documentElement.scrollTop))
	{
		var topOffset	= document.documentElement.scrollTop;
		var leftOffset	= document.documentElement.scrollLeft;
	}

	if(topOffset > 0)
	{
		var topMargin	= topPos*-1 + parseInt(topOffset);
	}else{
		var topMargin	= topPos*-1;
	}
	if(leftOffset > 0)
	{
		var leftMargin	= leftPos*-1 - parseInt(leftOffset);
	}else{
		var leftMargin = leftPos*-1;
	}
	imgDisplay.style.margin		= topMargin+'px 0px 0px '+leftMargin+'px';
	imgDisplay.style.width		= boxWidth+'px';
	imgDisplay.style.height		= divHeight+'px';
	imgDisplay.style.minHeight	= divHeight+'px';
	imgDisplay.style.opacity	= '1';
	imgDisplay.style.background	= '#ffffff';
	imgDisplay.filter			= 'alpha(opacity:'+100+')';
	imgDisplay.style.display	= 'block';
	imgDisplay.style.border		= '3px solid #dcddde';
	
	if((media == 'vid')||(media == 'img'))
	{
		imgDisplay.style.background	= "#ffffff url(\'/graphics/loading.gif\') center center no-repeat";
		caption			= caption.replace(/\[/g, "<");
		caption			= caption.replace(/\]/g, " />");
		var capWidth				= (boxWidth*1)-95;
		if(media == 'vid')
		{
			imgDisplay.innerHTML = "<div id=\"videoPlay\"></div><div id=\"imgUnder\" style=\"position: absolute; top: "+imgUnderTop+"px; left: 0px; width: "+boxWidth+"px\"><img id=\"closeButton\" src=\"http://"+location.host+"/graphics/close.png\" height=\"20\" width=\"64\" style=\"float:right; margin: 8px 12px 0px 8px;\" /><div id=\"caption\" style=\"width:"+capWidth+"px;\">"+caption+"</div></div>";
			loadVideo('videoPlay', scriptURL, boxWidth, boxHeight);
			videoReady();
			$('closeButton').onclick = function()
			{
				closeOver(imgDisplay, overLay);
			}
		}
		else if(media == 'img')
		{
			imgDisplay.innerHTML = "<img src=\""+img+"\" width=\""+boxWidth+"\" height=\""+imgHeight+"\" alt=\"\" /><div id=\"imgUnder\" style=\"position: absolute; top: "+imgUnderTop+"px; left: 0px; width: "+boxWidth+"px\"><img id=\"closeButton\" src=\"http://"+location.host+"/graphics/close.png\" height=\"20\" width=\"64\" style=\"float:right; margin: 8px 12px 0px 8px;\" /><div id=\"caption\" style=\"width:"+capWidth+"px;\">"+caption+"</div></div>";
			$('closeButton').onclick = function()
			{
				closeOver(imgDisplay, overLay);
			}
		}
	}
	else if(media == 'html')
	{
		imgDisplay.innerHTML = "<div id=\"boxContent\"></div><div id=\"imgUnder\"><img id=\"closeButton\" src=\"http://"+location.host+"/graphics/close.png\" height=\"20\" width=\"64\" style=\"float:right; margin: 8px 12px 0px 8px;\" /></div>";
		$('boxContent').style.height	= divHeight - 56+'px';
		var boxReq	= new xmlRequest();
		boxReq.open("GET", scriptURL, true);
		boxReq.onreadystatechange = function()
		{
			if (boxReq.readyState == 4 && boxReq.status == 200)
			{
				$('boxContent').innerHTML	= boxReq.responseText;
				$('closeButton').onclick = function()
				{
					closeOver(imgDisplay, overLay);
				}
			}
		}
		boxReq.send(null);
	}
	else if(media == 'gallery')
	{
		var boxReq	= new xmlRequest();
		boxReq.open("GET", scriptURL, true);
		boxReq.onreadystatechange = function()
		{
			if (boxReq.readyState == 4 && boxReq.status == 200)
			{
				var galleryData			= eval('(' + boxReq.responseText + ')');
				imgDisplay.innerHTML 	= "<img src=\""+galleryData.currentImg+"\" width=\""+boxWidth+"\" height=\""+boxHeight+"\" alt=\"\" /><div id=\"imgUnder\" style=\"position: absolute; top: "+imgUnderTop+"px; width: "+boxWidth+"px; left: 0px;\"><div style=\"float:right; width: 150px; margin: 8px 12px 0px 8px;\" /><a href=\"/eventGallery.php?image="+galleryData.prevgImgsrc+"&amp;imgID="+galleryData.prevImgID+"&amp;listFile="+galleryData.listFile+"\" onclick=\"return boxDisplay(this.href,  'gallery', 'imgDisplay', '"+galleryData.prevImgWidth+"', '"+galleryData.prevImgHeight+"', '"+galleryData.prevImgTitle+"');\"><img src=\"/graphics/prev-page.gif\" width=\"7\" height=\"7\"> previous</a> &nbsp; [<a href=\""+location.href+"\" id=\"closeButton\">close</a>] &nbsp; <a href=\"/eventGallery.php?image="+galleryData.nextImgsrc+"&amp;imgID="+galleryData.nextImgID+"&amp;listFile="+galleryData.listFile+"\" onclick=\"return boxDisplay(this.href,  'gallery', 'imgDisplay', '"+galleryData.nextImgWidth+"', '"+galleryData.nextImgHeight+"', '"+galleryData.nextImgTitle+"');\">next <img src=\"/graphics/next-page.gif\" width=\"7\" height=\"7\"></a></div><div id=\"caption\" style=\"padding: 8px;\">"+caption+"</div></div>";
				
				$('closeButton').onclick = function()
				{
					return closeOver(imgDisplay, overLay);
				}
			}
		}
		boxReq.send(null);
	}
	function closeOver(boxDisplay, overLay)
	{
		boxDisplay.style.position	= 'static';
		boxDisplay.style.width		= '0px';
		boxDisplay.style.height		= '0px';
		boxDisplay.style.display	= 'none';
		boxDisplay.innerHTML		= "";
		
		overLay.style.position		= 'static';
		overLay.style.width			= '0px';
		overLay.style.height		= '0px';
		overLay.style.display		= 'none';
		return false;
	}
	overLay.onclick = function()
	{
		closeOver(imgDisplay, overLay);
	}
	return false;
}

function doNothing()
{
	event.returnValue	= false;
	return false;
}

function inlineVideo(video, vidWidth, vidHeight)
{
	loadVideo('videoShow', video, vidWidth, vidHeight);
	videoReady();
	return false;
}

function swapMo(serverScript, month, year, tgtID, startEnd)
{
	var serverScript	= serverScript+"?month="+month+"&year="+year+"&startEnd="+startEnd;
	swapReq		= new xmlRequest();
	swapReq.open("GET", serverScript, true);
	swapReq.onreadystatechange = function()
	{
		if(swapReq.readyState == 4 && swapReq.status == 200)
		{
			$(tgtID).innerHTML	= swapReq.responseText;
		}
	}
	swapReq.send(null);
	return false;
}

function getWidth()
{
	var winWidth = 0;
	if (self.innerHeight)
	{
		winWidth	= self.innerWidth;
	}
	else if (document.documentElement && document.documentElement.clientHeight)
	{
		winWidth	= document.documentElement.clientWidth;
	}
	else if (document.body)
	{
		winWidth	= document.body.clientWidth;
	}
	return winWidth;
}

function getHeight()
{
	var winHeight = 0;
	if (self.innerHeight)
	{
		winHeight = self.innerHeight;
	}
	else if (document.documentElement && document.documentElement.clientHeight)
	{
		winHeight = document.documentElement.clientHeight;
	}
	else if (document.body)
	{
		winHeight = document.body.clientHeight;
	}
	return winHeight;
}

function loadVideo(divID, vidFile, imgWidth, imgHeight)
{
	var flashvars = 
	{
		duration: 0,
		file: vidFile,
		bufferlength: 5,
		frontcolor: "716d6c",
		lightcolor: "716d6c",
		screencolor: "2b2b2b",
		autostart: "true",
		displayclick: "play",
		repeat: "none"
	}
	var params = 
	{
		wmode: "opaque",
		allowfullscreen:"true", 
		allowscriptaccess:"always"
	}
	var attributes =
	{
		id:"vid",
		name:"vid"
	}
	swfobject.embedSWF("/scripts/player.swf", divID, imgWidth, imgHeight, "9", '/scripts/expressInstall.swf', flashvars, params, attributes);
}

function videoReady()
{
	player = window.document['mpl'];
}

function imageSwap(imgLink, img, tgtID, newID)
{
	var targetImg	= $(tgtID);
	var galleryReq	= new xmlRequest();
	serverScript	= 'http://'+location.host+'/galleryAjax.php';
	var replStr		= 'http://'+location.host+'/';
	var oldImage	= targetImg.src.replace(replStr, '');
	var newImgID	= newID.substr(4);
	var thumbImg	= $(newID);
	var imgDiv		= $('galleryImg'+tgtID.substr(7));
	var captionDiv	= $('galleryCap'+tgtID.substr(7));
	serverScript	= 'http://'+location.host+'/galleryAjax.php?swap='+oldImage+'&new='+newImgID;
	galleryReq.open("GET", serverScript, true);
	galleryReq.onreadystatechange = function()
	{
		if (galleryReq.readyState == 4 && galleryReq.status == 200)
		{
			
			var imgData			= eval('(' + galleryReq.responseText + ')');
			imgDiv.style.width	= imgData.newImgWidth+'px';
			divHeight			= imgData.newImgHeight*1+20;
			imgDiv.style.height	= divHeight+'px';
			targetImg.src		= 'http://'+location.host+'/graphics/clear.gif';
			imgDiv.style.background	= "#ffffff url(\'/graphics/loading.gif\') center center no-repeat";
			targetImg.src		= 'http://'+location.host+"/"+imgData.newImgSrc;
			targetImg.setAttribute('width', imgData.newImgWidth);
			targetImg.setAttribute('height', imgData.newImgHeight);
			targetImg.setAttribute('title', imgData.newImgTitle);
			targetImg.setAttribute('alt', imgData.newImgTitle);
			captionDiv.innerHTML	= imgData.newImgCaption;
		}
	}
	galleryReq.send(null);
	return false;
}

function galleryPager(tgtID, divHeight)
{
	galleryNum++;//	= parseInt(galleryNum) + 1;
	var targetDiv		= $(tgtID);
	var galleryID		= tgtID.substr(5);
	var pageReq			= new xmlRequest();
	var serverScript	= 'http://'+location.host+'/galleryAjax.php?pageGallery='+galleryID+'&height='+divHeight;
	pageReq.open("GET", serverScript, false);

	pageReq.send(null);
	pageData[galleryNum]	= eval('(' + pageReq.responseText + ')');
	targetDiv.innerHTML	= "<a href=\"http://"+location.host+"\" onclick=\"return thumbPage('prev', '"+pageData[galleryNum].pageNum+"', 'thumbs"+galleryID+"', '"+tgtID+"', '"+galleryNum+"');\"><img src=\"http://"+location.host+"/graphics/prev.gif\" height=\"7\" width=\"7\" alt=\"previous\" /></a>&nbsp; &nbsp;<a href=\"http://"+location.host+"\" onclick=\"return thumbPage('next', '"+pageData[galleryNum].pageNum+"', 'thumbs"+galleryID+"', '"+tgtID+"', '"+galleryNum+"');\"><img src=\"http://"+location.host+"/graphics/next.gif\" height=\"7\" width=\"7\" alt=\"next\" /></a>";
}

function thumbPage(pageSeq, pageNum, thumbDivID, pagerDivID, gNum)
{
	var serverScript	= "http://"+location.host+"/galleryAjax.php";
	var thumbDiv		= $(thumbDivID);
	var pagerDiv		= $(pagerDivID);
	var galleryID		= pagerDivID.substr(5);
	var thumbReq		= new xmlRequest();
	
	if(pageSeq == 'prev')
	{
		if(pageNum	== 1)
		{
			var begin	= pageData[gNum].Pages[parseInt(pageData[gNum].numPages)-1].begin;
			var limit	= pageData[gNum].Pages[parseInt(pageData[gNum].numPages)-1].limit;
			var newPage	= pageData[gNum].numPages;
		}else{
			var begin	= pageData[gNum].Pages[parseInt(pageNum)-2].begin;
			var limit	= pageData[gNum].Pages[parseInt(pageNum)-2].limit;
			var newPage	= parseInt(pageNum)-1;
		}
	}
	else if(pageSeq == 'next')
	{
		if(pageNum == parseInt(pageData[gNum].numPages))
		{
			var begin	= pageData[gNum].Pages[0].begin;
			var limit	= pageData[gNum].Pages[0].limit;
			var newPage	= 1;
		}else{
			var begin	= pageData[gNum].Pages[pageNum].begin;
			var limit	= pageData[gNum].Pages[pageNum].limit;
			var newPage	= parseInt(pageNum)+1;
		}
	}
	serverScript	= serverScript+'?newThumbPage='+galleryID+'&begin='+begin+'&limit='+limit+'&page='+newPage+'&galleryNum='+gNum;
	thumbReq.open("GET", serverScript, true);
	thumbReq.onreadystatechange = function()
	{
		if(thumbReq.readyState == 4 && thumbReq.status == 200)
		{
			thumbDiv.innerHTML	= thumbReq.responseText;
		}
	}
	thumbReq.send(null);
	return false;
}

function mailListInput(serverScript, divID)
{
	targetDiv	= $(divID);
	oldText		= targetDiv.innerHTML;
	targetDiv.innerHTML	= "<form name=\"mailListSignUp\" id=\"mailListSignUp\"><input name=\"emailInput\" id=\"emailInput\" type=\"text\" /></form>";
	emailInput	= $('emailInput');
	document.mailListSignUp.emailInput.focus();
	emailInput.onkeypress = function (event) 
	{
		event = event || window.event;
		if (event.keyCode == 13)
		{
			mailListSubmit(serverScript, divID)
			return false;
		}
	}
	return false;
}

function clearEmailPrompt(fieldID, phrase)
{
	var emailField = $(fieldID);
	if (emailField.value == phrase) 
	{
		savedPhrase	= phrase
		emailField.value = "";
	}
}

function setPrompt(fieldID, phrase) 
{
	var emailField = $(fieldID);
	if (emailField.value == "") 
	{
		emailField.value = savedPhrase;
		savedPhrase	= '';
	}
}

function clearPrompt(fieldID, phrase)
{
	var message = $(fieldID);
	if (message.value == phrase)
	{
		savedPhrase	= message.value;
		message.value = "";
	}
}

function ajaxFormPost(pgForm, serverScript, targetDiv)
{
	var errMsgs		= new Array();
	pgReq			= new xmlRequest();
	var formSubmit	= null;
	targetObj		= $(targetDiv);
	var stdBG		= "#ffffff";
	var highliteBG	= "#fff3c8";
	for(var i = 0; i < pgForm.elements.length; i++)
	{
		if(!formSubmit)
		{
			if((pgForm.elements[i].type == 'checkbox')||(pgForm.elements[i].type == 'radio'))
			{
				if(pgForm.elements[i].checked){formSubmit = pgForm.elements[i].name+'='+(pgForm.elements[i].value);}
			}else{
				if(pgForm.elements[i].className.indexOf('noSubmit') == -1)
				{
					if(pgForm.elements[i].value)
					{
						var fieldData	= pgForm.elements[i].value;
						fieldData		= escape(fieldData.replace("&", "AMP"));
						formSubmit		= pgForm.elements[i].name+'='+(fieldData);
					}
				}
			}
		}else{
			if((pgForm.elements[i].type == 'checkbox')||(pgForm.elements[i].type == 'radio'))
			{
				if(pgForm.elements[i].checked){formSubmit += '&'+ pgForm.elements[i].name+'='+(pgForm.elements[i].value);}
			}else{
				if(pgForm.elements[i].className.indexOf('noSubmit') == -1)
				{
					if(pgForm.elements[i].value)
					{
						var fieldData	= pgForm.elements[i].value;
						fieldData		= escape(fieldData.replace("&", "AMP"));
						formSubmit		+= '&'+pgForm.elements[i].name+'='+(fieldData);
					}
				}
			}
		}
		if(pgForm.elements[i].className.indexOf('required') != -1)
		{
			if(pgForm.elements[i].className.indexOf('email') != -1)
			{
				if(isValidEmail(pgForm.elements[i].value) == false)
				{
					errMsgs.push(pgForm.elements[i].name);
				}
			}
			else if((pgForm.elements[i].type == 'radio') || (pgForm.elements[i].type == 'checkbox'))
			{
				if(buttonChecked != pgForm.elements[i].name)
				{
					var checkRadio	= validateCheckRadio(pgForm, pgForm.elements[i].name);
					if(checkRadio == false)
					{
						errMsgs.push(pgForm.elements[i].name);
					}
				}
			}else{
				if(pgForm.elements[i].value == '')
				{
					errMsgs.push(pgForm.elements[i].name);
				}
			}
		}
	}
	for(var j = 0; j < pgForm.elements.length; j++)
	{
		if(pgForm.elements[j].className.indexOf('required') != -1)
		{
			var resetField	= pgForm.elements[j].name;
			if(isCheckRadio(pgForm, resetField))
			{
				if(pgForm[resetField].length)
				{
					for(var k = 0; k < pgForm[resetField].length; k++)
					{
						if(pgForm[resetField][k].parentElement)
						{
							pgForm[resetField][k].parentElement.style.background = stdBG;
						}else{
							pgForm[resetField][k].parentNode.style.background = stdBG;
						}
					}
				}else{
					if(pgForm[resetField].parentElement)
					{
						pgForm[resetField].parentElement.style.background = stdBG;
					}else{
						pgForm[resetField].parentNode.style.background = stdBG;
					}
				}
			}
			else if(pgForm[resetField].type == 'hidden')
			{
				if(pgForm[resetField].parentElement)
				{
					pgForm[resetField].parentElement.style.background = stdBG;
				}else{
					pgForm[resetField].parentNode.style.background = stdBG;
				}
			}else{
				pgForm[resetField].style.background = stdBG;
			}
		}
	}
	if(errMsgs.length > 0)
	{
		alert('Required Field(s) blank.\nPlease correct highlighted fields.');
		for(var i = 0; i < errMsgs.length; i++)
		{
			var fieldName	= errMsgs[i];
			if(isCheckRadio(pgForm, fieldName))
			{
				if(pgForm[fieldName].length)
				{
					for(l = 0; l < pgForm[fieldName].length; l++)
					{
						if(pgForm[fieldName][l].parentElement)
						{
							pgForm[fieldName][l].parentElement.style.background = highliteBG;
						}else{
							pgForm[fieldName][l].parentNode.style.background = highliteBG;
						}
					}
				}else{
					if(pgForm[fieldName].parentElement)
					{
						pgForm[fieldName].parentElement.style.background = highliteBG;
					}else{
						pgForm[fieldName].parentNode.style.background = highliteBG;
					}
				}
			}
			else if(pgForm[fieldName].type == 'hidden')
			{
				if(pgForm[fieldName].parentElement)
				{
					pgForm[fieldName].parentElement.style.background = highliteBG;
				}else{
					pgForm[fieldName].parentNode.style.background = highliteBG;
				}
			}else{
				pgForm[fieldName].style.background = highliteBG;
			}
		}
		return false;
	}
	
	pgReq.open("POST", serverScript, true);
	pgReq.setRequestHeader("Content-Type", "application/x-www-form-urlencoded charset=UTF-8");
	pgReq.onreadystatechange = function()
	{
		if (pgReq.readyState == 4 && pgReq.status == 200)
		{
			if(pgReq.responseText.substr(0, 6) == "ERROR:")
			{
				alert(pgReq.responseText.substr(6));
			}
			else if(pgReq.responseText.substr(0, 7) == "secCode")
			{
				var	refreshStr	= randomString(5);
				targetObj.src	='http://'+location.host+'/captcha.php?width=120&height=32&chars=6&refresh='+refreshStr;
				alert(pgReq.responseText.substr(7));
			}
			else if(pgReq.responseText.substr(0,2) == "OK")
			{
				alert(pgReq.responseText.substr(3));
				pgForm.reset();
			}
			else if(pgReq.responseText.substr(0,11) == "PAGERETURN:")
			{
				targetObj.innerHTML	= pgReq.responseText.substr(11);
			}
		}
	}
	pgReq.send(formSubmit);
	return false;
}

function showEndMonth(timeStamp)
{
	endMoReq			= new xmlRequest();
	var serverScript	= "http://"+location.host+"/currentMonthNameCalendar.php?moDate="+timeStamp;
	endMoReq.open("GET", serverScript, true);
	endMoReq.onreadystatechange = function()
	{
		if(endMoReq.readyState == 4 && endMoReq.status == 200)
		{
			$('endWrap').innerHTML	= endMoReq.responseText;
		}
	}
	endMoReq.send(null);
	return false;
}

function swapMo(serverScript, month, year, tgtID, startEnd)
{
	var serverScript	= serverScript+"?month="+month+"&year="+year+"&startEnd="+startEnd;
	swapReq		= new xmlRequest();
	swapReq.open("GET", serverScript, true);
	swapReq.onreadystatechange = function()
	{
		if(swapReq.readyState == 4 && swapReq.status == 200)
		{
			$(tgtID).innerHTML	= swapReq.responseText;
		}
	}
	swapReq.send(null);
	return false;
}
function submitQA(qaForm, serverScript, targetDiv)
{
	qaReq			= new xmlRequest();
	var formSubmit	= null;
	targetObj		= $(targetDiv);
	for(var i = 0; i < qaForm.elements.length; i++)
	{
		if(!formSubmit)
		{
			if(qaForm.elements[i].className.indexOf('noSubmit') == -1)
			{
				var fieldData	= qaForm.elements[i].value.replace("&", "AMP");
				formSubmit		= qaForm.elements[i].name+'='+(fieldData);
			}
		}else{
			if(qaForm.elements[i].className.indexOf('noSubmit') == -1)
			{
				var fieldData	= qaForm.elements[i].value.replace("&", "AMP");
				formSubmit		+= '&'+qaForm.elements[i].name+'='+(fieldData);
			}
		}
	}
	
	qaReq.open("POST", serverScript, true);
	qaReq.setRequestHeader("Content-Type", "application/x-www-form-urlencoded charset=UTF-8");
	qaReq.onreadystatechange = function()
	{
		if (qaReq.readyState == 4 && qaReq.status == 200)
		{
			targetObj.innerHTML	= qaReq.responseText;
		}
	}
	qaReq.send(formSubmit);
	return false;
}

function skipQA(serverScript, targetDiv)
{
	qaReq			= new xmlRequest();
	var formSubmit	= null;
	targetObj		= $(targetDiv);
		
	qaReq.open("GET", serverScript, true);
	qaReq.onreadystatechange = function()
	{
		if (qaReq.readyState == 4 && qaReq.status == 200)
		{
			targetObj.innerHTML	= qaReq.responseText;
		}
	}
	qaReq.send(null);
	return false;
}

function validateCheckRadio(pgForm, fieldName)
{
	var isChecked	= false;
	if(pgForm[fieldName].length)
	{
		for(var k = 0; k < pgForm[fieldName].length; k++)
		{
			if(pgForm[fieldName][k].checked)
			{
				isChecked		= true;
				buttonChecked	= fieldName;
				return isChecked;
			}
		}
	}else{
		if(pgForm[fieldName].checked)
		{
			isChecked		= true;
			buttonChecked	= fieldName;
			return isChecked;
		}
	}
	buttonChecked	= fieldName;
	return isChecked;
}

function isCheckRadio(pgForm, fieldName) 
{
//	alert(fieldName);
	if(!pgForm.elements[fieldName].length)
	{
		if((pgForm.elements[fieldName]) && ((pgForm.elements[fieldName].type == 'radio') || (pgForm.elements[fieldName].type == 'checkbox')))
		{
			return true;
		}else{
			return false;
		}
	}else{
		if((pgForm.elements[fieldName][0]) && ((pgForm.elements[fieldName][0].type == 'radio') || (pgForm.elements[fieldName][0].type == 'checkbox')))
		{
			return true;
		}else{
			return false;
		}
	}
}

function commentForm(serverScript, targetID)
{
	
	targetObj	= $(targetID);
	targetObj.innerHTML = "<iframe id=\"reviewForm\" src=\""+serverScript+"\" width=\"640\" height=\"640\" frameborder=\"0\" scrolling=\"no\"></iframe>\n<br /><a class=\"inline\" href=\"javascript: closeFrame('reviewForm', 'commentForm');\">Close Form</a>";
	return false;
}

function showUpload(chkBox, targetID)
{
	targetObj	= $(targetID);
	if(chkBox.checked)
	{
		targetObj.innerHTML	= "Image 1: <input name=\"images[1]\" type=\"file\" />\n\t<br />&nbsp;<br />\n\tImage 1: <input name=\"images[2]\" type=\"file\" />\n\t<br />&nbsp;<br />\n\tImage 1: <input name=\"images[3]\" type=\"file\" />\n\t<br />&nbsp;<br />";
	}else{
		targetObj.innerHTML	= "";
	}
}

function closeFrame(frameID, targetID)
{
	targetObj	= $(targetID);
	var frame = $(frameID);
	targetObj.innerHTML	= "";
	
}

function charCount(txtArea, fieldID, max)
{
	fieldID		= fieldID+'Chars';
	viewSpan	= $(fieldID);
	if(txtArea.value.length > max)
	{
		viewSpan.className	= 'warn';
	}else{
		viewSpan.className	= '';
	}
	var remainingChars	= max - txtArea.value.length;
	viewSpan.innerHTML	= remainingChars;
}

function showFullReview(textID, linkID)
{
	var reviewText	= $(textID);
	var openLink	= $(linkID);
	openLink.style.display		= 'none';
	reviewText.style.display	=  'inline';
}

function closeFullReview(textID, linkID)
{
	var reviewText	= $(textID);
	var openLink	= $(linkID);
	openLink.style.display		= 'inline';
	reviewText.style.display	= 'none';
}

function closeForm(targetID)
{
	targetObj	= $(targetID);
	targetObj.innerHTML	= oldText;
	return false;
}

function isValidEmail(email)
{
	email	= email.trim();
	if(email.search(/^[^@\s]+@([-a-z0-9]+\.)+[a-z]{2,}$/i) == -1)
	{
		return false;
	}else{
		return true;
	}
}

function isValidPass(pass)
{
	pass	= pass.trim();
	if(pass.search(/[-a-zA-Z0-9]/) == -1)
	{
		return false;
	}else{
		return true;
	}
}
function $(id) 
{
	return document.getElementById(id);
}

String.prototype.trim = function()
{
	return this.replace(/^\s+|\s+$/g,"");
}

String.prototype.ltrim = function()
{
	return this.replace(/^\s+/,"");
}

String.prototype.rtrim = function()
{
	return this.replace(/\s+$/,"");
}

function xmlRequest()
{
	try
	{
		xmlHttp=new XMLHttpRequest();
	}catch(e){
		try
		{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}catch(e){
			try
			{
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
			}catch (e){
				alert("Your browser is quite out-dated and does not support AJAX!");
			}
		}
	}
	return xmlHttp;
}

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name)
{
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function addToFav(pgName)
{
	
	if((pgName == "sitemap")||(pgName == "my-favorites"))
	{
		alert("This page cannot be added to My Favorites");
		return false;
	}
	var retVal	= confirm("Save "+pgName+" to your favorites?");
	if(retVal == true)
	{
		if(Cookie.enabled.cache == false)
		{
			alert("You must enable cookies for Add to Favorites to work");
			return false;
		}else{
			var favCookie		= new Cookie('favorites');
			if(favCookie.pages)
			{
				var favPages	= favCookie.pages.split("|");
				for(var i = 0; i < favPages.length; i++)
				{
					if(favPages[i] == pgName)
					{
						var hasPage	= true;
						break;
					}
					var hasPage	= false;
				}
				if(!hasPage)
				{
					favCookie.pages	+="|"+pgName;
					favCookie.store(365, '/');
					return false;
				}else{
					favCookie.store(365, '/');
					return false;
				}
			}else{
				favCookie.pages=pgName;
				favCookie.store(365, '/');
				return false;
			}
		}
	}else{
		return false;
	}
}

function remFav(url, pgName)
{
	var favCookie	= new Cookie('favorites');
	retVal	= confirm('Remove '+pgName+' from favorites?');
	if(retVal == true)
	{
		var favCookie	= new Cookie('favorites');
		var favPages	= favCookie.pages.split("|");
		var favCount	= favPages.length;
		var cookChk	= false;
		favCookie.pages = "";
		for(var i = 0; i < favCount; i++)
		{
			if(favPages[i] != pgName)
			{
				if(!cookChk)
				{
					favCookie.pages=favPages[i];
					cookChk	= true;
				}else{
					favCookie.pages	+="|"+favPages[i];
				}
			}
		}
		favCookie.store(365, '/');
		var checkFavs	= new Cookie('favorites');
		if(checkFavs.pages=="")
		{
			favCookie.remove(365, '/');
			window.location	= url;
			return false;
		}
		window.location	= url;
	}else{
		return false;
	}
	
}
function imgkeep(id) 
{
	$('imgFile-' + id).disabled = true;
}

function imgdelete(id) 
{
	$('imgFile-' + id).disabled = true;
}

function imgchange(id) 
{
	$('imgFile-' + id).disabled = false;
}

function getElementbyClass(rootobj, classname)
{
	var temparray	= new Array();
	var inc			= 0;
	for (var i = 0; i < rootobj.length; i++);
	{
		if (rootobj[i].className == classname)
		{
			temparray[inc++]=rootobj[i];
		}
	}
	return temparray
}

function getElementbyClass(rootobj, classname)
{
	var temparray	= new Array();
	var inc			= 0;
	var rootlength	= rootobj.length;
	for (i=0; i<rootlength; i++)
	{
		if (rootobj[i].className==classname){temparray[inc++]=rootobj[i];}
	}
	return temparray;
}

function Cookie(name)
{
	this.$name = name;  // Remember the name of this cookie
	var allcookies = document.cookie;
	
	if (allcookies == ""){return;}
	
	var cookies = allcookies.split(';');
	var cookie = null;
	
	for(var i = 0; i < cookies.length; i++)
	{
		cookies[i]	= cookies[i].trim();

		 // Does this cookie string begin with the name we want?
		if(cookies[i].substring(0, name.length+1) == (name + "="))
        	{
			cookie = cookies[i];
			break;
		}
	}

	if (cookie == null){return;}
	var cookieval = cookie.substring(name.length+1);

	var a = cookieval.split('&'); // Break it into an array of name/value pairs
	for(var i=0; i < a.length; i++)
	{
		a[i] = a[i].split(':');
	}

	for(var i = 0; i < a.length; i++)
	{
		this[a[i][0]] = decodeURIComponent(a[i][1]);
	}
}

Cookie.prototype.store = function(daysToLive, path, domain, secure)
{
	var cookieval = "";
	for(var prop in this)
	{
        
		if ((prop.charAt(0) == '$') || ((typeof this[prop]) == 'function')){continue;}
		if (cookieval != ""){cookieval += '&';}
		cookieval += prop + ':' + encodeURIComponent(this[prop]);
	}

	var cookie = this.$name + '=' + cookieval;
	if (daysToLive || daysToLive == 0)
	{
		var date = new Date();
		date.setTime(date.getTime()+(daysToLive*24*60*60*1000));
		cookie += ";expires="+date.toGMTString();
	}

	if (path){cookie += ";path=" + path;}
	if (domain){cookie += ";domain=" + domain;}
	if (secure){cookie += ";secure";}
	
	document.cookie = cookie;
}

Cookie.prototype.remove = function(path, domain, secure)
{
    // Delete the properties of the cookie
    for(var prop in this)
	{
		if (prop.charAt(0) != '$' && typeof this[prop] != 'function')
		delete this[prop];
	}

	// Then, store the cookie with a lifetime of 0
	this.store(0, path, domain, secure);
}

Cookie.enabled = function( )
{

	if (navigator.cookieEnabled != undefined) return navigator.cookieEnabled;
	if (Cookie.enabled.cache != undefined) return Cookie.enabled.cache;

	document.cookie = "testcookie=test; max-age=10000";  // Set cookie

    // Now see if that cookie was saved
	var cookies = document.cookie;
	if(cookies.indexOf("testcookie=test") == -1)
	{
        // The cookie was not saved
        	return Cookie.enabled.cache = false;
	}else{
		// Cookie was saved, so we've got to delete it before returning
		document.cookie = "testcookie=test; max-age=0";  // Delete cookie
		return Cookie.enabled.cache = true;
	}
}

function bookmarkPage(url, title)
{
	if (window.sidebar)
	{
		alert("Please press Ctrl+D to bookmark this page.");
	}
	else if(window.opera && window.print)
	{
		alert("Please press Ctrl+T to bookmark this page.");
	}
	else if(window.external)
	{
		window.external.AddFavorite(url, title);
	}
	return false;
}

function varitext(text)
{
	text=document;
	print(text);
	return false;
}

