document.write( "<div id=\"debug\" style=\"background-color:#fff;position:absolute;top:0;\"></div>" );

function go(prompt,url) {
	if ( prompt=='' ) prompt="Please confirm (Yes/No) ?";
	if (confirm(prompt)) {
		window.location = url;
		return true;
	}
}

function popup(url,width,height) {
	cusuwinpopup=window.open(url,'','toolbar=no,location=no,directories=no,menubar=no,status=yes,scrollbars=yes,resizable=no,width='+width+',height='+height);
	return false;
}

function sb(txt) { window.status = txt; return true; }

fetch_unix_timestamp = function() { return parseInt(new Date().getTime().toString().substring(0, 10))}

function limitText(limitField, limitCount, limitNum) {
	if (limitField.value.length > limitNum) {
		limitField.value = limitField.value.substring(0, limitNum);
	} else {
		document.getElementById(limitCount).innerHTML = limitNum - limitField.value.length;
	}
}

function debug (html,clear) {
	var elem=document.getElementById('debug');
	if (elem==undefined) return;
	if (clear) elem.innerHTML='';
	elem.innerHTML = elem.innerHTML+html;
}

function scrollObject(main, width, height, direct, pause, speed) {
	var self = this;
	this.main = main;
	this.width = width;
	this.height = height;
	this.direct = direct;
	this.pause = pause;
	this.speed = Math.max(1.001, Math.min((direct == "up" || direct == "down") ? height : width, speed));
	this.block = new Array();
	this.blockprev = this.offset = 0;
	this.blockcurr = 1;
	this.mouse = false;
	this.scroll = function() {
		if (!document.getElementById) return false;
		this.main = document.getElementById(this.main);
	    while (this.main.firstChild) this.main.removeChild(this.main.firstChild);
	    this.main.style.overflow = "hidden";
		this.main.style.position = "relative";
		this.main.style.width = this.width + "px";
		this.main.style.height = this.height + "px";
		for (var x = 0; x < this.block.length; x++) {
			var table = document.createElement('table');
			table.cellPadding = table.cellSpacing = table.border = "0";
			table.style.position = "absolute";
			table.style.left = table.style.top = "0px";
			table.style.width = this.width + "px";
			table.style.height = this.height + "px";
			table.style.overflow = table.style.visibility = "hidden";
			var tbody = document.createElement('tbody');
			var tr = document.createElement('tr');
			var td = document.createElement('td');
			td.innerHTML = this.block[x];
			tr.appendChild(td);
			tbody.appendChild(tr);
			table.appendChild(tbody);
			this.main.appendChild(this.block[x] = table);
		}
    	if (this.block.length > 1) {
			this.main.onmouseover = function() { self.mouse = true; }
			this.main.onmouseout = function() { self.mouse = false; }
			setInterval(function() {
        		if (!self.offset && self.scrollLoop()) self.block[self.blockcurr].style.visibility = "visible";
      		}, this.pause);
    	} 
		this.block[this.blockprev].style.visibility = "visible";
  	}
  	this.scrollLoop = function() {
		if (!this.offset) {
		  if (this.mouse) return false;
		  this.offset = (this.direct == "up" || this.direct == "down") ? this.height : this.width;
		} else this.offset = Math.floor(this.offset / this.speed);
		if (this.direct == "up" || this.direct == "down") {
		  this.block[this.blockcurr].style.top = ((this.direct == "up") ? this.offset : -this.offset) + "px";
		  this.block[this.blockprev].style.top = ((this.direct == "up") ? this.offset - this.height : this.height - this.offset) + "px";
		} else {
		  this.block[this.blockcurr].style.left = ((this.direct == "left") ? this.offset : -this.offset) + "px";
		  this.block[this.blockprev].style.left = ((this.direct == "left") ? this.offset - this.width : this.width - this.offset) + "px";
		}
		if (!this.offset) {
		  this.block[this.blockprev].style.visibility = "hidden";
		  this.blockprev = this.blockcurr;
		  if (++this.blockcurr >= this.block.length) this.blockcurr = 0;
		} else setTimeout(function() { self.scrollLoop(); }, 50);
		return true;
	}
	this.loadDataMarqueeAndScroll = function () {
		var listP=document.getElementById(this.main).childNodes;
		var aTmp = new Array ();
		for (var x=0; x<listP.length; x++){
			el=listP[x];
			if (el.nodeName=='P') aTmp.push(""+(el.innerHTML));
		}
		this.block = aTmp;
		this.scroll();	
	}
}

