<!-- Begin
/****************************************************************************************
'* Javascript Functions                                                                 *
'*--------------------------------------------------------------------------------------*
'* Abstract: Miscellaneous Client Side Scripts                                          *
'* Copyright (C) 2006-2010 Prosirius Technologies LLC                                   *
'* You may not download, install, run, use, view, share or modify this program or its   *
'* derivative works without a signed Software License Agreement from Prosirius          *
'* Technologies. US Federal and State Law prohibits these actions if you do not have    *
'* said License. Additional requirements exist. Please email Prosirius Technologies at: *
'* support@prosirius.com for more information.                                          *
'* Last Update: 06-01-10                                                                *
*****************************************************************************************/

var sButton="";
var xmlHttp;

function popUp(URL) {
// Opens a new window of 640 x 500 pixels in size
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=no,scrollbars=no,location=no,statusbar=no,menubar=no,resizable=yes,width=640,height=500,left=60,top=60');");
}

function popUpWin (url, win, width, height, sOptions) {
// Opens a new window of user defined size
	var leftPos = (screen.availWidth - width) / 2;
	var topPos = (screen.availHeight - height) / 2;
	sOptions += "width=" + width + ",height=" + height + ",left=" + leftPos + ",top=" + topPos;
	var newWin = window.open(url, win, sOptions);
	if (window.focus) {newWin.window.focus()};
}

function printthispage() {
// Opens a new window showing only the Content area from the calling page - used for "Print Page"
   var sOption="toolbar=yes,location=no,directories=yes,menubar=yes,"; 
       sOption +="scrollbars=yes,resizable=yes,width=640,height=480,left=60,top=60"; 
   var sWinHTML = document.getElementById('contentstart').innerHTML; 
   var newWin=window.open("","PrintThisPage",sOption); 
       newWin.document.open(); 
       newWin.document.write('<html><head><meta http-equiv="expires" content="0"><meta http-equiv="pragma" content="no-cache"><title>Print this Page</title><link href="themes/printstyles.css" rel="stylesheet" type="text/css"></head><body>'); 
       newWin.document.write('<span class="textnormal">Options: <a href="" onclick="window.print();return false;">Print</a>, <a href="javascript:close();">Close Window</a></span><br><hr><table width="580"><tr><td>');
	   newWin.document.write(sWinHTML);          
       newWin.document.write('</td></tr></table></body></html>'); 
       newWin.document.close(); 
       newWin.focus(); 
}

function showBlock(i) {
// Shows and Hides <div id='block999'> blocks of html code
	if (document.getElementById('block' + i).style.display == 'block') {
		document.getElementById('block' + i).style.display = 'none';
	}
	else {
		document.getElementById('block' + i).style.display = 'block';
	}
}

function hideBlock(i) {
// Hides <div id='block999'> blocks of html code
	document.getElementById('block' + i).style.display = 'none';
}

function setPosition(findObj,setObj) {
// Repositions an object "setObj" based on actual location of "findObj"
	var curleft = curtop = 0;
	var fObj = document.getElementById (findObj);
	var sObj = document.getElementById (setObj);
	if (fObj) {
		if (fObj.offsetParent) {
			do {
				curleft += fObj.offsetLeft;
				curtop += fObj.offsetTop;
			} while (fObj = fObj.offsetParent);
		if (sObj) {
			sObj.style.top = curtop;
			sObj.style.left = curleft;
			}
		}
	}
}

function checkURL(path,field) {
// Launches popup to check page and image URLS
	var i = Instr(field,"+");
	if(i>0) { //Get two fields
		var fld1 = RTrim(LTrim(String(field).substring(0,i)));
		var fld2 = RTrim(LTrim(String(field).substring(i+1,String(field).length)));
		fld1 = RTrim(LTrim(document.getElementById(fld1).value));
		fld2 = RTrim(LTrim(document.getElementById(fld2).value));
		if ((fld1=='na')||(fld1=='#')) { fld1 = ""; }
		if (fld1==fld2.substring(0,fld1.length)) { fld1 = ""; }
		if (fld2=='') {
			alert ("Please enter a valid website URL before checking.");
			return false;
		} else {
			var fld =  fld1 + fld2
		}
	} else { //Get Single field
		var fld = RTrim(LTrim(document.getElementById(field).value));
	}
	if (fld=='') {
		alert ("Please enter a valid website URL or image link in the field before checking.");
		return false;
	} else {
		day = new Date();
		id = day.getTime();
		popUpWin (path + "checkurl.asp?id=" + fld, id, 640, 480, "scrollbars=yes,resizable=yes,");
		return false;
	}
	
}

