//
//	COPYRIGHT NOTICE:
// 	Copyright 2002 - 2008 Barry Saxifrage. Stonebreaker Designs. All Rights Reserved.
//	By using this code you agree to indemnify Barry Saxifrage and Stonebreaker Designs 
//	from any liability that might arise from its use. Selling this code or distributing 
//	this code without prior written consent is expressly forbidden. Copyright notice  
//	must remain with this code. For more information: www.stonebreakerdesigns.com	
//

//================================
//
//	OPTIONS DB
//

	// GET RID OF THESE (DB)
	var gnModifiedDaysNew = 14;			
	
	// SECTIONS
	var gidSectionAds 		= 1;
	var gidSectionArticles 	= 2;
	var gidSectionBiz 		= 3;
	var gidSectionEvents 	= 4;
	var gidSectionMap 		= 5;
	var gidSectionGallery	= 6;
	var gidSectionLinks		= 7;
	var gidSectionPolls		= 8;
	// FRONTPAGE EXTRA SECTIONS 
	var gidFPSectionWeather = 100;
	var gidFPSectionEdNote  = 101;
	var gidFPSectionTopics  = 102;
	var gidFPSectionSearch  = 103;
	var gidFPSectionMarket  = 104;
	var gidFPSectionSubscribe  = 105;
	
	var gidCurTopic			= 0;
	var gstrCurTopic		= '';
	var aMemberLevels = new Array("Basic Staff", "Mid-level Staff", "Editorial Staff");
	var aMemberLevelsPl = new Array("Basic Staff", "Mid-level Staff", "Editorial Staff");
	var gnSampleMemberLabel = '(Sample&nbsp;Product&nbsp;List)';
		
		
//================================
//
//	STANDARD GLOBALS
//

	var aMonthsShort = new Array("Jan", "Feb", "Mar", "Apr", "May", "June", "July", "Aug", "Sept", "Oct", "Nov", "Dec");
	var aMonths      = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
	var aDays 		 = new Array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday");
	var aDaysShort 	 = new Array("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat");
	var aTODNames 	 = new Array("after midnight","sunrise","morning","afternoon","sunset","before midnight");

	var msecOneDay = 86400000;
	var msecOneYear = 31536000000;
	
	
//================================
//
//	<HEAD> FUNCTIONS
//
	
	function setBaseHref() 		 { return; } 
	function setBaseHrefSecure() { return; } 
	function setSkin() {
		if (gSkin != 1) {
			var ex = '';
			if ((gSkin > 1) && (gSkin <= 5)) { ex = gSkin; }
			document.writeln('<LINK REL="STYLESHEET" TYPE="text/css" HREF="'+gWWWPath+'skins/1_'+gSkin+'/skin'+ex+'.css">');
		} 
	}
	
	
//================================
//
//	MASTHEAD & SIDEBAR
//
	
	var nPendingReview = 0;
	var gstrSideMenu = ''; 
	var gstrEdToolbar = ''; 
	var gstrSideMenuColor = '';
	var gfShowAds   = 0;
	var gfShowArs   = 0;
	var gfShowBis   = 0;
	var gfShowEvs   = 0;
	var gfShowGas   = 0;
	var gfShowMas   = 0;
	var gfShowLis   = 0;
	var gfShowPos   = 0;
		
	function drawMasthead(aMasthead, fIsAdmin) {
	
		var aM = aMasthead[0].split("|");
		var iTimeOfDay			= aM[0];
		var strTimeOfDay		= aM[1];
		var strPix				= aM[2];
		var xNotUsed			= aM[3];
		var strTitle			= aM[4];
		var nTitleFontSize		= aM[5];
		var strFontColor		= aM[6];
		var posTitle			= aM[7];
		var fShowTitle			= aM[8];
		var posDate				= aM[9];
		var fShowDate			= aM[10];
		var strTitleShort		= aM[11];
		var fSubOn				= aM[12];
		var fSub1				= aM[13];
		var fSub2				= aM[14];
		var strMenuColor		= aM[15];
		gstrSideMenuColor		= aM[16];
		var fSideMenu			= aM[17];
		var fRSS				= aM[18];
		var nRSSIcon			= aM[19];
		var fCommandMP			= aM[20];
		var strWrapperBits		= aM[21];
		var nSProfileAccess		= aM[22];
		var strLiveTopics 		= aM[23];
		nPendingReview			= aM[24];
		var nMsgs				= aM[25];
		var idUser				= aM[26];
		var strUsername			= aM[27];
		var nLevel				= aM[28];
		var fEdMachine			= aM[29];
		var urlSignIn			= aM[30];
		var strEdStati			= aM[31];
		fEdMachine = (fEdMachine == 1);
		
		var aLiveTopics	= strLiveTopics.split(':');
		var nTopics = 0;
		if (strLiveTopics != '') {	nTopics = aLiveTopics.length;	}
		
		var aEdSt = strEdStati.split(':');
		gfShowAds   = aEdSt[0];
		gfShowArs   = aEdSt[1];
		gfShowBis   = aEdSt[2];
		gfShowEvs   = aEdSt[3];
		gfShowMas   = aEdSt[4];
		gfShowGas   = aEdSt[5];
		gfShowLis   = aEdSt[6];
		gfShowPos   = aEdSt[7];
		var fShowFPEdN   = aEdSt[8];
		var fShowFPWea   = aEdSt[9];
		var fShowFPSea   = aEdSt[10];
		var fShowFPTPC   = aEdSt[11];
		
		if (fIsAdmin) {
			var strEd ='';
			var fPBOpen0 = 1;
			var fPBOpen1 = 0;
			var fPBOpen2 = 0;
			var fPBOpen3 = 0;
			var fPBOpen4 = 0;
			var fPBOpen5 = 0;
			var fPBOpen6 = 0;
			var fPBOpen100 = 0;
			var strAdminPB = GetCookie('adminPB');
			if (isEmpty(strAdminPB)) {
				SetCookieYear('adminPB',':0:',"/");
			} else {
				if (strAdminPB.indexOf(':0:',0) >= 0) { fPBOpen0 =1; } else { fPBOpen0 = 0;}
				if (strAdminPB.indexOf(':1:',0) >= 0) { fPBOpen1 =1; } else { fPBOpen1 = 0;}
				if (strAdminPB.indexOf(':2:',0) >= 0) { fPBOpen2 =1; } else { fPBOpen2 = 0;}
				if (strAdminPB.indexOf(':3:',0) >= 0) { fPBOpen3 =1; } else { fPBOpen3 = 0;}
				if (strAdminPB.indexOf(':4:',0) >= 0) { fPBOpen4 =1; } else { fPBOpen4 = 0;}
				if (strAdminPB.indexOf(':5:',0) >= 0) { fPBOpen5 =1; } else { fPBOpen5 = 0;}
				if (strAdminPB.indexOf(':6:',0) >= 0) { fPBOpen6 =1; } else { fPBOpen6 = 0;}
				if (strAdminPB.indexOf(':100:',0) >= 0) { fPBOpen100 =1; } else { fPBOpen100 = 0;}
			}
			
			strEd += '<div id="admin_powerbar" class="adminbox">';
				strEd += '<div class="ed_pb_h"><a href="javascript:toggleEdPBSection(100)" class="ed_pb_h">Editor Tools<img src="bits/dlg_pop_down.gif" width="10" height="6" alt="" border="0"></a></div>';
				strEd += '<div id="ed_pb100" ';
				if (fPBOpen100 == 1) { strEd += 'style="display:block"'; }
				strEd += '>';
					strEd += '<div class="ed_pb_p">';
					strEd += 'Tools to manage Tideline.';
					// <br>'+getEdHelp(true,"checklist")+' To <a href="javascript:adminHelp(\'checklist\')" class="ed_pb_p">get started, click here</a>.' ;
					strEd += '</div>';
				strEd += htmlEdPowerHeader('Daily Tools', 0, fPBOpen0, 'dailytasks');
					strEd += htmlEdPowerLink(201,'Editor Desk & Stats',1);
					strEd += htmlEdPowerLink(200,'REVIEW &middot; '+nPendingReview,1);
					strEd += htmlEdPowerLink(202,'MESSAGES &middot; '+nMsgs,1);
					strEd += '</div>';
				strEd += htmlEdPowerHeader('Design & Layout', 1, fPBOpen1, 'design');
					strEd += htmlEdPowerLink(29,'Visual Designer',1);
					strEd += htmlEdPowerLink(9,'Masthead Image',1);
					strEd += htmlEdPowerLink(11,'Masthead Title & Date',1);
					strEd += htmlEdPowerLink(45,'Menubar',1);
					strEd += htmlEdPowerLink(44,'Right Sidebar',1);
					strEd += htmlEdPowerLink(26,'Skins: Fonts & Colors',1);
					strEd += '</div>';
				strEd += htmlEdPowerHeader('Frontpage', 2, fPBOpen2, 'frontpage');
					strEd += htmlEdPowerLink(48,'Top Banner',1);
					strEd += htmlEdPowerLink(41,'Arrange Frontpage',1);
					strEd += htmlEdPowerLink(27,'Editor\'s Note',fShowFPEdN);
					strEd += htmlEdPowerLink(20,'Weather',fShowFPWea);
					strEd += htmlEdPowerLink(34,'Search box',fShowFPSea);
					strEd += htmlEdPowerLink(42,'Subscribe box',1);
					strEd += htmlEdPowerLink(43,'Add Custom Element',1);
					strEd += htmlEdPowerLink(19,'Tidepool Critters',fShowFPTPC);
					strEd += '</div>';
				strEd +=  htmlEdPowerHeader('Postings', 3, fPBOpen3, 'postings');
					strEd += htmlEdPowerLink(6,'Classified Ads',gfShowAds);
					strEd += htmlEdPowerLink(8,'Articles',gfShowArs);
					strEd += htmlEdPowerLink(7,'Biz & Groups',gfShowBis);
					strEd += htmlEdPowerLink(204,'Sponsors List',gfShowBis);
					strEd += htmlEdPowerLink(5,'Events',gfShowEvs);
					strEd += htmlEdPowerLink(12,'Galleries',gfShowGas);
					strEd += htmlEdPowerLink(10,'Links',gfShowLis);
					strEd += htmlEdPowerLink(25,'Maps',gfShowMas);
					strEd += htmlEdPowerLink(16,'Polls',gfShowPos);
					strEd += '</div>';
				strEd +=  htmlEdPowerHeader('People', 4, fPBOpen4, 'managepeople');
					strEd += htmlEdPowerLink(21,'Security & Access',1);
					strEd += htmlEdPowerLink(47,'Staff & Messages',1);
					strEd += htmlEdPowerLink(206,'View Staff List',1);
					strEd += htmlEdPowerLink(204,'View Sponsor List',1);
					strEd += '</div>';
				strEd +=  htmlEdPowerHeader('Other Features', 5, fPBOpen5, 'otherfeatures');
					strEd += htmlEdPowerLink(28,'Special Sections',1);
					strEd += htmlEdPowerLink(33,'Weekly Newsletters',1);
					strEd += htmlEdPowerLink(17,'Email Subscriptions',1);
					strEd += htmlEdPowerLink(38,'RSS Subscriptions',1);
					strEd += htmlEdPowerLink(22,'SearchEngines options',1);
					strEd += htmlEdPowerLink(46,'SearchEngines index',1);
					strEd += '</div>';
				strEd +=  htmlEdPowerHeader('Support', 6, fPBOpen6, 'support');
					strEd += getEdHelp(true,'checklist') + ' <a href="javascript:adminHelp(\'checklist\')" class="ed_pb_link">Getting Started</a><br>';
					strEd += getEdHelp(true,'manual') + ' <a href="javascript:adminHelp(\'manual\')" class="ed_pb_link">Online Manual</a><br>';
					strEd += getEdHelp(true,'support') + ' <a href="javascript:adminHelp(\'support\')" class="ed_pb_link">Support</a><br>';
					strEd += htmlEdPowerLink(39,'Update Service',1);
					strEd += '</div>';
				strEd += '</div>'; // ed_pb100
			strEd += '</div>';
			strEd += '<div style="margin-top:4px;margin-bottom:4px;">'+getEdDot(fIsAdmin,44)+'&nbsp;<a href="javascript:adminCommand(44)" class="btn">Sidebar Options</a></div>';
			gstrEdToolbar += strEd;	
			strEd = '';
		}

		if (strPix != '') {
			strPix = gWWWPath + 'data/' + strPix;
			document.writeln('<img id="mh" name="masthead" src="' + strPix + '" alt="" border="0">');
		}
		
		document.writeln('<div id="bit1"></div><div id="bit2"></div><div id="bit3"></div><div id="bit4"></div><div id="bit5"></div>');
		
		if (fShowTitle == 1) {
			var str 	  = '';
			var strStyle  = 'style=" font-size:'+nTitleFontSize+'px;';
			var strStyle2 = 'style=" font-size:'+nTitleFontSize+'px;';
			if (posTitle != '') {
				var aP = posTitle.split(':');
				var x = parseInt(aP[0]);
				var y = parseInt(aP[1]);
				strStyle += 'left:'+x+'px;top:'+y+'px;';
				x += 1; y += 1;
				strStyle2 += 'left:'+x+'px;top:'+y+'px;';
			}
			if (strFontColor != '') {
				strStyle += 'color:#'+strFontColor+';';
			}
			strStyle += '"';
			strStyle2 += '"';
			
			str += '<div id="mh_titleshadow" '+strStyle2+'>'+ strTitle+'</div>';
			str += '<div id="mh_title" '+strStyle+'>'+ strTitle+'</div>';
			document.writeln(str);
			str = '';
		}
		
		if (fShowDate == 1) {
			var myDate = getNow();
			var nMonth = myDate.getMonth();
			var str 	 = '';
			var strStyle = 'style="';
			var strStyleA = 'style="';
			if (posDate != '') {
				var aP = posDate.split(':');
				strStyle += 'left:'+aP[0]+'px;top:'+aP[1]+'px;';
			}
			if (strFontColor != '') {
				strStyle += 'color:#'+strFontColor+';';
				strStyleA += 'color:#'+strFontColor+';';
			}
			strStyle += '"';
			strStyleA += '"';
			str += '<div id="mh_topdate" '+strStyle+'>';
				if (strUsername != '') { 
					str += 'Welcome <a href="javascript:showMember('+idUser+')" style="color:#ff6600;">'+strUsername+'</a><br>';
					if ((!fEdMachine) && (nMsgs > 0)) { 
						str += 'You have <a href="javascript:adminCommand(202);" style="color:#ff6600;">'+nMsgs+'  message'
						if (nMsgs > 1) { str += 's'; }
						str += '</a><br>'; 
					}	
				}
				str += aDays[myDate.getDay()] +' '+ strTimeOfDay+'<br>';
				str += aMonths[nMonth] + ' ' + myDate.getDate() + ', ' + timeGetYear(myDate) + '<br>';
				if (fIsAdmin) { str += getEdDot(fIsAdmin,11); }
			str += '</div>';
			document.writeln(str);
			str = '';
		}
		document.writeln(aMasthead[1]);
		
		var iLastCommand = aMasthead.length - 2;
		var iMuDropDown = 0;
		var fMuDDOpen 	= false;
		var strMHStyle 	= '';
		var strMSStyle 	= '';
		var strSide 	= '';
		if (isNotEmpty(strMenuColor))   	{ strMHStyle = ' style="color:#'+strMenuColor+';"'; }
		if (isNotEmpty(gstrSideMenuColor))  { strMSStyle = ' style="color:#'+gstrSideMenuColor+';"'; }
		str = '';
		str += '<div id="menubar">';
		strSide += '<div id="menubar_right">';
			str += '<table cellspacing="0" cellpadding="0"><tr>';

			for (var i = 2; i <= iLastCommand; i++) {
				var aMu = aMasthead[i].split("|");
				var strMuTitle	= aMu[0];
				var nMuLevel	= aMu[1];
				var idMuAction	= aMu[2];
				var idMuTopic	= aMu[3];
				var idMuSection	= aMu[4];
				var urlMu		= aMu[5];
				var nMuTarget	= aMu[6];
				var nMuStatus	= aMu[7];
				// get action
				var hrefMu		= '';
				if 		(idMuAction == 0) { hrefMu = '0'; }
				else if (idMuAction == 1) { hrefMu = '1'; }
				else if (idMuAction == 2) { hrefMu = '2'; }
				else if (idMuAction == 3) { if (nMuTarget == 1) { hrefMu = getWebsiteHref(urlMu); } else { hrefMu = getWebsiteHrefPlus(urlMu, 1); } }
				else if (idMuAction == 4) { hrefMu = 'href="javascript:showHome();"'; }
				else if (idMuAction == 5) {
					if 		(idMuSection == gidSectionAds) 	 	{ if (gfShowAds == 1) { hrefMu = 'href="javascript:showAds(0);"';} }
					else if (idMuSection == gidSectionArticles) { if (gfShowArs == 1) { hrefMu = 'href="javascript:showArticlesPage(0,0);"';} }
					else if (idMuSection == gidSectionBiz) 	 	{ if (gfShowBis == 1) { hrefMu = 'href="javascript:gotoBizCat(0);"';} }
					else if (idMuSection == gidSectionEvents) 	{ if (gfShowEvs == 1) { hrefMu = 'href="javascript:showCalendar(0);"';} }
					else if (idMuSection == gidSectionMap) 	 	{ if (gfShowMas == 1) { hrefMu = 'href="javascript:showMap(0);"';} }
					else if (idMuSection == gidSectionGallery)  { if (gfShowGas == 1) { hrefMu = 'href="javascript:showGallery(0);"';} }
					else if (idMuSection == gidSectionLinks) 	{ if (gfShowLis == 1) { hrefMu = 'href="javascript:showLinks(0);"';} }
					else if (idMuSection == gidSectionPolls) 	{ if (gfShowPos == 1) { hrefMu = 'href="javascript:showPolls(0);"';} }
				}
				else if (idMuAction ==  6) { 
					var strTopicNameUrl	= scrubTitleForURL(strMuTitle);
					if (idInList(idMuTopic,strLiveTopics)) { hrefMu = 'href="javascript:showTopic('+idMuTopic+',\''+strTopicNameUrl+'\');"'; }
				}
				else if (idMuAction ==  7) { if ((nTopics > 0) || fIsAdmin) { hrefMu = 'href="javascript:showTopics();"'; } }
				else if (idMuAction ==  8) { hrefMu = 'href="javascript:showSearch();"'; }
				else if (idMuAction ==  9) { if (fRSS > 0)  { hrefMu = 'href="javascript:showRSSList();"'; } }
				else if (idMuAction == 10) { if ((fSubOn > 0) && ((fSub1 > 0) || (fSub2 > 0))) { hrefMu = 'href="javascript:addSubscriptions();"'; } }
				else if (idMuAction == 11) { if (fSubOn > 0) { hrefMu = 'href="javascript:deleteSubscriptions();"'; } }
				else if (idMuAction == 12) { hrefMu = 'href="javascript:chooseSkin();"'; }
				else if (idMuAction == 13) { hrefMu = 'href="javascript:showHelp(1);"'; }
				else if (idMuAction == 14) { hrefMu = 'href="javascript:showHelp();"'; }
				else if (idMuAction == 15) { hrefMu = 'href="javascript:sendMessage(\'Problem Report\');"'; }
				else if (idMuAction == 16) { hrefMu = 'href="javascript:sendMessage(\'General Inquiry\');"'; }
				else if (idMuAction == 17) { if (nLevel >= 0) { hrefMu = 'href="javascript:signOut();"'; strMuTitle='Sign Out';} else if (urlSignIn != '') { hrefMu = 'href="javascript:signIn(\''+urlSignIn+'\');"'; strMuTitle='Sign In';} }
				else if (idMuAction == 18) { if (nLevel >= 0) { hrefMu = 'href="javascript:showMember('+idUser+');"'; }  }
				else if (idMuAction == 19) { if (nLevel >= nSProfileAccess) { hrefMu = 'href="javascript:showMember(0);"'; }  }
				else if (idMuAction == 20) { if (gfShowBis == 1) { hrefMu = 'href="javascript:showProductList(0,0);"'; }  }
				else if (idMuAction == 21) { hrefMu = 'href="javascript:showPage(\''+urlMu+'\');"';  }
				else if (idMuAction == 22) { hrefMu = 'href="javascript:showNewsletters(1)";';  }
				else if (idMuAction == 23) { if (nLevel >= 0) { hrefMu = 'href="javascript:adminCommand(202)";'; }  }
				else if (idMuAction == 24) { if (nLevel >= 0) { hrefMu = 'href="javascript:resetMemberPassword('+idUser+');";'; }  }
				// if valid
				if (hrefMu != '') {
					// TOP LEVEL MENU
					if (nMuLevel == 1) {
						// close existing menu if one is open
						if (fMuDDOpen) {
							str += '</div></div></td>';
							strSide += '</div>';
							fMuDDOpen = false;
						}
						if (idMuAction == 2) {
							// dropdown. create title. open dd box.
							fMuDDOpen = true;
							iMuDropDown++;
							var strMenuId = 'mh_menu_'+iMuDropDown;
							str += '<td valign="top">';
							str += '<div class="m_header"><a href="javascript:showMenu(\''+strMenuId+'\')" onMouseOver="showMenu(\''+strMenuId+'\')" onMouseOut="menu_t = 1; delayHide();" class="m_h_text" '+strMHStyle+'>'+strMuTitle+'<img src="'+gWWWPath+'bits/menu-down.gif" width="10" height="6" alt="" border="0"></a></div>';
							str += '<div style="position:relative;"><div id="'+strMenuId+'" >';
							strSide += '<div class="mh_side_menu">';
							strSide += getMenuSectionSide(strMuTitle, strMSStyle);
						} else {
							//	bang menu. no dropdown
							str += '<td valign="top">';
							str += '<div class="m_header" style="padding-left:0px;"><a class="m_h_text" '+hrefMu+' title="'+strMuTitle+'" '+strMHStyle+'>'+strMuTitle+' </a></div>';
							str += '</td>';
							strSide += '<div class="ms_header"><a class="ms_h_text" '+hrefMu+' title="'+strMuTitle+'" '+strMSStyle+'>'+strMuTitle+' </a></div>';
						}

					// COMMAND
					} else {
						if (idMuAction == 0) {
							// sep
							str += getMenuSection('');
							strSide += getMenuSectionSide('', strMSStyle);
						} else if (idMuAction == 1) { 
							// subhead
							str += getMenuSection(strMuTitle);
							strSide += getMenuSectionSide(strMuTitle, strMSStyle);
						} else {
							// cmd
							str 	+= '<a '+hrefMu+' class="m_c_text" onMouseOut="menu_t = 1; delayHide()" onMouseOver="menu_t = 2;" >'+strMuTitle+'</a>';
							strSide += '<a '+hrefMu+' class="ms_c_text" '+strMSStyle+'>'+strMuTitle+'</a><br>';
						}
					}
				}
			}
			// close existing menu if one is open
			if (fMuDDOpen) {
				str += '</div></div></td>';
				strSide += '</div>';
				fMuDDOpen = false;
			}
			//
			if (fIsAdmin) { 
				str += '<td>';
				str += getEdDot(fIsAdmin,45); 
				str += '</td>';
			}

			str += '</tr>';
			str += '</table>';
		str += '</div>';
		strSide += '</div>';
		if (fSideMenu == 1) { gstrSideMenu = strSide; }
		else 				{ strSide = ''; }
		document.writeln(str);

	}
	function drawEditorTools () {
		if (gstrEdToolbar != '') { document.writeln(gstrEdToolbar); }
	}
	function drawSideMenubar () {
		if (gstrSideMenu != '') { document.writeln(gstrSideMenu); }
	}
	function htmlEdPowerLink (iCmd, strCmd, nSt) {
		var strCl = 'ed_pb_link';
		if (nSt == 0) { strCl = 'ed_pb_linkx'; }
		var strEPL = getEdDot(true, iCmd)+' <a href="javascript:adminCommand('+iCmd+')" class="'+strCl+'">'+strCmd+'</a><br>';
		return strEPL;
	}
	function htmlEdPowerHeader (strH, i, fOpen, strTopic) {
		var strEPL = '<div class="h2_admin"><table cellpadding="0" cellpadding="0" width="100%"><tr>';
		strEPL += '<td><a href="javascript:toggleEdPBSection(\''+i+'\')">'+strH+'<img src="bits/dlg_pop_down.gif" width="10" height="6" alt="" border="0"></a></td>';
		strEPL += '<td align="right">';
		strEPL += getEdHelp(true, strTopic);
		strEPL += '</td>';
		strEPL += '</tr></table></div>';
		strEPL += '<div id="ed_pb'+i+'" ';
		if (fOpen == 1) { strEPL += 'style="display:block"'; }
		strEPL += '>';
		return strEPL;
	}
	function toggleEdPBSection(i) {
		var fShowPB = false;
		var id = 'ed_pb'+i;
		var d = getDOM(id,1);
		if (d) {
			if (d.display == "block") { 
				d.display = "none";
			} else {
				d.display = "block";	
				fShowPB	= true;
			}
		}
		var strCNew 	= '';
		var strCMatch 	= ':'+i+':';
		var strAdminPB  = GetCookie('adminPB');
		if (isEmpty(strAdminPB)) {
			// no cookie
			if (fShowPB) { SetCookieYear('adminPB',strCMatch,"/"); }
		} else {
			var iM = strAdminPB.indexOf(strCMatch,0);
			if ((fShowPB) && (iM < 0)) { 
				strCNew = strAdminPB + i + ':';
				SetCookieYear('adminPB',strCNew,"/");
			}
			if ((!fShowPB) && (iM >= 0)) {
				var cchPB = strAdminPB.length;
				var cchPBMatch = strCMatch.length - 1;
				strCNew = strAdminPB.substring(0,iM) + strAdminPB.substring(iM+cchPBMatch,cchPB);
				SetCookieYear('adminPB',strCNew,"/");
			}
		}
	}
	
	function drawSidebarSponsors(aSideBz, strOptions) {
		var str = '';
		var aSBO = strOptions.split('|');
		var nSBFmt	 			= aSBO[0];
		var nSBQty	 			= aSBO[1];
		var nSBOrd	 			= aSBO[2];
		var strSBTitle	 		= aSBO[3];
		str += '<div id="sbar_sponsor_area">';
		if (strSBTitle != '') {
			var strExStyle = '';
			if (isNotEmpty(gstrSideMenuColor))   { strExStyle = ' style="color:#'+gstrSideMenuColor+';"'; }
			str += '<a class="ms_h_text" href="javascript:gotoBizCat(0);" title="'+strSBTitle+'" '+strExStyle+'>'+strSBTitle+' </a>';
		}
		for (var i = 0; i < aSideBz.length - 1; i++) {
			var aS = aSideBz[i].split('|');
			var idBiz	 			= aS[0];
			var strTitle	 		= aS[1];
			var strTitleURL			= scrubTitleForURL(strTitle);
			var urlPhotoMain	 	= aS[2];
	
			str += '<div class="sbar_sponsor">'
				if (urlPhotoMain != "") {
					str += '<a href="javascript:showSponsor('+idBiz+',\''+strTitleURL+'\')" class="btn" title="More about '+strTitle+'...">';
					str += '<img src="biz/biz_'+idBiz+'/thumb_'+urlPhotoMain+'" alt="More about '+strTitle+'..." width="220" border="1">';
					str += '</a>';
				}
			str += '</div>';
		}
		str += '</div>';
		document.writeln(str); str = '';
	}
	function drawSidebarMPProducts(aMPProd, strMPInfo) {
		drawMPProdsCore(aMPProd, strMPInfo, fIsAdmin, 0, 1);
	}

	
	  
