//================================
//
//	GLOBAL SITE SETTINGS
//
//================================
	// 	-- server paths
	var gWWWPath = "http://www.oregonwool.com/"					// path to www folder
	var gWWWPathSecure = "https://www.oregonwool.com/"		// secure path to www folder
 	var gCGIPath = "http://www.oregonwool.com/cgi-bin/";	    // cgi server path
 	var gCGIPathSecure = "https://www.oregonwool.com/cgi-bin/";	// secure cgi server path
	var gPhotoPath = "/farmpix";
	var gPhotoPathBreeds = "/breedpix";
	var gPhotoPathArticles = "/articles";
	//	-- time arrays
	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 msecOneDay = 86400000;
	var msecOneYear = 31536000000;
	//	-- defaults
	var gDefaultDaysBeforeNoticeExpires = 30;	
	//	-- email
	var gstrEmailSuffix = '@oregonwool.com';
	// 	-- settings
	var gnMaxDaysStillNew = 30;
	var gnMaxThumbnailsOnFarmPage = 8;
	var gnMaxThumbnailsOnArticles = 16;
	var gnMaxThumbnailsOnProductBrowsing = 16;
	var gnSampleFarmLabel = '(Sample&nbsp;Membership)';
	//	-- globals
	var aAnimals = new Array("Alpaca","Goat","Llama","Rabbit","Sheep");

	// 	-- base href tags
	function setBaseHref() 		 { document.writeln('<base href="'+gWWWPath+'">'); }
	function setBaseHrefSecure() { document.writeln('<base href="'+gWWWPathSecure+'">'); }