function insertIMG(field) { 
// Displays TextArea Toolbar allowing user to link images
   var leftPos = ((screen.availWidth/2)-240);
   var topPos = ((screen.availHeight/2)-130);
   var sOption="toolbar=no,location=no,directories=no,menubar=no,"; 
       sOption +="scrollbars=no,resizable=yes,width=480,height=260,left=" + leftPos + ",top=" + topPos;
   var newWin=window.open("","InsertIMG",sOption); 
       newWin.document.open(); 
       newWin.document.write('<html><head><meta http-equiv="expires" content="0"><meta http-equiv="pragma" content="no-cache"><title>Insert Forum Image</title>\n');
       newWin.document.write('<style type="text/css">body {font-size:12px;color:#000000;background-color:#E0E0E0;} table,td {font-family:verdana,sans-serif;font-size:12px;}</style>');
	   newWin.document.write('<script type="text/javascript">');
	   newWin.document.write('function trimString(str) { str=str.replace(new RegExp("^[ ]+", "g"), ""); return str.replace(new RegExp("[ ]+$", "g"), "");} ');
 	   newWin.document.write('function Mid(str, start, len) { if (start < 0 || len < 0) return ""; var iEnd, iLen = String(str).length; if (start + len > iLen) iEnd = iLen; else iEnd = start + len; return String(str).substring(start,iEnd); }');
	   newWin.document.write('function Instr(strSearch, strSearchFor) { for (var i=0; i < (strSearch.length - strSearchFor.length); i++) { if (Mid(strSearch, i, strSearchFor.length) == strSearchFor) return i; } return -1; }');
	   newWin.document.write('function addImage(myField) { var oForm = document.imgForm;');
	   newWin.document.write('var newlink = trimString(document.imgForm.url1.value);');
	   newWin.document.write('if(Instr(newlink.toLowerCase(),"://") == -1) newlink = oForm.init.value + newlink; ');
	   newWin.document.write('if (newlink.length<12) { alert("Please enter a valid URL to the image."); return false; }');
	   newWin.document.write('newlink=newlink.replace(new RegExp(" ", "g"), "%20");');
	   newWin.document.write('var filx = String(newlink).substring(newlink.length-4,newlink.length);');
	   newWin.document.write('filx = filx.toLowerCase();');
	   newWin.document.write('if((filx!=".jpg")&&(filx!="jpeg")&&(filx!=".gif")) {');
	   newWin.document.write('alert("File type must be GIF, JPG or JPEG."); return false; }');
	   newWin.document.write('var html = " [img]" + newlink + "[/img] "; ');
	   newWin.document.write('insertAtCursor(myField,html,true); window.close(); return true; }');
	   newWin.document.write('function insertAtCursor(myField, myValue, myMode) {');
	   newWin.document.write('if (document.selection) { myField.focus();');
	   newWin.document.write('if (myMode==true) { sel = window.opener.document.selection.createRange();');
	   newWin.document.write('} else { sel = document.selection.createRange(); }');
	   newWin.document.write('sel.text = myValue;');
	   newWin.document.write('sel.moveStart("character", -myValue.length); }');
	   newWin.document.write('else if (myField.selectionStart || myField.selectionStart == "0") {');
	   newWin.document.write('var startPos = myField.selectionStart;');
	   newWin.document.write('var endPos = myField.selectionEnd;');
	   newWin.document.write('myField.value = myField.value.substring(0, startPos) + myValue + myField.value.substring(endPos, myField.value.length); }');
	   newWin.document.write('else { myField.value += myValue; } }');
	   newWin.document.write('</script></head>\n<body><center><br>'); 
       newWin.document.write('\n<form name="imgForm" onSubmit="return addImage(window.opener.' + field + ');">');
       newWin.document.write('\n<table cellpadding="4" cellspacing="4" border="0" style="border:1px dashed #C0C0C0;background-color:#F0F0F0;">');
       newWin.document.write('\n<tr bgcolor="#E0E0E0"><td colspan="3"><span style="font-style: italic;"><strong>Tip:</strong> Keep size to less than 530 pixels wide.<br>We accept GIF, JPG and JPEG images only!</span></td></tr>');
       newWin.document.write('\n<tr><td colspan="3"><br></td></tr>');
       newWin.document.write('\n<tr><td align="right"><strong>Enter URL : </strong></td><td>');
	   newWin.document.write('<select name="init" id="init" tabindex="1"><option value="http://" selected>http://</option><option value="https://">https://</option><option value="ftp://">ftp://</option></select></td>');
	   newWin.document.write('<td><input name="url1" type="text" id="url1" size="30" maxlength="128" tabindex="2"><br>\n</td></tr>');
       newWin.document.write('\n<tr><td>&nbsp;</td><td colspan="2"><strong>Example:</strong><br>www.website.com/myphoto.gif</td></tr>');
       newWin.document.write('\n<tr><td colspan="3">&nbsp;</td></tr>');
	   newWin.document.write('<tr><td colspan="3"><center><input type="submit" value="Insert Image">&nbsp;&nbsp;&nbsp;');
       newWin.document.write('\n<input type="button" value="Cancel" onClick="window.close();"></center></td></tr>');
	   newWin.document.write('\n</table>\n</form></center></body></html>'); 
       newWin.document.close(); 
       newWin.focus(); 
}

