/* Global Variables */
	var Tabs = new Array();
	var Bars = new Array();
	var objUser;

	var intervalID
	var x;
	var f;
	var headerbar = "";
	var hlinks = "";
	var tabindex = 'tab0links';
	var ShowHide = "show"
	var bolPrefSave = false;
	var divCustomizeOpen = false;
	var sAutoRedirect = "";

/*
	var cssStyle = "default";
	var usrCountry = "";
	var usrAccountID = (-1);
	var usrRegistered = 0;
	var autoLoad = 0;
	var usrPCode = "x";
*/
	
	
	function setShowHideLabel(val){
		document.getElementById("showhide").innerHTML = val;
	}

function ScrollIn() {
		if (ShowHide == "show" ) {
			ShowHide = "hide";
			setShowHideLabel("Hide&nbsp;Tabs");
			x = document.getElementById("flashcontainer");
			f = x.style.height.replace('px','');
			
			if (x.style.display == "none" || x.style.display == "") {
				intervalID = setInterval('doscrollin()', 10);
				document["showhideimg"].src = "imgs/up_arrow.jpg";
				return false;
			} else {
				x.style.height = 10;
				document["showhideimg"].src = "imgs/up_arrow.jpg";
			}

		} else {
			ShowHide = "show"
			setShowHideLabel("Show&nbsp;Tabs");
			ScrollOut();
			document["showhideimg"].src = "imgs/down_arrow.jpg";
		}
	}

/*	
	function ScrollIn() {
		if (ShowHide == "show" ) {
			ShowHide = "hide";
			setShowHideLabel("Hide&nbsp;Tabs");
			x = document.getElementById("flashcontainer");
			f = x.style.height.replace('px','');
			
			if (x.style.display == "none" || x.style.display == "") {
				intervalID = setInterval('doscrollin()', 10);
				document["showhideimg"].src = "imgs/tri_up.gif";
				return false;
			} else {
				x.style.height = 10;
				document["showhideimg"].src = "imgs/tri_up.gif";
			}

		} else {
			ShowHide = "show"
			setShowHideLabel("Show&nbsp;Tabs");
			ScrollOut();
			document["showhideimg"].src = "imgs/tri_down.gif";
		}
	}
*/
	

	function ScrollOut() {
		x = document.getElementById("flashcontainer");
		f = x.style.height.replace('px','');
		if (x.style.display == "none" || x.style.display == "") {
			intervalID = setInterval('doscrollout()', 10)
		} 
	}

	function toggleInstant(id, ref, slink) {
		divCustomizeOpen = true;
	
		switch(slink) {
			case "More":
				Personalise.location = "site/more.asp?catid=" + Tabs[ref].CatID + "&tabid=" + ref;
				break;
			case "Personalise":
				Personalise.location = "site/tabbar/personalise.asp?catid=" + Tabs[ref].CatID + "&tabid=" + ref + "&ctry=" + objUser.TabBarCountry + "&msg=" + objUser.TakeOwnershipMsg();
				break;
			case "Preferences":
				Personalise.location = "site/tabbar/preferences.asp?tabid=" + ref + "&pcode=" + objUser.Postcode + "&ctry=" + objUser.TabBarCountry + "&msg=" + objUser.TakeOwnershipMsg();
				break;
		}

		x2 = document.getElementById(id);
		x2.style.display = "inline";
		return false;
	}
	
	function toggleInstantClose(id) {
		x2 = document.getElementById(id);
		x2.style.display = "none";
		return false;
	}


function doscrollin() {
	//setup
	
	if (f < 40) {
		f = (f-0) + 4;
		x.style.height = f;
	} else {
		var div_tabrow = document.getElementById("tabrow");
		div_tabrow.style.display = "inline";
		clearInterval(intervalID)
	}
}

function doscrollout() {
	if (f > 0) {
		x2 = document.getElementById("customizerow");
		x2.style.display = "none";	
		var div_tabrow = document.getElementById("tabrow");
		div_tabrow.style.display = "none";
		f = (f-0) - 4;
		x.style.height = f;
	} else {
		clearInterval(intervalID)
	}
}



/* =====================================================*/
/* BOF: User Defined Objects */
/* =====================================================*/

function c_Tabs(title, catid, showtab, tablinks) {
	this.Title = title;
	this.CatID = catid;
	this.ShowTab = showtab;
	this.TabLinks = tablinks;
}