//================================
//
//	SHOW MAIN WINDOWS and DIALOGS
//
	

	function showHome() {
		location = gCGIPath + 'show_home.cgi';
	}
	function showSearch() {
		location = gCGIPath + 'show_search.cgi';
	}
	function doSearch(strTerms, nRealm, nFields,  nAndOr) {
		if (strTerms == null) { strTerms = ''; }
		if (nRealm == null)   { nRealm = 0; }
		if (nFields == null)  { nFields = 0; }
		if (nAndOr == null)   { nAndOr = 0; }
		strTerms = escape(strTerms);
		location = gCGIPath + 'show_search.cgi?SEARCH='+strTerms+'&P='+nRealm+'&F='+nFields+'&S='+nAndOr;
	}
	function showAuthor(strA) {
		strA = escape(strA);
		location = gCGIPath + 'show_author.cgi?N='+strA; 
	}	
	function showArticlesPage(idTopic,id) {
		if (idTopic == null)   { idTopic = 0; }
		if (id 		== null)   { id = 0; }
		if ((idTopic <= 0) && (id == 0)) { location = gCGIPath + 'show_articles.cgi'; }
		else { location = gCGIPath + 'show_articles.cgi?ID='+id+'&TOPIC='+idTopic; }
	}
	function showArticles(idTopic,id,strTitle,iStart,nShow,nStatus) {
		var url = '';
		if (idTopic == null)   { idTopic = 0; }
		if (id 		== null)   { id = 0; }
		if (strTitle == null)   { strTitle = ''; }
		
		url = gWWWPath + 'show' + id + 'a';
		if (idTopic > 0) { url += idTopic + 's'; }
		
		if (iStart  == null)   { iStart = 0; }
		if (nShow   == null)   { nShow = 30; }
		if (nStatus == null)   { nStatus = 1; }
		if ((iStart > 0) || (nShow != 30) || (nStatus != 1)) { url += iStart+'x'+nShow+'y'+nStatus+'z'; }
		url += '/' + escape(strTitle);
		location = url ;
	}
	function showArticleComments(idA, idC,nStatus) {
		location = gCGIPath + 'show_articlecomments.cgi?IDA='+idA+'&IDC='+idC+'&S='+nStatus;
	}
	function showAd(idTopic,idAd) {
		location = gCGIPath + 'show_classad.cgi?TOPIC='+idTopic+'&ID='+idAd;
	}
	function showAds(idTopic,nStatus,iStart,nShow) {
		var nSt  = 1;
		var nExp = 0;
		if (nStatus == -1) { nSt = -1; }
		if (nStatus == -2) { nExp = 1 }
		location = gCGIPath + 'show_classads.cgi?TOPIC='+idTopic+'&S='+nSt+'&EXP='+nExp+'&ISTART='+iStart+'&NSHOW='+nShow;
	}
	function showBiz(id) {
		location = gCGIPath + 'show_biz.cgi?ID='+id;
	}
	function gotoBizCat(idTopic,idShow,nStatus) {
		location = gCGIPath + 'show_bizlist.cgi?TOPIC='+idTopic+'&CAT='+idShow+'&S='+nStatus;
	}
	function showSponsor(id,strTitle) {
		if (strTitle == null)   { strTitle = ''; }
		if (id 		 == null)   { id = 0; }
		location = gWWWPath + 'show'+id+'b/'+strTitle;
	}
	function showProduct(id,strTitle) {
		if (strTitle == null)   { strTitle = ''; }
		if (id 		 == null)   { id = 0; }
		location = gWWWPath + 'show'+id+'v/'+strTitle;
	}
	function showProductList(idCat,idSub,nStatus) {
		var nSt  = 1;
		if (nStatus == -1) { nSt = -1; }
		location = gCGIPath + 'show_product_list.cgi?CAT='+idCat+'&SUBCAT='+idSub+'&S='+nSt;
	}
	function showSponsorPolicies(id) {
		var strCGI = "show_biz_sponsorpolicies.cgi?ID="+id;
		showWindowCGI("SponsorPolicies",440,560,strCGI);
	}
	function showPrivacyPolicy() {
		var strCGI = 'show_biz_privacypolicy.cgi';
		showWindowCGI("PrivacyPolicy",440,560,strCGI);
	}
	function showLinks(idTopic) {
		location = gCGIPath + 'show_links.cgi?TOPIC='+idTopic;
	}
	function showGallery(idTopic,iStart,nShow,nStatus,idCat) {
		var strI = '';
		var strN = '';
		var strS = '';
		var strT = '';
		if (iStart != null)   { strI = '&ISTART='+iStart; }
		if (nShow != null)    { strN = '&NSHOW='+nShow; }
		if (nStatus != null)  { strS = '&S='+nStatus; }
		if (idCat != null)    { strT = '&T='+idCat; }
		if (idTopic	 == null) { idTopic = 0; }
		location = gCGIPath + 'show_gallery.cgi?TOPIC='+idTopic+strI+strN+strS+strT;
	}
	function showGalleryPage(id,strTitle) {
		if (strTitle == null)   { strTitle = ''; }
		if (id 		 == null)   { id = 0; }
		location = gWWWPath + 'show'+id+'g/'+strTitle;
	}
	function showGalleryItem(idTopic,id,strTitle) {
		if (strTitle == null)   { strTitle = ''; }
		if (idTopic	 == null) { idTopic = 0; }
		location = gWWWPath + 'show'+id+'h'+idTopic+'s/'+strTitle;
	}
	function showNewsletters(nS) {
		location = gCGIPath + 'show_newsletters.cgi?S='+nS;
	}
	function showNewsletter(id, fOwnWindow) {
		if (fOwnWindow) {
			var strCGI = 'show_newsletter.cgi?ID='+id+'&M=0';
			showWindowCGI("ViewNewsletterForPrinting",530,700,strCGI);
		} else {
			location = gCGIPath + 'show_newsletter.cgi?ID='+id+'&M=1';
		}
	}
	function showEvent(id) {
		location = gCGIPath + 'show_event.cgi?ID='+id;
	}
	function showCalendar(idTopic,strDayA,strDayZ,nView,nWeek,nExport,nStatus,fInPop,fOpenPopup) {
		if (idTopic == null) { idTopic = 0; }
		if (nView == null)   { nView = 0; }
		if (nWeek == null)   { nWeek = 0; }
		if (strDayA == null) { strDayA = 0; }
		if (strDayZ == null) { strDayZ = 0; }
		if (nExport == null) { nExport = 0; }
		if (nStatus == null) { nStatus = 1; }
		if (fInPop == null)  { fInPop = 0; }
		var urlCal = 'show_calendar.cgi?TOPIC='+idTopic+'&WEEK='+nWeek+'&VIEW='+nView+'&DAYA='+strDayA+'&DAYZ='+strDayZ+'&EXPORT='+nExport+'&S='+nStatus+'&POP='+fInPop;
		if (fOpenPopup == 1) {
			showWindowCGI("PrintCalendar",800,600,urlCal);
		} else {
			location = gCGIPath + urlCal;
		}
	}
	function showPolls(idTopic,id,iStart,nShow,nStatus) {
		if (idTopic == null) { idTopic = 0; }
		if (id == null)   	 { id = 0; }
		if (iStart == null)  { iStart = 0; }
		if (nShow == null)   { nShow = 0; }
		location = gCGIPath + 'show_polls.cgi?TOPIC='+idTopic+'&ID='+id+'&ISTART='+iStart+'&NSHOW='+nShow+'&S='+nStatus;
	}
	function showMap(idTopic,id,nStatus) {
		location = gCGIPath + 'show_map.cgi?TOPIC='+idTopic+'&ID='+id+'&S='+nStatus;
	}
	function showHelp(id,nStatus) {
		location = gCGIPath + 'show_help.cgi?ID='+id+'&S='+nStatus;
	}
	function showBigMapX(idTopic,idMapX) {
		location = gCGIPath + 'show_mapitem.cgi?TOPIC='+idTopic+'&ID='+idMapX;
	}
	function showTopics() {
		location = gCGIPath + 'show_topics.cgi';
	}
	function showTopic(id,strTitle) {
		if (strTitle == null)   { strTitle = ''; }
		if (id 		 == null)   { id = 0; }
		location = gWWWPath + 'show'+id+'s/'+strTitle;
	}
	function showPage(urlPath) {
		location = gCGIPath + 'show.cgi?P='+urlPath;
	}
	function showCustomPage(id) {
		location = gCGIPath + 'show_page.cgi?ID='+id;
	}
	function showMember(id,nSort,nExtra) {
		if (id	   == null)   { id = 0; }
		if (nSort  == null)   { nSort = 0; }
		if (nExtra == null)   { nExtra = 0; }
		location = gCGIPath + 'show_member.cgi?ID='+id+'&SORT='+nSort+'&EXTRA='+nExtra;
	}
	function showRSSList(id) {
		location = gCGIPath + 'show_rss_list.cgi';
	}

	//	DIALOGS
	// 	-- biz dialogs
	function addBiz(nCatagory) {
		var strCGI = "dlg_biz_new.cgi?CAT="+nCatagory;
		showDialogCGI("NewBizListing",590,700,strCGI);
	}
	function editBizPlus(id) {
		var strCGI = "dlg_biz_edit.cgi?ID="+id;
		showDialogCGI("EditBizListing",590,700,strCGI);
	}
	function deleteBiz(id) {
		var strCGI = "dlg_biz_del.cgi?ID="+id;
		showDialogCGI("DeleteBizListing",590,300,strCGI);
	}
	function undeleteBiz(id) {
		var fOK = confirm('Are you sure you want to UNDELETE this? Readers will be able to see it.');
		if (fOK) {
			var strCGI = "submit_biz_undel.cgi?ID="+id;
			showDialogCGI("UndeleteItem",590,300,strCGI);
		}
	}
	function askBizSponsor() {
		var strCGI = "dlg_biz_sponsorinfo.cgi";
		showDialogCGI("SponsorInfo",590,600,strCGI);
	}
	function sponsorBiz(id) {
		var strCGI = "dlg_biz_sponsor.cgi?ID="+id;
		showDialogCGI("SponsorBizListing",590,700,strCGI);
	}
	function editSponsorPassword(id, fRefresh) {
		if (fRefresh) {	alert('After changing this password you may need to refresh your browser to see the results'); }
		var strCGI = "dlg_biz_password.cgi?ID="+id;
		showDialogCGISecure("ChangeSponsorPassword",590,400,strCGI);
	}
	function showInquiryHistory(id, nStart, idP) {
		var strCGI = "show_biz_inquiries.cgi?ID="+id+'&NSTART='+nStart+'&P='+idP;
		showDialogCGI("ViewInquiryHistory",590,500,strCGI);
	}
	

	//	-- Product dialogs
	function addProduct(idMPMem) {
		var strCGI = "dlg_product_new.cgi?MPMEMBERID="+idMPMem;
		showDialogCGI("NewProd",590,820,strCGI);
	}
	function editProduct(idProduct) {
		var strCGI = "dlg_product_edit.cgi?ID="+idProduct;
		showDialogCGI("EditProduct",590,820,strCGI);
	}
	function delProduct(idProduct) {
		var strCGI = "dlg_product_del.cgi?ID="+idProduct;
		showDialogCGI("DelProduct",590,350,strCGI);
	}
	function undeleteProduct(id) {
		var fOK = confirm('Are you sure you want to UNDELETE this? Readers will be able to see it.');
		if (fOK) {
			var strCGI = "submit_product_undel.cgi?ID="+id;
			showDialogCGI("UndeleteProduct",590,300,strCGI);
		}
	}
	function arrangeProducts(idMPMem) {
		var strCGI = "dlg_productlist_arrange.cgi?ID="+idMPMem;
		showDialogCGI("MoveProduct",590,800,strCGI);
	}

	
	
	
	function addEvent(idTopic, nDay, nMonth, nYear) {
		if (nDay == 0) {
			var 	tToday =  new Date();		
			var 	nDay = tToday.getDate();
			var 	nMonth = tToday.getMonth()+1;
			var 	nYear = timeGetYear(tToday);
		}
		var strCGI = "dlg_event_new.cgi?TOPIC="+idTopic+"&DATE=" + nDay + ":"+ nMonth + ":"+ nYear;
		showDialogCGI("NewEvent",590,670,strCGI);
	}
	function noaddEvent () {}
	function editEventPlus(id) {
		var strCGI = "dlg_event_edit.cgi?ID="+id;
		showDialogCGI("EditEvent",590,670,strCGI);
	}
	function deleteEvent(id) {
		var strCGI = "dlg_event_del.cgi?ID="+id;
		showDialogCGI("DeleteEvent",590,360,strCGI);
	}
	function undeleteEvent(id) {
		var fOK = confirm('Are you sure you want to UNDELETE this? Readers will be able to see it.');
		if (fOK) {
			var strCGI = "submit_event_undel.cgi?ID="+id;
			showDialogCGI("UndeleteItem",590,300,strCGI);
		}
	}
	function addAd(idTopic, nCategory) {
		var strCGI = "dlg_ad_new.cgi?TOPIC="+idTopic+"&CAT="+nCategory;
		showDialogCGI("NewClassifiedAd",590,670,strCGI);
	}
	function editAdPlus(id) {
		var strCGI = "dlg_ad_edit.cgi?ID="+id;
		showDialogCGI("EditClassifiedAd",590,670,strCGI);
	}
	function deleteAd(id) {
		var strCGI = "dlg_ad_del.cgi?ID="+id;
		showDialogCGI("DeleteClassifiedAd",590,300,strCGI);
	}
	function undeleteAd(id) {
		var fOK = confirm('This makes the ad viewable by readers AND sets it to expire 4 weeks from today. Continue?');
		if (fOK) {
			var strCGI = "submit_ad_undel.cgi?ID="+id;
			showDialogCGI("UndeleteItem",590,300,strCGI);
		}
	}
	function addArticle(idTopic, nCategory) {
		var strCGI = "dlg_article_new.cgi?TOPIC="+idTopic+"&CAT="+nCategory;
		showDialogCGI("NewArticle",590,670,strCGI);
	}
	function editArticlePlus(id) {
		var strCGI = "dlg_article_edit.cgi?ID="+id;
		showDialogCGI("EditArticle",590,670,strCGI);
	}
	function deleteArticle(id) {
		var strCGI = "dlg_article_del.cgi?ID="+id;
		showDialogCGI("DeleteArticle",590,300,strCGI);
	}
	function undeleteArticle(id) {
		var fOK = confirm('Are you sure you want to UNDELETE this? Readers will be able to see it.');
		if (fOK) {
			var strCGI = "submit_article_undel.cgi?ID="+id;
			showDialogCGI("UndeleteItem",590,300,strCGI);
		}
	}
	function emailArticle(id) {
		var strCGI = "dlg_article_email.cgi?ID="+id;
		showDialogCGI("DeleteArticle",590,460,strCGI);
	}
	function printArticle(id) {
		var strCGI = "show_pop_article_print.cgi?ID="+id;
		showWindowCGI("PrintArticle",500,500,strCGI);
	}
	function orderArticles(n) {
		SetCookieYear('articleOrder',n,"/");
		location.reload();
	}
	function addArticleType() {
		var strCGI = "dlg_articletype_new.cgi";
		showDialogCGI("NewArticleType",590,320,strCGI);
	}
	function editArticleType(id) {
		var strCGI = "dlg_articletype_edit.cgi?ID="+id;
		showDialogCGI("EditArticleType",590,320,strCGI);
	}
	function deleteArticleType(id) {
		var fOK = confirm('Are you sure you want to DELETE this article CATEGORY?');
		if (fOK) {
			var strCGI = "submit_articletype_del.cgi?ID="+id;
			showDialogCGI("DeleteArticleType",590,300,strCGI);
		}
	}
	function fetchAttachment(id,url) {
		var t 		= getNow(); 
		var strCGI = "show_article_attachment.cgi?ID="+id+"&F="+url+"&X="+t.getTime()+"/"+url;
		showWindowCGI("ArticleAttachment",500,500,strCGI);
	}
	function getAttachmentLink(id,url) {
		var t 		= getNow(); 
		var strCGI = gCGIPath+"show_article_attachment.cgi?ID="+id+"&F="+url+"&X="+t.getTime()+"/"+url;
		return strCGI;
	}
	function addComment(idArticle) {
		var strCGI = "dlg_articlecomment_new.cgi?A="+idArticle;
		showDialogCGI("NewArticleComment",590,670,strCGI);
	}
	function editComment(id) {
		var strCGI = "dlg_articlecomment_edit.cgi?ID="+id;
		showDialogCGI("EditArticleComment",590,670,strCGI);
	}
	function deleteComment(id) {
		var strCGI = "dlg_articlecomment_del.cgi?ID="+id;
		showDialogCGI("DeleteArticleComment",590,300,strCGI);
	}
	 
	function addBizType() {
		var strCGI = "dlg_biztype_new.cgi";
		showDialogCGI("NewBizType",590,520,strCGI);
	}
	function editBizType(id) {
		var strCGI = "dlg_biztype_edit.cgi?ID="+id;
		showDialogCGI("EditBizType",590,520,strCGI);
	}
	function arrangeBizTypes() {
		var strCGI = "dlg_biztype_arrange.cgi";
		showDialogCGI("ArrangeBizType",590,700,strCGI);
	}
	function deleteBizType(id) {
		var strCGI = "dlg_biztype_del.cgi?ID="+id;
		showDialogCGI("DeleteBizType",590,300,strCGI);
	}
	function undeleteBizType(id) {
		var fOK = confirm('Are you sure you want to UNDELETE this? Readers will be able to see it.');
		if (fOK) {
			var strCGI = "submit_biztype_undel.cgi?ID="+id;
			showDialogCGI("UndeleteBizType",590,300,strCGI);
		}
	}
	function addSubscriptions() {
		var strCGI = "dlg_subscribe.cgi";
		showDialogCGI("OptSubscriptions",590,600,strCGI);
	}
	function deleteSubscriptions() {
		var strCGI = "dlg_subscribe_x.cgi";
		showDialogCGI("OptSubscriptions",590,330,strCGI);
	}
	function chooseSkin() {
		var strCGI = "dlg_options_skin.cgi";
		showDialogCGI("OptSkin",590,300,strCGI);
	}
	function addGalleryItem(idTopic, idC) {
		var strCGI = "dlg_gallery_new.cgi?TOPIC="+idTopic+"&CAT="+idC;
		showDialogCGI("NewGalleryItem",590,670,strCGI);
	}
	function editGalleryItem(id) {
		var strCGI = "dlg_gallery_edit.cgi?ID="+id;
		showDialogCGI("EditGalleryItem",590,670,strCGI);
	}
	function deleteGalleryItem(id) {
		var strCGI = "dlg_gallery_del.cgi?ID="+id;
		showDialogCGI("DeleteGalleryItem",590,300,strCGI);
	}
	function undeleteGalleryItem(id) {
		var fOK = confirm('Are you sure you want to UNDELETE this? Readers will be able to see it.');
		if (fOK) {
			var strCGI = "submit_gallery_undel.cgi?ID="+id;
			showDialogCGI("UndeleteItem",590,300,strCGI);
		}
	}
	function edchoiceGalleryItem(id) {
		var fOK = confirm('This item will appear on the frontpage, replacing what is there now. Continue?');
		if (fOK) {
			var strCGI = "submit_gallery_edchoice.cgi?ID="+id;
			showDialogCGI("EdChoiceGalleryItem",590,300,strCGI);
		}
	}
	function editMapX(idMapX) {
		var strCGI = "dlg_mapx_edit.cgi?ID="+idMapX;
		showDialogCGI("EditMapX",590,670,strCGI);
	}
	function addPoll(idTopic) {
		var strCGI = "dlg_poll_new.cgi?TOPIC="+idTopic;
		showDialogCGI("NewPoll",590,500,strCGI);
	}
	function editPoll(id) {
		var strCGI = "dlg_poll_edit.cgi?ID="+id;
		showDialogCGI("EditPoll",590,500,strCGI);
	}
	function delPoll(id) {
		var fOK = confirm('Are you sure you want to DELETE this poll? Readers will not be able to see the results anymore.');
		if (fOK) {
			var strCGI = "submit_poll_del.cgi?ID="+id;
			showDialogCGI("DeletePoll",590,300,strCGI);
		}
	}
	function undeletePoll(id) {
		var fOK = confirm('Are you sure you want to UNDELETE this? Readers will be able to see it.');
		if (fOK) {
			var strCGI = "submit_poll_undel.cgi?ID="+id;
			showDialogCGI("UndeleteItem",590,300,strCGI);
		}
	}
	function closePoll(id) {
		var fOK = confirm('Are you sure you want to CLOSE this poll? Readers will NOT be able to vote anymore.');
		if (fOK) {
			var strCGI = "submit_poll_close.cgi?ID="+id;
			showDialogCGI("ClosePoll",590,300,strCGI);
		}
	}
	function openPoll(id) {
		var fOK = confirm('Are you sure you want to make this poll ACTIVE? Readers will be able to vote on it.');
		if (fOK) {
			var strCGI = "submit_poll_open.cgi?ID="+id;
			showDialogCGI("OpenPoll",590,300,strCGI);
		}
	}
	function addLink(idTopic) {
		var strCGI = "dlg_link_new.cgi?TOPIC="+idTopic;
		showDialogCGI("NewLink",590,580,strCGI);
	}
	function editLink(idLink) {
		var strCGI = "dlg_link_edit.cgi?ID="+idLink;
		showDialogCGI("EditLink",590,580,strCGI);
	}
	function delLink(idLink) {
		var fOK = confirm('Are you sure you want to delete this link?');
		if (fOK) {
			var strCGI = "submit_link_del.cgi?ID="+idLink;
			showDialogCGI("DeleteLink",590,300,strCGI);
		}
	}
	function addTopicType() {
		var strCGI = "dlg_topictype_new.cgi";
		showDialogCGI("NewTopicType",590,500,strCGI);
	}
	function editTopicType(id) {
		var strCGI = "dlg_topictype_edit.cgi?ID="+id;
		showDialogCGI("EditTopicType",590,500,strCGI);
	}
	function delTopicType(id) {
		var strCGI = "submit_topictype_del.cgi?ID="+id;
		showDialogCGI("DeleteTopicType",590,300,strCGI);
	}
	function arrangeTopicTypes() {
		var strCGI = "dlg_topictype_arrange.cgi";
		showDialogCGI("ArrangeTopicTypes",590,500,strCGI);
	}
	function addTopic(){
		var strCGI = "dlg_topic_new.cgi";
		showDialogCGI("NewTopic",590,700,strCGI);
	}
	function editTopic(id) {
		var strCGI = "dlg_topic_edit.cgi?ID="+id;
		showDialogCGI("EditTopic",590,700,strCGI);
	}
	function arrangeTopics() {
		var strCGI = "dlg_topic_arrange.cgi";
		showDialogCGI("ArrangeTopics",590,500,strCGI);
	}
	function moveTopic(id,n) {
		var strCGI = "submit_topic_move.cgi?ID="+id+"&N="+n;
		showDialogCGI("MoveTopic",590,300,strCGI);
	}
	function orderTopics(n) {
		SetCookie('topicOrdering',n,'','/');
		location.reload();
	}
	function setTopicStatus(id, nS) {
		var strA = '';
		if      (nS == 0) { strA = "HIDE THIS SECTION NOW? Readers *won't* be able to see this section anymore. Editors always can. Continue?"; }
		else if (nS == 1) { strA = "CLOSE THIS SECTION NOW? Readers will be able to see it...but it will be closed to changes. Editors still make changes. Continue?"; }
		else if (nS == 2) { strA = 'OPEN THIS SECTION NOW? Readers will be able to add and change items in this section. Continue?'; }
		var fOK = false;
		if (strA != '') {
			fOK = confirm(strA);
		}
		if (fOK) {
			var strCGI = "submit_topic_status.cgi?ID="+id+"&S="+nS;
			showDialogCGI("SetTopicStatus",590,300,strCGI);
		}
	}

	function addCustomPage(idTopic) {
		var strCGI = "dlg_page_new.cgi?TOPIC="+idTopic;
		showDialogCGI("NewPage",590,580,strCGI);
	}
	function editCustomPage(id) {
		var strCGI = "dlg_page_edit.cgi?ID="+id;
		showDialogCGI("EditPage",590,580,strCGI);
	}
	function delCustomPage(id) {
		var strCGI = "dlg_page_del.cgi?ID="+id;
		showDialogCGI("DeletePage",590,580,strCGI);
	}
	function addCustomPageBit(idPage) {
		var strCGI = "dlg_pagebit_new.cgi?PAGE="+idPage;
		showDialogCGI("NewPagebit",590,580,strCGI);
	}
	function editCustomPageBit(id) {
		var strCGI = "dlg_page_editbit.cgi?ID="+id;
		showDialogCGI("EditPagebit",590,580,strCGI);
	}
	function delCustomPageBit(id) {
		var fOK = confirm('Are you sure you want to DELETE this chunk of the page?');
		if (fOK) {
			var strCGI = "dlg_pagebit_del.cgi?ID="+id;
			showDialogCGI("DeletePagebit",590,580,strCGI);
		}
	}
	
	

	function addHelpType() {
		var strCGI = "dlg_helptype_new.cgi";
		showDialogCGI("NewHelpType",590,500,strCGI);
	}
	function editHelpType(id) {
		var strCGI = "dlg_helptype_edit.cgi?ID="+id;
		showDialogCGI("EditHelpType",590,500,strCGI);
	}
	function addHelp(){
		var strCGI = "dlg_help_new.cgi";
		showDialogCGI("NewHelpTopic",590,700,strCGI);
	}
	function editHelp(id) {
		var strCGI = "dlg_help_edit.cgi?ID="+id;
		showDialogCGI("EditHelpTopic",590,700,strCGI);
	}
	function editHelpText(id) {
		var strCGI = "dlg_help_edittext.cgi?ID="+id;
		showDialogCGI("EditHelpTopicText",590,800,strCGI);
	}
	function delHelp(id) {
		var fOK = confirm('This will remove this topic. To temporarily hide it from readers, choose the "make pending" command instead. Continue with deleting?! ');
		if (fOK) {
			var strCGI = "submit_help_del.cgi?ID="+id;
			showDialogCGI("DeleteHelpTopic",590,300,strCGI);
		}
	}
	function undeleteHelp(id) {
		var fOK = confirm('Are you sure you want to UNDELETE this? Readers will be able to see it.');
		if (fOK) {
			var strCGI = "submit_help_undel.cgi?ID="+id;
			showDialogCGI("UndeleteItem",590,300,strCGI);
		}
	}
	function closeHelp(id) {
		var fOK = confirm('Are you sure you want to change this to pending? Readers will NOT be able to see it.');
		if (fOK) {
			var strCGI = "submit_help_close.cgi?ID="+id;
			showDialogCGI("CloseHelp",590,300,strCGI);
		}
	}
	function openHelp(id) {
		var fOK = confirm('Are you sure you want to make this visible to readers now?');
		if (fOK) {
			var strCGI = "submit_help_open.cgi?ID="+id;
			showDialogCGI("OpenHelp",590,300,strCGI);
		}
	}
	function sendMessage(strSubject) {
		strSubject = escape(strSubject);
		var strCGI = "dlg_message_new.cgi?SUBJECT="+strSubject;
		showDialogCGI("SendMessage",590,450,strCGI);
	}
	function sendMessageEx(strSubject, strMsg, strName) {
		strSubject = escape(strSubject);
		strMsg = escape(strMsg);
		strName = escape(strName);
		var strCGI = "dlg_message_new.cgi?SUBJECT="+strSubject+"&MSG="+strMsg+"&NAME="+strName;
		showDialogCGI("SendMessage",590,450,strCGI);
	}
	function sendMemberMessage() {
		var strCGI = "dlg_message_member_new.cgi";
		showDialogCGI("SendMessage",590,400,strCGI);
	}
	function assignMessage(id) {
		var strCGI = "dlg_message_assign.cgi?ID="+id;
		showDialogCGI("AssignMessage",590,320,strCGI);
	}
	function emailMessage(id) {
		var strCGI = "dlg_message_email.cgi?ID="+id;
		showDialogCGI("EmailMessage",590,450,strCGI);
	}
	function forwardMessage(id) {
		var strCGI = "dlg_message_forward.cgi?ID="+id;
		showDialogCGI("ForwardMessage",590,450,strCGI);
	}
	function replyMessage(id) {
		var strCGI = "dlg_message_reply.cgi?ID="+id;
		showDialogCGI("ReplyMessage",590,450,strCGI);
	}
	function viewMessage(id) {
		var strCGI = "show_admin_msg.cgi?ID="+id;
		showDialogCGI("ViewMessage",460,300,strCGI);
	}
	function delMessage(id, nLoc) {
		location = gCGIPath + 'submit_message_del.cgi?ID='+id+'&LOC='+nLoc;
	}
	function saveMessage(id) {
		location = gCGIPath + 'submit_message_save.cgi?ID='+id;
	}
	function toInboxMessage(id) {
		location = gCGIPath + 'submit_message_toinbox.cgi?ID='+id;
	}
	function chartStats(strType, id) {
		var strCGI = "show_admin_statschart.cgi?V="+strType+"&ID="+id;
		showDialogCGI("StatChart",650,400,strCGI);
	}
	function editMember(id) {
		var strCGI = "dlg_member_edit.cgi?ID="+id;
		showDialogCGI("EditMember",590,800,strCGI);
	}
	function resetMemberPassword(id) {
		var strCGI = "dlg_member_password.cgi?ID="+id;
		showDialogCGISecure("EditMemberPassword",590,400,strCGI);
	}
	function showInfoWindow(idInfo) {
		var strCGI = "show_infotip.cgi?ID="+idInfo;
		showDialogCGI("InfoTip",350,500,strCGI);
	}

	
	//  CREATE DIALOG WINDOWS
	// -- Create minimum-crome client side browser window
	function wndOpenNewDialog(strWndName, dxPref, dyPref) {
		var dx = screen.width - 80 ;
		var dy = screen.height - 160;
		if (dxPref > dx) {dxPref = dx;}
		if (dyPref > dy) {dyPref = dy;}
		var strParams = "scrollbars,status,resizable,width=" + dxPref +",height="+ dyPref;
		var wndNew = window.open("",strWndName,strParams);
		var xWnd = parseInt((dx + 70 - dxPref)/2);
		if (xWnd < 10) { xWnd = 10; }
		wndNew.moveTo(xWnd,82);
		return wndNew;
	}
	// open dialog in own window
	function showDialog(strName,dx,dy,strURL) {
		var wndName = "wnd"+strName;
		var strPath = gWWWPath+strURL;
		var wndNew = wndOpenNewDialog(wndName,dx,dy);
		if (wndNew != null) {
			wndNew.location = strPath;
			wndNew.focus();
		} else {
			alert("Sorry, the "+strName+" window could not be opened. Please try again. If you continue having troubles, please let us know. Thank you.");
		}
	}	
	// -- Call cgi program to return correct dialog html for the client side window
	function showDialogCGI(strName,dx,dy,strCGI) {
		var wndName = "wnd"+strName;
		var strCGIPath = gCGIPath+strCGI;
		var wndNew = wndOpenNewDialog(wndName,dx,dy);
		if (wndNew != null) {
			wndNew.location = strCGIPath;
			wndNew.focus();
		} else {
			alert("Sorry, the "+strName+" window could not be opened. Please try again. If you continue having troubles, please let us know. Thank you.");
		}
	}	
	// -- Call cgi program securely to return correct dialog html for the client side window
	function showDialogCGISecure(strName,dx,dy,strCGI) {
		var wndName = "wnd"+strName;
		var strCGIPath = gCGIPathSecure+strCGI;
		var wndNew = wndOpenNewDialog(wndName,dx,dy);
		if (wndNew != null) {
			wndNew.location = strCGIPath;
			wndNew.focus();
		} else {
			alert("Sorry, the "+strName+" window could not be opened. Please try again. If you continue having troubles, please let us know. Thank you.");
		}
	}	
	// -- Create high-chrome client side browser window	
	function wndOpenNewWindow(strWndName, dxPref, dyPref) {
		var dx = screen.width - 80 ;
		var dy = screen.height - 160;
		if (dxPref > dx) {dxPref = dx;}
		if (dyPref > dy) {dyPref = dy;}
		var strParams = "status,menubar,scrollbars,resizable,width=" + dxPref +",height="+ dyPref;
		var wndNew = window.open("",strWndName,strParams);
		var xWnd = parseInt((dx + 70 - dxPref)/2);
		if (xWnd < 10) { xWnd = 10; }
		wndNew.moveTo(xWnd,82);
		return wndNew;
	}
	// -- Call cgi program securely to return correct dialog html for the client side window
	function showWindowCGI(strName,dx,dy,strCGI) {
		var wndName = "wnd"+strName;
		var strCGIPath = gCGIPath+strCGI;
		var wndNew = wndOpenNewWindow(wndName,dx,dy);
		if (wndNew != null) {
			wndNew.location = strCGIPath;
			wndNew.focus();
		} else {
			alert("Sorry, the "+strName+" window could not be opened. Please try again. If you continue having troubles, please let us know. Thank you.");
		}
	}	
	
	// EXTERNAL DOCUMENT WINDOWS
	// -- create href for external website
	function getWebsiteHref(strURL) {
		var str = '';
		var urlEscaped = escape(strURL);
		if (strURL.substring(0,2) == '..') {								
			str += ' href="javascript:showPage(\''+strURL+'\')" ';
		} else {
			str += ' href="'+gCGIPath+'show_website.cgi?URL='+urlEscaped+'" target="_blank" ';
		}
		return str;
	}
	function getWebsiteHrefPlus(strURL,IsInternalLink) {
		var str = '';
		var urlEscaped = escape(strURL);
		str += ' href="'+gCGIPath+'show_website.cgi?URL='+urlEscaped+'" ';
		if (IsInternalLink != 1) {	str += ' target="_blank" '; }
		return str;
	}
	