function insertURL(txt, field) { 
// Displays TextArea Toolbar allowing user to enter links
   var leftPos = ((screen.availWidth/2)-240);
   var topPos = ((screen.availHeight/2)-150);
   var sOption="toolbar=no,location=no,directories=no,menubar=no,"; 
       sOption +="scrollbars=no,resizable=yes,width=480,height=300,left=" + leftPos + ",top=" + topPos;
   var newWin=window.open("","InsertURL",sOption); 
       newWin.document.open(); 
       newWin.document.write('<html><head><meta http-equiv="expires" content="0"><meta http-equiv="pragma" content="no-cache"><title>Insert Link</title>\n');
       newWin.document.write('<style type="text/css">body {font-size:12px;color:#000000;background-color:#E0E0E0;} table,td {font-family:verdana,sans-serif;font-size:12px;}</style>');
	   newWin.document.write('<script type="text/javascript">');
	   newWin.document.write('function trimString(str) { str=str.replace(new RegExp("^[ ]+", "g"), ""); return str.replace(new RegExp("[ ]+$", "g"), "");} ');
 	   newWin.document.write('function Mid(str, start, len) { if (start < 0 || len < 0) return ""; var iEnd, iLen = String(str).length; if (start + len > iLen) iEnd = iLen; else iEnd = start + len; return String(str).substring(start,iEnd); }');
	   newWin.document.write('function Instr(strSearch, strSearchFor) { for (var i=0; i < (strSearch.length - strSearchFor.length); i++) { if (Mid(strSearch, i, strSearchFor.length) == strSearchFor) return i; } return -1; }');
	   newWin.document.write('function addLink(myField) { var oForm = document.linkForm;');
	   newWin.document.write('if (oForm.url1.value == "") { alert("Please enter a URL."); return false; }');
 	   newWin.document.write('var newlink = trimString(oForm.url1.value);');
	   newWin.document.write('if(Instr(newlink.toLowerCase(),"://") == -1) newlink = oForm.init.value + newlink; ');
	   newWin.document.write('newlink=newlink.replace(new RegExp(" ", "g"), "%20");');
	   newWin.document.write('if (oForm.linkText.value == "") { var html = " [url]" + newlink + "[/url]"; ');
	   newWin.document.write('} else { var html = " [url=" + newlink + "]" + trimString(document.linkForm.linkText.value) + "[/url]"; }');
	   newWin.document.write('insertAtCursor(myField,html,true); window.close(); return true; }');
	   newWin.document.write('function insertAtCursor(myField, myValue, myMode) {');
	   newWin.document.write('if (document.selection) { myField.focus();');
	   newWin.document.write('if (myMode==true) { sel = window.opener.document.selection.createRange();');
	   newWin.document.write('} else { sel = document.selection.createRange(); }');
	   newWin.document.write('sel.text = myValue;');
	   newWin.document.write('sel.moveStart("character", -myValue.length); }');
	   newWin.document.write('else if (myField.selectionStart || myField.selectionStart == "0") {');
	   newWin.document.write('var startPos = myField.selectionStart;');
	   newWin.document.write('var endPos = myField.selectionEnd;');
	   newWin.document.write('myField.value = myField.value.substring(0, startPos) + myValue + myField.value.substring(endPos, myField.value.length); }');
	   newWin.document.write('else { myField.value += myValue; } }');
	   newWin.document.write('</script></head>\n<body><center><br>'); 
       newWin.document.write('\n<form name="linkForm" onSubmit="return addLink(window.opener.' + field + ');">');
       newWin.document.write('\n<table cellpadding="4" cellspacing="4" border="0" style="border:1px dashed #C0C0C0;background-color:#F0F0F0;">');
       newWin.document.write('\n<tr bgcolor="#E0E0E0"><td colspan="3"><span style="font-style: italic;"><strong>Tip:</strong> To insert an email address, start with &quot;mailto:&quot;</span></td></tr>');
       newWin.document.write('\n<tr><td colspan="3"><br></td></tr>');
       newWin.document.write('\n<tr><td align="right"><strong>Enter URL : </strong></td><td>');
	   newWin.document.write('<select name="init" id="init" tabindex="1"><option value="http://" selected>http://</option><option value="mailto:">mailto:</option><option value="https://">https://</option><option value="ftp://">ftp://</option></select></td>');
	   newWin.document.write('<td><input name="url1" type="text" id="url1" size="30" maxlength="128" tabindex="2"><br>\n</td></tr>');
       newWin.document.write('\n<tr><td>&nbsp;</td><td colspan="2"><strong>Example:</strong> www.website.com</td></tr>');
	   newWin.document.write('<tr><td align="right"><strong>Optional Label : </strong></td><td colspan="2"><input name="linkText" type="text" id="linkText" size="40" maxlength="40" value="' + txt + '" tabindex="3"><br>\n</td></tr>');
       newWin.document.write('\n<tr><td>&nbsp;</td><td colspan="2"><strong>Example:</strong> My Favorite Website</td></tr>');
       newWin.document.write('\n<tr><td colspan="3">&nbsp;</td></tr>');
	   newWin.document.write('<tr><td colspan="3"><center><input type="submit" value="Insert Link">&nbsp;&nbsp;&nbsp;');
       newWin.document.write('\n<input type="button" value="Cancel" onClick="window.close();"></center></td></tr>');
	   newWin.document.write('\n</table>\n</form></center>'); 
	   newWin.document.write('\n</body></html>'); 
       newWin.document.close(); 
       newWin.focus(); 
}