function slide(main, width, height, direct, pause, speed) {
	var self = this;
	this.main = document.getElementById(main);
	this.width = width;
	this.height = height;
	this.direct = direct;
	this.pause = pause;
	this.speed = Math.max(1.001, Math.min((direct == "up" || direct == "down") ? height : width, speed));
	this.block = new Array();
	this.blockprev = this.offset = 0;
	this.blockcurr = 1;
	this.mouse = false;
	this.scroll = function() {
		if (!document.getElementById) return false;
		this.main = document.getElementById(this.main);
	    while (this.main.firstChild) this.main.removeChild(this.main.firstChild);
	    this.main.style.overflow = "hidden";
		this.main.style.position = "relative";
		this.main.style.width = this.width + "px";
		this.main.style.height = this.height + "px";
		for (var x = 0; x < this.block.length; x++) {
			var table = document.createElement('table');
			table.cellPadding = table.cellSpacing = table.border = "0";
			table.style.position = "absolute";
			table.style.left = table.style.top = "0px";
			table.style.width = this.width + "px";
			table.style.height = this.height + "px";
			table.style.overflow = table.style.visibility = "hidden";
			var tbody = document.createElement('tbody');
			var tr = document.createElement('tr');
			var td = document.createElement('td');
			td.innerHTML = this.block[x];
			tr.appendChild(td);
			tbody.appendChild(tr);
			table.appendChild(tbody);
			this.main.appendChild(this.block[x] = table);
		}
    	if (this.block.length > 1) {
			this.main.onmouseover = function() { self.mouse = true; }
			this.main.onmouseout = function() { self.mouse = false; }
			setInterval(function() {
        		if (!self.offset && self.scrollLoop()) self.block[self.blockcurr].style.visibility = "visible";
      		}, this.pause);
    	} 
		this.block[this.blockprev].style.visibility = "visible";
  	}
  	this.scrollLoop = function() {
		if (!this.offset) {
		  if (this.mouse) return false;
		  this.offset = (this.direct == "up" || this.direct == "down") ? this.height : this.width;
		} else this.offset = Math.floor(this.offset / this.speed);
		if (this.direct == "up" || this.direct == "down") {
		  this.block[this.blockcurr].style.top = ((this.direct == "up") ? this.offset : -this.offset) + "px";
		  this.block[this.blockprev].style.top = ((this.direct == "up") ? this.offset - this.height : this.height - this.offset) + "px";
		} else {
		  this.block[this.blockcurr].style.left = ((this.direct == "left") ? this.offset : -this.offset) + "px";
		  this.block[this.blockprev].style.left = ((this.direct == "left") ? this.offset - this.width : this.width - this.offset) + "px";
		}
		if (!this.offset) {
		  this.block[this.blockprev].style.visibility = "hidden";
		  this.blockprev = this.blockcurr;
		  if (++this.blockcurr >= this.block.length) this.blockcurr = 0;
		} else setTimeout(function() { self.scrollLoop(); }, 50);
		return true;
	}
	this.slidein1 = function () {
		var listP=document.getElementById(this.main).childNodes;
		var aTmp = new Array ();
		for (var x=0; x<listP.length; x++){
			el=listP[x];
			if (el.nodeName=='P') aTmp.push(""+(el.innerHTML));
		}
		this.block = aTmp;
		this.scroll();	
	}
	this.slidein = function () {
		this.main.style.visibility="visible";
	}
	this.slideout = function () {
		this.main.style.visibility="hidden";
	}
}

/**
 * dom tools functions
 */
