// Flash Rewrite
function IE_HtmlRewrite(objParent) {
	if (window.ActiveXObject && objParent) {
		objParent.innerHTML = objParent.innerHTML;
	}
}

// Select
function selectShow(Name) {
	selectObj = document.getElementById(Name);
	selectObj.style.display='block';
}

function selectHide(Name) {
	selectObj = document.getElementById(Name);
	selectObj.style.display='none';
}

// Png file
function setPng24(obj) {
	obj.width=obj.height=1;
	obj.className=obj.className.replace(/\bpng24\b/i,'');
	obj.style.filter =
	"progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+ obj.src +"',sizingMethod='image');"
	obj.src=''; 
	return '';
}

// Menu
function initNavigation(seq) {
	nav = document.getElementById("topmenu");
	nav.menu = new Array();
	nav.current = null;
	nav.menuseq = 0;
	navLen = nav.childNodes.length;
	
	allA = nav.getElementsByTagName("a")
	for(k = 0; k < allA.length; k++) {
		allA.item(k).onmouseover = allA.item(k).onfocus = function () {
			nav.isOver = true;
		}
		allA.item(k).onmouseout = allA.item(k).onblur = function () {
			nav.isOver = false;
			setTimeout(function () {
				if (nav.isOver == false) {
					if (nav.menu[seq])
						nav.menu[seq].onmouseover();
					else if(nav.current) {
						menuImg = nav.current.childNodes.item(0);
						//menuImg.src = menuImg.src.replace("_on.gif", ".gif");
						if (nav.current.submenu)
							nav.current.submenu.style.display = "none";
						nav.current = null;
					}
				}
			}, 99999999999999999);
		}
	}

	for (i = 0; i < navLen; i++) {
		navItem = nav.childNodes.item(i);
		if (navItem.tagName != "LI")
			continue;

		navAnchor = navItem.getElementsByTagName("a").item(0);
		navAnchor.submenu = navItem.getElementsByTagName("ul").item(0);
		
		navAnchor.onmouseover = navAnchor.onfocus = function () {
			if (nav.current) {
				menuImg = nav.current.childNodes.item(0);
				//menuImg.src = menuImg.src.replace("_on.gif", ".gif");
				if (nav.current.submenu)
					nav.current.submenu.style.display = "none";
				nav.current = null;
			}
			if (nav.current != this) {
				menuImg = this.childNodes.item(0);
				//menuImg.src = menuImg.src.replace(".gif", "_on.gif");
				if (this.submenu)
					this.submenu.style.display = "block";
				nav.current = this;
			}
			nav.isOver = true;
		}
		nav.menuseq++;
		nav.menu[nav.menuseq] = navAnchor;
	}
	if (nav.menu[seq])
		nav.menu[seq].onmouseover();
}

function SLB_setCenter(obj) {
	if (obj) {
		document.getElementById(obj).style.display = "block";
		var w = fnIsIETrueBody().clientWidth;
		var h = fnIsIETrueBody().clientHeight;
		var objw = document.getElementById(obj).offsetWidth;
		var objh = document.getElementById(obj).offsetHeight;
		var l = fnIsIETrueBody().scrollLeft + (w-objw)/2;
		var t = fnIsIETrueBody().scrollTop + (h-objh)/2;
		document.getElementById(obj).style.left = l + "px";
		document.getElementById(obj).style.top = t + "px";
	}
}

function fnIsIETrueBody(){
	return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body;
}

// Calendar Layer
function layerShow(layerId) {
	document.getElementById(layerId).style.display = "block";
}
function layerHide(layerId) {
	document.getElementById(layerId).style.display = "none";
}

// Img over
function imageOn(imgEl) {
	imgEl.src = imgEl.src.replace(".gif", "_on.gif");
}
function imageOut(imgEl) {
	imgEl.src = imgEl.src.replace("_on.gif", ".gif");
}

// FAQ
function initToggle(tabContainer) {
	triggers = tabContainer.getElementsByTagName("a");

	for(i = 0; i < triggers.length; i++) {
		triggers.item(i).targetEl = document.getElementById(triggers.item(i).href.split("#")[1]);
		if (!triggers.item(i).targetEl)
			continue;

		triggers.item(i).targetEl.style.display = "none";
		triggers.item(i).onclick = function () {
			if (tabContainer.current == this) {
				this.targetEl.style.display = "none";
				tabContainer.current = null;
			} else {
				if (tabContainer.current) {
					tabContainer.current.targetEl.style.display = "none";
				}
				this.targetEl.style.display = "block";
				tabContainer.current = this;
			}
			return false;
		}
	}
}

// Popup
function PopupOpen(strUrl,strWindowName,strWidth,strHeight) {
	var strWindowFeatures = "width="+strWidth+",height="+strHeight;
	var strWindowPopup = window.open(strUrl,strWindowName,strWindowFeatures);
}

// photoScollWrap
function photoScrollWidth(widthV) {
	var photoScrollList=document.getElementById("photoScollList");
	var photoScrollEa = photoScrollList.getElementsByTagName("li");
	var photoScrollWidth = photoScrollEa.length * widthV;
	photoScrollList.style.width = photoScrollWidth + "px";
}

function photoScrollMove(moveF,moveV,EA) {
	var photoScrollList=document.getElementById("photoScollList");
	var photoScrollLeft = photoScrollList.style.left;
	photoScrollLeft = parseInt(photoScrollLeft.replace("px",""));
	photoScrollWidth = photoScrollList.style.width;
	photoScrollWidth = parseInt(photoScrollWidth.replace("px",""));
	photoScrollWidth = -(photoScrollWidth + (moveV*EA));
	if (moveF == "P") {
		if (photoScrollLeft !=0) {
			photoScrollList.style.left = photoScrollLeft + moveV + "px";
		}
		else {
			alert("No more Image");
		}
	}
	else {
		if (photoScrollLeft > photoScrollWidth) {
			photoScrollList.style.left = photoScrollLeft + moveV + "px";
		}
		else {
			alert("No more Image");
		}
	}
}

function photoScrollWidthB(widthV) {
	var photoScrollListB=document.getElementById("photoScollListB");
	var photoScrollEaB = photoScrollListB.getElementsByTagName("li");
	var photoScrollWidthB = photoScrollEaB.length * widthV;
	photoScrollListB.style.width = photoScrollWidthB + "px";
}

function photoScrollMoveB(moveF,moveV,EA) {
	var photoScrollListB=document.getElementById("photoScollListB");
	var photoScrollLeftB = photoScrollListB.style.left;
	photoScrollLeftB = parseInt(photoScrollLeftB.replace("px",""));
	photoScrollWidthB = photoScrollListB.style.width;
	photoScrollWidthB = parseInt(photoScrollWidthB.replace("px",""));
	photoScrollWidthB = -(photoScrollWidthB + (moveV*EA));
	if (moveF == "P") {
		if (photoScrollLeftB !=0) {
			photoScrollListB.style.left = photoScrollLeftB + moveV + "px";
		}
		else {
			alert("No more Image");
		}
	}
	else {
		if (photoScrollLeftB > photoScrollWidthB) {
			photoScrollListB.style.left = photoScrollLeftB + moveV + "px";
		}
		else {
			alert("No more Image");
		}
	}
}
/* paging  */
function cmdMove(url, num, listcount){
	document.pagingFrm.pageNum.value = num;
	document.pagingFrm.startNum.value = (num * listcount) - (listcount) + 1;
	document.pagingFrm.endNum.value = num * listcount;
	document.pagingFrm.action = url;
	document.pagingFrm.submit();
}