function insertSmiley(field,iMSize) { 
// Displays TextArea Toolbar smiley selector
   var leftPos = ((screen.availWidth/2)-150);
   var topPos = ((screen.availHeight/2)-140);
   var sOption="toolbar=no,location=no,directories=no,menubar=no,"; 
       sOption +="scrollbars=no,resizable=yes,width=300,height=280,left=" + leftPos + ",top=" + topPos;
   var newWin=window.open("","Smiley",sOption); 
   newWin.document.open(); 
   newWin.document.write('<html><head><meta http-equiv="expires" content="0"><meta http-equiv="pragma" content="no-cache"><title>Insert Smiley</title>');
   newWin.document.write('<style type="text/css">body {font-size:12px;color:#000000;background-color:#E0E0E0;} table,td {font-family:verdana,sans-serif;font-size:11px;}</style>');
   newWin.document.write('<script type="text/javascript">');
   newWin.document.write('function addSmile(myField,myValue) {');
   newWin.document.write('insertAtCursor(myField," " + myValue + " ",true);');
   newWin.document.write('window.close(); return true; }');
   newWin.document.write('function insertAtCursor(myField, myValue, myMode) {');
   newWin.document.write('if (document.selection) { myField.focus();');
   newWin.document.write('if (myMode==true) { sel = window.opener.document.selection.createRange();');
   newWin.document.write('} else { sel = document.selection.createRange(); }');
   newWin.document.write('sel.text = myValue;');
   newWin.document.write('sel.moveStart("character", -myValue.length); }');
   newWin.document.write('else if (myField.selectionStart || myField.selectionStart == "0") {');
   newWin.document.write('var startPos = myField.selectionStart;');
   newWin.document.write('var endPos = myField.selectionEnd;');
   newWin.document.write('myField.value = myField.value.substring(0, startPos) + myValue + myField.value.substring(endPos, myField.value.length); }');
   newWin.document.write('else { myField.value += myValue; } }');
   
   newWin.document.write('</script></head>\n');
   newWin.document.write('<body><center><table cellpadding="6" style="border:1px dashed #C0C0C0;background-color:#F0F0F0;"><tr><td colspan="3"><strong>Select a Smiley or click on Cancel</strong></td></tr><tr><td colspan="3"><hr></td></tr>');
   newWin.document.write('<tr>');
   newWin.document.write('<td><a href="javascript:addSmile(window.opener.' + field + ",'[:)]'" + ')">');
   newWin.document.write('<img src="images/smiley/smiley1b.gif" width="22" height="22" border="0" alt="Smile" title="Smile" /></a>&nbsp;Smile</td>');
   newWin.document.write('<td><a href="javascript:addSmile(window.opener.' + field + ",'[:(]'" + ')">');
   newWin.document.write('<img src="images/smiley/smiley2b.gif" width="22" height="22" border="0" alt="Sad" title="Sad" /></a>&nbsp;Sad</td>');
   newWin.document.write('<td><a href="javascript:addSmile(window.opener.' + field + ",'[:x]'" + ')">');
   newWin.document.write('<img src="images/smiley/smiley3b.gif" width="22" height="22" border="0" alt="Angry" title="Angry" /></a>&nbsp;Angry</td>');
   newWin.document.write('</tr>');
   newWin.document.write('\n<tr>');
   newWin.document.write('<td><a href="javascript:addSmile(window.opener.' + field + ",'[:err:]'" + ')">');
   newWin.document.write('<img src="images/smiley/smiley4b.gif" width="22" height="22" border="0" alt="Smile" title="Smile" /></a>&nbsp;Confused</td>');
   newWin.document.write('<td><a href="javascript:addSmile(window.opener.' + field + ",'[:D]'" + ')">');
   newWin.document.write('<img src="images/smiley/smiley5b.gif" width="22" height="22" border="0" alt="Grin" title="Grin" /></a>&nbsp;Grin</td>');
   newWin.document.write('<td><a href="javascript:addSmile(window.opener.' + field + ",'[;)]'" + ')">');
   newWin.document.write('<img src="images/smiley/smiley6b.gif" width="22" height="22" border="0" alt="Wink" title="Wink" /></a>&nbsp;Wink</td>');
   newWin.document.write('</tr>');
   newWin.document.write('\n<tr>');
   newWin.document.write('<td><a href="javascript:addSmile(window.opener.' + field + ",'[8)]'" + ')">');
   newWin.document.write('<img src="images/smiley/smiley7b.gif" width="22" height="22" border="0" alt="Crazy" title="Crazy" /></a>&nbsp;Crazy</td>');
   newWin.document.write('<td><a href="javascript:addSmile(window.opener.' + field + ",'[B)]'" + ')">');
   newWin.document.write('<img src="images/smiley/smiley8b.gif" width="22" height="22" border="0" alt="Cool" title="Cool" /></a>&nbsp;Cool</td>');
   newWin.document.write('<td><a href="javascript:addSmile(window.opener.' + field + ",'[:*]'" + ')">');
   newWin.document.write('<img src="images/smiley/smiley9b.gif" width="22" height="22" border="0" alt="Kiss" title="Kiss" /></a>&nbsp;Kiss</td>');
   newWin.document.write('</tr>');
   newWin.document.write('\n</table>\n<br><br><form name="linkForm">');
   newWin.document.write('<input type="button" value="Cancel" onClick="window.close();">');
   newWin.document.write('</form></center></body></html>'); 
   newWin.document.close(); 
   newWin.focus(); 
}
function popupHelp(bImg) { 
// Help form for TextArea Toolbar
	var leftPos = (screen.availWidth - 540) / 2;
	var topPos = (screen.availHeight - 460) / 2;
	var sOption="toolbar=no,location=no,directories=no,menubar=no,"; 
       sOption +="scrollbars=no,resizable=yes,width=540,height=460,left=" + leftPos + ",top=" + topPos;
	var newWin=window.open("","HelpMsg",sOption); 
	newWin.document.open(); 
	newWin.document.write('<html><head><meta http-equiv="expires" content="0"><meta http-equiv="pragma" content="no-cache"><title>Help</title>\n');
	newWin.document.write('<style type="text/css">body {font-size:11px;color:#000000;background-color:#E0E0E0;} table,td {font-family:verdana,sans-serif;font-size:11px;}</style>');
	newWin.document.write('</head>\n<body><center><br>'); 
	newWin.document.write('\n<table width="500" cellpadding="4" cellspacing="4" border="0" style="background-color:#FFFFFF;border:1px solid #000000;">');
	newWin.document.write('\n<tr bgcolor="#E0E0E0"><td><span style="font-style:italic;font-weight:bold;">Help</span></td></tr>');
	newWin.document.write('\n<tr><td>');
	newWin.document.write("You can now add Smileys and BBCode to your post.<br /><br /><strong>For Smileys:</strong> Click on the Smiley button. A popup window will display. Select the smiley you want to show.<br /><br />");
	newWin.document.write("<hr /><strong>For BBCode:</strong> Click on bold [b], italics [i], highlight [u] or [quote] buttons. The system will add starting and ending tags. ");
	newWin.document.write("Enter your text between the starting [b] and ending [/b] tags like this:<br /><br />");
	newWin.document.write("&nbsp;&nbsp;&nbsp;[b]<b>This is bold text</b>[/b]<br />");
	newWin.document.write("&nbsp;&nbsp;&nbsp;[center]text[/center]&nbsp;&nbsp;&nbsp;(This centers text)<br />&nbsp;&nbsp;&nbsp;[code]text[code]&nbsp;&nbsp;&nbsp;(Pre-formatted text)<br />");
	newWin.document.write("&nbsp;&nbsp;&nbsp;[size=14]text[/size]&nbsp;&nbsp;&nbsp;(Valid font sizes are 10 to 20).<br /><br />");
	newWin.document.write("<hr /><strong>To add a link:</strong> Click the link icon (planet/link) and fill out the form or enter them manually using:<br /><br />");
	newWin.document.write("&nbsp;&nbsp;&nbsp;[url]http://www.website.com[/url] or<br />&nbsp;&nbsp;&nbsp;[url=http://www.website.com]Optional Label[/url]<br />");
	if (bImg==true) {
		newWin.document.write("&nbsp;&nbsp;&nbsp;[img]http://www.website.com/mypic.gif[/img]<br />");
		newWin.document.write("&nbsp;&nbsp;&nbsp;[youtube]videoID[/youtube]&nbsp;&nbsp;&nbsp;(Example: [youtube]nm7_nJ6u3CQ[/youtube])<br />");
	}
	newWin.document.write('</td></tr>');
	newWin.document.write('\n<tr><td><center><form><input type="button" value="Close" onClick="window.close();"></center></form></td></tr>');
	newWin.document.write('\n</table>\n</center></body></html>'); 
	newWin.document.close(); 
	newWin.focus(); 
}