// =======================
//
//	ADMIN FEATURES
//
	function signIn(urlSignIn) {
		showDialogCGISecure("SignIn",590,300,urlSignIn);
	}
	function signInSponsor(id) {
		var strCGI = "dlg_biz_signin.cgi?ID="+id;
		showDialogCGISecure("SponsorSignIn",590,300,strCGI);
	}
	function signOut() {
		document.location = gCGIPath+"submit_signout.cgi";
	}
	function signOutSponsor() {
		var strCGI = "submit_biz_signout.cgi";
		showDialogCGI("SponsorSignout",590,300,strCGI);
	}
	function loginExpired() {
		location = gCGIPath + 'show_home.cgi?EXPIRED=1';
	}
	function loginExpiredBiz() {
		alert("Your session has expired. Please sign in again.");
		refreshPage();
	}
	function adminHelp(strHelp) {
		var urlCGI = 'http://www.stonebreakerdesigns.com/cgi-bin/tidehelp/TidelineHelp.cgi?T='+strHelp;
		var wndNew = wndOpenNewWindow("AdminHelp",900,600);
		if (wndNew != null) {
			wndNew.location = urlCGI;
			wndNew.focus();
		} else {
			alert("Sorry, the help window could not be opened. Please try again. If you continue having troubles, please let us know. Thank you.");
		}
	}
	function adminCommand(iCommand) {
		var urlCGI = '';
		var fDlg = true;
		if (iCommand == 1) { urlCGI = gCGIPath+"admin_show_sessions.cgi"; }
		else if (iCommand == 2) { urlCGI = gCGIPath+"admin_show_db.cgi"; }
		else if (iCommand == 3) { urlCGI = gCGIPath+"admin_checktmpdir.cgi"; }
		else if (iCommand == 4) { urlCGI = gCGIPath+"admin_nightly.cgi?UPDATE=2"; }
		else if (iCommand == 5) { urlCGI = gCGIPath+"dlg_adminoptions_event.cgi"; }
		else if (iCommand == 6) { urlCGI = gCGIPath+"dlg_adminoptions_ad.cgi"; }
		else if (iCommand == 7) { urlCGI = gCGIPath+"dlg_adminoptions_biz.cgi"; }
		else if (iCommand == 8) { urlCGI = gCGIPath+"dlg_adminoptions_article.cgi"; }
		else if (iCommand == 9) { urlCGI = gCGIPath+"dlg_adminoptions_masthead_images.cgi"; }
		else if (iCommand == 10) { urlCGI = gCGIPath+"dlg_adminoptions_link.cgi"; }
		else if (iCommand == 11) { urlCGI = gCGIPath+"dlg_adminoptions_masthead.cgi"; }
		else if (iCommand == 12) { urlCGI = gCGIPath+"dlg_adminoptions_gallery.cgi"; }
		else if (iCommand == 13) { urlCGI = gCGIPath+"admin_nightly.cgi?UPDATE=1"; }
		else if (iCommand == 14) { urlCGI = gCGIPath+"admin_nightly.cgi?UPDATE=0"; }
		else if (iCommand == 15) { urlCGI = gCGIPath+"admin_nightly.cgi?UPDATE=3"; }
		else if (iCommand == 16) { urlCGI = gCGIPath+"dlg_adminoptions_poll.cgi"; }
		else if (iCommand == 17) { urlCGI = gCGIPath+"dlg_adminoptions_subscribe.cgi"; }
		else if (iCommand == 18) { urlCGI = gCGIPath+"admin_nightly.cgi?UPDATE=4"; }
		else if (iCommand == 19) { urlCGI = gCGIPath+"dlg_adminoptions_tidepool.cgi"; }
		else if (iCommand == 20) { urlCGI = gCGIPath+"dlg_adminoptions_weather.cgi"; }
		else if (iCommand == 21) { urlCGI = gCGIPath+"dlg_adminoptions_security.cgi"; }
		else if (iCommand == 22) { urlCGI = gCGIPath+"dlg_adminoptions_searchengines.cgi"; }
		else if (iCommand == 23) { urlCGI = gCGIPath+"admin_nightly.cgi?UPDATE=5"; }
		else if (iCommand == 24) { urlCGI = gCGIPath+"admin_nightly.cgi?UPDATE=6"; }
		else if (iCommand == 25) { urlCGI = gCGIPath+"dlg_adminoptions_map.cgi"; }
		else if (iCommand == 26) { urlCGI = gCGIPath+"dlg_adminoptions_skins.cgi"; }
		else if (iCommand == 27) { urlCGI = gCGIPath+"dlg_ednote_edit.cgi"; }
		else if (iCommand == 28) { urlCGI = gCGIPath+"dlg_adminoptions_topics.cgi"; }
		else if (iCommand == 29) { urlCGI = gCGIPath+"dlg_adminoptions_images.cgi"; }
		else if (iCommand == 30) { urlCGI = gCGIPath+"dlg_adminoptions_images_custom.cgi?N=1"; }
		else if (iCommand == 31) { urlCGI = gCGIPath+"dlg_adminoptions_images_custom.cgi?N=2"; }
		else if (iCommand == 32) { urlCGI = gCGIPath+"dlg_attachtype_list.cgi"; }
		else if (iCommand == 33) { urlCGI = gCGIPath+"dlg_adminoptions_newsletter.cgi"; }
		else if (iCommand == 34) { urlCGI = gCGIPath+"dlg_adminoptions_search.cgi"; }
		else if (iCommand == 35) { urlCGI = gCGIPath+"dlg_adminoptions_subscribe_x.cgi"; }
		else if (iCommand == 37) { urlCGI = gCGIPath+"admin_nightly.cgi?UPDATE=7"; }
		else if (iCommand == 38) { urlCGI = gCGIPath+"dlg_adminoptions_rss.cgi"; }
		else if (iCommand == 39) { urlCGI = gCGIPath+"dlg_adminoptions_tus.cgi"; }
		else if (iCommand == 40) { urlCGI = gCGIPath+"admin_nightly.cgi?UPDATE=8"; }
		else if (iCommand == 41) { urlCGI = gCGIPath+"dlg_frontpage_arrange.cgi"; }
		else if (iCommand == 42) { urlCGI = gCGIPath+"dlg_adminoptions_fpsubscribe.cgi"; }
		else if (iCommand == 43) { urlCGI = gCGIPath+"dlg_pagebit_new.cgi"; }
		else if (iCommand == 44) { urlCGI = gCGIPath+"dlg_adminoptions_sidebar.cgi"; }
		else if (iCommand == 45) { urlCGI = gCGIPath+"dlg_adminoptions_menubar.cgi"; }
		else if (iCommand == 46) { urlCGI = gCGIPath+"show_sitemap.cgi"; fDlg = false; }
		else if (iCommand == 47) { urlCGI = gCGIPath+"dlg_adminoptions_membership.cgi"; }
		else if (iCommand == 48) { urlCGI = gCGIPath+"dlg_adminoptions_fpbanner.cgi"; }
		
		else if (iCommand == 100) { urlCGI = gCGIPath+"dlg_topic_edit.cgi?ID="+gidCurTopic; }
		else if (iCommand == 105) { urlCGI = gCGIPath+"dlg_admintopics_event.cgi?ID="+gidCurTopic; }
		else if (iCommand == 106) { urlCGI = gCGIPath+"dlg_admintopics_ad.cgi?ID="+gidCurTopic; }
		else if (iCommand == 107) { urlCGI = gCGIPath+"dlg_admintopics_biz.cgi?ID="+gidCurTopic; }
		else if (iCommand == 108) { urlCGI = gCGIPath+"dlg_admintopics_article.cgi?ID="+gidCurTopic; }
		else if (iCommand == 110) { urlCGI = gCGIPath+"dlg_admintopics_link.cgi?ID="+gidCurTopic; }
		else if (iCommand == 112) { urlCGI = gCGIPath+"dlg_admintopics_gallery.cgi?ID="+gidCurTopic; }
		else if (iCommand == 116) { urlCGI = gCGIPath+"dlg_admintopics_poll.cgi?ID="+gidCurTopic; }
		else if (iCommand == 125) { urlCGI = gCGIPath+"dlg_admintopics_map.cgi?ID="+gidCurTopic; }
		
		else if (iCommand == 200) { urlCGI = gCGIPath+"show_admin_review.cgi"; fDlg = false; }
		else if (iCommand == 201) { urlCGI = gCGIPath+"show_admin_summary.cgi"; fDlg = false; }
		else if (iCommand == 202) { urlCGI = gCGIPath+"show_member_messages.cgi?F=0"; fDlg = false; }
		else if (iCommand == 203) { urlCGI = gCGIPath+"show_member_messages.cgi?F=1"; fDlg = false; }
		else if (iCommand == 204) { urlCGI = gCGIPath+"show_admin_sponsors.cgi"; fDlg = false; }
		else if (iCommand == 206) { urlCGI = gCGIPath+"show_member.cgi"; fDlg = false; }
	
		if (urlCGI != '') {
			if (fDlg) {
				var wndNew = wndOpenNewWindow("AdminTool",590,700);
				if (wndNew != null) {
					wndNew.location = urlCGI;
					wndNew.focus();
				} else {
					alert("Sorry, the Admin window could not be opened. Please try again. If you continue having troubles, please let us know. Thank you.");
				}
			} else {
				location = urlCGI;
			}
		} else {
			alert("Sorry, you requested a command that doesn't exist. Command ID ="+iCommand);
		}
	}
	
	function getEdDot(fIsAdmin,idCmd) {
		var strR = '';
		if (fIsAdmin) {
			strR += '<a href="javascript:adminCommand('+idCmd+')" title="Change preferences...">';
			strR += '<img src="'+gWWWPath+'bits/ed-dot.gif" width="12" height="12" alt="Change preferences..." border="0" onmouseover="this.src=\''+gWWWPath+'bits/ed-dot2.gif\'" onmouseout="this.src=\''+gWWWPath+'bits/ed-dot.gif\'" style="padding-left:2px;">';
			strR += '</a>';
		}
		return strR;
		
	}
	function getEdHelp(fIsAdmin,strHelpTopic) {
		var strR = '';
		if (fIsAdmin) {
			strR += '<a href="javascript:adminHelp(\''+strHelpTopic+'\')" title="Help info...">';
			strR += '<img src="'+gWWWPath+'bits/ed-help.gif" width="12" height="12" alt="Help info..." border="0" onmouseover="this.src=\''+gWWWPath+'bits/ed-help2.gif\'" onmouseout="this.src=\''+gWWWPath+'bits/ed-help.gif\'" style="padding-left:2px;">';
			strR += '</a>';
		}
		return strR;
		
	}