function c_TabLinks(url, shortname, popup) {
	this.URL = url;
	this.Shortname = shortname;
	this.Popup = popup;
}

function c_Bars(id, name) {
	this.Id = id;
	this.Name = name;
}

function c_UserDetails_createCookieString() {
	rtn = this.AccountID + "~" + this.Registered + "~" + this.Username + "~" + this.Postcode + "~" + this.TabStyle + "~" + 
		this.TabBarCountry + "~"  + this.AutoLoadLink + "~" + this.LandingPage + "~" + this.TabBarID + "~" + this.TabBarOwnerID + "~" + 
		this.TabBarEditable + "~" + this.DefaultTabBar + "~" + this.GoogleSearchLanguage + "~" + this.GoogleSearchDomain

	return compressString(rtn);
}

function c_UserDetails_setDisplayOwnershipMsgFlag() {
	if (this.AccountID == this.TabBarOwnerID) {
		var rtn = 'no';
	} else {
//		if (this.TabBarEditable == 1) {
			var rtn = 'yes';
//		} else {
//			var rtn = 'no';
//		}
	}	
	return rtn;
}

function c_UserDetails (accountid, registered, username, userpostcode, tabstyle, tabbarcountry, autoloadlink, landingpage, tabbarid, tabbarownerid, tabbareditable, defaulttabbar, gslanguage, gsdomain) {
	this.AccountID = accountid;
	this.Registered = registered;
	this.Username = username;
	this.Postcode = userpostcode;
	this.TabStyle = tabstyle;
	this.TabBarCountry = tabbarcountry;
	this.AutoLoadLink = autoloadlink;
	this.LandingPage = landingpage;
	this.TabBarID = tabbarid
	this.TabBarOwnerID = tabbarownerid
	this.TabBarEditable = tabbareditable
	this.DefaultTabBar = defaulttabbar
	this.GoogleSearchLanguage = gslanguage
	this.GoogleSearchDomain = gsdomain
	
	this.TakeOwnershipMsg = c_UserDetails_setDisplayOwnershipMsgFlag;
	this.CookieString = c_UserDetails_createCookieString;
}

/* =====================================================*/
/* EOF: User Defined Objects */
/* =====================================================*/


/* ================================================================= */
function setup() {
	if (!location.hash == "") {
		handleHash();
	}

	if (location.hash == "#Sent_By_A_Friend") {
		//# Set-off the "Finger Banner Of Tabmarks!"
		initbox();
	}

	var cookiecontentsTabs = decompressString(getCookie("tm"));
	var cookiecontentsUsr = decompressString(getCookie("tmu"));
	var cookiecontentsBars = getCookie("tml");

	
	if (!cookiecontentsTabs) {
		// New Guest
		loadCookie(const_User, const_Tabs, "");

	} else {
		if (cookiecontentsUsr) {
			// Registered New User
			var aryNewVersion2 = cookiecontentsUsr.split("~");
			
			if (aryNewVersion2[0] == 557) {
				// Derren User
				loadCookie(const_User, const_Tabs, "");
			} else {
				loadCookie(cookiecontentsUsr, cookiecontentsTabs, cookiecontentsBars);
			}
		} else {
			var aryNewVersion = cookiecontentsTabs.split("~");
			
			if (aryNewVersion[2] < 0) {
				// Previous Guest
				loadCookie(const_User, const_Tabs, "");
			} else {
				
				if (aryNewVersion[5] == 1) {
					// Old Registered User
					window.location.href = "newversion_registered.asp?a=" + aryNewVersion[2] + "&r=" + aryNewVersion[5]
					return false;
				} else {
					window.location.href = "newversion.asp";
					return false;
				}
			}
		}
	}

	showContent(objUser.LandingPage, 0);
	setLittleLinks();

	headerbar = "<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\"><tr>";
	hlinks = "";
	setHeaders();

	document.getElementById("tabbar").innerHTML = headerbar;
	document.getElementById("alllinks").innerHTML = hlinks;
	ScrollIn();
	
	var tmpAutoLoadLink = objUser.AutoLoadLink;
	objUser.AutoLoadLink = 0;
	showTabLinks(tabindex);
	objUser.AutoLoadLink = tmpAutoLoadLink;

	styleGoogleSearch();
}