function bookmarkthispage (title) {
// Use browser bookmarking feature to add a bookmark for this page
	if (document.all)
		window.external.AddFavorite(self.location, title);
	else 
		if (window.sidebar)
			window.sidebar.addPanel(title, self.location, "")
}

function Instr(strSearch, charSearchFor) {
// Emulate VB Instr function
	for (i=0; i < Len(strSearch); i++)
	{
	    if (charSearchFor == Mid(strSearch, i, 1))
	    {
			return i;
	    }
	}
	return -1;
}

function Mid(str, start, len) {
// Emulate VB Mid function
	if (start < 0 || len < 0) return "";
    var iEnd, iLen = String(str).length;
    if (start + len > iLen)
		iEnd = iLen;
	else
		iEnd = start + len;
	return String(str).substring(start,iEnd);
}

function Len(str) {
// Emulate VB Len function
	return String(str).length;
}

function LCase(str) {
// Emulate VB LCase function
	return String(str).toLowerCase();
}

function LTrim(str) {
// Emulate VB LTrim function
  var whitespace = new String(" \t\n\r");
  var s = new String(str);
  if (whitespace.indexOf(s.charAt(0)) != -1) {
     var j=0, i = s.length;
     while (j < i && whitespace.indexOf(s.charAt(j)) != -1)
           j++;
     s = s.substring(j, i);
  }
  return s;
}

function RTrim(str) {
// Emulate VB RTrim function
  var whitespace = new String(" \t\n\r");
  var s = new String(str);
  if (whitespace.indexOf(s.charAt(s.length-1)) != -1) {
     var i = s.length - 1;
     while (i >= 0 && whitespace.indexOf(s.charAt(i)) != -1)
           i--;
     s = s.substring(0, i+1);
  }
  return s;
}

function confirmDelete() {
// Asks user if they really want to delete
    var agree=confirm("Deleting information cannot be undone.\nClick OK to continue delete.");
    if (agree)
        return true;
    else
        return false;
} 

function confirmOperation() {
// Asks user if they are sure
    var agree=confirm("Are you sure you want to do this?");
    if (agree)
        return true;
    else
        return false;
} 

function confirmUpload() {
// Ask users if they really want to upload
    var agree=confirm("You are about to upload a photo to the server. Upload time depends upon photo size and your connection speed. Click OK to continue.");
    if (agree)
        return true;
    else
        return false;
} 

function confirmImageUpload (msg) {
// Check Image Upload Form
	filn=document.uploadphoto.filenametext.value;
	var upMode=1;

	if(filn=='') {
		try { 
			surl = getCheckedValue(document.forms['uploadphoto'].elements['fObject'])
			switch (surl)
			{
				case "url": // upload
					filn=document.uploadphoto.url1.value;
					upMode=2;
					break
				case "pag": // page gallery
					filn = getCheckedValue(document.forms['uploadphoto'].elements['gal1'])
					upMode=2;
					break
			}
		}
		catch (e) {}
		if(filn=='') {
			alert(msg);
			document.uploadphoto.filenametext.focus();
			return false
		}
	}

	//drop to lowercase and get right 3 characters
	filx = LCase(RTrim(filn));
	if(Len(filx)>3) { filx=Mid(filx,Len(filx)-4,4) }
	if((filx!=".jpg")&&(filx!="jpeg")&&(filx!=".gif")) {
		//error if file type is wrong
		alert("File type must be GIF, JPG or JPEG.");
		return false
	} else {
		//Make sure they really want to do this
		if(upMode==1) {
			var agree=confirm("You are about to upload an image to the server. Upload time depends upon file size and connection speed. Click OK to continue.");
			if (agree)
				return true;
			else
				return false;
		} else { return true; }
	}	
}

function getCheckedValue(rObj) {
// returns value of radio button or empty string if nothing selected

	if(!rObj) { return ""; }
	var radioLength = rObj.length;
	if(radioLength == undefined)
		if(rObj.checked)
			return rObj.value;
		else
			return "";
	for (var i = 0; i < radioLength; i++) {
		if(rObj[i].checked) { return rObj[i].value; }
	}
	return "";
}

function AddRTELink() {
   var oForm = document.linkForm;
   var iurl = 0;

	// validate form
	// check to see if Link Text exists
	if (oForm.linkText.value == '') {
		alert('Please enter link text.');
		return false;
	}
	// make sure a radio button is selected
	var inputs = oForm.getElementsByTagName ('input');
	if (inputs) {
		for (var i = 0; i < inputs.length; ++i) {
			if (inputs[i].type == 'radio' && inputs[i].name == 'fObject')
				if(inputs[i].checked == true) iurl = i
			}
	}
	if ((iurl == 0)) {
		alert('Please use the radio buttons to select an option.');
		return false;
	}

   var newlink = '';
   var newtarget = '';
   var target = document.linkForm.linkTarget.options[document.linkForm.linkTarget.selectedIndex].value;

	// process link options
	switch (iurl)
	{
	case 1: // external website URL
	   if (oForm.url1.value > '') {
			newlink = LTrim(document.linkForm.url1.value);
			if (Mid(newlink.toLowerCase(), 0, 7) != 'http://') {
				if (document.linkForm.init.value != 'na') {
					newlink = document.linkForm.init.value + newlink;
				}
			}
	   } else {
	      alert('Enter an external Web URL (website address).');
		  return false;
	   }
		break
	case 2: // local web page
	   if (oForm.url2.value > '') {
			newlink = oForm.url2.value;
	   } else {
	      alert('Select a local Web Page from the list.');
		  return false;
	   }
		break
	case 3: // local news article
	   if (oForm.url3.value > '') {
			newlink = oForm.url3.value;
	   } else {
	      alert('Select a News Article from the list.');
		  return false;
	   }
		break
	case 4: // email address
	   if (oForm.url4.value > '') {
			newlink = "mailto:" + LTrim(document.linkForm.url4.value);
	   } else {
	      alert('Enter an Email Address.');
		  return false;
	   }
		break
	case 5: // shopping product
	   if (oForm.url5.value > '') {
			newlink = oForm.url5.value;
	   } else {
	      alert('Select a Shopping Product from the list.');
		  return false;
	   }
		break
	}
   
   if ( target == 'p') {
	newlink = "javascript:popUp('" + newlink + "')";
	newtarget = '';
   } else {
	newtarget = ' target="' + target + '"';
   }

   var html = '<a href="' + newlink + '"' + newtarget  + ">" + document.linkForm.linkText.value + '</a>';

   window.opener.insertHTML(html);
   window.close();
   return true;
}