//================================
//
//	PAGE BITS
//

	function addPageBit(p,t,s) {
		var strCGI = "dlg_pagebit_new.cgi?P="+p+"&T="+t+"S="+s;
		showDialogCGI("NewCustomPageBit",590,670,strCGI);
	}
	function editPageBit(id) {
		var strCGI = "dlg_pagebit_edit.cgi?ID="+id;
		showDialogCGI("EditCustomPageBit",590,670,strCGI);
	}
	function deletePageBit(id) {
		var fOK = confirm('Are you sure you want to DELETE this custom page bit? Continue?');
		if (fOK) {
			var strCGI = "submit_pagebit_del.cgi?ID="+id;
			showDialogCGI("DeleteCustomPageBit",590,300,strCGI);
		}
	}
	function drawPageBit (strInfo, fIsAdmin, dxCol) {
		var str = '';
		var aB = strInfo.split('|');
		var idBit 			= aB[0];
		var idBitType		= aB[1];
		
		if (idBitType == 1) {
			var strBitTitle 	= aB[2];
			var strBitText 		= aB[3];
			var strBitOpts 		= aB[4];
			var urlPix1			= aB[5];
			var urlPix2			= aB[6];
			var urlPix3			= aB[7];
			var urlPix4			= aB[8];
			var urlPix5			= aB[9];
			var strCap1			= aB[10];
			var strCap2			= aB[11];
			var strCap3			= aB[12];
			var strCap4			= aB[13];
			var strCap5			= aB[14];
			var urlPixLink1		= aB[15];
			var urlPixLink2		= aB[16];
			var urlPixLink3		= aB[17];
			var urlPixLink4		= aB[18];
			var urlPixLink5		= aB[19];
			var nNewWnd1		= aB[20];
			var nNewWnd2		= aB[21];
			var nNewWnd3		= aB[22];
			var nNewWnd4		= aB[23];
			var nNewWnd5		= aB[24];
			var aAtUrl			= new Array();
			aAtUrl[1]			= aB[25];
			aAtUrl[2]			= aB[26];
			aAtUrl[3]			= aB[27];
			aAtUrl[4]			= aB[28];
			aAtUrl[5]			= aB[29];
			var aAtStr			= new Array();
			aAtStr[1]			= aB[30];
			aAtStr[2]			= aB[31];
			aAtStr[3]			= aB[32];
			aAtStr[4]			= aB[33];
			aAtStr[5]			= aB[34];
			var strEmail 		= aB[35];
			var idPage	 		= aB[36];
			var idBitSection	= aB[37];
			var idBitTopic		= aB[38];
			var aAtPixInfo		= new Array();
			aAtPixInfo[1]		= aB[39];
			aAtPixInfo[2]		= aB[40];
			aAtPixInfo[3]		= aB[41];
			aAtPixInfo[4]		= aB[42];
			aAtPixInfo[5]		= aB[43];
			var aAtIcon			= new Array();
			aAtIcon[1]			= aB[44];
			aAtIcon[2]			= aB[45];
			aAtIcon[3]			= aB[46];
			aAtIcon[4]			= aB[47];
			aAtIcon[5]			= aB[48];
			var aAtSize			= new Array();
			aAtSize[1]			= aB[49];
			aAtSize[2]			= aB[50];
			aAtSize[3]			= aB[51];
			aAtSize[4]			= aB[51];
			aAtSize[5]			= aB[53];
			
			var aBitOpts		= strBitOpts.split(':');
			var dxFont			= aBitOpts[0];
			var nPixLayout		= aBitOpts[1];
			var nBitPad			= aBitOpts[2];
			var nBitMargin		= aBitOpts[3];
			var rgbText			= aBitOpts[4];
			var rbgBack			= aBitOpts[5];
			var rbgBorder		= aBitOpts[6];
			var nBitSet 		= parseInt(idBit/200);
			var strPixDir 		= 'tidepages/set_'+nBitSet+'/bit_'+idBit; 
			var strStyleBA		= '';
			if (nBitPad > 0) 	 { strStyleBA += 'padding:'+nBitPad+'px;'; }
			if (nBitMargin > 0)  { strStyleBA += 'margin-bottom:'+nBitMargin+'px;'; }
			if (rgbText != '')   { strStyleBA += 'color:#'+rgbText+';'; }
			if (rbgBack != '')   { strStyleBA += 'background-color:#'+rbgBack+';'; }
			if (rbgBorder != '') { strStyleBA += 'border:1px solid #'+rbgBorder+';'; }
			if (strStyleBA != ''){ strStyleBA = 'style="'+strStyleBA+'"'; }
			
			str += '<div class="bit_area" '+strStyleBA+'>';
				// top pix
				str += htmlBitPix(strPixDir, urlPix1, strCap1, urlPixLink1, nNewWnd1, aAtPixInfo[1]);
				// other pix
				var fPixOther = false;
				var htmlPixOther = '';
				htmlPixOther += htmlBitPix(strPixDir, urlPix2, strCap2, urlPixLink2, nNewWnd2, aAtPixInfo[2]);
				htmlPixOther += htmlBitPix(strPixDir, urlPix3, strCap3, urlPixLink3, nNewWnd3, aAtPixInfo[3]);
				htmlPixOther += htmlBitPix(strPixDir, urlPix4, strCap4, urlPixLink4, nNewWnd4, aAtPixInfo[4]);
				htmlPixOther += htmlBitPix(strPixDir, urlPix5, strCap5, urlPixLink5, nNewWnd5, aAtPixInfo[5]);
				// text
				if (strBitText != '') {
					var strStyleEx = '';
					if (dxFont > 4) { strStyleEx = 'style="font-size:'+dxFont+'px;"'; }
					str += '<div class="bit_text" '+strStyleEx+'>';
					if (htmlPixOther != '') {
						if (nPixLayout == 2) {
							str += '<div style="float:right;padding-left:10px;">'+htmlPixOther+'</div>';
							fPixOther = true;
						}
						if (nPixLayout == 1) {
							str += '<div style="float:left;padding-right:10px;">'+htmlPixOther+'</div>';
							fPixOther = true;
						}
					}	
					str += makeURLsHot(strBitText);
					str += '</div>';
				}
				// pix
				if (!fPixOther && (htmlPixOther != '')) { 
					str += htmlPixOther;
					fPixOther = true;
				}
				
				// attach
				var urlEscaped = '';
				var str2 = '';
				for (var u = 1; u <= 5; u++) {
					var urlThis 	= aAtUrl[u];
					if (urlThis != '') {
						// name
						var strThisName = aAtStr[u];
						if (strThisName == '') { strThisName = urlThis; }
						// icon
						var strIcon = aAtIcon[u];
						if (strIcon == '') { strIcon = 'attach'; }
						// url
						urlEscaped = escape(urlThis);
						var urlFull = strPixDir+'/'+urlEscaped;
						// target
						var strTarg = ' target="_blank" ';
						if (strIcon == 'audio') { strTarg = ''; }
						// link
						str2 += '<a class="bit_attach" href="'+urlFull+'" '+strTarg+' title="Click to open '+urlThis+'...">';
						str2 += '<img src="bits/icon16_'+strIcon+'.gif" width="16" height="16" alt="Click to view '+urlThis+'..." border="0">&nbsp;';
						str2 += strThisName;
						// filesize
						var nKB = parseInt(aAtSize[u] / 1024) + 1;
						str2 += ' &middot '+nKB+'k';
						str2 += '</a><br>';
					}
				}
				if (str2 != '') {
					str += '<div class="bit_attach_area">';							
					str += str2;
					str += '</div>';
				}

				if (strEmail != "") {
					str += '<div class="bit_email_area">';							
					str += '<a class="bit_email" href="' + createMailString(strEmail) + '" title="Use your email program to send an email..."><img src="bits/atools_reply.gif" width="16" height="16" alt="" border="0"> '+getMailAddress(strEmail)+'</a>';
					str += '</div>';							
				}

			str += '</div>';
		}
		if (fIsAdmin) {
			str += '<div class="bit_ftr_area">CUSTOM ELEMENT ';
			str += getFooterDivider();
			str += '<a href="javascript:editPageBit('+idBit+')" class="bit_ftr">edit</a>';
			str += getFooterDivider();
			str += '<a href="javascript:deletePageBit('+idBit+')" class="bit_ftr">del</a>';
			str += '</div>';
		}
		document.writeln(str);
	}
	function htmlBitPix(strPixDir, urlPix, strCap, urlLink, nLinkOpt, strPixInfo) {
		var strBP = '';
		if (urlPix != '') {
			var fLink = false;	if (urlLink != '') { fLink = true; }
			var fSame = 0; if (nLinkOpt == 0) { fSame = 1; }
			var aPI = strPixInfo.split(':');
			var dx = aPI[0];
			var dy = aPI[1];
			var strStEx = '';
			if (dx > 0) { strStEx = 'style="width:'+dx+'px;"'; }
			strBP += '<div class="bit_pix_area" '+strStEx+'>';
				if (fLink) { strBP += '<a '+getWebsiteHrefPlus(urlLink, fSame)+'>'; }
				strBP += '<img class="bit_pix" src="'+strPixDir+'/'+urlPix+'" border="1"  title="'+strCap+'">';
				if (fLink) { strBP += '</a>'; }
				if (strCap != '') { strBP += '<div class="bit_pix_cap">'+strCap+'</div>'; }
			strBP += '</div>';
		}
		return (strBP);
	}
	
	
	