function styleGoogleSearch() {
	document.forms[0].sa.style.width = "88px";
	document.forms[0].sa.style.height = "17px";
	document.forms[0].sa.style.border = "1px solid #000000";
	document.forms[0].sa.style.font = "9px Verdana normal";
	document.forms[0].q.style.border = "1px solid #000000";
	document.forms[0].q.style.font = "9px Verdana";
	document.forms[0].q.style.height = "16px";
	document.forms[0].style.padding = "0px";
	document.forms[0].style.margin = "0px";
}

function setHeaders() {
	var tmp1stTab = '';
	var strGSearch = "<!-- Search Google -->\n" + 
										"<center>\n" + 
										"<form method=\"get\" action=\"http://" + objUser.GoogleSearchDomain + "/custom\" target=\"google_window\">\n" + 
										"<table>\n" + 
										"<tr><td nowrap=\"nowrap\" valign=\"top\" align=\"left\">\n" + 
										"<input type=\"text\" name=\"q\" size=\"16\" maxlength=\"255\" value=\"\"></input>\n" + 
										"<input type=\"submit\" name=\"sa\" value=\"Google Search\"></input>\n" + 
										"<input type=\"hidden\" name=\"client\" value=\"pub-1878620887351581\"></input>\n" + 
										"<input type=\"hidden\" name=\"forid\" value=\"1\"></input>\n" + 
										"<input type=\"hidden\" name=\"channel\" value=\"2551473462\"></input>\n" + 
										"<input type=\"hidden\" name=\"ie\" value=\"ISO-8859-1\"></input>\n" + 
										"<input type=\"hidden\" name=\"oe\" value=\"ISO-8859-1\"></input>\n" + 
										"<input type=\"hidden\" name=\"cof\" value=\"GALT:#008000;GL:1;DIV:#CCCCCC;VLC:663399;AH:center;BGC:FFFFFF;LBGC:FFFFFF;ALC:0000FF;LC:0000FF;T:000000;GFNT:0000FF;GIMP:0000FF;FORID:1;\"></input>\n" + 
										"<input type=\"hidden\" name=\"hl\" value=\"" + objUser.GoogleSearchLanguage + "\"></input>\n" + 
										"</td></tr></table>" + 
										"</form>" + 
										"</center>" + 
										"<!-- Search Google -->";	


	for (var c=0; c < Tabs.length; c++) 
	{
		if (Tabs[c].ShowTab == 1) {
			if (tmp1stTab == '') { tmp1stTab = 'tab'+c+'links'; }
			
			headerbar += "<td id=\"tab" + c + "Left\" class=\"tab" + c + "Left\"></td>";
			headerbar += "<td id=\"tab" + c + "Centre\" class=\"tab" + c + "Centre\" nowrap>&nbsp;<a onClick=\"showTabLinks('tab" + c + "links');return false;\" href=\"#Show_Links\">" + Tabs[c].Title + "</a>&nbsp;</td>";
			headerbar += "<td id=\"tab" + c + "Right\" class=\"tab" + c + "Right\"></td>";
			
			hlinks += "<div align=\"center\" id=\"tab" + c +"links\"><table cellpadding=\"0\" cellspacing=\"0\" border=\"0\"><tr><td nowrap>";
		
			for (var i=0; i < Tabs[c].TabLinks.length; i++) 
			{	
				hlinks +="<a href=\"#" + Tabs[c].TabLinks[i].Shortname + "\" title=\"" + Tabs[c].TabLinks[i].Shortname + "\" onClick=\"return showContent('" + decompressString(Tabs[c].TabLinks[i].URL) + "'," + Tabs[c].TabLinks[i].Popup + ");\">" + Tabs[c].TabLinks[i].Shortname + "</a> | ";			
				
			}
			
			//hlinks += "<a href=\"#More_Links\" onClick=\"toggleInstant('customizerow', " + c + ", 'More')\;return false;\">More</a> | ";

			if (objUser.AccountID == -1 || objUser.Registered == 0) {
				//hlinks += "<a href=\"#Personalise\" onClick=\"return showContent('site/wiz/step1.asp?ctry=" + objUser.TabBarCountry + "');\">Personalise</a></td></tr></table></div>";
				hlinks += "<a href=\"#Personalise\" onClick=\"return showContent('site/wiz/step_1.asp?ctry=" + objUser.TabBarCountry + "');\">Personalise</a></td></tr></table></div>";				
			} else {
				hlinks += "<a href=\"#Personalise\" onClick=\"toggleInstant('customizerow', " + c + ", 'Personalise');return false;\">Personalise</a></td></tr></table></div>";
			}
			
		}
		
		tabindex = tmp1stTab;
		
	}
	
	hlinks += "<div id=\"tab10links\" align=\"center\"><table cellpadding=\"0\" cellspacing=\"0\" border=\"0\"><tr><td nowrap>";
	if (objUser.Registered == 1) {
		hlinks += "<a href=\"#Edit_Details\" onClick=\"return showContent('site/editaccount.asp?n=' + Date());\">Edit your details</a>";
	}
	hlinks += "</td></tr></table></div>";
	
	/* Add myPreferences Tab */
	headerbar += "<td id=\"tab10Left\" class=\"tab10Left\"></td>";
	if (objUser.AccountID == -1 || objUser.Registered == 0) {
		//headerbar += "<td id=\"tab10Centre\" class=\"tab10Centre\" nowrap><a onClick=\"return showContent('site/wiz/step1.asp?ctry=" + objUser.TabBarCountry + "');\" href=\"#My_Preferences\">Preferences</a>&nbsp;&nbsp;|</td><td id=\"tab10Right\" class=\"tab10Right\"></td>";
		headerbar += "<td id=\"tab10Centre\" class=\"tab10Centre\" nowrap><a onClick=\"return showContent('site/wiz/step_1.asp?ctry=" + objUser.TabBarCountry + "');\" href=\"#My_Preferences\">Preferences</a>&nbsp;&nbsp;|</td><td id=\"tab10Right\" class=\"tab10Right\"></td>";
	} else {
		headerbar += "<td id=\"tab10Centre\" class=\"tab10Centre\" nowrap><a onClick=\"showTabLinks('tab10links');return false;\" href=\"#My_Preferences\">Preferences</a>&nbsp;&nbsp;|</td><td id=\"tab10Right\" class=\"tab10Right\"></td>";
	}
	
	/*  Google Search */
	headerbar += "<td id=\"tab11Centre\" class=\"tab11Centre\">" + strGSearch + "</td><td id=\"tab11Right\" class=\"tab11Right\"></td>";
	
	headerbar += "</tr></table>";
}