function getSelText(field) {
// Gets Selected Text
	var txt = "";
	if (document.getSelection) { // Firefox
		txt = (field.value).substring(field.selectionStart,field.selectionEnd) + ""; 
		if (txt.length ==0) {
			txt = document.getSelection();
			}
		}
	else if (document.selection && document.selection.createRange) { // IE
		var range = document.selection.createRange();
		txt = range.text;
		}
		else { // Other Browsers
			if(window.getSelection()) { // Safari
				txt = window.getSelection() + "";
				if(txt=="") {
					txt = (field.value).substring(field.selectionStart,field.selectionEnd) + ""; 
					}
				}
			else {
				var txt = "";
			}
		}
	return txt;
}

function getTimeZone() {
// Returns number of hours offset from UTC
	var dtDate = new Date('1/1/' + (new Date()).getUTCFullYear());
	var intOffset = 100;
	var intMonth;
	var intHoursUtc;
	var intHours;
	var intDaysMultiplyBy;
	for (intMonth=0;intMonth < 12;intMonth++) {
		dtDate.setUTCMonth(dtDate.getUTCMonth() + 1);
		if (intOffset > (dtDate.getTimezoneOffset() * (-1))) {
			intOffset = (dtDate.getTimezoneOffset() * (-1));
		}
	}
	// set into cookie for use by ASP
	setCookie ("UserTZ",parseInt(intOffset/60),3);
	return true
}

function addHTML(field,cntfield,maxlimit,sCode) {
// Inserts code into field upon button press - used mostly by Textarea Toolbar
	var selTxt=getSelText(field) + "";
	if(selTxt.length > 0) {
		insertAtCursor(field,sCode.replace(/\?/,selTxt),false);
	}
	else {
		insertAtCursor(field,sCode,false);
	}
	//field.value += sCode;
	field.focus();
	cntfield.value = maxlimit - field.value.length;
}

function clearHTML(field,cntfield,maxlimit) {
// Clears field upon button press
	field.value = "";
	field.focus();
	cntfield.value = maxlimit;
}

function textCounter (field,cntfield,maxlimit) {
// Shows Count-down counter as user is entering text into textarea
	if (field.value.length > maxlimit)
		field.value = field.value.substring(0, maxlimit);
	else
		cntfield.value = maxlimit - field.value.length;
}

function limitText(limitField, limitCount, limitNum) {
// Keeps user from entering too much text into text area
	if (limitField.value.length > limitNum) 
		{ limitField.value = limitField.value.substring(0, limitNum); }
	else 
		{ limitCount.value = limitNum - limitField.value.length; }
}

function setCookie (cookieName,cookieValue,nDays) {
// Sets Cookie - used mostly for themes
	var today = new Date();
	 var expire = new Date();
	 if (nDays==null || nDays==0) nDays=1;
	 expire.setTime(today.getTime() + 3600000*24*nDays);
	 document.cookie = cookieName+"="+escape(cookieValue) + ";expires="+expire.toGMTString();
}

function sessionKeepAlive() {
// Keep entry forms from timing out and loosing session variables
    var imgAlive = new Image();
    var d = new Date();
    imgAlive.src = 'sessionkeepalive.asp?d=' + d;
}

function checkUserIcons (setRadio) {
// For User Icon selection, when a user clicks an Image, select appropriate radio button
	var radios = document.getElementById ('userradios');
	if (radios) {
	  var inputs = radios.getElementsByTagName ('input');
	  if (inputs) {
	    for (var i = 0; i < inputs.length; ++i) {
	      if (inputs[i].type == 'radio' && inputs[i].name == 'usericon')
	        inputs[i].checked = inputs[i].value == setRadio;
	    }
	  }
	}
}

function setCheck(frm,setValue) {
// Sets all checkboxes on frm form
	var count = document.getElementById(frm).elements.length;
    for (var i=0; i < count; i++) 
	{
		if (document.getElementById(frm).elements[i].type == 'checkbox') {
			document.getElementById(frm).elements[i].checked = setValue;
		}
	}
}

function setAdUnitCheck (setValue) {
// Sets and Clears checkboxes on Ad Unit Page
	document.ads.WeekDays1.checked = setValue;
	document.ads.WeekDays2.checked = setValue;
	document.ads.WeekDays3.checked = setValue;
	document.ads.WeekDays4.checked = setValue;
	document.ads.WeekDays5.checked = setValue;
	document.ads.WeekDays6.checked = setValue;
	document.ads.WeekDays7.checked = setValue;
}

function setButtonValue(sVar) {
// Use as part of routine to fire javascript when button is clicked
	sButton=sVar;
}

function isNumberString (InString)  {
// Tests to see if a string is numeric
	if((isNaN(InString)==true)||(InString.length==0))
		return (false);
	var RefString="1234567890";
	for (Count=0; Count < InString.length; Count++)
		{
		TempChar= InString.substring (Count, Count+1);
		if (RefString.indexOf (TempChar, 0)==-1)  
			return (false);
		}
	return (true);
}

function toggleDiv(szDivID, iState) {// 0=hidden, 1=show
// Shows and Hides a DIV

	if(document.layers) {
		//nn4  
		document.layers[szDivID].visibility = iState ? "show" : "hide"; 
	}
	else if(document.getElementById) {
		//ie5+ and Firefox
		var obj = document.getElementById(szDivID);
		if(iState==true)
			obj.style.display = 'block';
		else
			obj.style.display = 'none';
		//obj.style.visibility = iState ? "visible" : "hidden";
	}
    else if(document.all) {
		//ie
		document.all[szDivID].style.visibility = iState ? "visible" : "hidden";
	}
}