//================================
//
//	PRODUCT FUNCTIONS
//
	function drawMPProdsCore(aMPProd, strMPInfo, fIsAdmin, nCol, nLoc) {
		var str = '';
 		var aO = strMPInfo.split('|');
		var aOpt	 			= aO[3].split(':'); 
			var nFPFormat			= parseInt(aOpt[0]);
			var nFPQuantity 		= parseInt(aOpt[1]);
			var nFPOrder			= parseInt(aOpt[2]);
			var strFPTitle			= aOpt[3];
		var strTitle		= aO[4];	
		var strText	 		= aO[5];	
		var nStatus			= parseInt(aO[6]);	
		var fFrontpage		= true;
		var fSidebar		= false;
		var cssProdTitleEx   = '';
		if (nLoc == 1) { 
			fFrontpage = false; 
			fSidebar = true; 
			cssProdTitleEx   = ' style="font-size:11px;" ';
		}

		if (nStatus > 0) {
			if (fFrontpage) { 
				// title
				if (strTitle != '') {
						str += getFpHeadOpening(fIsAdmin, 0,'', 'showProductList(0,0)', strTitle, 7, 'mk');
						str += '</div>';
				}
				// shop
				str += '<div class="btn" style="margin-bottom:4px;">';
					str += '<a href="javascript:showProductList(0,0)" class="btn" title="Click to view all...">Browse all</a>';
					str += getFooterDivider();
					str += '<a href="javascript:showProductList(0,0)" class="btn" title="Shop online...">Shop</a>';
				str += '</div>';
				// text
				if (strText != '') {
					str += '<div class="ednote_text" style="margin-bottom:4px;">';
					str += makeURLsHot(strText);
					str += '</div>';
				}
			} 
			else if (fSidebar) {
				str += '<div id="sbar_prod_area">';
				if (strFPTitle != '') {
					var strExStyle = '';
					if (isNotEmpty(gstrSideMenuColor))   { strExStyle = ' style="color:#'+gstrSideMenuColor+';font-size:13px;"'; }
					str += '<a class="ms_h_text" href="javascript:showProductList(0,0);" title="'+strFPTitle+'" '+strExStyle+'>'+strFPTitle+' </a>';
				}
			}
			document.writeln(str);
			str = '';
			
			// Products
			var nProds = aMPProd.length - 1;
			for (var i = 0; i < nProds; i++) {
				var aA = aMPProd[i].split("|");
				var idP				= aA[0];
				var strP	 		= aA[1];
				var strVNameURL	= scrubTitleForURL(strP);
				var strPPix	 		= aA[2];
				var idPT			= aA[3];
				var strPT	 		= aA[4];
				var idM		 		= aA[5];
				var strM	 		= aA[6];
				var strMURL			= scrubTitleForURL(strM);
				if (fFrontpage) { str += '<div class="mk_area" style="margin-bottom:4px;">'; }
				else if (fSidebar) {str += '<div class="sbar_product">'; }
						//image
						var	urlPhoto = 'biz/biz_' + idM + '/pr_' + idP + '/thumb_' + strPPix;
						str += '<table cellpadding="0" cellspacing="0">';
						str += '<tr>';
						if (nFPFormat == 1) {
							str += '<td valign="top">';
							str += '<a href="javascript:showProduct('+idP+',\''+strVNameURL+'\')" title="View details...">'; 
							str += '<img ';
							str += 'src="'+urlPhoto+'" ';
							str += 'alt="View details..." title="View details..." ';
							str += 'width="100" ';
							str += 'border="1" style="margin-right:6px;">';
							str += '</a>';
							str += '</td>';
						}
						str += '<td valign="top">';
						str += '<div class="mk_title">';
							// title
							str += '<a href="javascript:showProduct('+idP+',\''+strVNameURL+'\')" class="mk_title" '+cssProdTitleEx+' title="View details...">'; 
							str += strP;
							str += '</a>';
						str += '</div>';
						str += '<div class="mk_text">';
							// owner
							str += '<a href="javascript:showSponsor('+idM+',\''+strMURL+'\')" class="mk_text" title="View details...">'; 
							str += 'by '+strM;
							str += '</a>';
						str += '</div>';
						str += '</td></tr>';
						str += '</table>';
				str += '</div>';
				document.writeln(str);
				str = '';
			}
			if (fFrontpage) { document.writeln('<div class="fp_vertspacer">&nbsp;</div>'); }
			else if (fSidebar) { document.writeln('</div>'); }
		}
	}	
	
	function togglePopOpen(id){
		var d = getDOM(id,1);
		if (d.display == "block") { 
			d.display = "none";
		} else {
			d.display = "block";		
		}
	}
	
	function toggleMenu(id){
		var d = getDOM(id,1);
		if (d.visibility == "visible") { 
			d.visibility = "hidden";
		} else {
			d.visibility = "visible";		
		}
	}
	