function reload(bCreateCookie) {
	if (bCreateCookie) {
		createCookie();
	}
	loadCookie("", "", "");
	headerbar = "<table cellpadding=0 cellspacing=0 border=0><tr>"
	hlinks = ""
	setHeaders();

	document.getElementById("tabbar").innerHTML = headerbar;
	styleGoogleSearch();
	document.getElementById("alllinks").innerHTML = hlinks;
	setLittleLinks();
	showTabLinks(tabindex)
}

function reloadStyle() {

	//reload stylesheet
	var linkTag;
	var linksArray = document.getElementsByTagName("link");

	for(var linkNum=0; linkNum<linksArray.length; linkNum++) {
		linkTag = linksArray[linkNum];
		
		if(linkTag.getAttribute("href").indexOf("styler.asp")>0) {
			//var intid = setTimeout('var linkTag = document.getElementsByTagName("link")[' + linkNum + '];linkTag.setAttribute("href", "css/themes/styler.asp?now=" + Date());', 10);
			linkTag.setAttribute("href", "css/themes/styler.asp?now=" + Date());
			break;
		}
	}

}

/* =====================================================*/
/* Functions */
/* =====================================================*/
function loadCookie(valUser, valTabs, valBars) {
	/*
			User Details Separator:				"~"
			Tab Separator:								"~"
			Tab Property Separator:				"|"
			Tab Links Sepsrator:					"¬"
			Tab Link Property Separator:	"@"
	*/
	if (valUser == "") {
		valUser = decompressString(getCookie("tmu"));
	}
	if (valTabs == "") {
		valTabs = decompressString(getCookie("tm"));
	}
	if (valBars == "") {
		valBars = getCookie("tml");
	}
	
	// Load User Details
	// =========================
	var aryUsrDetails = valUser.split("~");
	/*
			0:	Account ID
			1:	Registered
			2:	Username
			3:	User Postcode
			4:	Tab Style
			5:	Tab Bar Country
			6:	Auto Load Link
			7:	Landing Page
			8:	Tab Bar ID
			9:	Tab Bar Owner ID
			10:	Tab Bar Editable
			11: Default Tab Bar
			12: Google Search Language
			13: Google Search Domain
	*/
	objUser = new c_UserDetails(aryUsrDetails[0], aryUsrDetails[1], aryUsrDetails[2], aryUsrDetails[3], aryUsrDetails[4], aryUsrDetails[5], aryUsrDetails[6], aryUsrDetails[7], aryUsrDetails[8], aryUsrDetails[9], aryUsrDetails[10], aryUsrDetails[11], aryUsrDetails[12], aryUsrDetails[13]);

	
	// Load Tabs
	// =========================
	var intTabID = 0;
	var aryTabs = valTabs.split("~");
	
	// Get Tab Properties
	for (var t=0; t < aryTabs.length; t++) {
		aryTabProps = aryTabs[t].split("|");
		/*
				0:	Tab Title
				1:	Category ID
				2:	Show Tab
				3:	Tab Links
		*/
		Tabs[t] = new c_Tabs(quirkPlus(aryTabProps[0]), aryTabProps[1], aryTabProps[2], createLinksArray(aryTabProps[3]));
	}
	
	if (valBars != null) {
		// Get Tab Bars
		var aryBars = valBars.split("~");
		
		Bars = new Array();
		
		for (var t=0; t < aryBars.length; t++) {
			aryTabProps = aryBars[t].split("|");
			/*
					0:	ID
					1:	Name
			*/
			
			Bars[t] = new c_Bars(aryTabProps[0], quirkPlus(aryTabProps[1]));
		}
	}
}


