/* body */
function initBoardList() {
	cssFirstChild(document.getElementsBySelector(".Ltbl_list tbody tr"), "first-child");

	boardRowEl = document.getElementsBySelector(".Ltbl_list tbody tr");
	for(i=0; i<boardRowEl.length; i++) {
		boardRowEl[i].onmouseover = function boardListRowOver() {
			this.className = this.className + " over";
		}
		boardRowEl[i].onmouseout = function boardListRowOut() {
			this.className = this.className.replace("over", "");
		}
	}
}


// css first-child
function cssFirstChild(el, clsname) {
	if (el[0]) {
		if (el[0].className) {
			el[0].className = el[0].className + " " + clsname;
		} else {
			el[0].className = clsname;
		}
	}
}


function allblur() { 
for (i = 0; i < document.links.length; i++)
document.links[i].onfocus = document.links[i].blur;}

var node;
var imgOriName;
function setForBrowserType(evt){
	var imgName;
	var evt = evt || window.event;
	node = evt.target || window.event.srcElement;
	var targetSrc = node.getAttribute("src");
	var imgIndex = targetSrc.lastIndexOf('/');

	imgName = targetSrc.substring(imgIndex,targetSrc.length);
	var imgNameSplit = imgName.split('.');
	imgOriName = imgNameSplit[0];
}
/* btn over */
   function changeImg(evt) 
   {   
	  setForBrowserType(evt);
      node.src="/images/common" + imgOriName + "_on.gif";
   } 

   function restoreImg(evt) 
   { 
      node.src="/images/common" + imgOriName + ".gif";
   } 
      
   function changeoverImg(evt) 
   { 
      node.src="/images" + imgOriName +"_over.gif";
   } 

   function changebtnImg(evt) 
   {   
	  setForBrowserType(evt);
      node.src="/images/btn" + imgOriName + "_on.gif";
   } 

   function restorebtnImg(evt) 
   { 
      node.src="/images/btn" + imgOriName + ".gif";
   } 
   
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}

MM_reloadPage(true);

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function sh_layers() { //v6.0
  var i,p,v,obj,args=sh_layers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v;}
	obj.zIndex=10;
}

function sh_layers2() { //v6.0  
  var i,p,v,e,obj,args=sh_layers2.arguments;
  /*for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; 
*/
    //obj.left = document.body.scrollLeft + event.clientX - 400;
    //obj.top = document.body.scrollTop + event.clientY - 130;
    for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];e=args[i+3];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; 
	// obj.left = Number(cfGetX(e)-350)+"px";
    // obj.top  = (Number(cfGetY(e)-300))+"px";
	obj.left = cfGetX(e);
	obj.top = cfGetY(e);
	}
}

function insertFlash(swf, width, height, bgcolor, id, flashvars)
{
	var strFlashTag = new String();

	if (navigator.appName.indexOf("Microsoft") != -1)
	{
		strFlashTag += '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ';
		strFlashTag += 'codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=version=8,0,0,0" ';
		strFlashTag += 'id="' + id + '" width="' + width + '" height="' + height + '">';
		strFlashTag += '<param name="movie" value="' + swf + '"/>';

		if(flashvars != null) {strFlashTag += '<param name="flashvars" value="' + flashvars + '"/>'};
		strFlashTag += '<param name="quality" value="best"/>';
		strFlashTag += '<param name="bgcolor" value="' + bgcolor + '"/>';
		strFlashTag += '<param name="menu" value="false"/>';
		strFlashTag += '<param name="salign" value="LT"/>';
		strFlashTag += '<param name="scale" value="noscale"/>';
		strFlashTag += '<param name="wmode" value="transparent"/>';
		strFlashTag += '<param name="allowScriptAccess" value="sameDomain"/>';
		strFlashTag += '</object>';
	}
	else
	{
		strFlashTag += '<embed src="' + swf + '" ';
		strFlashTag += 'quality="best" ';
		strFlashTag += 'bgcolor="' + bgcolor + '" ';
		strFlashTag += 'width="' + width + '" ';
		strFlashTag += 'height="' + height + '" ';
		strFlashTag += 'menu="false" ';
		strFlashTag += 'scale="noscale" ';
		strFlashTag += 'id="' + id + '" ';
		strFlashTag += 'salign="LT" ';
		strFlashTag += 'wmode="transparent" ';
		strFlashTag += 'allowScriptAccess="sameDomain" ';
		if(flashvars != null) {strFlashTag += 'flashvars="' + flashvars + '" '};
		strFlashTag += 'type="application/x-shockwave-flash" ';
		strFlashTag += 'pluginspage="http://www.macromedia.com/go/getflashplayer">';
		strFlashTag += '</embed>';
	}

	document.write(strFlashTag);
}





function Floating(FloatingObj,MarginX,MarginY,Percentage,setTime) {
	this.FloatingObj = FloatingObj;
	this.MarginX = (MarginX) ? MarginX : 0;
	this.MarginY = (MarginY) ? MarginY : 0;
	this.Percentage = (Percentage) ? Percentage : 20;
	this.setTime = (setTime) ? setTime : 10;
	this.FloatingObj.style.position = "absolute";
	this.Body = null;
	this.setTimeOut = null;
	this.Run();
}