dom = {
	element : function (id) {
		var e = document.getElementById(id);
		return e;
	} ,
	
	toggle : function (id) {
		o=document.getElementById(id)
		var display = dom.getStyle(o, "display");
	    if (o.style) o.style.display = (display != "none") ? "none" : dom.getDisplayStyleByTagName(o);
	} ,

	solo : function (show,hide1,hide2,hide3,hide4,hide5) {
		o=document.getElementById(show)
		if (o!=undefined) {
			var display = dom.getStyle(o, "display");
		    if (o.style) o.style.display = dom.getDisplayStyleByTagName(o);
		}
		if(hide1 != undefined) {
			o=document.getElementById(hide1)
			if (o!=undefined) {
				var display = dom.getStyle(o, "display");
				if (o.style) o.style.display = "none";
			}
		}
		if(hide2 != undefined) {
			o=document.getElementById(hide2)
			if (o!=undefined) {
				var display = dom.getStyle(o, "display");
				if (o.style) o.style.display = "none";
			}
		}
		if(hide3 != undefined) {
			o=document.getElementById(hide3)
			if (o!=undefined) {
				var display = dom.getStyle(o, "display");
				if (o.style) o.style.display = "none";
			}
		}
		if(hide4 != undefined) {
			o=document.getElementById(hide4)
			if (o!=undefined) {
				var display = dom.getStyle(o, "display");
				if (o.style) o.style.display = "none";
			}
		}
		if(hide5 != undefined) {
			o=document.getElementById(hide5)
			if (o!=undefined) {
				var display = dom.getStyle(o, "display");
				if (o.style) o.style.display = "none";
			}
		}

	} ,
		
	getDisplayStyleByTagName : function (o) {
		n = o.nodeName.toLowerCase(); 
		return (
			n == "span"
			|| n == "img"
			|| n == "a"
			) ? "inline" : "block";
	} ,
	
	getStyle : function (el, style) {
		if (!document.getElementById || !el) return;
		if (document.defaultView && document.defaultView.getComputedStyle) {
			return document.defaultView.getComputedStyle(el, "").getPropertyValue(style);
		} else if (el.currentStyle) {
			return el.currentStyle[style];
		} else {
			return el.style.display;
		}
	} ,
	
	getFormValue : function(id) {
		params='podcast[title]='+dom.element('edit-title').value;
		params+='&podcast[body]='+dom.element('edit-podcast-body').value;
		return params;
	}
	
}

/**
 * Ajax tools functions
 */