function createLinksArray(strAllLinks) {
	var TabLinks = new Array();
	var aryLinks = strAllLinks.split("¬");

	if ("[" + strAllLinks + "]" != "[]") {
		// Loop through Links
		for (var l=0; l < aryLinks.length; l++) {
			// Get Link Properties
			aryLinkProps = aryLinks[l].split("@");
			/*
					0:	URL
					1:	Shortname
					2:	Popup
			*/
			TabLinks[l] = new c_TabLinks(compressString(aryLinkProps[0]), quirkPlus(aryLinkProps[1]), aryLinkProps[2]);
		}
	}
	
	return TabLinks;
}


function createCookie() {
	/*
			User Details Separator:				"~"
			Tab Separator:								"~"
			Tab Property Separator:				"|"
			Tab Links Separator:					"¬"
			Tab Link Property Separator:	"@"
	*/
	var strCookie = "";
	var strTabLinks

	for (var t=0; t < Tabs.length; t++) {

		/* Add Tab Properties */
		strCookie += Tabs[t].Title + "|" + Tabs[t].CatID + "|" + Tabs[t].ShowTab + "|";

		/* Add Tab Links */
		strTabLinks = "";
		for (var l=0; l < Tabs[t].TabLinks.length; l++) {
			strTabLinks += Tabs[t].TabLinks[l].URL + "@" + Tabs[t].TabLinks[l].Shortname + "@" + Tabs[t].TabLinks[l].Popup + "¬";
		}
		
		if (strTabLinks.length > 1) {
			strTabLinks = strTabLinks.substr(0, (strTabLinks.length - 1));
		}
		
		strCookie += strTabLinks + "~";
		
	}

	if (strCookie.length > 1) {
		strCookie = strCookie.substr(0, (strCookie.length - 1));
	}


	var now = new Date();
	// fix the bug in Navigator 2.0, Macintosh
	fixDate(now);
	now.setTime(now.getTime() + (365 * 50) * 24 * 60 * 60 * 1000); // 50yrs from now
	
	//create Tabs Cookie
	deleteCookie('tm');
	setCookie("tm", compressString(strCookie), now, "", "");

	//create User Details Cookie
	deleteCookie("tmu");
	setCookie("tmu", objUser.CookieString(), now, "", "");

	return false;
}

function makeTabActive() {
	var elementID = tabindex;
	
	elementID = elementID.replace('links', 'Left');
	identity = document.getElementById(elementID);
	identity.className = elementID + "Active";	

	elementID = elementID.replace('Left', 'Centre');
	identity = document.getElementById(elementID);
	identity.className = elementID + "Active";	
	
	elementID = elementID.replace('Centre', 'Right');
	identity = document.getElementById(elementID);
	identity.className = elementID + "Active";	

	return true;
}