//================================
//
//	READER OPTIONS
//

	function changeReaderOptions(idSkin,nFPRefresh) {
		if (idSkin <= 0) 	 { SetCookie('skin','','',"/"); }
		else 			 	 { SetCookieYear('skin',idSkin,"/"); }
		if (nFPRefresh <= 0) { SetCookie('tidefprefresh','','',"/"); }
		else 			 	 { SetCookieYear('tidefprefresh',nFPRefresh,"/");  }
		top.location.reload();
	}

//================================
//
//	ADS
//
	function showAdImage(idAd, idImgDiv, urlAdPhoto) {
		var str = '<img src="ads/ad_'+idAd+'/'+urlAdPhoto+'" width="180" alt="" border="1" onclick="hideAdImage('+idAd+',\''+idImgDiv+'\',\''+urlAdPhoto+'\')" >';
		var dom 	 = getDOM(idImgDiv,0);
		dom.innerHTML = str;
	}
	function hideAdImage(idAd, idImgDiv, urlAdPhoto) {
		var str = '<img src="bits/photo.gif" width="180" alt="" border="1"  title="Click to view photo..."  alt="Click to view photo..." onclick="showAdImage('+idAd+',\''+idImgDiv+'\',\''+urlAdPhoto+'\')" >';
		var dom 	 = getDOM(idImgDiv,0);
		dom.innerHTML = str;
	}
	function drawAdList(aAds, idAdTypeMatch, fIsAdmin, fCanPost, nStatusShow, nFormat, nMax) {
		var str = ''; 	
		var nPixSoFar = 0;
		var nAds = aAds.length - 1;
		var iAd = 0;
		for (var i = 0; i < nAds; i++) {
			var aA = aAds[i].split("|");
			var idAd			= aA[0];
			var idAdType		= aA[1];
			var strAdType		= aA[2];
			var tStart 			= aA[3];
			var tFinish			= aA[4];
			var strAuthor 		= aA[5];
			var strTitle 		= aA[6];
			var strDescription	= aA[7];
			var urlPhoto 		= aA[8];
			var strEmail 		= aA[9];
			var urlWebsite 		= aA[10];
			var nModifiedDays	= aA[11];
			var strDelDate		= aA[12];
			var nExpDays		= aA[13];
			var nStatus			= aA[14];
			
			if ((idAdTypeMatch <= 0) || (idAdTypeMatch == idAdType)) {
				
				str += '<div class="ad_area">';
					// TITLE
					str += '<div class="ad_title">';
						if (nFormat == 0) { str += '<a class="ad_title" href="javascript:togglePopOpen(\'fp_a'+idAd+'\');" title="click to open and close...">'; }
						str += strTitle;
						if (nModifiedDays <= gnModifiedDaysNew ) { str += '<img src="bits/updated2.gif" width="11" height="11" alt="New or Updated" title="New or Updated" border="0">';					}
						if (nFormat == 0) { str += '</a>'; }
					str += '</div>';
					
					if (nFormat == 0) { str += '<div id="fp_a'+idAd+'" style="display:none">'; }
						// PHOTO
						if (urlPhoto != '') {
							str += '<div class="ad_pix">';
								str += '<div id="img_ad'+idAd+'">';
								if (nPixSoFar == 0) {
									str += '<img src="ads/ad_'+idAd+'/'+urlPhoto+'" width="180" alt="" border="1" onclick="hideAdImage('+idAd+',\'img_ad'+idAd+'\',\''+urlPhoto+'\')" >';
									nPixSoFar++;
								} else {
									str += '<img src="bits/photo.gif" title="Click to view photo..."  alt="Click to view photo..." border="1" onclick="showAdImage('+idAd+',\'img_ad'+idAd+'\',\''+urlPhoto+'\')" width="180" style="cursor:pointer">';
								}
								str += '</div>';
							str += '</div>';
						}
						
						// TEXT 
						str += '<div class="ad_text">';
							if (nExpDays > 0) {
								str += '<b>AD EXPIRED: '+tFinish+'</b><br>';
							}
							str += strDescription;
						str += '</div>';
						
						// FOOTER
						str += '<div class="ad_ftr">';
							fShowDivider = false;
							str += 'by '+strAuthor;
							fShowDivider = true;
							if (strEmail != "") {
								if (fShowDivider) { str += getFooterDivider(); }
								str += '<a class="ad_ftr" href="' + createMailString(strEmail) + '">email</a>';
								fShowDivider = true;
							}
							if (urlWebsite != "") {
								if (fShowDivider) { str += getFooterDivider(); }
								str += '<a class="ad_ftr" ';
								str += getWebsiteHref(urlWebsite);
								str += '>website</a>';
								fShowDivider = true;
							} 
							if (fCanPost && (nStatus > 0)) {
								if (fShowDivider) { str += getFooterDivider(); }
								str += '<a class="ad_ftr" href="javascript:editAdPlus('+ idAd + ')">edit</a>';
								fShowDivider = true;
								if (fShowDivider) { str += getFooterDivider(); }
								str += '<a class="ad_ftr" href="JavaScript:deleteAd('+ idAd + ')">del</a>';
								fShowDivider = true;
							}
							if (fIsAdmin && (nStatus < 0)) {
								if (strDelDate == '') { strDelDate = '(unknown date)'; }
								if (fShowDivider) { str += getFooterDivider(); }
								str += '<span class="ad_ftr">Deleted on '+strDelDate + getFooterDivider() + '</span>';
								str += '<a class="ad_ftr" href="javascript:undeleteAd('+ idAd + ')">undelete</a>';
								fShowDivider = true;
							}
					str += '</div>';
				if (nFormat == 0) { str += '</div>'; }
	
				str += '</div>';
				document.writeln(str);
				str = '';
			}
		} 
	}

//================================
//
//	SPONSOR
//
	function showProductThumb(idProduct, urlPhotoToShow) {
		var str = '';
		var idImgDiv = 'img_p'+idProduct;
		str = '<img src="'+urlPhotoToShow+'" width="100" alt="view details..." title="view details..." border="0" onclick="showProduct('+idProduct+')"  class="pixClick">';
		var dom 	 = getDOM(idImgDiv,0);
		dom.innerHTML = str;
	}

//================================
//
//	GALLERY
//
	function drawGalleryList(aGallery, fIsAdmin, nFormat, nLayout, idTopic, nStatusShow) {
		var str = ''; 	
		var strT = '';
		var str1 = ''; 	
		var str2 = ''; 	
		var str3 = ''; 	
		var dxCol1 = 280;
		var dxCol2 = 280;
		var dxCol3 = 220;
		var iCol = 1;

		if (nLayout == 1) { 
			str += '<table width="760" cellspacing="0" cellpadding="0">'; 
		}
		
		if (nLayout == 2) { 
			str += '<table width="760" cellspacing="0" cellpadding="0">'; 
			str1 += '<tr><td width="'+dxCol1+'" valign="top" ><div style="margin-right:60px;">';	
			str2 += '<td width="'+dxCol2+'" valign="top" ><div style="margin-right:60px;">';	
			str3 += '<td width="'+dxCol3+'" valign="top" ><div style="margin-right:0px;">';	
		}
		
		if (nLayout == 3) { 
			dxCol1 = 264;
			dxCol2 = 232;
			dxCol3 = 264;
			str += '<table width="760" cellspacing="0" cellpadding="0">'; 
			str1 += '<tr><td width="'+dxCol1+'" valign="top" ><div style="margin-left:44px;">';	
			str2 += '<td width="'+dxCol2+'" valign="top" ><div style="margin-left:6px;margin-right:6px;">';	
			str3 += '<td width="'+dxCol3+'" valign="top" ><div style="margin-right:44px;">';	
		}
		
		for (var i = 0; i < aGallery.length - 1; i++) {
			var aA = aGallery[i].split("|");
			var idG				= aA[0];
			var strAuthor 		= aA[1];
			var strTitle 		= aA[2];
			var strDescription	= aA[3];
			var urlPhoto 		= aA[4];
			var strEmail 		= aA[5];
			var urlWebsite 		= aA[6];
			var nModifiedDays	= aA[7];
			var strDate			= aA[8];
			
			if (nLayout == 1) {
				if 		(iCol == 1) { str += '<tr><td width="'+dxCol1+'" valign="top" ><div style="margin-right:60px;">';	}
				else if (iCol == 2) { str += '<td width="'+dxCol2+'" valign="top" ><div style="margin-right:60px;">';	}
				else if (iCol == 3) { str += '<td width="'+dxCol3+'" valign="top" ><div style="margin-right:0px;">';	}
			}

			strT = '';
			strT += '<div id="ga_area_'+i+'" class="ga_area">';
				strT += htmlInnerOneGallery(aA, fIsAdmin, nFormat, nLayout, idTopic, nStatusShow)
			strT += '</div>';
			if ((nLayout == 2) || (nLayout == 3)) {
				if 		(iCol == 1) { str1 += strT;	}
				else if (iCol == 2) { str2 += strT;	}
				else if (iCol == 3) { str3 += strT;	}
			} else {
				str += strT;
			}

			if (nLayout == 1) {
				if 		(iCol == 1) { str += '</div></td>';	}
				else if (iCol == 2) { str += '</div></td>';	}
				else if (iCol == 3) { str += '</div></td></tr>';	}
			}
			iCol++;
			if (iCol > 3) { iCol = 1; }
		}

		if (nLayout == 1) {	
			if (iCol == 2) { str += '<td width="'+dxCol2+'" valign="top" >&nbsp;</td>';}
			if (iCol >= 2) { str += '<td width="'+dxCol3+'" valign="top" >&nbsp;</td></tr>';	}
			str += '</table>';	
		}
		
		if ((nLayout == 2) || (nLayout == 3)) {	
			str1 += '&nbsp;</td>';
			str2 += '&nbsp;</td>';
			str3 += '&nbsp;</td></tr>';	
			str += str1 + str2 + str3;
			str += '</table>';	
			
		}
		document.writeln(str);
		
	}

	function htmlInnerOneGallery(aA, fIsAdmin, nFormat, nLayout, idTopic, nStatusShow) {
			var idG				= aA[0];
			var strAuthor 		= aA[1];
			var strTitle 		= aA[2];
			var urlMTitle 			= scrubTitleForURL(strTitle);
			var strDescription	= aA[3];
			var urlPhoto 		= aA[4];
			var strEmail 		= aA[5];
			var urlWebsite 		= aA[6];
			var nModifiedDays	= aA[7];
			var strDate			= aA[8];
			
			var str = '';
			// PHOTO
			if (urlPhoto != '') {
				str += '<div class="ga_pix">';
					str += '<a href="javascript:showGalleryItem('+idTopic+','+idG+',\''+urlMTitle+'\');" title="Click to view \''+strTitle+'\' by '+strAuthor+'...">'; 
					str += '<img src="gallery/gallery_'+idG+'/thumb_'+urlPhoto+'" alt="Click to view \''+strTitle+'\' by '+strAuthor+'..."  title="Click to view \''+strTitle+'\' by '+strAuthor+'..." width="200" border="1">';
					str += '</a>';
				str += '</div>';
			}
			
			if ((nFormat == 1) || (urlPhoto == '')) {
				// TITLE
				str += '<div class="ga_title">';
					str += '<a class="ga_title" href="javascript:showGalleryItem('+idTopic+','+idG+',\''+urlMTitle+'\');" title="Click to view \''+strTitle+'\' by '+strAuthor+'...">'; 
					str += strTitle;
					if (nModifiedDays <= gnModifiedDaysNew ) { str += '<img src="bits/updated2.gif" width="11" height="11" alt="New or Updated" title="New or Updated" border="0">';					}
					str += '</a>'; 
				str += '</div>';
				// TEXT 
				str += '<div class="ga_text">';
					str += makeURLsHot(strDescription);
				str += '</div>';
			}
			
			// DATE
			if (nFormat == 1) {
				str += '<div class="ga_date">'+strDate+'</div>';
			}
			
			// FOOTER
			if (nFormat != 2) {
				str += '<div class="ga_ftr">';
					fShowDivider = false;
					str += 'by '+strAuthor;
					fShowDivider = true;
					if (fShowDivider) { str += getFooterDivider(); }
					if (nStatusShow < 0) {
							str += '<a class="ga_ftr" href="javascript:undeleteGalleryItem('+idG+');">undelete</a>';					
					} else {
						if (urlPhoto != "") {
							str += '<a class="ga_ftr" href="javascript:showGalleryItem('+idTopic+','+idG+',\''+urlMTitle+'\');">view big</a>';
						} else {
							str += '<a class="ga_ftr" href="javascript:showGalleryItem('+idTopic+','+idG+',\''+urlMTitle+'\');">view details</a>';						
						}
					}
					fShowDivider = true;
				str += '</div>';
			}

			return str;
	}
	