function toggleCheck(szDivID) {
// Toggles Div based on checkbox
	if (szDivID.checked)
		{ toggleDiv('cartbuttons',1); }
	else
		{ toggleDiv('cartbuttons',0); }
}


function toggleLocation(iState) {// 0=Photo, 1=Map, 2=Weather
// Shows and Hides location data on trip location page
	var gphoto = document.getElementById('locPhoto');
	var gmap = document.getElementById('locMap');
	var gweather = document.getElementById('locWeather');
	switch (iState)
	{
	case 0:
		gphoto.style.display='block';
		try
			{ gmap.style.display='none'; }
		catch (e) { }
		try
			{ gweather.style.display='none' }
		catch (e) { }
		break
	case 1:
		gphoto.style.display='none';
		try
			{ gmap.style.display='block'; }
		catch (e) { }
		try
			{ gweather.style.display='none' }
		catch (e) { }
		break
	case 2:
		gphoto.style.display='none';
		try
			{ gmap.style.display='none'; }
		catch (e) { }
		try
			{ gweather.style.display='block' }
		catch (e) { }
		break
	}
}

function toggleMultiImage () {
	if (document.cartprod.multiimageflag.checked == 1) {
		toggleDiv('SingleImage',0);
		toggleDiv('MultiImage',1);
	} else {
		toggleDiv('SingleImage',1);
		toggleDiv('MultiImage',0);
	}
}

function toggleReqLicense () {
	if (document.cartprod.requirelicense.checked == 1) {
		toggleDiv('ReqLicense',1);
	} else {
		toggleDiv('ReqLicense',0);
	}
}

function toggleAdBlock (optObj) {
// Toggle Product Option Types
	var i = optObj.options[optObj.selectedIndex].value-0;
	if(i==0) {
		toggleDiv('gadsense',0);
		toggleDiv('padspace',0);
	} else 
		if(i==5) {
			toggleDiv('gadsense',0);
			toggleDiv('padspace',1);
		} else {
			toggleDiv('gadsense',1);
			toggleDiv('padspace',0);
		}
}
function toggleProdOptions (optObj) {
// Toggle Product Option Types
	var oname = optObj.name;
	if(oname == 'option1type') 
		var optx = 1;
	else
		var optx = 2;
	var i = optObj.options[optObj.selectedIndex].value-0;
	
	if(i==0)
		toggleDiv('Option' + optx + 'Frame',0);
	else
		toggleDiv('Option' + optx + 'Frame',1);
	
	// Set help field
	for (j=1; j < 6; j++)
		toggleDiv('Option' + optx + 'Help' + j,0);

	if(i>0)
		toggleDiv('Option' + optx + 'Help' + i,1);

	// On Option 1 (Text Box), hide selection field
	if(i==1)
		toggleDiv('Option' + optx + 'Sel',0);
	else
		toggleDiv('Option' + optx + 'Sel',1);

}
function toggleMenuLinkType (optObj) {
// Toggle Menu Editor Link Types
	var i = optObj.options[optObj.selectedIndex].value-0;
	for (j=1; j < 4; j++)
		toggleDiv('type'+ j,0);
	if(i != 4)
		toggleDiv('type'+ i,1);
}
function changeImage (imgName, imgSrc, iWidth) {
// Replaces an image
	var gphoto = document.getElementById(imgName);
    var img = document.createElement('img');
    img.onload = function (evt) {
        gphoto.src=this.src;
        gphoto.width=iWidth;
    }
    img.src = imgSrc;
	return false;
}

function changeDescDiv (menuObj) {
// Changes description field label on trip form
	var i = menuObj.selectedIndex;
	if (menuObj.options[i].value == 'new') {
		// selected Add New Location
		toggleDiv("tripdesc",0);
		toggleDiv("locname",1);
		toggleDiv("locfield",1);
		toggleDiv("locdesc",1);
		document.savetrip.locationname.value = "";
	}
	else {
		// selected an existing Location
		toggleDiv("locname",0);
		toggleDiv("locfield",0);
		toggleDiv("locdesc",0);
		toggleDiv("tripdesc",1);
		document.savetrip.locationname.value = menuObj.options[i].value;
	}
}

function GenDir() {
// Creates a random name of 8 characters
	var startvalid = "abcdefghjkmnoprstuwxyz";
	var validchars = "abcdefghjkmnoprstuwxyz346789";
	var actualsize = Math.floor(Math.random() * (1)) + 8;

	document.carttrans.downloaddirtext.value = startvalid.charAt(Math.floor(Math.random() * startvalid.length));
	for (var count = 1; count < actualsize; count++)
		document.carttrans.downloaddirtext.value += validchars.charAt(Math.floor(Math.random() * validchars.length));
	document.carttrans.makedownloaddir.checked = true;
}

function clearMatrix() {
// Clears all entries from Matrix style shopping products
	try
	{
	iMXcol=document.cartjump.mxcol.value-0;
	iMXrow=document.cartjump.mxrow.value-0;
	}
	catch (e)
	{
	iMXcol=0;
	iMXrow=0;
	}

	for (var i = 0; i < iMXrow ; ++i) {
		for (var j = 0; j < iMXcol ; ++j) {
			try {document.getElementById("mx" + i + "_" + j).value=''; }
			catch (e)
				{ }
			}
		}
}

function playsound(surl) {
// Plays sound using browser function
	document.getElementById('soundspan').innerHTML="<embed src='"+surl+"' height=0 width=0 autostart=true loop=false>";
}

function formatDate(d, f) {
// Formats date string
	var d = new Date(d);
	var months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
	var days = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
	return " - " + f.replace(/(yyyy|mmmm|mmm|mm|dddd|ddd|dd|hh|nn|ss|a\/p)/gi,
	function($1) {
		switch ( $1.toLowerCase()) {
			case 'yyyy': return d.getFullYear();
			case 'mmm': return months[d.getMonth()].substr(0, 3);
			case 'mm': return (d.getMonth() + 1);
			case 'dd': return d.getDate();
			case 'hh': return ((h = d.getHours() % 12) ? h : 12);
			case 'nn': return d.getMinutes();
			case 'ss': return d.getSeconds();
			case 'a/p': return d.getHours() < 12 ? 'a' : 'p';
			}
		}
	);
}
function dateToday () {
// Returns today's date in readable format
	var now = new Date(); 
	var days = 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 date = ((now.getDate()<10) ? "0" : "")+ now.getDate(); 
	today = days[now.getDay()] + ", " + months[now.getMonth()] + " " + date + ", " + (fourdigits(now.getYear())); 
	document.write(today);
}