function makeTabInactive() {
	var elementID = tabindex;
	
	elementID = elementID.replace('links', 'Left');
	identity = document.getElementById(elementID);
	identity.className = elementID;	

	elementID = elementID.replace('Left', 'Centre');
	identity = document.getElementById(elementID);
	identity.className = elementID;	
	
	elementID = elementID.replace('Centre', 'Right');
	identity = document.getElementById(elementID);
	identity.className = elementID;	
	
	return true;
}

function showContent(link, popup) {
	var tmp = ""
	if (divCustomizeOpen == true) {
		toggleInstantClose("customizerow");
		divCustomizeOpen = false;
	}

	var c = document.getElementById('google_window');

	if (popup == 1) {
		if (sAutoRedirect == "") {
			window.open(link);
		} else {
			tmp = sAutoRedirect;
			sAutoRedirect = "";
			window.open(tmp);
		}
		return false;
	}

	if (sAutoRedirect == "") {
		c.src = link;
	} else {
		tmp = sAutoRedirect;
		sAutoRedirect = "";
		c.src = tmp;
	}
	return false;
}

function showTabLinks(id) {
	if (divCustomizeOpen == true) {
		toggleInstantClose("customizerow");
		divCustomizeOpen = false;
	} else {
		divCustomizeOpen = true;
	}
	
	for (var i=0; i < Tabs.length; i++) {
		if (Tabs[i].ShowTab == 1) {
			tls = document.getElementById('tab' + i + 'links');
			tls.style.display = "none";
		}
	}
	
	tls = document.getElementById('tab10links');
	tls.style.display = "none";
	
	tls = document.getElementById(id);

	makeTabInactive();
	tabindex=id;
	makeTabActive();
	tls.style.display = "block"; //"inline";
	var t = id.replace(/tab/gi,"");

	if (id == "tab10links") {
		if (bolPrefSave) {
			bolPrefSave = false;
		} else {
			toggleInstant('customizerow', 10, 'Preferences');
		}
	} else {
		if (objUser.AutoLoadLink == 1) {
			return showContent(decompressString(Tabs[parseInt(t)].TabLinks[0].URL), Tabs[parseInt(t)].TabLinks[0].Popup);
		}
	}
}