//================================
//
//	POLL
//
	function votePoll() {
		var frm = document.frmPoll;
		var id = frm.ID.value;
		var nChoice = 0;
		for (var i = 0; i <= 5; i++) {
			if (frm.CHOICE[i].checked) {
				nChoice = i+1;
				break;
			}
		}
		if (nChoice == 0) {
			alert('Please select an answer submitting your vote.');
			return false;
		} else {
			var strCGI = "submit_poll_vote.cgi?ID="+id+"&CHOICE="+nChoice;
			showDialogCGI("PollVote",590,300,strCGI);
			return false;
		}
	}

	function votePendingPoll(frm) {
		alert('This Poll is not open and ready to accept votes yet.');
		return false;
	}

	function drawPoll(strEditRecord, fIsAdmin, nFormat, fOnFrontpage, idTopic) {
		var aP = strEditRecord.split('|');
		var idPoll	 			= aP[0];
		var nStatus				= aP[20];
		
		var strTypeToDraw			= 'results';
		
		if (nStatus == 2) { 
			// -- ACTIVE
			if (acceptsCookies()) {
				var idsPollsVoted = GetCookie('pollsvoted');
				var idThisPoll	  = ':'+idPoll+':'
				var nTestLoc
				if (isNotEmpty(idsPollsVoted) && (idsPollsVoted.indexOf(idThisPoll, 0) >= 0)) {
					strTypeToDraw = 'results';
				} else {
					strTypeToDraw = 'active';
				}
			}
		} else if (nStatus == 0) {
			strTypeToDraw = 'pending';
		}
		
		if (strTypeToDraw == 'results') {
			drawPollResults(strEditRecord, fIsAdmin, nFormat, fOnFrontpage, idTopic);
		} else if (strTypeToDraw == 'active') {
			drawActivePoll(strEditRecord, fIsAdmin, nFormat, fOnFrontpage, idTopic);
		} else {
			drawActivePoll(strEditRecord, fIsAdmin, nFormat, fOnFrontpage, idTopic);
		}

	}

	function drawActivePoll(strEditRecord, fIsAdmin, nFormat, fOnFrontpage, idTopic) {
		var str = ''; 	
		var aP = strEditRecord.split('|');
		var idPoll	 			= aP[0];
		var idPollType 			= aP[1];
		var strDate				= aP[2];
		var strTitle			= aP[3];
		var strQ				= aP[4];
		var strC1				= aP[5];
		var strC2				= aP[6];
		var strC3				= aP[7];
		var strC4				= aP[8];
		var strC5				= aP[9];
		var strC6				= aP[10];
		var strButtonLabel		= aP[19];
		var nStatus				= aP[20];
			
		var strStyleEx = '';
		if (fOnFrontpage) { strStyleEx = '_fp'; }
		
		str += '<div class="po_area'+strStyleEx+'">';
		
			var strFrmReturn = 'votePendingPoll()';
			if (nStatus == 2) { strFrmReturn = 'votePoll()'; }
			str += '<form name="frmPoll" method="POST" action="" enctype="multipart/form-data" onSubmit="return false;" style="margin-bottom:0px;">';
				// DATE
				if (nFormat == 1) {
					str += '<div class="po_date'+strStyleEx+'">'+ strDate+'</div>';
				}
				// TITLE
				str += '<div class="po_title'+strStyleEx+'">'+ strTitle+'</div>';
				str += '<table style="table-layout:fixed">';
					// FORCE SIZING
					str += '<COL WIDTH="25"><COL WIDTH="25">'; 
					// Q
					str += '<tr><td valign="top"><div class="po_Q'+strStyleEx+'">Q</div></td>';
					str += '<td colspan="2" valign="bottom"><div class="po_qst'+strStyleEx+'"> '+ strQ+'</div></td></tr>';
					// choices
					if (strC1 != '') { 
						str += '<tr><td><div style="margin-left:12px;">&nbsp;</div></td><td width="26"><input type="Radio" name="CHOICE" value="1"></td>';
						str += '<td valign="bottom"><div class="po_c'+strStyleEx+'">'+strC1+'</div></td></tr>';
					}
					if (strC2 != '') { 
						str += '<tr><td>&nbsp;</td><td width="20"><input type="Radio" name="CHOICE" value="2"></td>';
						str += '<td valign="bottom"><div class="po_c'+strStyleEx+'">'+strC2+'</div></td></tr>';
					}
					if (strC3 != '') { 
						str += '<tr><td>&nbsp;</td><td width="20"><input type="Radio" name="CHOICE" value="3"></td>';
						str += '<td valign="bottom"><div class="po_c'+strStyleEx+'">'+strC3+'</div></td></tr>';
					}
					if (strC4 != '') { 
						str += '<tr><td>&nbsp;</td><td width="20"><input type="Radio" name="CHOICE" value="4"></td>';
						str += '<td valign="bottom"><div class="po_c'+strStyleEx+'">'+strC4+'</div></td></tr>';
					}
					if (strC5 != '') { 
						str += '<tr><td>&nbsp;</td><td width="20"><input type="Radio" name="CHOICE" value="5"></td>';
						str += '<td valign="bottom"><div class="po_c'+strStyleEx+'">'+strC5+'</div></td></tr>';
					}
					if (strC6 != '') { 
						str += '<tr><td>&nbsp;</td><td width="20"><input type="Radio" name="CHOICE" value="6"></td>';
						str += '<td valign="bottom"><div class="po_c'+strStyleEx+'">'+strC6+'</div></td></tr>';
					}
				str += '</table>';
				// hidden id
				str += '<input type="hidden" name="ID" value="'+idPoll+'">';
				// page redirect info
				var strLoc = idPoll;
				if (fOnFrontpage) { strLoc = 0; }
				str += '<input type="hidden" name="LOC" value="'+strLoc+'">';
				// button
				if (strButtonLabel == '') { strButtonLabel = 'Vote'; }
				str += '<div class="po_btn_area'+strStyleEx+'">';
					str += '<input type="BUTTON" value="'+strButtonLabel+'" class="po_btn" onclick="'+strFrmReturn+'"><br>';
					str += 'Vote to see results';
				str += '</div>';
			str += '</form>';
			
		str += '</div>';
		str += getPollFooter(fIsAdmin, idPoll, idPollType, nStatus, idTopic);
		document.writeln(str);
		
	}
	
	function drawPollResults(strEditRecord, fIsAdmin, nFormat, fOnFrontpage, idTopic) {
		var str = ''; 	
		var aP = strEditRecord.split('|');
		var idPoll	 			= aP[0];
		var idPollType 			= aP[1];
		var strDate				= aP[2];
		var strTitle			= aP[3];
		var strQ				= aP[4];
		var strC1				= aP[5];
		var strC2				= aP[6];
		var strC3				= aP[7];
		var strC4				= aP[8];
		var strC5				= aP[9];
		var strC6				= aP[10];
		var nV1					= parseInt(aP[11]);
		var nV2					= parseInt(aP[12]);
		var nV3					= parseInt(aP[13]);
		var nV4					= parseInt(aP[14]);
		var nV5					= parseInt(aP[15]);
		var nV6					= parseInt(aP[16]);
		var nAnswer				= parseInt(aP[17]);
		var strAnswerInfo		= aP[18];
		var strButtonLabel		= aP[19];
		var nStatus				= aP[20];
		
		var nVTotal = nV1 + nV2 + nV3 + nV4 + nV5 + nV6;
		if (idPollType == 0) { nAnswer = 0; }
		var strStyleEx = '';
		if (fOnFrontpage) { strStyleEx = '_fp'; }
			
		str += '<div class="po_area'+strStyleEx+'">';
		
				// DATE
				if (nFormat == 1) {
					str += '<div class="po_date'+strStyleEx+'">'+ strDate+'</div>';
				}
				// TITLE
				str += '<div class="po_title'+strStyleEx+'">'+ strTitle+'</div>';
				str += '<table>'; 
					// Q
					str += '<tr><td><div class="po_Q'+strStyleEx+'">Q</div></td>';
					str += '<td colspan="2"><div class="po_qst'+strStyleEx+'"> '+ strQ+'</div></td></tr>';
				str += '</table>'; 
				str += '<table>'; 
					// choices
					for (var i = 1; i <= 6; i++) {
						var strC = '';
						var nV   = 0;
						eval('strC = strC'+i);
						if (strC != '') { 
							eval('nV = nV'+i);
							var nPer = Math.round((nV * 100) / nVTotal);
							var pxPer = parseInt((nPer + 1) / 2);
							var pxPerEmpty = 50 - pxPer;
							str += '<tr>';
								str += '<td>';
									if (nAnswer == i) {
										str += '<div class="po_bar_correct'+strStyleEx+'">';
									} else {
										str += '<div class="po_bar'+strStyleEx+'">';
									}
										var pxH = 14;
										if (fOnFrontpage) { pxH = 11; }
										str += '<img src="spacer.gif" width="'+pxPerEmpty+'" height="'+pxH+'" alt="" border="0">';
										if (nPer > 0) {
											str += '<img src="bits/pollbar.gif" width="'+pxPer+'" height="'+pxH+'" alt="" border="0">';
											str += '<div class="po_per'+strStyleEx+'">'+nPer+'%</div>';
										}
									str += '</div>';
								str += '</td>';
								str += '<td valign="top">';
									if (nAnswer == i) {
										str += '<div class="po_c_yes'+strStyleEx+'">'+strC+'';
									} else {
										str += '<div class="po_c'+strStyleEx+'">'+strC;
									}
									if (nFormat == 1) {
										str += ' <span class="po_vot'+strStyleEx+'">('+nV+' votes)</span>';
									}
									str += '</div>';
								str += '</td>';
							str += '</tr>';
						}
					}
				str += '</table>';
				if (nAnswer > 0) {
					str += '<table>'; 
						// A
						var strA = eval('strC'+nAnswer);
						str += '<tr><td><div class="po_Q'+strStyleEx+'">A</div></td>';
						str += '<td colspan="2"><div class="po_ans'+strStyleEx+'"> ';
							str += strA;
							if (nFormat == 0) {
								str += ' <a href="javascript:showPolls('+idTopic+','+idPoll+')" class="po_ainfo'+strStyleEx+'">(more info...)</a>';
							}
						str += '</div></td></tr>';
						if (strAnswerInfo != '') {
							str += '<tr><td>&nbsp;</td><td><div class="po_ainfo'+strStyleEx+'">';
							if (nFormat == 1) {
								str += makeURLsHot(strAnswerInfo);
							}
							str += '</div></td></tr>';
						}
					str += '</table>'; 
				}
				
		// RESULTS LABEL
		str += '<div class="po_r_lbl'+strStyleEx+'">results from '+nVTotal+' votes</div>';
		str += '</div>';

		// FOOTER
		str += getPollFooter(fIsAdmin, idPoll, idPollType, nStatus, idTopic);
		
		document.writeln(str);
		
	}
	
	function getPollFooter(fIsAdmin, idPoll, idPollType, nStatus, idTopic) {
		var str = '';
		if (fIsAdmin) {
			// FOOTER
			str += '<div class="ga_ftr">';
				// type of poll
				if (nStatus    == -1) { str += 'Deleted '; }
				if (nStatus    ==  0) { str += 'Pending '; }
				if (nStatus    ==  1) { str += 'Closed '; }
				if (nStatus    ==  2) { str += 'Active '; }
				if (idPollType ==  0) { str += 'Survey '; }
				if (idPollType ==  1) { str += 'Quiz '; }
				
				if (nStatus    == -1) {
					str += getFooterDivider();
					str += '<a class="ga_ftr" href="javascript:undeletePoll('+idPoll+');">undelete</a>';				
				} else {
					str += getFooterDivider();
					str += '<a class="ga_ftr" href="javascript:addPoll('+idTopic+');">new</a>';
					str += getFooterDivider();
					str += '<a class="ga_ftr" href="javascript:editPoll('+idPoll+');">edit</a>';
					str += getFooterDivider();
					if (nStatus == 2) {
						str += '<a class="ga_ftr" href="javascript:closePoll('+idPoll+');">close</a>';
					} else {
						str += '<a class="ga_ftr" href="javascript:openPoll('+idPoll+');">open</a>';				
					}
					if (nStatus >= 0) {
						str += getFooterDivider();
						str += '<a class="ga_ftr" href="javascript:delPoll('+idPoll+');">del</a>';
					}
				}
			str += '&nbsp;</div>';
		}
		return str;
	}
	
//================================
//
//	BIZ FUNCTIONS
//
	function shuffle(Q) { 
		var R, T, J;
   		for (J = Q.length-1; J > 0; J--) { 
			R=randomN(J+1) ; 
			T=Q[J] ; 
			Q[J]=Q[R] ; 
			Q[R]=T ;
		} 
   		return Q ;
	}	
	
	