function timeToday () {
// Returns time in readable format
	var currentTime = new Date()
	var hours = currentTime.getHours()
	var minutes = currentTime.getMinutes()
	if (minutes < 10)
		minutes = "0" + minutes
	if(hours > 12)
		document.write((hours - 12) + ":" + minutes + " PM")
	else
		if(hours < 12)
			document.write(hours + ":" + minutes + " AM");
		else
			if(hours = 0)
				document.write("12:" + minutes + " AM");
			else
				document.write("12:" + minutes + " PM");
}

function fourdigits (number) {
// Part of dateToday 
	return (number < 2000) ? number + 1900 : number;
} 

function insertAtCursor(myField, myValue, myMode) {
// Insert myField at current cursor location
	if (document.selection) {
		// IE
		myField.focus();
		if (myMode==true) { sel = window.opener.document.selection.createRange();
		} else { sel = document.selection.createRange(); }
		sel.text = myValue;
		sel.moveStart('character', -myValue.length);
	}
	else if (myField.selectionStart || myField.selectionStart == '0') {
		// Mozilla
		var startPos = myField.selectionStart;
		var endPos = myField.selectionEnd;
		myField.value =
		myField.value.substring(0, startPos) + myValue + myField.value.substring(endPos, myField.value.length);
		}
	else { myField.value += myValue; }
}

function dowImage(photoDir) {
// select a different image for each day of the week
	var dow = new Array('sunday','monday','tuesday','wednesday','thursday','friday','saturday');
	var now = new Date;
	var dayNow = now.getDay();
	var img = dow[dayNow];
	document.write('<img src="'+photoDir+'/dowimage/'+img+'.jpg" border="0" alt="'+img+'\'s photo" title="'+img+'\'s photo" class="dowimage">');
}

function showHideObj (sobj) {
// show and hides property map for PS-Realty module
	var gmap = document.getElementById(sobj);
	try
	{
		if ((gmap.style.display == 'block')||(gmap.style.display == ''))
			gmap.style.display = 'none';
		else
			gmap.style.display = 'block';
	}
	catch (e) { }
}

function testMailColors() {
// update sample mail template with correct colors from page
	var tcol = '#' + document.getElementById('textcolor').value;
	document.getElementById('mmbg').style.backgroundColor = '#' + document.getElementById('bgcolor').value;
	document.getElementById('mmhead').style.backgroundColor = '#' + document.getElementById('headercolor').value;
	document.getElementById('mmbody').style.backgroundColor = '#' + document.getElementById('bodycolor').value;
	document.getElementById('mmfoot').style.backgroundColor = '#' + document.getElementById('footercolor').value;
	document.getElementById('mmtx1').style.color = tcol;
	document.getElementById('mmtx2').style.color = tcol;
	document.getElementById('mmtx3').style.color = tcol;
	document.getElementById('mmtx4').style.color = tcol;
	if(document.getElementById('inclogo').checked) {
		document.getElementById('mmlogo').style.display = 'block';
	} else {
		document.getElementById('mmlogo').style.display = 'none';
	}
}

function setMailColors(iScheme) {
// sample color schedules for Mail Manager
	switch (iScheme) {
	case 0: // Jungle
		var arrColors = new Array("99CC00", "FFCC66", "FFFFFF", "000000", "FFFFCC");
		break
	case 1: // Beach
		var arrColors = new Array("1EABC7", "AAE95D", "FAFFF5", "293109", "47D3FF");
		break
	case 2: // Desert
		var arrColors = new Array("DFD8C2", "D6CFB7", "FBF4DE", "4C2923", "AEBD89");
		break
	case 3: // Mountain
		var arrColors = new Array("44749D", "C6D4E1", "FFFFFF", "000000", "EBE7E0");
		break
	case 4: // Artic
		var arrColors = new Array("9BBEF5", "BBD1F7", "FFFFFF", "004890", "DEEAFF");
		break
	case 5: // Urban
		var arrColors = new Array("ABBDBB", "BADDDB", "FEFFF8", "12223D", "858585");
		break
	case 6: // Forest
		var arrColors = new Array("6FA069", "B3C392", "D8DFBE", "033033", "AB956C");
		break
	case 7: // Wetlands
		var arrColors = new Array("93DBCC", "DE7C59", "F4FFE9", "000000", "A9D6BA");
		break
	case 8: // Grassland
		var arrColors = new Array("8CC23A", "ACE359", "F0FFD9", "336600", "D3FF91");
		break
	case 9: // Reef
		var arrColors = new Array("1890C0", "ACFFFF", "D0FFFF", "004848", "45C4C4");
		break
	case 10: // Spring
		var arrColors = new Array("7ED0D6", "C3FF68", "F4FCE8", "333333", "87D69B");
		break
	case 11: // Summer
		var arrColors = new Array("FBFF4C", "FCBE41", "FFFFFF", "085996", "46D7F0");
		break
	case 12: // Fall
		var arrColors = new Array("F2E9C6", "FCA90F", "F5F2BC", "000000", "FAC421");
		break
	case 13: // Winter
		var arrColors = new Array("F0F0F0", "E5E6C9", "F8F8EC", "000000", "BDCDD0");
		break
	case 14: // Surf
		var arrColors = new Array("2CC9E8", "F0417B", "F0F0F0", "484848", "C2DE37");
		break
		}
	document.getElementById('bgcolor').value = arrColors[0];
	document.getElementById('headercolor').value = arrColors[1];
	document.getElementById('bodycolor').value = arrColors[2];
	document.getElementById('textcolor').value = arrColors[3];
	document.getElementById('footercolor').value = arrColors[4];
	testMailColors();
}
// End -->