function setLittleLinks() {
	var disp = "";
	var curTabmarks = "";

	if (objUser.Registered == 1) {
		disp += "<a onclick=\"deleteCookie('tm');deleteCookie('tmu');deleteCookie('tml');window.location.reload(true);\" href=\"#Logout\">Logout</a>&nbsp;|&nbsp;";
		
		//drop-down
		disp += "<div style=\"position:relative;display:inline; padding:0px; margin:0px; z-index:4;\" onMouseOver=\"javascript:clearTimeout(timerID);reveal('libraryOptions');return false;\" OnMouseOut=\"timerID = setTimeout('hideMenu(libraryOptions)',500);\"><a onclick=\"hideMenu('libraryOptions');return showContent('site/lib/index.asp?now=' +Date(),0);\" href=\"#Manage_Your_Tabmarks_Library\" title=\"Manage Your Tabmarks Library\">Library&nbsp;<img src=\"imgs/down_arrow.jpg\" width=12 height=12 border=0 align=\"absmiddle\"></a>"
		disp += "<div id=\"libraryOptions\" class=\"moreMenu\" style=\"visibility: hidden;\" OnMouseOut=\"javascript:hideMenu('libraryOptions');\"><a onclick=\"hideMenu('libraryOptions');return showContent('site/lib/index.asp?now=' +Date(),0);\" href=\"#Manage_Your_Tabmarks_Library\" title=\"Manage Your Tabmarks Library\" class=\"itemAnchorAdmin\" >Manage&nbsp;<img src=\"/imgs/spanner12x12.gif\" width=12 height=12 border=0 align=\"absmiddle\"></a>"
		disp += "<a onclick=\"hideMenu('libraryOptions');return showContent('site/lib/tabbar.asp?act=a&aid=" + objUser.AccountID + "&now=' +Date(),0);\" href=\"#Add_to_Tabmarks_Library\" title=\"Add a new Tabmarks to your library\" class=\"itemAnchorAdmin\" >Add new Tabmarks</a>"
		if(Bars.length > 1) {
			
			for(var i=0;i<Bars.length;i++) {
				if(Bars[i].Name.length > 25) {
					if(Bars[i].Id == objUser.TabBarID) {
						disp += "<a onclick=\"return showContent('site/loadnewtabbar.asp?tbid=" + Bars[i].Id + "&reload=1&now=' + Date());\" href=\"#View_Tabmarks\" class=\"itemAnchor\" title=\"" + Bars[i].Name + "\">" + Bars[i].Name.substr(0,24) + " &#8226;...</a>"
						curTabmarks = Bars[i].Name;
					} else {
						disp += "<a onclick=\"return showContent('site/loadnewtabbar.asp?tbid=" + Bars[i].Id + "&reload=1&now=' + Date());\" href=\"#View_Tabmarks\" class=\"itemAnchor\" title=\"" + Bars[i].Name + "\">" + Bars[i].Name.substr(0,24) + "...</a>"					
					}
				} else {
					if(Bars[i].Id == objUser.TabBarID) {
						disp += "<a onclick=\"return showContent('site/loadnewtabbar.asp?tbid=" + Bars[i].Id + "&reload=1&now=' + Date());\" href=\"#View_Tabmarks\" class=\"itemAnchor\" >" + Bars[i].Name + " &#8226;</a>"
						curTabmarks = Bars[i].Name;
					} else {
						disp += "<a onclick=\"return showContent('site/loadnewtabbar.asp?tbid=" + Bars[i].Id + "&reload=1&now=' + Date());\" href=\"#View_Tabmarks\" class=\"itemAnchor\" >" + Bars[i].Name + "</a>"
					}
				}
			}
			
		}
		disp += "</div></div>&nbsp;|&nbsp;";
		
		disp += "<a onClick=\"return showContent('site/sendtofriend.asp?tbid=" + objUser.TabBarID + "',0);\" href=\"#Send_To_Friend\" title=\"Send this set of Tabmarks to a friend\">Send&nbsp;to&nbsp;Friend</a>&nbsp;|&nbsp;";
	}
	else {
		disp += "<a onclick=\"return showContent('site/login.asp');\" href=\"#Login\">Login</a>&nbsp;|&nbsp;";
	}

	disp += "<a id=showhide onClick=\"ScrollIn();return false;\" href=\"#Show_Hide_Tabs\">Hide&nbsp;Tabs</a><img name=\"showhideimg\" id=\"showhideimg\" src=\"imgs/up_arrow.jpg\" width=12 height=12 hspace=\"3\" align=\"absbottom\">&nbsp;";
	
	if (curTabmarks != "") {
		disp += "<br>currently viewing: " + curTabmarks + "&nbsp;&nbsp;";
	}
	
	document.getElementById("access").innerHTML = disp;
}


function pageRefresh() {
	window.location.reload(true);
	return false;
}

function quirkPlus(val) {
	if (typeof(val) != "undefined"){ 
		val = val.replace(/\+/gi,' ');
	}
	return val;
}

function makeTabmarksHome(obj) {
	var bug = new Image();
	var site = "";

	obj.style.behavior="url(#default#homepage)";
	site = "usa";
	makehp.setHomePage("http://www.tabmarks.com");

	if (makehp.isHomePage("http://www.tabmarks.com/") || makehp.isHomePage("http://www.tabmarks.com") || makehp.isHomePage("http://www.tabmarks.co.uk") || makehp.isHomePage("http://www.tabmarks.co.uk/")) {
		toggleInstantClose("makehplink");
		bug.src = "hpbug.asp?s=" + site + "&r=" + Math.random();
	}

}

function reloadPage(bForceGet) {
	if (bForceGet) {
		window.location.reload(true);
	} else {
		window.location.reload(false);
	}
}

function removeHash() {
	var url = location.href;
	rExp = /#Sent_By_A_Friend/gi;
	rExp2 = /#_Sent_By_A_Friend/gi;
	
	var tmp = url.replace(rExp, '');
	tmp = tmp.replace(rExp2, '');
	
	location.href = tmp + "#" + escape(sAutoRedirect);
}