//================================
//
//	SHOW MAIN WINDOWS and DIALOGS
//
//================================
	// MAIN WINDOW
	function forceframe() {
		if ((self.location == top.location) && (location.protocol != "file:")) {
			location.href = "/index.html?page=" + escape(self.location);
		}
		if (self.location != top.location) {
			top.document.title = self.document.title;
		}	
	}
	function showHome() {
		top.frmMain.location = gCGIPath + 'woolnet_home.cgi';
	}
	function showProduct(idProduct, fInMain) {
		if (fInMain == 1) {
			top.frmMain.location = gCGIPath + "woolnet_show_product.cgi?T=1&ID="+idProduct;
		} else {
			var strCGI = "woolnet_show_product.cgi?T=0&ID="+idProduct;
			showDialogCGI("ViewProd",640,600,strCGI);
		}
	}
	function showInquiryHistory(idFarm, nStart) {
		var strCGI = "woolnet_show_inquiries.cgi?ID="+idFarm+'&NSTART='+nStart;
		showDialogCGI("ViewInquiryHistory",640,500,strCGI);
	}
	function visitFarm(idFarm) {
		//if (idFarm == 1) {
		//	editFarmPassword(1);
		//} else {
			//location.href = gCGIPath + 'woolnet_show_member.cgi?ID='+idFarm;
			top.frmMain.location = gCGIPath + 'woolnet_show_member.cgi?ID='+idFarm;
		//}
	}
	function showFarmList(idType,nSort) {
		idType = parseInt(idType);
		nSort = parseInt(nSort);
		if (idType <= 0) { idType = 1; }
		if ((nSort <= 0) || (nSort > 3)) { nSort = 1; }
		top.frmMain.location = gCGIPath + 'woolnet_show_memberlist.cgi?TYPE='+idType+'&SORT='+nSort;
	}
	function showFarmMap(idType) {
		idType = parseInt(idType);
		if (idType <= 0) { idType = 1; }
		top.frmMain.location = gCGIPath + 'woolnet_show_membermap.cgi?TYPE='+idType;
	}
	function showProductList(idCategoryType,idSubCategory) {
		top.frmMain.location = gCGIPath + 'woolnet_show_p_catlist.cgi?TYPE='+idCategoryType+'&SHOWSUBCAT='+idSubCategory;
	}
	function showBreeds() {
		top.frmMain.location = gCGIPath + 'woolnet_show_breeds.cgi';
	}
	function showBreedInfo(idBreed) {
		var strCGI = "woolnet_show_breedinfo.cgi?ID="+idBreed;
		showDialogCGI("ViewBreed",640,600,strCGI);
	}
	function showArticles(iStart,nShow,nStatus) {
		top.frmMain.location = gCGIPath + 'woolnet_show_articles.cgi?ISTART='+iStart+'&NSHOW='+nShow+'&S='+nStatus;
	}
	function showArticle(id) {
		var strCGI = 'woolnet_show_article.cgi?ID='+id;
		showDialogCGI("ViewArticle",530,700,strCGI);
	}
	function showArticlePrint(id) {
		var strCGI = 'woolnet_show_article_print.cgi?ID='+id;
		showWindowCGI("ViewArticleForPrinting",530,700,strCGI);
	}
	function showNewsletters() {
		top.frmMain.location = gCGIPath + 'woolnet_show_newsletters.cgi';
	}
	function showNewsletter(id, fOwnWindow) {
		if (fOwnWindow) {
			var strCGI = 'woolnet_show_newsletter.cgi?ID='+id+'&M=0';
			showWindowCGI("ViewNewsletterForPrinting",530,700,strCGI);
		} else {
			top.frmMain.location = gCGIPath + 'woolnet_show_newsletter.cgi?ID='+id+'&M=1';
		}
	}
	function showLinks() {
		top.frmMain.location = gCGIPath + 'woolnet_show_links.cgi';
	}
	function showStats() {
		top.frmMain.location = gCGIPath + 'woolnet_admin_show_stats.cgi';
	}
	function showPrivacyPolicy() {
		showDialog("EditFarmInfo",390,500,"privacy_policy.html");
	}
	function viewMembershipForm() {
		var wndNew = wndOpenNewWindow('wndMembershipForm',670,600);
		if (wndNew != null) {
			wndNew.location = gWWWPath+'membership_form.html';
			wndNew.focus();
		} else {
			alert("Sorry, the Membership Form could not be opened. Please try again. If you continue having troubles, please let us know. Thank you.");
		}
	}
	function popToFarm(idFarm) {
		if (opener != null) {
			opener.visitFarm(idFarm);
			opener.focus();
			//window.close();
		} else {
			//open in this window
			visitFarm(idFarm);
		}
	}

	// SEARCHING
	function showSearch(strS,idRealm) {
		if (strS == null) { strS = ''; }
		else { strS = escape(strS); }
		top.frmMain.location = gCGIPath + 'woolnet_show_search.cgi?SEARCH='+strS+'&REALM='+idRealm;
	}
	function checkSearch(frm) {
		if (frm.SEARCH.value == '') { alert("Please enter something to search for."); return false; }
		else {	frm.action = gCGIPath+"woolnet_show_search.cgi"; }
	}
		

	//	DIALOGS
	
	// 		-- stats
	function chartStats(strType, id) {
		var strCGI = "woolnet_show_statschart.cgi?V="+strType+"&ID="+id;
		showDialogCGI("StatChart",680,400,strCGI);
	}
	
	// 		-- admin
	function sendSpecialEmail() {
		var strCGI = "woolnet_dlg_email_special.cgi";
		showDialogCGI("SpecialEmail",590,680,strCGI);
	}
	function adminMembership() {
		var strCGI = "woolnet_dlg_admin_members.cgi";
		showDialogCGI("AdminNewsletter",590,620,strCGI);
	}
	function adminSiteOptions() {
		var strCGI = "woolnet_dlg_admin_site.cgi";
		showDialogCGI("AdminNewsletter",590,620,strCGI);
	}

	//		-- newsletters
	function createBackIssueNewsletter(id) {
		var fOK = confirm('Do you want to create this newsletter now?');
		if (fOK) {
			var strCGI = "woolnet_submit_news_backissue.cgi?ID="+id;
			showDialogCGI("CreatePastIssue",590,400,strCGI);
		}
	}
	function editNewsletter(id) {
		var strCGI = "woolnet_dlg_news_edit.cgi?ID="+id;
		showDialogCGI("EditNewsletter",590,600,strCGI);
	}
	function deleteNewsletter(id) {
		var fOK = confirm('Are you sure you want to DELETE this newsletter? It can NOT be restored exactly the same later.');
		if (fOK) {
			var strCGI = "woolnet_submit_news_del.cgi?ID="+id;
			showDialogCGI("DeleteNewsletter",590,330,strCGI);
		}
	}
	function adminSubscriptions() {
		var strCGI = "woolnet_dlg_admin_subscriptions.cgi";
		showDialogCGI("AdminSubscriptions",590,620,strCGI);
	}
	function adminNewsletter() {
		var strCGI = "woolnet_dlg_admin_news.cgi";
		showDialogCGI("AdminNewsletter",590,620,strCGI);
	}

	//		-- subscriptions
	function addSubscriptions() {
		var strCGI = "woolnet_dlg_subscribe.cgi";
		showDialogCGI("OptSubscriptions",590,640,strCGI);
	}
	function deleteSubscriptions() {
		var strCGI = "woolnet_dlg_subscribe_x.cgi";
		showDialogCGI("OptSubscriptions",590,360,strCGI);
	}

	//	-- Farm dialogs
	function addFarm() {
		var strCGI = "woolnet_dlg_member_new.cgi";
		showDialogCGI("NewFarm",590,600,strCGI);
	}
	function editFarm(idFarm) {
		var strCGI = "woolnet_dlg_member_edit.cgi?ID="+idFarm;
		showDialogCGI("EditFarmInfo",590,560,strCGI);
	}
	function editFarmName(idFarm) {
		var strCGI = "woolnet_dlg_member_rename.cgi?ID="+idFarm;
		showDialogCGI("EditFarmName",590,340,strCGI);
	}
	function editFarmMapPin(idFarm) {
		var strCGI = "woolnet_dlg_member_mappin.cgi?ID="+idFarm;
		showDialogCGI("EditFarmMapLocation",590,640,strCGI);
	}
	function editFarmPassword(idFarm) {
		var strCGI = "woolnet_dlg_member_password.cgi?ID="+idFarm;
		showDialogCGISecure("EditFarmPassword",590,460,strCGI);
	}
	function upgradeMembership(idFarm) {
		var fOK = confirm('Upgrade this membership to FULL MEMBERSHIP? This will make it visible to the public and other members.');
		if (fOK) {
			var strCGI = "woolnet_submit_member_membership.cgi?ID="+idFarm+"&STATUS=1";
			showDialogCGI("ChangeFarmMembership",590,300,strCGI);
		}
	}
	function downgradeMembership(idFarm) {
		var fOK =  confirm('Downgrade this membership to SAMPLE MEMBERSHIP? This will hide it and all it\'s products from the public and other members.');
		if (fOK) {
			var strCGI = "woolnet_submit_member_membership.cgi?ID="+idFarm+"&STATUS=2";
			showDialogCGI("ChangeFarmMembership",590,300,strCGI);
		}
	}
	function archiveFarm(idFarm) {
		var fOK = confirm('Are you sure you want to archive this member? It\'s listing and all it\'s products will no longer show up.');
		if (fOK) {
			var strCGI = "woolnet_submit_member_archive.cgi?ID="+idFarm;
			showDialogCGI("ArchiveFarm",590,300,strCGI);
		}
	}
	function unarchiveFarm(idFarm) {
		var strCGI = "woolnet_dlg_member_unarchive.cgi";
		showDialogCGI("UnarchiveFarm",590,360,strCGI);
	}
	//	-- Product dialogs
	function addProduct(idFarm) {
		var strCGI = "woolnet_dlg_product_new.cgi?FARMID="+idFarm;
		showDialogCGI("NewProd",590,820,strCGI);
	}
	function editProduct(idProduct) {
		var strCGI = "woolnet_dlg_product_edit.cgi?ID="+idProduct;
		showDialogCGI("EditProd",590,820,strCGI);
	}
	function delProduct(idProduct) {
		var fOK = confirm('Are you sure you want to DELETE this product?');
		if (fOK) {
			var strCGI = "woolnet_submit_product_del.cgi?ID="+idProduct;
			showDialogCGI("DelProd",590,300,strCGI);
		}
	}
	function moveProductUp(idProduct) {
		var strCGI = "woolnet_submit_product_move.cgi?ID="+idProduct+"&JUMP=-1";
		showDialogCGI("MoveProduct",590,300,strCGI);
	}
	function moveProductDown(idProduct) {
		var strCGI = "woolnet_submit_product_move.cgi?ID="+idProduct+"&JUMP=1";;
		showDialogCGI("MoveProduct",590,300,strCGI);
	}
	function arrangeProducts(idFarm) {
		var strCGI = "woolnet_dlg_productlist_arrange.cgi?ID="+idFarm;
		showDialogCGI("MoveProduct",590,800,strCGI);
	}
	//	-- Categories dialogs
	function addCategory() {
		var strCGI = "woolnet_dlg_category_new.cgi";
		showDialogCGI("NewCategory",590,560,strCGI);
	}
	function editCategory(idCat) {
		var strCGI = "woolnet_dlg_category_edit.cgi?ID="+idCat;
		showDialogCGI("EditCategory",590,560,strCGI);
	}
	function delCategory(idCat) {
		var fOK = confirm('Are you sure you want to DELETE this category?');
		if (fOK) {
			var strCGI = "woolnet_submit_category_del.cgi?ID="+idCat;
			showDialogCGI("DelCategory",590,300,strCGI);
		}
	}
	function addSubCategory() {
		var strCGI = "woolnet_dlg_producttype_new.cgi";
		showDialogCGI("NewPType",590,560,strCGI);
	}
	function editSubCategory(idType) {
		var strCGI = "woolnet_dlg_producttype_edit.cgi?ID="+idType;
		showDialogCGI("EditPType",590,560,strCGI);
	}
	function delSubCategory(idType) {
		var fOK = confirm('Are you sure you want to DELETE this sub-category?');
		if (fOK) {
			var strCGI = "woolnet_submit_producttype_del.cgi?ID="+idType;
			showDialogCGI("DelPType",590,300,strCGI);
		}
	}
	//	-- Breed dialogs
	function addBreed() {
		var strCGI = "woolnet_dlg_breed_new.cgi";
		showDialogCGI("NewBreed",590,500,strCGI);
	}
	function editBreed(idBreed) {
		var strCGI = "woolnet_dlg_breed_edit.cgi?ID="+idBreed;
		showDialogCGI("EditBreed",590,500,strCGI);
	}
	
	//		-- articles
	function addArticle(nCategory) {
		var strCGI = "woolnet_dlg_article_new.cgi?CAT="+nCategory;
		showDialogCGI("NewArticle",590,670,strCGI);
	}
	function editArticle(id) {
		var strCGI = "woolnet_dlg_article_edit.cgi?ID="+id;
		showDialogCGI("EditArticle",590,670,strCGI);
	}
	function deleteArticle(id) {
		var fOK = confirm('Are you sure you want to DELETE this? Readers will no longer be able to see it.');
		if (fOK) {
			var strCGI = "woolnet_submit_article_del.cgi?ID="+id;
			showDialogCGI("DeleteArticle",590,300,strCGI);
		}
	}
	function deleteArticleDirect(id) {
		var strCGI = "woolnet_submit_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 = "woolnet_submit_article_undel.cgi?ID="+id;
			showDialogCGI("UndeleteItem",590,300,strCGI);
		}
	}
	function undeleteArticleDirect(id) {
		var strCGI = "woolnet_submit_article_undel.cgi?ID="+id;
		showDialogCGI("UndeleteArticle",590,300,strCGI);
	}
	function addArticleType() {
		var strCGI = "woolnet_dlg_articletype_new.cgi";
		showDialogCGI("NewArticleType",590,360,strCGI);
	}
	function editArticleType(id) {
		var strCGI = "woolnet_dlg_articletype_edit.cgi?ID="+id;
		showDialogCGI("EditArticleType",590,360,strCGI);
	}
	function deleteArticleType(id) {
		var fOK = confirm('Are you sure you want to DELETE this article CATEGORY?');
		if (fOK) {
			var strCGI = "woolnet_submit_articletype_del.cgi?ID="+id;
			showDialogCGI("DeleteArticleType",590,300,strCGI);
		}
	}
	function emailArticle(id) {
		var strCGI = "woolnet_dlg_article_email.cgi?ID="+id;
		showDialogCGI("EmailArticle",590,460,strCGI);
	}
	function adminArticles() {
		var strCGI = "woolnet_dlg_admin_articles.cgi";
		showDialogCGI("AdminArticle",590,620,strCGI);
	}
	function adminAttachments() {
		var strCGI = "woolnet_dlg_admin_attachments.cgi";
		showDialogCGI("AdminAttach",590,700,strCGI);
	}


	function orderArticles(n) {
		SetCookieYear('articleOrder',n,"/");
		location.reload();
	}

	//	-- Link dialogs
	function addLinkType() {
		var strCGI = "woolnet_dlg_linktype_new.cgi";
		showDialogCGI("NewLinkType",590,500,strCGI);
	}
	function editLinkType(idLink) {
		var strCGI = "woolnet_dlg_linktype_edit.cgi?ID="+idLink;
		showDialogCGI("EditLinkType",590,500,strCGI);
	}
	function addLink(idLink) {
		var strCGI = "woolnet_dlg_link_new.cgi";
		showDialogCGI("NewLink",590,500,strCGI);
	}
	function editLink(idLink) {
		var strCGI = "woolnet_dlg_link_edit.cgi?ID="+idLink;
		showDialogCGI("EditLink",590,500,strCGI);
	}
	function delLink(idLink) {
		var fOK = confirm('Are you sure you want to delete this link?');
		if (fOK) {
			var strCGI = "woolnet_submit_link_del.cgi?ID="+idLink;
			showDialogCGI("DeleteLink",590,300,strCGI);
		}
	}
	//	-- Event dialogs
	function addEvent(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 = "woolnet_dlg_event_new.cgi?DATE=" + nDay + ":"+ nMonth + ":"+ nYear;
		showDialogCGI("NewEvent",590,560,strCGI);
	}
	function noaddEvent () {
	
	}
	function editEvent(idEvent) {
		var strCGI = "woolnet_dlg_event_edit.cgi?ID="+idEvent;
		showDialogCGI("EditNotice",590,560,strCGI);
	}
	function deleteEvent(idEvent) {
		var strCGI = "woolnet_dlg_event_del.cgi?ID="+idEvent;
		showDialogCGI("DeleteEvent",590,300,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 = "woolnet_submit_event_undel.cgi?ID="+id;
			showDialogCGI("UndeleteItem",590,300,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
	
	//	-- show website
	function showWebsite(strURL) {
		if (strURL.indexOf("http") < 0) {
			strURL = "http://" + strURL;
		}
		var dy = screen.height - 200;
		var strParams = "status,toolbar,menubar,location,scrollbars,resizable,width=500,height=500";
		var wndNew = window.open("","wndWebsite",strParams);
		wndNew.moveTo(10,10);
		wndNew.location = strURL;
		wndNew.focus();
	}
	function showWebsitePlus(strURL,IsInternalLink) {
		if (IsInternalLink == 0) {
			top.frmMain.location = strURL;
		} else {
			showWebsite(strURL);
		}
	}
	
// =======================
//
//	ADMIN FEATURES
//
// =======================	
	
	// SignIn
	function signIn() {
		var strCGI = "woolnet_dlg_signin.cgi";
		showDialogCGISecure("SignIn",590,430,strCGI);
	}
	function signOut() {
		var strCGI = "woolnet_submit_signout.cgi";
		top.document.location = gCGIPath+strCGI;
	}
	function loginExpired() {
		top.document.location = gWWWPath+'index.html';
	}
	//	-- admin command dialogs
	function adminCommand(iCommand) {
		var urlCGI = '';
		if (iCommand == 1) { urlCGI = gCGIPath+"admin_show_sessions.cgi"; }
		else if (iCommand == 3) { urlCGI = gCGIPath+"admin_checktmpdir.cgi"; }
		
		if (urlCGI != '') {
			var wndNew = wndOpenNewWindow("AdminTool",600,600);
			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 {
			alert("Sorry, you requested a command that doesn't exist. Command ID ="+iCommand);
		}
	}
	function getEdDot() {
		var strR = '';
		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;">';
		return strR;
		
	}


//================================
//
//	PRODUCT FUNCTIONS
//
//================================

	function togglePopOpen(id){
		var d = getDOM(id,1);
		if (d.display == "block") { 
			d.display = "none";
		} else {
			d.display = "block";		
		}
	}
	function addPhotoPath (strPhotoName, idFarm) {
		if (strPhotoName != '') {
			strPhotoName = gPhotoPath+'/farm'+idFarm+'/'+strPhotoName;
		}
		return strPhotoName;
	}
	function showFarmThumb(idFarm, urlPhotoToShow) {
		var str = '';
		var idImgDiv = 'img_f'+idFarm;
		str = '<img src="'+urlPhotoToShow+'" width="64" alt="view details..." title="view details..." border="0" onclick="visitFarm('+idFarm+')"  class="pixClick">';
		var dom 	 = getDOM(idImgDiv,0);
		dom.innerHTML = str;
	}
	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;
	}
	function showArticleThumb(id, urlPhotoToShow) {
		var str = '';
		var idImgDiv = 'img_p'+id;
		str = '<img src="'+urlPhotoToShow+'" width="64" alt="view details..." title="view details..." border="0" onclick="showArticle('+id+')"  class="pixClick">';
		var dom 	 = getDOM(idImgDiv,0);
		dom.innerHTML = str;
	}
		

//================================
//
//	TEXT, NUMBER AND DATE FUNCTIONS
//
//================================

	// ---------------------------------------------
	// CHECK THAT PASSWORD IS VALID
	// 		checks password for errors
	function passwordError(strPass, strPasswordType) {
		var fError = false;
		var reIllegals = /[^a-zA-Z0-9\!\#\$\?]/;
		var reNonLetter = /[^a-zA-Z]/;
		// empty
		if (strPass == '') {
			alert ("Your "+strPasswordType+" password can't be empty. Please try again.");
			fError = true;
		} else 
		// too few characters
		if (strPass.length < 6) {
			alert ("Your "+strPasswordType+" password must have at least 6 characters. Please try again.");
			fError = true;		
		} else
		// too many
		if (strPass.length > 20) {
			alert ("Your "+strPasswordType+" password must have at fewer than 20 characters. Please try again.");
			fError = true;		
		} else
		// disallowed characters
		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
		// all letters
		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;
	}
	
	// ---------------------------------------------
	// SHORTEN TEXT
	//
	//
	function shortenText(szText) {
		while (szText.indexOf('<br><br>', 0) > 0) {
			szText = szText.replace('<br><br>', '<br>');
		}
		var cchMinText = 100;
		var cchMaxText = 260;
		var cchText = szText.length;
		var fMidSentence = false;
		var fTruncText = (cchText > cchMaxText);
		if (fTruncText) {
			// find first period after min
			var iDot = szText.indexOf(".", cchMinText) + 1;
			// else find first space after min
			if (iDot <= 0) {
				iDot = szText.indexOf(" ",cchMinText); 
				fMidSentence = true;
			}
			// shorten text
			szText = szText.substring(0,iDot);
			if (fMidSentence) {szText += "..."; }
			szText += ' <span class="moretext">(more...)</span> '
		}
		return szText;
	}

	// ---------------------------------------------
	// MAKE HYPERLINKS
	// 		looks through a string for website urls...if found turns into hyperlink before displaying
	//		-- looks for www. or http:// or https:// to start
	//		-- finds all urls
	//		-- then works backwards through string to add <a href="[foundurl]">[foundurl]</a> 
	function makeURLsHot(txt, strClassName) {
		// PART 1: SEARCH
		// init search vars
		txt += ' ';
		var strSearch = txt;	// this is string to search...shorten each time to remaining unsearched portion of the string
		var aURL = new Array();		// array of urls found
		var aposURL = new Array();  // array of url positions in txt
		var iURL = -1;				// index of current found url
		var indexLastMatch = 0;		// keeps track of where last match was 
		// create search reg ex
		var regexWeb = /(((https?:\/\/www\.)|(www\.)|(https?:\/\/)|(ftp:\/\/))[^< !:'"\)\]]*)./i;
		// do first search
		var reMatch = regexWeb.exec(strSearch);
		while (reMatch) {
			// found one -- save results
			iURL++;
			var strFound = reMatch[1];
			aURL[iURL] = strFound;
			aposURL[iURL] = indexLastMatch + reMatch.index;
			indexLastMatch = indexLastMatch + reMatch.index + strFound.length;
			// change search string to remaining part of string
			strSearch = txt.substring(indexLastMatch,txt.length);
			reMatch = regexWeb.exec(strSearch);
		}
		
		// PART 2: PUT IN HOT LINKS
		var strMatch = '';		
		var lenMatch = 0;
		var iMatch = -1;
		var strPre = '';
		var strPost = '';
		var reHTTP = /^http/i;
		var strHTTP = '';
		var rePERIOD = /\.$/;
		for (var u = iURL; u >= 0; u--) {
			// get url string
			strMatch = aURL[u];
			// remove trailing period if there is one (end of sentence)
			strMatch = strMatch.replace(rePERIOD, '');
			// figure position to put in link
			lenMatch = strMatch.length;
			iMatch = aposURL[u];
			// add http:// if not already in url
			if (!reHTTP.test(strMatch)) {
				strMatch = 'http://'+strMatch;
			}
			// put in link
			strPre = txt.substring(0,(iMatch+lenMatch));
			strPost = txt.substring((iMatch+lenMatch),txt.length);
			txt = strPre + '</a>' + strPost;
			strPre = txt.substring(0,iMatch);
			strPost = txt.substring(iMatch,txt.length);
			txt = strPre + '<a href="'+strMatch+'" target="_blank" class="'+strClassName+'">' + strPost;
		}
		// return result
		return txt;
	}

	// ---------------------------------------------
	// GET EVENT DATE HTML STRING
	// 		-- new mySQL date version
	//		-- strEStart and strEEnd format: 2003-06-28 09:00:00
	//		-- nFormat 
	//				1=long   ex: Wednesday, 31 May, 9:00a-2:00p
	//				0=short  ex: 31 May, 9:00a-2:00p
	function getEventDateHTML(strEStart, strEEnd, nFormat) {
		strReturn = '';

		//
		//	1. CALCULATE DATA
		//
		
		// get start date pieces
		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];
		
		// get end date pieces
		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];
		
		// 		-- today
		var tToday = new Date();
		tToday.setHours(12);
		var nTodayDay 		= tToday.getDate();
		var nTodayMonth 	= tToday.getMonth() + 1;
		var nTodayYear 		= timeGetYear(tToday);
		var msecToday 		= tToday.getTime();
		var msecTomorrow 	= msecToday + msecOneDay;
		
		// 		-- tE1: exact start time of event to the second
		var tE1 = new Date(nStartYear,nStartMonth-1,nStartDay, nStartHour, nStartMinute, nStartSecond); 
		var msecE1 = tE1.getTime();
		var nWeekday = tE1.getDay();
		
		// 		-- tE2: exact end time of event to the second
		var tE2 = new Date(nEndYear,nEndMonth-1,nEndDay, nEndHour, nEndMinute, nEndSecond); 
		var msecE2 = tE2.getTime();

		//		-- tE1DayBegins: first second in the day the event starts, for date comparisions
		var tE1DayBegins = new Date(nStartYear,nStartMonth-1,nStartDay, 0, 0, 0); 
		var msecE1DayBegins = tE1DayBegins.getTime();
		
		//		-- tE2DayEnds: last second in the day the event ends, for date comparisions
		var tE2DayEnds = new Date(nEndYear,nEndMonth-1,nEndDay, 23, 59, 59); 
		var msecE2DayEnds = tE2DayEnds.getTime();
		
		//
		//	2. BUILD STRING
		//
		
		// 		2a: TODAY, TOMORROW or DAYNAME
		//		-- only for long format
		if (nFormat == 1) {
			if ((msecToday > msecE1DayBegins) && (msecToday < msecE2DayEnds)) {
				strReturn += 'Today';				
			} else if ((msecTomorrow > msecE1DayBegins) && (msecTomorrow < msecE2DayEnds)) {
				strReturn += 'Tomorrow';										
			} else {
				strReturn += aDays[nWeekday];
			}
			strReturn += ', ';
		}
		// 		2b: DAY MONTH or DAY MONTH - DAY MONTH
		//		-- ex: 31 May 
		//		-- ex: 9 May - 12 May
		//		-- ex: 31 May - 2 Jun
		strReturn += nStartDay + ' ' +  aMonthsShort[nStartMonth-1];
		if (nStartDay != nEndDay) {
			strReturn += ' - ' + nEndDay + ' ' + aMonthsShort[nEndMonth-1];
		}
		// 		2c: HOUR:MIN A/P - HOUR:MIN A/P  or 'All Day'
		//		-- "All Day" if starts at midnight and ends one second before next midnight
		//		-- else 9:15a-10:30a format
		if (nStartDay == nEndDay) {
			if ((msecE1 == msecE1DayBegins) && (msecE2 == msecE2DayEnds)) {
				strReturn += ', all day';		
			} else {
				strReturn += ', ';
				strReturn += getTimeString(nStartHour, nStartMinute);
				var nMins = ((nEndHour-nStartHour) * 60) + (nEndMinute-nStartMinute);
				if (nMins > 5) {
					strReturn += '-' + getTimeString(nEndHour, nEndMinute);	
				}		
			}
		}
		
		return strReturn;
	}
	
	// PARSE MYSQL DATETIME
	// 		-- new mySQL date version
	//		-- mysql datetime format: 2003-06-28 09:00:00
	//		-- returns an array of pieces
	//				[0] = year
	//				[1] = month
	//				[2] = day
	//				[3] = hour
	//				[4] = minute
	//				[5] = seconds
	//				[6] = msecs from now ... negative if in the past
	function parseMysqlDatetime(datetime) {
		var aDT = new Array();

		// get start date pieces
		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);
		
		// determine msecs from now()
		var tToday 			= new Date();
		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 timeGetYear(dateIn) {
		// IE AND NETSCAPE RETURN DIFFERENT VALUES FOR GETYEAR()!
		var yearIn = dateIn.getYear();
		if (yearIn < 1900) {yearIn += 1900;}
		return yearIn;
	}
	
	function getTimeString (nH,nM) {
	
		var numH = parseInt(nH,0);
		var numM = parseInt(nM,0);
		
		// round up times that aren't given in 5 minute increments;
		// this will apply mainly to ending times; 
		// 3:00-5:00pm instead of 3:00-4:59p, for example.
		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 + ':' + strExtra0 + strMinute + '' + strAMPM;
		
		return strReturn;
	}

	function getTimeOfDay(tIn) {
		var i;
		var aT = new Array();
		if (tIn == '0') {
			var myDate = new Date();
			myDate = getCortesTime(myDate);
			tIn = ((myDate.getHours()) * 100) + myDate.getMinutes();
		} else {
			aT = tIn.split(":");
			tIn = (getInt(aT[0]) * 100) + getInt(aT[1]);
		}
		var gtimeSunrise = '7:18';
		var gtimeSunset = '16:35';
		aT = gtimeSunrise.split(":");
		var tRise = (getInt(aT[0]) * 100) + getInt(aT[1]);
		aT = gtimeSunset.split(":");
		var tSet = (getInt(aT[0]) * 100) + getInt(aT[1]);
		// night or dusk?
		if 			(tIn < tRise - 45)		{ i = 0; } //pre-dawn
		else if 	(tIn < tRise + 45) 		{ i = 1; } //dawn
		else if 	(tIn < 1200) 			{ i = 2; } //morning
		else if 	(tIn < tSet - 45) 		{ i = 3; } //afternoon
		else if 	(tIn < tSet + 45) 		{ i = 4; } //dusk
		else 								{ i = 5; } //night
		return i;
	}
	
	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 a random number from 0...(N-1) inclusive
		return Math.floor(N*(Math.random()%1)) ;
	}
	
	function dequote( str ) {
		str = str.replace(/['"]/g, "");
		return str;
	}
	function requote( str ) {
		str = str.replace(/&#34;/g, '"');
		str = str.replace(/&#39;/g, "'");
		return str;
	}
	
	function trimStringCenter (strIn, cchMax) {
		var strReturn = strIn;
		var sep = '...';
		if (strIn.length > cchMax) {
			var cch = strIn.length;
			var cchLeft = parseInt((cchMax * 2) / 3);
			var cchRight = cchMax - cchLeft - 3;
			var strLeft = strIn.substring(0,cchLeft);
			var cchStartRight = cch - cchRight;
			var strRight = strIn.substring(cchStartRight, cch);
			strReturn = strLeft + sep + strRight;
		}
		return strReturn;
	}

	function refreshPage() {
		location.reload();
	}	 
	function refreshSite() {
		top.location.reload();
	}	 
	
	function getFooterDivider() {
		var str = '<span class="footerdivider"><img src="/bits/footer_dot.gif" width="6" height="6" alt="" border="0"></span>';
		return str;
	} 


//================================
//
//	MISC
//
//================================

	function drawMA(strMA) {
		 var str = '';
		 while (strMA.indexOf(',,,', 0) > 0) {
		  	strMA= strMA.replace(',,,', '@');
		 }
		 while (strMA.indexOf('***', 0) > 0) {
		  	strMA= strMA.replace('***', '.');
		 }
		 str = '<a href="'+'mai';
		 str += 'lt'+'o:'+strMA+'">'+strMA+'</a>';
		 document.writeln(str);
	}
	function unscrubEmail(strMA) {
		 var str = '';
		 while (strMA.indexOf(',,,', 0) > 0) {
		  	strMA= strMA.replace(',,,', '@');
		 }
		 while (strMA.indexOf('***', 0) > 0) {
		  	strMA= strMA.replace('***', '.');
		 }
		 return strMA;
	}

	// ---------------------------------------------
	// IDinList
	//		-- general function that looks for a match to id in a list of ids
	//		-- id list format: id:id:id:id
	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;
	}

	
//================================
//
//	POPUP MENUS
//
//================================
	
		//		-- TO SHOW A MENU: 
		//			<a href="javascript:showMenu('menu_id_name')" onMouseOut="menu_t = 1; delayHide()">Link name <img src="arrow3.gif" width="10" height="5" alt="" border="0"></a><br>
		//		-- EACH MENU COMMAND: 
		//			<a href="javascript:foo()" class="menuLink" onMouseOut="menu_t = 1; delayHide()" onMouseOver="menu_t = 2;"  onClick="menu_t = 0; delayHide();">Command Name...</a><br>
		//		-- EACH MENUHEADER (non-active text line in menu)
		//			<div class="menuheader" onMouseOut="menu_t = 1; delayHide()" onMouseOver="menu_t = 2;">text</div>

		// global menu variables
		var domMenu_cur = null;
		var domMenu_old = null;
		var menu_t = 0;
		var menu_lDelay = 3;
		var menu_lCount = 0;
		var menu_pause = 100;
		
		function showMenu(menuName){
			if (isDHTML) {
				menu_t = 2;
				// hide any existing open menu
				if (domMenu_old) {
					//domMenu_old.visibility = 'hidden'; 
					domMenu_old.display = 'none'; 
					domMenu_old.zIndex = '0'; 
					menu_t = 2; 
					menu_lCount = 0;
				}
				// get DOM for new menu
				// set position and then show new menu
				domMenu_cur = getDOM(menuName,1);
				if (domMenu_old != domMenu_cur) {	
					//domMenu_cur.visibility = 'visible';
					domMenu_cur.display = 'block';
					domMenu_cur.zIndex = 1000;
					domMenu_old = domMenu_cur;
				}
				// Resets oldDom if it is the same as the current DOM
				else { domMenu_old = null; }
			}
			// Returns a 'null' value for non-DHTML Browsers 
			else { return null; }
		}
		
		function delayHide() {
			// Checks to see if there is a menu showing and whether 
			// the global variable 'menu_t' has been set to 0
		    if ((domMenu_old) && (menu_t == 0)) {
				// Hides the old menu, resets menu conditions, 
				// and stops the function running
		        //domMenu_old.visibility = 'hidden'; 
		        domMenu_old.display = 'none'; 
		        domMenu_old.zIndex = '0';
		        domMenu_old = null;
		        menu_lCount = 0; 
		        return false;
		    }
			// Interupts the function if another menu is opened
		    if (menu_t == 2) { menu_lCount = 0; return false; }
			// Repeats the function adding 1 to lCount each time until 
			// lCount is equal to lDelay and then sets 't' to 0 so that 
			// the menu will hide when it runs again
		    if (menu_t == 1) { 
		        menu_lCount = menu_lCount + 1;
		        if (menu_lDelay <= menu_lCount) { menu_t = 0; }
		        //if (menu_lDelay >= menu_lCount) { setTimeout('delayHide(' + menu_t + ')',menu_pause); }
		        setTimeout('delayHide()',menu_pause);
		    }
		}
		

	
//================================
//
//	COOKIES
//  	Cookie Functions -- "Night of the Living Cookie" Version (25-Jul-96)
//  	Written by:  Bill Dortch, hIdaho Design <bdortch@hidaho.com>
//  	The following functions are released to the public domain.
//
//================================

	// "Internal" function to return the decoded value of a cookie
	function getCookieVal (offset) {
	  var endstr = document.cookie.indexOf (";", offset);
	  if (endstr == -1)
	    endstr = document.cookie.length;
	  return unescape(document.cookie.substring(offset, endstr));
	}
	//  get cookie specified by "name".
	function GetCookie (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;
	}
	//  create or update a cookie.
	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) {
	  document.cookie = name + "=" + escape (value) +
	    ((expires) ? "; expires=" + expires.toGMTString() : "") +
	    ((path) ? "; path=" + path : "") +
	    ((domain) ? "; domain=" + domain : "") +
	    ((secure) ? "; secure" : "");
	}
	//  delete a cookie
	function DeleteCookie (name,path,domain) {
	  if (GetCookie(name)) {
	    document.cookie = name + "=" +
	      ((path) ? "; path=" + path : "") +
	      ((domain) ? "; domain=" + domain : "") +
	      "; expires=Thu, 01-Jan-70 00:00:01 GMT";
	  }
	}

	
//================================
//
//	DOM
//
//================================

var isDHTML = 0;
var isID = 0;
var isAll = 0;
var isLayers = 0;

if (document.getElementById) {isID = 1; isDHTML = 1;}
if (document.all) {isAll = 1; isDHTML = 1;}
browserVersion = parseInt(navigator.appVersion);
if ((navigator.appName.indexOf('Netscape') != -1) && (browserVersion == 4)) {isLayers=1; isDHTML = 1;}

// Get object's browser specific DOM reference
function getDOM(objID,fStyle) {
	if (fStyle == 1) {
		if (isID) {return (document.getElementById(objID).style);}
		else {
			if (isAll) {return (document.all[objID].style);}
			else {
				if (isLayers) {return (document.layers[objID]);}
			}
		}
	}
	else {
		if (isID) {return (document.getElementById(objID));}
		else {
			if (isAll) {return (document.all[objID]);}
			else {
				if (isLayers) {return (document.layers[objID]);}
			}
		}	
	}
}
	