Floating.prototype.Run = function () {
	if ((document.documentElement.scrollLeft + document.documentElement.scrollTop) > (document.body.scrollLeft + document.body.scrollTop)) {
		this.Body = document.documentElement;
	} else {
		this.Body = document.body;
	}

	var This = this;
	var FloatingObjLeft = (this.FloatingObj.style.left) ? parseInt(this.FloatingObj.style.left,10) : this.FloatingObj.offsetLeft;
	var FloatingObjTop = (this.FloatingObj.style.top) ? parseInt(this.FloatingObj.style.top,10) : this.FloatingObj.offsetTop;
	var DocLeft = this.Body.scrollLeft + this.MarginX;
	var DocTop = this.Body.scrollTop + this.MarginY;

	var MoveX = Math.abs(FloatingObjLeft - DocLeft);
	MoveX = Math.ceil(MoveX / this.Percentage);
	var MoveY = Math.abs(FloatingObjTop - DocTop);
	MoveY = Math.ceil(MoveY / this.Percentage);

	if (FloatingObjLeft < DocLeft) {
		this.FloatingObj.style.left = FloatingObjLeft + MoveX + "px";
	} else {
		this.FloatingObj.style.left = FloatingObjLeft - MoveX + "px";
	}

	if (FloatingObjTop < DocTop) {
		this.FloatingObj.style.top = FloatingObjTop + MoveY + "px";
	} else {
		this.FloatingObj.style.top = FloatingObjTop - MoveY + "px";
	}

	window.clearTimeout(this.setTimeOut);
	this.setTimeOut = window.setTimeout(function () { This.Run(); },this.setTime);
}


/*-------------------------Tab menu--------------------------*/
  
if (typeof(lafui) == "undefined")
  lafui = new Object();
 
/*
 * Name : lafui.LhhMenu 
 * Parameter : menuId - UL Element as menu root element
 *             index - default selected menu index (start from 0). optional.
 */
lafui.LhhMenu = function (menuId, index1, index2) {
	this.currentMenuIndex = -1;
	this.menuLI = new Array();

	this.onMouseOverMenu = function () {
		this.hhMenu.inactivateMenu(this.hhMenu.currentMenuIndex);
		this.hhMenu.activateMenu(this.index);
	}
	this.onMouseOutMenu = function () {			
		this.hhMenu.inactivateMenu(this.index);
		this.hhMenu.activateMenu(this.hhMenu.currentMenuIndex);
	}	
	this.setCurrentMenu = function (index1, index2) {
		if (index1 >=0) { 
			this.activateMenu(index1);
			if (this.currentMenuIndex >= 0) {
				this.menuLI[this.currentMenuIndex].className = "";
				this.inactivateMenu(this.currentMenuIndex);
				for(var j=0;j<this.menuLI[this.currentMenuIndex].subUL.getElementsByTagName("LI").length;j++) {
				    this.menuLI[this.currentMenuIndex].subUL.getElementsByTagName("LI")[j].className=""; 					
				}
			}
			this.currentMenuIndex = index1;
			this.menuLI[index1].className = "Lcurrent";
			var subMenu = this.menuLI[index1].subUL.getElementsByTagName("LI");
			for(var i=0;i<subMenu.length;i++) {
				if (index2 >= 0 && i == index2) { 
					subMenu[index2].className = "Lcurrent";
					this.activateMenu(index1);
				} 
				else 
					subMenu[i].className = "";
			}
		}
	}
	this.activateMenu = function (index) {
		if (index >= 0) this.menuLI[index].subUL.style.display="block";
	}
	this.inactivateMenu = function (index) {
		if (index >= 0) this.menuLI[index].subUL.style.display="none";
	}
		
	var cnt = 0;
	var menuUL = document.getElementById(menuId);
	for (var i=0; i<menuUL.childNodes.length; i++) {
		if (menuUL.childNodes[i].nodeType == 1) { 
			menuUL.childNodes[i].onmouseover = this.onMouseOverMenu;
			menuUL.childNodes[i].onmouseout = this.onMouseOutMenu;
			this.menuLI[cnt] = menuUL.childNodes[i];
			this.menuLI[cnt].hhMenu = this;
			this.menuLI[cnt].index = cnt;
			this.menuLI[cnt].subUL = this.menuLI[cnt].getElementsByTagName('UL')[0];			
			
			cnt++;
		}
	}
	this.setCurrentMenu(index1, index2);
}
/*-------------------------Tr color change--------------------------*/
function bgChange(className, hoverColor, backColor) {
	var tableObj = document.getElementsByTagName("table");
	var tempTable= new Array();
	var count=0;
	var trObj;
	for(var i=0;i<tableObj.length;i++) {
		if(tableObj[i].className == className) {
			tempTable[count]=tableObj[i];
			count++;
		}
	}
	for(var j=0;j<tempTable.length;j++){
		trObj = tempTable[j].getElementsByTagName("tbody")[0].getElementsByTagName("tr");
		
		for(var z=0;z<trObj.length;z++){
			addEvent(trObj[z], "mouseover", hoverColor);
			addEvent(trObj[z], "mouseout", backColor);
		}
		
	} 
}
function addEvent(obj, event, color){
	 var onEvent = "on"+event;
	method= function() {
		obj.style.backgroundColor = color;
	}
	if(obj.addEventListener) {
		obj.addEventListener(event, method, false);
	} else if(obj.attachEvent) {
		obj.attachEvent(onEvent, method);
	} else if(obj.onEvent) {
		obj.onEvent = method;
	}
} 

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}