ajax = {
	Version: '0.0.2',
	loadStatusText:'<div class="loading">Loading...</div>',
	boxHeader:'<div style="text-align:right;"><input type="submit" value="close" onClick="ajax.HideBox()"></div>',
	activeRequestCount: 0,
	getTransport : function() {
		var xmlHttp=null;
		// Firefox, Opera 8.0+, Safari
		try { xmlHttp=new XMLHttpRequest(); }
		catch (e) {
			// Internet Explorer
			try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); }
			catch (e) { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");}
		}
		return xmlHttp;
	} ,
	
	Updater : function(container, url, headerText) {
		this.container=container;
		this.stateChange = function stateChange() {
			if (transport.readyState==4) {
//			alert(transport.responseText);
//				document.getElementById(container).innerHTML=headerText;
//				document.getElementById(container).innerHTML=transport.responseText;
				document.getElementById(container).innerHTML=(typeof(headerText)!='undefined'?headerText:'')+transport.responseText;
			}
		}
		
		document.getElementById(this.container).innerHTML=ajax.loadStatusText+document.getElementById(this.container).innerHTML;
		var transport=ajax.getTransport();
		if (transport==null) {
			alert('Your browser does not support AJAX!');
			return;
		}
		transport.onreadystatechange=this.stateChange;
		transport.open("GET",url,true);
		transport.send(null);
	} ,
	
	create_http_handle : function(TYPE){
		var http_handle = false;
		if (window.XMLHttpRequest){
			http_handle = new XMLHttpRequest();
			if (http_handle.overrideMimeType){
				if (TYPE == "XML"){
					http_handle.overrideMimeType('text/xml');
				} else {
					http_handle.overrideMimeType('text/html');
				}
			}
		} else if (window.ActiveXObject){
			try {
				http_handle = new ActiveXObject("Msxml2.XMLHTTP");
			} catch (e) {
				try {
					http_handle = new ActiveXObject("Microsoft.XMLHTTP");
				} catch (e) {}
			}
		}
		if (!http_handle){
			alert("We are sorry but you are using an outdated browser.  To view this site you must update your browser.");
			return false;
		} else {
			return http_handle;
		}
	} ,
	
	sendHTTPrequest : function(id, url, method, params, type){
		if (type== "")type= "HTML";
		http = this.create_http_handle(type);
		http.onreadystatechange = function() {
			if(http.readyState == 4 && http.status == 200) {
				// id in format function() them evaluate function
				if (id.indexOf('(')>0) {
					eval(id);
				} else {
					document.getElementById(id).innerHTML=http.responseText;
				}
			}
		}
		//Kill the Cache problem in IE.
		var now = "upid=" + new Date().getTime();
		params += (params.indexOf("?")+1) ? "&" : "?";
		params += now;
		if (method == "POST"){
			http.open('POST', url, true);
			http.setRequestHeader("Content-type", "application/x-www-form-URLencoded");
			http.setRequestHeader("Content-length", params.length);
			http.setRequestHeader("Connection", "close");
			http.send(params);
		} else {
			http.open('GET', url+ params, true);
			http.send(null);
		}
	} ,
	
	link : function (id,url,header) {
		new ajax.Updater(id,url,header);
		return false;
	} ,
	
	go : function (id,prompt,url) {
		if ( prompt== '' ) prompt='Please confirm to continue?';
		if (confirm(prompt)) {
			new ajax.Updater(id,url);
		}
	} ,

	getAbsolutePos : function(el) {
		var r = { x: el.offsetLeft, y: el.offsetTop };
		if (el.offsetParent) {
			var tmp = ajax.getAbsolutePos(el.offsetParent);
			r.x += tmp.x;
			r.y += tmp.y;
		}
		return r;
	} ,

	box : function (e,id,width,height,text){
	//	ajax.HideBox();
		if(document.all)e = event;
		
		var obj = document.getElementById(id);

		obj.style.display = 'block';
		obj.style.position= 'absolute';
		obj.style.width = width+'px';
		if (height>0) obj.style.height= height+'px';
		var st = Math.max(document.body.scrollTop,document.documentElement.scrollTop);
		if(navigator.userAgent.toLowerCase().indexOf('safari')>=0)st=0; 
		if (obj.offsetParent) parent_r=ajax.getAbsolutePos(obj.offsetParent);

		var leftPos = e.clientX - parent_r.x;
		if(leftPos<0)leftPos = 0;
		obj.style.left = leftPos + 'px';
	//	obj.style.top = e.clientY - obj.offsetHeight -1 + st + 'px';
		obj.style.top = e.clientY+st+10+ 'px';
	//	text = text+'left='+obj.style.left+', top='+obj.style.top+',clientX='+e.clientX+',clientY='+e.clientY+',offsetHeight='+obj.offsetHeight;
		if (text.substr(0,4)=='url:') {
			url=text.substr(4,text.length-4);
			new ajax.Updater('box',url,ajax.boxHeader);
		} else {
			obj.innerHTML = text;
		}
	} ,

	HideBox : function () {
		document.getElementById('box').style.display = 'none';
	} ,
	
	viewimage : function view_image(img,width,height,prop) {
		var scroll = "no"
		var w = width;
		var h = height;
		if (width>=800) { w=800; scroll = "yes"; }
		if (height>=800) { h=800; scroll = "yes"; }
		view_image_win=window.open("",'','toolbar=no,location=no,directories=no,menubar=no,status=no,scrollbars='+scroll+',resizable=yes,width='+w+',height='+h);
		view_image_win.focus();
		view_image_win.document.write("<html>\n");
		view_image_win.document.write("<head><title>"+img+" : "+width+"x"+height+" pixel</title><style><!-- * {margin:0;padding:0}--></style></head>\n");
		view_image_win.document.write("<body>\n");
		view_image_win.document.write("<center><img src='"+img+"' ><center>");
		view_image_win.document.write("</body>\n");
		view_image_win.document.write("</html>\n");
		view_image_win.document.close();
	} ,

	linkRelationInit : function () {
		var a_list=document.getElementsByTagName("A") //array containing the A elements
//		alert('<p><em>relation init</em></p>');
		for (var x=0; x<a_list.length; x++){ //loop through each A element
			alink=a_list[x];
			if (alink.getAttribute("rel")){
				var modifiedurl=alink.getAttribute("href").replace(/^http:\/\/[^\/]+\//i, "http://"+window.location.hostname+"/")
				alink.setAttribute("href", modifiedurl) //replace URL's root domain with dynamic root domain, for ajax security sake
				alink.onclick=function(){
//					alert('link relation')
					ajax.Updater(this.getAttribute("rel"),this.getAttribute("href"))
					return false
				}
			}
		}
	} ,
	
	relation : function (e) {
		e?evt=e:evt=event;
		var elem=evt.target?evt.target:evt.srcElement;
		if (elem.tagName=='A' && elem.getAttribute('rel')) {
			var modifiedurl=elem.getAttribute("href").replace(/^http:\/\/[^\/]+\//i, "http://"+window.location.hostname+"/")
//			alert('relation '+elem.tagName+' rel '+elem.getAttribute('rel')+' href='+modifiedurl);
			elem.setAttribute("href", modifiedurl) //replace URL's root domain with dynamic root domain, for ajax security sake
//			elem.onclick=function(){
//				ajax.Updater(this.getAttribute("rel"),this.getAttribute("href"))
//				return false
//			}
			ajax.Updater(elem.getAttribute('rel'),modifiedurl)
			e.stopPropagation;
			return false
		}
	}
	
}

/**
 * Editor functions
 */
editor = {
	version : '0.0.3b',
	controls : new Array() ,
	start_tag : '',
	end_tag : '',
	
	click : function (e) {
		e?evt=e:evt=event;
		var cSrc=evt.target?evt.target:evt.srcElement;
		var elem=document.getElementsByTagName('textarea');
		var ctrl=cSrc.parentNode;
//		alert(ctrl);
//alert('click '+ctrl+' : '+ctrl.id+' : '+ctrl.className);
		if (ctrl && ctrl.className=='editor') {
			myField=document.getElementById(ctrl.title);
//			alert('set myField ',editor.myField.id);
//			debug('<p>control parent id '+ctrl.id+' : '+ctrl.title+' : '+ctrl.className+' : '+ctrl.parentNode.id+'</p>',false);
//			debug('insert into id '+myField.id+' tag = '+editor.start_tag+' | '+editor.end_tag);
			if (editor.start_tag) editor.insertCode(myField,editor.start_tag,editor.end_tag);
		}
		editor.start_tag='';
		editor.end_tag='';
	} ,

	insert : function (i,o) {
		if(o == undefined) { o=''; }
		this.start_tag=i;
		this.end_tag=o;
	} ,
	
	insertCode : function(myField,i,o) {
		// IE selection support
		if (document.selection) {
			myField.focus();
			sel = document.selection.createRange();
			if (sel.text.length > 0) {
				sel.text = i + sel.text + o;
			} else {
				sel.text = i + o;
			}
			myField.focus();
		// MOZILLA selection support
		} else if (myField.selectionStart || myField.selectionStart == '0') {
			var startPos = myField.selectionStart;
			var endPos = myField.selectionEnd;
			var cursorPos = endPos;
			var scrollTop = myField.scrollTop;
			if (startPos != endPos) {
				myField.value = myField.value.substring(0, startPos)
				+ i
				+ myField.value.substring(startPos, endPos) 
				+ o
				+ myField.value.substring(endPos, myField.value.length);
				cursorPos = cursorPos + i.length + o.length;
			} else {
				myField.value = myField.value.substring(0, startPos) 
				+ i 
				+ o 
				+ myField.value.substring(endPos, myField.value.length);
				cursorPos = startPos + i.length;
			}
			myField.focus();
			myField.selectionStart = cursorPos;
			myField.selectionEnd = cursorPos;
			myField.scrollTop = scrollTop;
		// SAFARI and others
		} else {
			myField.value += i+o;
			myField.focus();
		}
	} ,
	
	url : function (i) {
	    var defaultValue = 'http://';
		var url = prompt('enter your url' ,defaultValue);
		if (url == undefined) return;

		// insert BBcode Link
//		this.insert('[url='+ url + ']','[/url]');

		// insert Markdown Link
		this.insert('[',']('+url+')');
	} ,
	
	image : function (src) {
	    var defaultValue = 'http://';
		if (src == undefined) {
			src = prompt('enter your image location', defaultValue);
			if (src == undefined || src==defaultValue) return;
		}
		// insert BBcode Image
//		this.insert('[img]'+src,'[/img]');

		// insert Markdown Image
		this.insert('![คำอธิบายภาพ',']('+src+' "ชื่อภาพ")');
	} ,

	emotion : function (id) {
		dom.toggle(id);
	} ,
	
	color : function (id) {
		this.COLORS = [
		  ["ffffff", "cccccc", "c0c0c0", "999999", "666666", "333333", "000000"], // blacks
		  ["ffcccc", "ff6666", "ff0000", "cc0000", "990000", "660000", "330000"], // reds
		  ["ffcc99", "ff9966", "ff9900", "ff6600", "cc6600", "993300", "663300"], // oranges
		  ["ffff99", "ffff66", "ffcc66", "ffcc33", "cc9933", "996633", "663333"], // yellows
		  ["ffffcc", "ffff33", "ffff00", "ffcc00", "999900", "666600", "333300"], // olives
		  ["99ff99", "66ff99", "33ff33", "33cc00", "009900", "006600", "003300"], // greens
		  ["99ffff", "33ffff", "66cccc", "00cccc", "339999", "336666", "003333"], // turquoises
		  ["ccffff", "66ffff", "33ccff", "3366ff", "3333ff", "000099", "000066"], // blues
		  ["ccccff", "9999ff", "6666cc", "6633ff", "6600cc", "333399", "330099"], // purples
		  ["ffccff", "ff99ff", "cc66cc", "cc33cc", "993399", "663366", "330033"] // violets
		  ];

		var cell_width = 14;
		var html = "";
		for (var i = 0; i < this.COLORS.length; i++) {
		  for (var j = 0; j < this.COLORS[i].length; j++) {
			html=html+'<img src="/library/img/none.gif" width="'+cell_width+'" height="'+cell_width+'" onClick="editor.insert(\'[color=#' + this.COLORS[i][j] + ']\',\'[/color]\')" style="background-color:#'+this.COLORS[i][j]+';margin:0 1px 1px 0;">';
		  }
		}
		var elem=document.getElementById(id);
		if (elem==undefined) return;
		elem.innerHTML = html;
		dom.toggle(id);
	}
}


/**
 * Tab content
 */
function tabs(id) {
	var self = this;
	this.id = id;
	this.waitTime=0;
	this.rotateTime = 1000;
	this.tabCount=0;
	this.tabId=new Array();

	this.display = function (sID) {
		oObj = document.getElementById(sID);
		if (oObj) {
			oObj.style.display='inline';
		}
	}
	this.hide = function (sID) {
		oObj = document.getElementById(sID);
		if (oObj) {
			oObj.style.display='none';
		}
	}
	this.getTabCount = function () {
		var listLI=document.getElementById(this.id).childNodes;
		for (var x=0; x<listLI.length; x++){
			el=listLI[x];
			if (el.nodeType==1 && el.nodeName=='LI') {
				this.tabCount++;
				this.tabId[this.tabCount]=el.id;
			}
		}
	}
	this.getTab = function (id){
		if (this.tabCount==0) this.getTabCount();
		for (i=1;i<=this.tabCount;i++) {
			if (id == i) {
				this.display(this.tabId[i]+'-content');
				document.getElementById(this.tabId[i]).className ='active';
			} else {
				this.hide(this.tabId[i]+'-content');
				document.getElementById(this.tabId[i]).className ='inactive';
			}
		}
	}
	this.click = function (id) {
		this.getTab(id);
		if (this.waitTime>0) {
			this.stoper();
			this.timer = setTimeout(function() { self.rotate(id,this.rotateTime); }, this.waitTime);
		}
	}
	this.rotate = function (id,rotateTime,waitTime){
		if (rotateTime>0) this.waitTime=rotateTime;
		if (waitTime>0) this.waitTime=waitTime;
		if (id >this.tabCount) id=1;
		this.getTab(id);
		id++;
		this.timer = setTimeout(function() { self.rotate(id,this.rotateTime); }, this.waitTime);
	}
	this.stoper = function () {
		clearTimeout(this.timer);
	}
}

// drop-down menu
// this function is from gotoknow.org http://gotoknow.org//javascripts/application.js
// bug for IE
sfHover = function (id) {
	if (typeof document.attachEvent=='undefined') return;
	// set default id for user-menu
	if (id==null) id='user-menu';
//	if (id==undefined) id='user-menu';

	// add class property sfhover to id user-menu LI tags
	if (document.getElementById(id)) {
		var sfEls = document.getElementById(id).getElementsByTagName("LI");

		// add class property sfhover to all LI tags
		// var sfEls = document.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"), "");}
		}
	}
}

/* init bb click */
if (typeof document.attachEvent!='undefined') {
	window.attachEvent("onload", sfHover);
	window.attachEvent("onload", ajax.linkRelationInit);
	document.attachEvent('onclick',editor.click);
} else {
	window.addEventListener('load',ajax.linkRelationInit,false);
	document.addEventListener('click',editor.click,false);
//	document.addEventListener('click',ajax.relation,true);
}

document.write( "<script type='text/javascript' src='/library/boxover.js'><\/script>" );