//================================
//
//	TEXT, NUMBER AND DATE FUNCTIONS
//

	function passwordError(strPass, strPasswordType) {
		var fError = false;
		var reIllegals = /[^a-zA-Z0-9\!\#\$\?]/;
		var reNonLetter = /[^a-zA-Z]/;
		if (strPass == '') {
			alert ("Your "+strPasswordType+" password can't be empty. Please try again.");
			fError = true;
		} else 
		if (strPass.length < 6) {
			alert ("Your "+strPasswordType+" password must have at least 6 characters. Please try again.");
			fError = true;		
		} else
		if (strPass.length > 20) {
			alert ("Your "+strPasswordType+" password must have at fewer than 20 characters. Please try again.");
			fError = true;		
		} else
		if (strPass.search(reIllegals) >= 0) {
			alert ("Your "+strPasswordType+" password contains characters that are not allowed. Please try again using only letters, numbers and accpeted symbols.");
			fError = true;		
		} else
		if (strPass.search(reNonLetter) == -1) {
			alert ("Your "+strPasswordType+" password must contain at least one character that is not a letter. Please try again by adding a number or accpeted symbol.");
			fError = true;		
		} 
		return fError;
	}
	
	function shortenText(strText, cchMaxText) {
		cchMaxText = parseInt(cchMaxText);
		if (cchMaxText <= 0) { cchMaxText = 200; }
		// remove extra lines
		while (strText.indexOf('<br><br>', 0) > 0) {
			strText = strText.replace('<br><br>', '<br>');
		}
		// remove fancy links
		var regexWeb = /(((https?:\/\/www\.)|(www\.)|(https?:\/\/)|(ftp:\/\/))[^< !:'"\)\[\]]*) *\[([^\]]+)\]/gi;
		var strText = strText.replace(regexWeb, "$7");
		
		var cchText = strText.length;
		if (cchText > cchMaxText) {
			var fMidSentence = false;
			var cchMinText = parseInt(cchMaxText/2);
			if (cchMinText < 0) { cchMinText = 0; }
			// find first period after min
			var iDot = strText.indexOf(".", cchMinText) + 1;
			// else find first space after min
			if ((iDot <= 0) || (iDot > cchMaxText)) {
				fMidSentence = true;
				iDot = strText.indexOf(" ",cchMinText); 
				// if still too long then lop it at max
				if ((iDot <= 0) || (iDot > cchMaxText)) {
					iDot = cchMaxText; 
				}
			}
			// shorten text
			strText = strText.substring(0,iDot);
			if (fMidSentence) {strText += "..."; }
			strText += ' <span class="ar_more"> continued... </span> '
			strText += "</b></i></u></span>"; 
		}
		// replace pseudo-images
		strText = strText.replace(/&#40;\*&#41;/g, '<img src="bits/listdot_tiny.gif" border="0">');
		// replace pseudo-@ that hides email
		strText = strText.replace(/,,,/g, '@');

		return strText;
	}

	function makeURLsHot(txt, strClassName) {
		txt += ' ';
		var strSearch = txt;	
		var aURL = new Array();		
		var aposURL = new Array();  
		var iURL = -1;				
		var indexLastMatch = 0;		
		var regexWeb = /(((https?:\/\/www\.)|(www\.)|(https?:\/\/)|(ftp:\/\/)|(javascript:))[^< !:"\[\]]*)./i;
		var reMatch = regexWeb.exec(strSearch);
		while (reMatch) {
			iURL++;
			var strFound = reMatch[1];
			aURL[iURL] = strFound;
			aposURL[iURL] = indexLastMatch + reMatch.index;
			indexLastMatch = indexLastMatch + reMatch.index + strFound.length;
			strSearch = txt.substring(indexLastMatch,txt.length);
			reMatch = regexWeb.exec(strSearch);
		}
		
		var strMatch = '';		
		var lenMatch = 0;
		var iMatch = -1;
		var strPre = '';
		var strPost = '';
		var reHTTP = /^www/i;
		var strHTTP = '';
		var rePERIOD = /[\.\,\?]$/;
		for (var u = iURL; u >= 0; u--) {
			strMatch = aURL[u];
			strMatch = strMatch.replace(rePERIOD, '');
			lenMatch = strMatch.length;
			iMatch = aposURL[u];
			var strLinkText = strMatch;
			if (reHTTP.test(strMatch)) {
				strMatch = 'http://'+strMatch;
			}
			strPre = txt.substring(0,iMatch);
			strPost = txt.substring((iMatch+lenMatch),txt.length);
			var reBRACKET = /^ *\[/;
			if (reBRACKET.test(strPost)) {
				strPost = strPost.replace(reBRACKET, '');
				var reREALTEXT = /^.+\]/;
				if (reREALTEXT.test(strPost)) {
					var iClose = strPost.indexOf(']');
					strLinkText = strPost.substring(0,iClose);
					strPost = strPost.substring((iClose+1), strPost.length);
				}
			}
			var strTarg  = 'target="_blank"';
			if (strMatch.indexOf(gCGIPath) == 0) {
				strTarg = '';
			}
			else if (strMatch.indexOf('javascript:') == 0) {
				strTarg = '';
			}
			var strClass = 'class="urlHot"';
			if (strClassName != null) { strClass = 'class="'+strClassName+'"'; }
			var strNewLink = '<a href="'+strMatch+'"  '+strTarg+' '+strClass+'>' + strLinkText + '</a>';
			txt = strPre + strNewLink +strPost;
		}
		// replace pseudo-images
		txt = txt.replace(/&#40;\*&#41;/g, '<img src="bits/listdot_tiny.gif" border="0">');
		// replace pseudo-@ that hides email
		txt = txt.replace(/,,,/g, '@');
		
		return txt;
	}
	function extractDomain(url) {
		var i = url.indexOf("http://", 0);
		if (i >= 0) { url = url.substring(7,url.length); }
		i = url.indexOf("https://", 0);
		if (i >= 0) { url = url.substring(8,url.length); }		
		i = url.indexOf("/", 0);
		if (i >= 0) { url = url.substring(0,i); }
		return url;
	}
	function getMailAddress(strEmailFromDB) {
		var str = '';
		while (strEmailFromDB.indexOf(',,,', 0) > 0) {
			strEmailFromDB = strEmailFromDB.replace(',,,', '@');
		}
		while (strEmailFromDB.indexOf('***', 0) > 0) {
			strEmailFromDB = strEmailFromDB.replace('***', '.');
		}
		str = strEmailFromDB;
		return str;
	}
	function createMailString(strEmailFromDB) {
		var str = '';
		strEmailFromDB = getMailAddress(strEmailFromDB);
		str = 'mai'+'lto:'+strEmailFromDB;
		return str;
	}
	function showMailAddress(strEmailFromDB) {
		var str = getMailAddress(strEmailFromDB);
		if (str != '') {
			alert(str);
		}
	}
	function drawMailLink(strE) {
		if (isNotEmpty(strE)) { 
			var str = '<a href="'+createMailString(strE)+'">'+getMailAddress(strE)+'</a>';
		 	document.write(str);
		}
	}

	function getEventDateHTML(strEStart, strEEnd, nFormat) {
		var strReturn = '';
		var aD = parseMysqlDatetime(strEStart);
		var nStartYear 		= aD[0];
		var nStartMonth		= aD[1];
		var nStartDay 		= aD[2];
		var nStartHour		= aD[3];
		var nStartMinute	= aD[4];
		var nStartSecond	= aD[5];
		
		aD = parseMysqlDatetime(strEEnd);
		var nEndYear 		= aD[0];
		var nEndMonth		= aD[1];
		var nEndDay 		= aD[2];
		var nEndHour		= aD[3];
		var nEndMinute		= aD[4];
		var nEndSecond		= aD[5];
		
		var tToday = getNow();
		tToday.setHours(12);
		var nTodayDay 		= tToday.getDate();
		var nTodayMonth 	= tToday.getMonth() + 1;
		var nTodayYear 		= timeGetYear(tToday);
		var msecToday 		= tToday.getTime();
		var msecTomorrow 	= msecToday + msecOneDay;
		
		var tE1 = new Date(nStartYear,nStartMonth-1,nStartDay, nStartHour, nStartMinute, nStartSecond); 
		var msecE1 = tE1.getTime();
		var nWeekday = tE1.getDay();
		var tE2 = new Date(nEndYear,nEndMonth-1,nEndDay, nEndHour, nEndMinute, nEndSecond); 
		var msecE2 = tE2.getTime();
		var tE1DayBegins = new Date(nStartYear,nStartMonth-1,nStartDay, 0, 0, 0); 
		var msecE1DayBegins = tE1DayBegins.getTime();
		var tE2DayEnds = new Date(nEndYear,nEndMonth-1,nEndDay, 23, 59, 59); 
		var msecE2DayEnds = tE2DayEnds.getTime();

		if (nFormat == 1) {
			if ((msecToday > msecE1DayBegins) && (msecToday < msecE2DayEnds)) {
				strReturn += 'Today';				
			} else if ((msecTomorrow > msecE1DayBegins) && (msecTomorrow < msecE2DayEnds)) {
				strReturn += 'Tomorrow';										
			} else {
				strReturn += aDays[nWeekday];
			}
			strReturn += ', ';
		}

		strReturn += nStartDay + ' ' +  aMonthsShort[nStartMonth-1];
		if (nStartDay != nEndDay) {
			strReturn += ' - ' + nEndDay + ' ' + aMonthsShort[nEndMonth-1];
		}

		if (nStartDay == nEndDay) {
			if ((msecE1 == msecE1DayBegins) && (msecE2 == msecE2DayEnds)) {
				strReturn += '';		
			} else {
				strReturn += ', ';
				strReturn += getTimeString(nStartHour, nStartMinute);
				var nMins = ((nEndHour-nStartHour) * 60) + (nEndMinute-nStartMinute) + 1;
				if (nMins == 2) {
					strReturn += ' on';	
				}		
				if (nMins > 5) {
					strReturn += '-' + getTimeString(nEndHour, nEndMinute);	
				}		
			}
		}
		
		return strReturn;
	}
	
	function getNow() {
		var aNow = gServerTime.split(':');
		var nYear = parseInt(aNow[5]) + 1900;
		var tNow = new Date(nYear, aNow[4],aNow[3],aNow[2],aNow[1],aNow[0]);
		return tNow;
	}
	function getYearFromToday() {
		var tYear = getNow();
		var msecYear = tYear.getTime() + msecOneYear;
		tYear.setTime(msecYear);
		return tYear;	
	}

	function parseMysqlDatetime(datetime) {
		var aDT = new Array();
		var aD = datetime.split(' ');
		if (aD.length == 1) { aD[1] = '00:00:01'; }
		var aDateIn	= aD[0].split('-');
		var aTimeIn	= aD[1].split(':');
		aDT[0] 		= aDateIn[0];
		aDT[1]		= parseInt(aDateIn[1],10);
		aDT[2]		= parseInt(aDateIn[2],10);
		aDT[3]		= parseInt(aTimeIn[0],10);
		aDT[4]		= parseInt(aTimeIn[1],10);
		aDT[5]		= parseInt(aTimeIn[2],10);
		var tToday 			= getNow();
		var msecToday 		= tToday.getTime();
		var nMonthIn 		= aDT[1] - 1;
		var tIn				= new Date(aDT[0],nMonthIn,aDT[2],aDT[3],aDT[4],aDT[5]);
		var msecIn			= tIn.getTime();
		aDT[6]				  = msecIn - msecToday;
		
		return aDT;
	}

	function msecFromMysqlDatetime(datetime) {
		var aD = parseMysqlDatetime(datetime);
		var tDate = new Date(aD[0],(aD[1] - 1),aD[2],aD[3],aD[4],aD[5]);
		var msecDate = tDate.getTime();
		return msecDate;
	}
	function mysqlDateFromMsec(msec) {
		var tDate = new Date(msec);
		var strMysqlDate = timeGetYear(tShow) + '-' + (tDate.getMonth() + 1) + '-' + tDate.getDay();
		return strMysqlDate;
	}
	
	function timeGetYear(dateIn) {
		// IE AND NETSCAPE RETURN DIFFERENT VALUES FOR GETYEAR()!
		var yearIn = dateIn.getYear();
		if (yearIn < 1900) {yearIn += 1900;}
		return yearIn;
	}
	function getDaysInMonth(t) {
		var nReturn = 0;
		var aDaysInM = new Array(31,28,31,30,31,30,31,31,30,31,30,31);
		var iMonth = t.getMonth();
		nDays = aDaysInM[iMonth];
		if (nDays > 28) { nReturn = nDays; }
		else {
			var msect = t.getTime();
			var tNext = new Date(msect);
			tNext.setHours(0);
			tNext.setDate(1);
			tNext.setMonth(iMonth + 1);
			tNext.setDate(1);
			msect = tNext.getTime() - 120000;
			tNext.setTime(msect);
			nDays = tNext.getDate();
			nReturn = nDays;
		}
		return nReturn;
		
	}
	
	function getTimeString (nH,nM) {
		var numH = parseInt(nH,0);
		var numM = parseInt(nM,0);
		if (numM%5 != 0) { 
			numM = numM+1;
			if (numM == 60) {
				numM = 0;
				numH = numH+1; 
				if (numH == 24) {
					numH = 0;
				}
			}
		}
		
		var strReturn = '';
		var strAMPM = 'a';
		var strHour = numH;
		var strMinute = numM;
		var strExtra0 = '';

		if (numH > 11) { strAMPM = 'p'; }
		if (numM < 10) { strExtra0 = '0'; }
		if (numH == 0) { strHour = '12'; }
		else if (numH > 12) { strHour = numH - 12;}
		
		strReturn = strHour;
		if (strMinute != 0) { strReturn += ':' + strExtra0 + strMinute; }
		strReturn += '' + strAMPM;
		
		return strReturn;
	}

	function getInt(strIn) {
		if (strIn.charAt(0) == '0') {strIn = strIn.charAt(1);} //needed for parseInt bug with '08'
		strIn = parseInt(strIn);
		return strIn;
	}
	
	function isNotEmpty(val) {
		if ((val == null) || (val == '')) {
			return false;
		} else {
			return true;
		}
	}
	function isEmpty(val) {
		if ((val == null) || (val == '')) {
			return true;
		} else {
			return false;
		}
	}
	
	function randomN(N) { 
		// returns 0 to (N-1)
		return Math.floor(N*(Math.random()%1)) ;
	}
	
	function dequote( str ) {
		str = str.replace(/['"]/g, "");
		return str;
	}
	function scrubTitleForURL(str) {
		str = str.replace(/&#[0-9]+;/g, "");
		str = str.replace(/ /g, "_");
		str = str.replace(/[^a-zA-Z0-9\-\_]/g, "");
		return str;
	}
	
	function refreshPage() {
		location.reload();
	}	 
	function refreshTideline() {
		location.reload();
	}	 

	function refreshSite() {
		location.reload();
	}	 
	
	function getFooterDivider() {
		var str = ' &middot; ';
		return str;
	} 

	function getMemberLevel(nLevel) {
		return aMemberLevels[nLevel];
	}
	function getMemberLevelPlural(nLevel) {
		return aMemberLevelsPl[nLevel];
	}

//================================
//
//	MISC
//

	function idInList(id,idList) {
		var fReturn = false;
		idList += '';
		var aList = idList.split(":");
		for (var z = 0; z <= aList.length-1; z++) {
			if (id == aList[z]) {
				fReturn = true;
				break;
			}
		}
		return fReturn;
	}

	function getFileExt(urlFile) {
		var strExt = '';
		var reExt = /\.(.{2,4})$/i;
		var reMatch = reExt.exec(urlFile);
		if (reMatch) {
			strExt = reMatch[1];
			strExt = strExt.toLowerCase();
		}
		return strExt;
	}
		
	function fPNG() {
		var strUAG = navigator.userAgent;
		var fPNG = false;
		if ((strUAG.indexOf("Mozilla/5") != -1) || (strUAG.indexOf("Firefox") != -1)) { fPNG = true; }
		return fPNG;
	}
//================================
//
//	POPUP MENUS
//

	function getMenuHead(strMenuId, strText, rgbColor) {
		var str = '';
		var strStyle = ''
		if (isNotEmpty(rgbColor)) { strStyle = ' style="color:#'+rgbColor+';" '; }
		// stop ie wrap
		str += '<div class="m_header" ><a href="javascript:showMenu(\''+strMenuId+'\')" onMouseOver="showMenu(\''+strMenuId+'\')" onMouseOut="menu_t = 1; delayHide();" class="m_h_text" '+strStyle+'>'+strText+'<img src="'+gWWWPath+'bits/menu-down.gif" width="10" height="6" alt="" border="0"></a></div>';

		return str;
	}
	function getMenuCommand(strText, strJsCommand) {
		var str = '';
		str += '<a href="javascript:'+strJsCommand+'" class="m_c_text" onMouseOut="menu_t = 1; delayHide()" onMouseOver="menu_t = 2;" >'+strText+'</a>';

		return str;
	}
	function getMenuCommandSide(strText, strJsCommand, strMSStyle) {
		var str = '';
		str += '<a href="javascript:'+strJsCommand+'" class="ms_c_text" '+strMSStyle+'>'+strText+'</a><br>';

		return str;
	}
	function getMenuCommandExtra(strText, strCommand, isInternal, fOwnWindow) {
		var str = '';
		if (isInternal == 1) {
			str += '<a href="javascript:showPage(\''+strCommand+'\')" class="m_c_text" onMouseOut="menu_t = 1; delayHide()" onMouseOver="menu_t = 2;" >'+strText+'</a>';
		} else {
			if (fOwnWindow == 1) {
				str += '<a ';
				str += getWebsiteHref(strCommand);
				str += ' class="m_c_text" onMouseOut="menu_t = 1; delayHide()" onMouseOver="menu_t = 2;" >'+strText+'</a>';		
			} else {
				str += '<a ';
				str += getWebsiteHrefPlus(strCommand,1);
				str += ' class="m_c_text" onMouseOut="menu_t = 1; delayHide()" onMouseOver="menu_t = 2;" >'+strText+'</a>';					
			}	
		}
		return str;
	}
	function getMenuCommandSideExtra(strText, strCommand, isInternal, fOwnWindow, strMSStyle) {
		var str = '';
		if (isInternal == 1) {
			str += '<a href="javascript:showPage(\''+strCommand+'\')" class="ms_c_text"  '+strMSStyle+'>'+strText+'</a>';
		} else {
			if (fOwnWindow == 1) {
				str += '<a ';
				str += getWebsiteHref(strCommand);
				str += ' class="ms_c_text"  '+strMSStyle+'>'+strText+'</a>';		
			} else {
				str += '<a ';
				str += getWebsiteHrefPlus(strCommand,1);
				str += ' class="ms_c_text"  '+strMSStyle+'>'+strText+'</a>';					
			}	
		}
		str += '<br>';
		return str;
	}
	function getMenuSection(strText) {
		var str = '';
		str += '<div class="m_section" onMouseOut="menu_t = 1; delayHide()" onMouseOver="menu_t = 2;">'+strText+'</div>';

		return str;
	}
	function getMenuSectionSide(strText, strMSStyle) {
		var str = '';
		if (strText != '') { str += '<div class="ms_section" '+strMSStyle+'>'+strText+'</div>'; }

		return str;
	}
	
	// global menu variables
	var domMenu_cur = null;
	var domMenu_old = null;
	var menu_t = 0;
	var menu_lDelay = 10;
	var menu_lCount = 0;
	var menu_pause = 100;
	
	function showMenu(menuName){
		menu_t      = 2;
		domMenu_cur = getDOM(menuName,1);
		if (domMenu_old && (domMenu_old != domMenu_cur)) {
			domMenu_old.display = 'none'; 
			domMenu_old.zIndex = '0'; 
			menu_t = 2; 
			menu_lCount = 0;
		}
		domMenu_cur.display = 'block';
		domMenu_cur.zIndex = 1000;
		domMenu_old = domMenu_cur;
	}
	
	function delayHide() {
	    if ((domMenu_old) && (menu_t == 0)) {
	        domMenu_old.display = 'none'; 
	        domMenu_old.zIndex = '0';
	        domMenu_old = null;
	        menu_lCount = 0; 
	        return false;
	    }
	    if (menu_t == 2) { menu_lCount = 0; return false; }
	    if (menu_t == 1) { 
	        menu_lCount = menu_lCount + 1;
	        if (menu_lDelay <= menu_lCount) { menu_t = 0; }
	        setTimeout('delayHide()',menu_pause);
	    }
	}
		

	
//================================
//
//	COOKIES
//

	function getCookieVal (offset) {
	  var endstr = document.cookie.indexOf (";", offset);
	  if (endstr == -1)
	    endstr = document.cookie.length;
	  return unescape(document.cookie.substring(offset, endstr));
	}
	function GetCookie (name) {
	  if (gSiteId != 1) { name = gSiteId+'_'+name; }
	  var arg = name + "=";
	  var alen = arg.length;
	  var clen = document.cookie.length;
	  var i = 0;
	  while (i < clen) {
	    var j = i + alen;
	    if (document.cookie.substring(i, j) == arg)
	      return getCookieVal (j);
	    i = document.cookie.indexOf(" ", i) + 1;
	    if (i == 0) break; 
	  }
	  return null;
	}
	function SetCookieYear (name, value, path, domain, secure) {
		var dateExp = new Date();
		dateExp.setTime(dateExp.getTime() + msecOneYear);		
		SetCookie (name,value,dateExp,path,domain,secure)
	}
	function SetCookie (name,value,expires,path,domain,secure) {
	  if (gSiteId != 1) { name = gSiteId+'_'+name; }
	  document.cookie = name + "=" + escape (value) +
	    ((expires) ? "; expires=" + expires.toGMTString() : "") +
	    ((path) ? "; path=" + path : "") +
	    ((domain) ? "; domain=" + domain : "") +
	    ((secure) ? "; secure" : "");
	}
	function DeleteCookie (name,path,domain) {
	  if (gSiteId != 1) { name = gSiteId+'_'+name; }
	  if (GetCookie(name)) {
	    document.cookie = name + "=" +
	      ((path) ? "; path=" + path : "") +
	      ((domain) ? "; domain=" + domain : "") +
	      "; expires=Thu, 01-Jan-70 00:00:01 GMT";
	  }
	}
	function acceptsCookies() {
		var fReturn = false;
		SetCookie('testAccept','35s6');
		var nVal = GetCookie('testAccept');
		fReturn = (nVal == '35s6');
		return fReturn
	}
	
//================================
//
//	DOM
//
var isID = 0;
var isAll = 0;
if (document.getElementById) {isID  = 1; }
if (document.all) 			 {isAll = 1; }

	function getDOM(objID,fStyle) {
		if (fStyle == 1) {
			if (isID) 		{ if ( document.getElementById(objID)) { return (document.getElementById(objID).style); } }
			else if (isAll) {return (document.all[objID].style);}
			else 			{return null; }
		}
		else {
			if (isID) 		{ if ( document.getElementById(objID)) { return (document.getElementById(objID)); } }
			else if (isAll) {return (document.all[objID]);}
			else 			{return null; }
		}
	}
	function getLeft(objID){
		var dom = getDOM(objID,0);
		var domStyle = getDOM(objID,1);
		if (domStyle.pixelLeft) return domStyle.pixelLeft;
		else if (domStyle.left) return domStyle.left;
		else if (dom.offsetLeft) return dom.offsetLeft;
		return (null);
	}
	function getTop(objID){
		var dom = getDOM(objID,0);
		var domStyle = getDOM(objID,1);
		if (domStyle.pixelTop) return domStyle.pixelTop;
		else if (domStyle.top) return domStyle.top;
		else if (dom.offsetTop) return dom.offsetTop;
		return (null);
	}

	function getMouseX(evt) {
		var x = -1;
		if (evt.x) 		{ x = evt.x + findScrollLeft();}
		if (evt.pageX) 	{ x = evt.pageX; }
		return x;
	}
	function getMouseY(evt) {
		var y = -1;
		if (evt.y) 		{ y = evt.y + findScrollTop(); }
		if (evt.pageY) 	{ y = evt.pageY;  }
		return y;
	}
	function findScrollLeft() {
		if (window.pageXOffset != null)
			return window.pageXOffset; 
		if (document.body.scrollLeft != null)
			return document.body.scrollLeft;
		return (null);
	}
	
	function findScrollTop() {
		if (window.pageYOffset != null)
			return window.pageYOffset;
		if (document.body.scrollHeight != null)
			return document.body.scrollTop;
		return (null);
	}
	function scrollToDiv(objID) {
		var d = getDOM(objID,0);
		var n = 0;
		if (d.offsetParent) {
			n = d.offsetTop;
			while (d.offsetParent) { 
				d = d.offsetParent;	
				if (d.offsetTop) {
					n += d.offsetTop;
				}
			}
		scrollTo(0,n);
		}
	}
