// a little netscape 4 fix, easy enough
if (!document.getElementById && navigator) { with (navigator) {
  if (appName=='Netscape' && parseInt(appVersion)==4) {
	document.writeln('<style>#nav a div {text-indent:0;margin:0;}</style>');
  }
}}
var advBrowser= typeof(encodeURIComponent) == 'function';  // IE 5.5+ and Netscape 6+ and Mozilla
// see http://www.worldtimzone.com/res/encode/ for an alternative for older browsers
var fsValue='';

if (advBrowser) {
	fsValue= readCookie('fsempjs');
	if (fsValue=='') {
		fsValue= encodeURIComponent('[' + strFix(document.URL) + '], ' + strFix(document.referrer));
		document.cookie= 'fsempjs=' + fsValue + ';path=/'
	} else {
		fsValue= encodeURIComponent(strFix(decodeURIComponent(fsValue))); // no funny business, strFix optional
	}
}

//
function strFix(st) {
	st= st.toString();
	var len= st.length;
	if (len>200) st= st.substring(0,len-5) + '...';
	return st;
}

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

//
function wrtFormParam() {
	document.writeln('<input type="hidden" name="fsValue" value="' + fsValue + '">');
	// document.writeln('<pre>(fsValue: ' + fsValue + ')</pre>');
}

//
function addbookmark(url) {
  if (url=='') { url= 'http://luckycat.com/' } else { url= 'http://luckycat.com/fengshui/' + url }
  if (document.all) { window.external.AddFavorite(url,document.title) }
  // else if (window.sidebar && window.sidebar.addPanel) { window.sidebar.addPanel(document.title,url,'') }
  else { alert('To bookmark in most browsers, please use Control-D or Cmd-D, or the browser menu.') }
}

// !suckerfish, http://www.htmldog.com/articles/suckerfish/,
// ...also http://www.htmldog.com/ptg/archives/000050.php#comment182
// sfHover = function() {
// 	var sfEls = document.getElementById("nav").getElementsByTagName("LI");
// 	for (var i=0; i<sfEls.length; i++) {
// 		sfEls[i].onmouseover=function() {
// 			this.className+=" sfhover";
// 		}
// 		sfEls[i].onmouseout=function() {
// 			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
// 		}
// 	}
// }
// if (window.attachEvent) window.attachEvent("onload", sfHover);
// !/suckerfish

// modifed suckerfish, so can use <ul id="nav" onMouseOver="sfHover()"> for quicker load
var sfdoLoad= document.all && document.getElementById; // IE only, and byId required below
// sfdoLoad=true;  // test
sfHover = function() {
  if (sfdoLoad) {
	var sfEls = document.getElementById('nav').getElementsByTagName('LI');
	if (sfEls && (sfEls.length > 0)) { // DOM is ready
		sfdoLoad= false;  // mark done
		for (var i=0; i<sfEls.length; i++) {
			sfEls[i].onmouseover=function() {
				this.className= 'sfhover'
			}
			sfEls[i].onmouseout=function() {
				this.className= ''
			}
		}
	}
  }
}
// fall back to body onLoad, which waits for all images to load
if (document.all) { // Load sfHover only in IE; other browsers don't need it
	if (window.attachEvent) window.attachEvent('onload', sfHover);
	else window.onload = sfHover; // Mac IE5 needs this
}

//
function menu2atoggle() {
	if (document.getElementById) {
		menu= document.getElementById('menu2a');
		menu.className= menu.className=='menu2' ? 'menu2a' : 'menu2';
	}
}