function handleHash() {
	var sHash = location.hash;

	if (sHash.indexOf(".") != -1) {
		sAutoRedirect = unescape(sHash.replace(/#/gi, ''));
	}
}

function decompressString(sVal) {
	var tmp = sVal

	if (tmp != "" && tmp != null) {
		var rExp = /½/gi;
		var rExp2 = /¼/gi;
		var rExp3 = /¾/gi;
		var rExp4 = /¿/gi;
		var rExp5 = /º/gi;
		var rExp6 = /¹/gi;
		var rExp7 = /¸/gi;
		var rExp8 = /·/gi;
		var rExp9 = /¶/gi;
		var rExp10 = /µ/gi;		
		
		tmp = tmp.replace(rExp, 'http://www.');
		tmp = tmp.replace(rExp2, 'https://www.');
		tmp = tmp.replace(rExp3, 'http://');
		tmp = tmp.replace(rExp4, 'https://');
		tmp = tmp.replace(rExp5, 'www.');
		tmp = tmp.replace(rExp6, '.co.uk');
		tmp = tmp.replace(rExp7, '.com');
		tmp = tmp.replace(rExp8, '.html');
		tmp = tmp.replace(rExp9, '.htm');
		tmp = tmp.replace(rExp10, '.asp');		
	}

	return tmp;
}

function compressString(sVal) {
	var tmp = sVal
	
	if (tmp != "" && tmp != null) {
		var rExp = /http:\/\/www\./gi;
		var rExp2 = /https:\/\/www\./gi;
		var rExp3 = /http:\/\//gi;
		var rExp4 = /https:\/\//gi;
		var rExp5 = /www\./gi;
		var rExp6 = /\.co\.uk/gi;
		var rExp7 = /\.com/gi;
		var rExp8 = /\.html/gi;
		var rExp9 = /\.htm/gi;
		var rExp10 = /\.asp/gi;

		tmp = tmp.replace(rExp, '½');
		tmp = tmp.replace(rExp2, '¼');
		tmp = tmp.replace(rExp3, '¾');
		tmp = tmp.replace(rExp4, '¿');
		tmp = tmp.replace(rExp5, 'º');
		tmp = tmp.replace(rExp6, '¹');
		tmp = tmp.replace(rExp7, '¸');
		tmp = tmp.replace(rExp8, '·');
		tmp = tmp.replace(rExp9, '¶');
		tmp = tmp.replace(rExp10, 'µ');		
		
	}
	
	return tmp;
}









/*
   name - name of the cookie
   value - value of the cookie
   [expires] - expiration date of the cookie
     (defaults to end of current session)
   [path] - path for which the cookie is valid
     (defaults to path of calling document)
   [domain] - domain for which the cookie is valid
     (defaults to domain of calling document)
   [secure] - Boolean value indicating if the cookie transmission requires
     a secure transmission
   * an argument defaults when it is assigned null as a placeholder
   * a null placeholder is not required for trailing omitted arguments
*/

function setCookie(name, value, expires, path, domain, secure) {
  var curCookie = name + "=" + escape(value) +
      ((expires) ? "; expires=" + expires.toGMTString() : "") +
      ((path) ? "; path=" + path : "") +
      ((domain) ? "; domain=" + domain : "") +
      ((secure) ? "; secure" : "");
			
  document.cookie = curCookie;
}


/*
  name - name of the desired cookie
  return string containing value of specified cookie or null
  if cookie does not exist
*/

function getCookie(name) {
  var dc = document.cookie;
  var prefix = name + "=";
  var begin = dc.indexOf("; " + prefix);
  if (begin == -1) {
    begin = dc.indexOf(prefix);
    if (begin != 0) return null;
  } else
    begin += 2;
  var end = document.cookie.indexOf(";", begin);
  if (end == -1)
    end = dc.length;
  return unescape(dc.substring(begin + prefix.length, end));
}


/*
   name - name of the cookie
   [path] - path of the cookie (must be same as path used to create cookie)
   [domain] - domain of the cookie (must be same as domain used to
     create cookie)
   path and domain default if assigned null or omitted if no explicit
     argument proceeds
*/

function deleteCookie(name, path, domain) {
  if (getCookie(name)) {
    document.cookie = name + "=" +
    ((path) ? "; path=" + path : "") +
    ((domain) ? "; domain=" + domain : "") +
    "; expires=Thu, 01-Jan-80 00:00:01 GMT";
  }
}

// date - any instance of the Date object
// * hand all instances of the Date object to this function for "repairs"

function fixDate(date) {
  var base = new Date(0);
  var skew = base.getTime();
  if (skew > 0)
    date.setTime(date.getTime() - skew);
}