// JavaScript Document

<!--
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

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 MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
<!--showhidemeu-->
function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.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;
  }
}
<!--ShowShade-->
var isImageShow;
function ShowShade(id,c){
	isArrowShow = false;
	isImageShow = true;
	ShowAg();
	if (zXmlHttp.isSupported()){
		RemoveAllChild(c);
		GetMenuList(id,c);
	}
}
function ShowContentDriect(id,c){
	isArrowShow = false;
	isImageShow = true;
	ShowAg();
	if (zXmlHttp.isSupported()){
		RemoveAllChild(c);
		showContent(id);
	}
}
<!--showhideShade-->
function ShowAg(){
	MM_showHideLayers('topMenu','','show','menulist','','show','logo','','show','content','','show','Act','','show','slimg','','show');
	if(isArrowShow){
		arrowShow();
	}
}
function HideShade(){
	MM_showHideLayers('topMenu','','hide','menulist','','hide','logo','','hide','content','','hide','Act','','hide','up','','hide','down','','hide','slimg','','hide');
}
<!--movescroll-->
var isArrowShow;
function arrowShow(){
	MM_showHideLayers('up','','show','down','','show');
}
function arrowHide(){
	MM_showHideLayers('up','','hide','down','','hide');
}
var isMove;
function MoveScroll(c,w){
	isMove = true;
	move(c,w);
}
function move(c,w){
	var cl = document.getElementById(c);
	var scrHeight = cl.scrollHeight;
	var scrTop = cl.scrollTop;
	
	switch(w){
		case "up":
			moveup(c,scrTop);
			break;
		case "down":
			movedown(c,scrHeight-scrTop);
			break;
		default:
			break;
	}
	
}
function moveup(c,d){
	if(isMove){
		var cl = document.getElementById(c);
		d=d-10;
		if(d>0){			
			cl.scrollTop=d;
			setTimeout("moveup('"+c+"',"+d+")","100");
		}
		else{
			cl.scrollTop=0;
		}
	}
}
function movedown(c,d){
	if(isMove){
		var cl = document.getElementById(c);
		d=d-10;
		if(d>0){			
			cl.scrollTop=cl.scrollTop+10;
			setTimeout("movedown('"+c+"',"+d+")","100");
		}
		else{
			cl.scrollTop=cl.scrollHeight;
		}
	}
}
function stopm(){
	isMove = false;
}
<!--AJAX-->
var setInnerHTML = function (el, htmlCode) {
   if(htmlCode != '')
   {
    var ua = navigator.userAgent.toLowerCase();
    if (ua.indexOf('msie') >= 0 && ua.indexOf('opera') < 0) {
        htmlCode = '<div style="display:none"></div>' + htmlCode;
        htmlCode = htmlCode.replace(/<script([^>]*)>/gi,
                                    '<script$1 defer="true">');
		el.innerHTML = htmlCode;
        el.removeChild(el.firstChild);
    }
    else {
        var el_next = el.nextSibling;
        var el_parent = el.parentNode;
        el_parent.removeChild(el);
        el.innerHTML = htmlCode;
        if (el_next) {
            el_parent.insertBefore(el, el_next)
        } else {
            el_parent.appendChild(el);
        }
    }
   }
}
function GetMenuList(id,c){
	var oXmlHttp = zXmlHttp.createRequest();
	oXmlHttp.open("GET", "menu.aspx?id="+id, true);
	oXmlHttp.onreadystatechange = function(){
		if (oXmlHttp.readyState == 4){
			if (oXmlHttp.status == 200||oXmlHttp.status == 0){
				var ht='';
				var oXmlDom = oXmlHttp.responseXML;
				var cl = document.getElementById(c);
				var oRoot = oXmlDom.documentElement;
				var menus = oRoot.getElementsByTagName("menu");
				var rootImg = oRoot.getAttribute("imgs");
				
				ShowImages(rootImg);
				
				for(var i=0;i<menus.length; i++){
					var menuid,name,thing,overImgs;
					var oCurrentChild = menus[i].firstChild;
					
					do{
						switch (oCurrentChild.tagName) {
							case "id":
								menuid = oCurrentChild.text;
								break;
							case "name":
								name = oCurrentChild.text;
								break;
							case "thing":
								thing = oCurrentChild.text;
								break;
							case "imgs":
								overImgs = oCurrentChild.text;
								break;
							default:
								break;
						}
					}while(oCurrentChild = oCurrentChild.nextSibling);
					
					ht += '<div id="menu' + menuid + '" class="divcontent"><img src="images/dit.gif" width="10" height="9">&nbsp;&nbsp;&nbsp;&nbsp;<a href=javascript:'+thing+' onMouseOver=javascript:ShowImageWhenMove("'+overImgs+'"); class="amenu">'+name+'</a><br><br><br><br><br><div id="cmenu' + menuid + '" class="divcontent"></div></div>';
				}

				setInnerHTML(cl,ht);
			}
		}
	};
	oXmlHttp.send(null);
}
function ShowImageWhenMove(url){
	if(isImageShow){
		ShowImages(url);
	}
}
function RemoveAllChild(c){
	var cl = document.getElementById(c);
	if(cl.firstChild){
		do{
			var fcl = cl.firstChild;
			fcl.parentNode.removeChild(fcl);
			showMenuId = null;
		}while(cl.firstChild)
	}
}
function ShowImages(url){
	isArrowShow = false;
	arrowHide();

	var imgs = document.createElement("img");
	var back=document.createElement("div");
	imgs.src = url;
	imgs.className="showimgs";
	back.align='center';
	back.appendChild(imgs);
	
	ShowContentB("contentr");
	if(document.all.td1.firstChild){
		document.all.td1.removeChild(document.all.td1.firstChild);
	}
	document.all.td1.appendChild(back);
	if(document.all.logo.firstChild){
		document.all.logo.removeChild(document.all.logo.firstChild);
	}
}
function ShowSmallImage(url){
	var imgs = document.createElement("img");
	imgs.src = url;
	imgs.className="showsmallimgs";

	if(document.all.logo.firstChild){
		document.all.logo.removeChild(document.all.logo.firstChild);
	}
	document.all.logo.appendChild(imgs);
}
function ShowContentB(url){
	var cl = document.getElementById("content");
	//var back = document.createElement("div");
	//back.className=url;
	ScrollChange(url);
	cl.firstChild.className = url;
	//if(cl.firstChild){alert(cl.firstChild.id);
	//	cl.removeChild(cl.firstChild);
	//}
	//cl.appendChild(back);
}
function ScrollChange(url)
{
	var cl = document.getElementById("slimg");
	if(url=='contentr')
	{
		cl.className="contentshowr";
	}
	else
	{
		cl.className="slhide";
	}
}
//////////////////////////////////////////////////////////////////////////
function showContent(id){
	var oXmlHttp = zXmlHttp.createRequest();
	isImageShow = false;
	//isArrowShow = true;
	//arrowShow();
	ShowContentImg(id);
	oXmlHttp.open("GET", "msg.aspx?ismsg=f&id="+id, true);
	oXmlHttp.onreadystatechange = function(){
		if (oXmlHttp.readyState == 4){
			if (oXmlHttp.status == 200||oXmlHttp.status == 0){
				var msg = oXmlHttp.responseText;
				var cl = document.getElementById("td1");
				var divmsg = document.createElement("div");
				if(cl.firstChild){
					cl.removeChild(cl.firstChild);
				}
				cl.appendChild(divmsg);
				
				setInnerHTML(divmsg,msg);				
			}
		}
	};
	oXmlHttp.send(null);
}
function showContentByKey(id,key){
	var oXmlHttp = zXmlHttp.createRequest();
	//isArrowShow = true;
	//arrowShow();
	ShowContentImg(id);
	oXmlHttp.open("GET", "msg.aspx?key="+escape(key)+"&id="+id, true);
	oXmlHttp.onreadystatechange = function(){
		if (oXmlHttp.readyState == 4){
			if (oXmlHttp.status == 200||oXmlHttp.status == 0){
				var msg = oXmlHttp.responseText;
				var cl = document.getElementById("td1");
				var divmsg = document.createElement("div");
				
				setInnerHTML(divmsg,msg);
				
				if(cl.firstChild){
					cl.removeChild(cl.firstChild);
				}
				cl.appendChild(divmsg);
			}
		}
	};
	oXmlHttp.send(null);
}
function ShowContentImg(id){
	var oXmlHttp = zXmlHttp.createRequest();
	oXmlHttp.open("GET", "msgimg.aspx?id="+id, true);
	oXmlHttp.onreadystatechange = function(){
		if (oXmlHttp.readyState == 4){
			if (oXmlHttp.status == 200||oXmlHttp.status == 0){
				var oXmlDom = oXmlHttp.responseXML;
				var oRoot = oXmlDom.documentElement;
				var backImg = oRoot.getAttribute("back");
				var logoImg = oRoot.getAttribute("logo");

				if(backImg=='contentw'){
					isArrowShow = true;
					arrowShow();
				}
				ShowContentB(backImg);
				ShowSmallImage(logoImg);
			}
		}
	};
	oXmlHttp.send(null);
}
///////////////////////////////////////////////////////////////////////////
var showMenuId = null;
function showhideChildMenu(id,c){
/*
alert(id);
alert(c);
alert(showMenuId);
	if(showMenuId){
		if(showMenuId==c){
			hidemenu(c);
			showMenuId = null;
		}
		else{
			isArrowShow = false;
			arrowHide();
			hidemenu(showMenuId);
			GetMenuList(id,c);
			showMenuId = c;
		}
	}
	else{
		isArrowShow = false;
		arrowHide();
		GetMenuList(id,c);
		showMenuId = c;
	}	
*/
	var cl = document.getElementById(c);
	
	if(cl.firstChild){
		hidemenu(c);
	}
	else{
		isArrowShow = false;
		arrowHide();
		GetMenuList(id,c);
	}
}
function hidemenu(c){
	var cl = document.getElementById(c);
	for(var i=cl.childNodes.length-1;i>=0;i--){
		cl.childNodes[i].parentNode.removeChild(cl.childNodes[i]);
	}
}
<!--product-->
function previousPage(c){
	var cl = document.getElementById(c);
	var lcl = cl.lastChild;
	cl.removeChild(lcl);
	cl.insertBefore(lcl,cl.firstChild);
	lcl = cl.lastChild;
	cl.removeChild(lcl);
	cl.insertBefore(lcl,cl.firstChild);
}

function nextPage(c){
	var cl = document.getElementById(c);
	var fcl = cl.firstChild;
	cl.removeChild(fcl);
	cl.appendChild(fcl);
	fcl = cl.firstChild;
	cl.removeChild(fcl);
	cl.appendChild(fcl);
}

function showProduct(id){
	var oXmlHttp = zXmlHttp.createRequest();
	
	oXmlHttp.open("GET", "msg.aspx?ismsg=t&id="+id, true);
	oXmlHttp.onreadystatechange = function(){
		if (oXmlHttp.readyState == 4){
			if (oXmlHttp.status == 200||oXmlHttp.status == 0){
				var msg = oXmlHttp.responseText;
				var cl = document.getElementById("pContent");
				var divmsg = document.createElement("div");
				
				setInnerHTML(divmsg,msg);
								
				if(cl.firstChild){
					cl.removeChild(cl.firstChild);
				}
				cl.appendChild(divmsg);
			}
		}
	};
	oXmlHttp.send(null);
}
//-->
///////////////////////////////////////////////////////////////////////////////////////////
var jspeed=1;
var isMove=false;
function changeMoveSpeed(evt){
	if(isMove){
		var cl = document.getElementById("mov");
		//cl.offsetLeft+=Number(event.clientX);
		evt = evt ? evt : (window.event ? window.event : null);
		var x = evt.clientX-cl.offsetWidth/2;
		if(x<16){
			x = 16;
		}
		if(x>171-cl.offsetWidth){
			x=171-cl.offsetWidth
		}
		cl.style.left = x-16;
		//alert(event.clientX+"="+cl.offsetLeft);
		jspeed = cl.offsetLeft/2;
		if(jspeed<1){
			jspeed = 1;
		}
	}
}
function moveStart(){
	isMove=true;
}
function moveEnd(){
	isMove=false;
}

//////////////////////////////////////////////////////////////////////////////////////////SelectImgWindow
function oldSize(c){
	var ch = c.height;
	var cw = c.width;
	if(ch>cw){
		c.height = 300;
		c.width = cw*300/ch;
	}
	else{
		c.width = 321;
		c.height = ch*321/cw;
	}
}
function bigSize(c){
	c.height = c.height*1.1;
	c.width = c.width*1.1;
}
function smallSize(c){
	c.height = c.height/1.1;
	c.width = c.width/1.1;
}

var objs = new Object();
function removeAryItem(c){
	var cl = document.getElementById('imglist');
	var ci = document.getElementById('imgshow')
	cl.removeChild(c);
	delFromAry(c.id);
	if(ci.firstChild){
		ci.removeChild(ci.firstChild);
	}
}
function itemMouseOver(c){
	c.className="imgNameM";
}
function itemMouseOut(c){
	c.className="imgName";
}
function delFromAry(itmeId){
	delete objs[itmeId];
}
function getImg(id,url,c){
	var imgs = document.createElement("img");
	var cl = document.getElementById(c);
	imgs.id = id;
	imgs.src = url;

	if(cl.firstChild){
		cl.removeChild(cl.firstChild);
	}
	cl.appendChild(imgs);
}
function showImg(c){
	getImg('viewimg',objs[c.id],'imgshow');
}

function showImgD(v){
	getImg('viewimg',v,'imgshow');
}
function addAryItem(c,v){
	var cl = document.getElementById('imglist');
	var cl1 = document.getElementById(c);
	if(cl1 == '[object]')return;
	var ht = '<div id="' + c + '" class="imgName" onMouseOver="itemMouseOver(this)" onMouseOut="itemMouseOut(this)" onClick="showImg(this)" onDblClick="removeAryItem(this)">' + v + '</div>';
	cl.innerHTML += ht;
	objs[c] = v;
}

function returnImg(){
	var imgurl = '';
	for(var key in objs)imgurl += ','+objs[key];
	window.returnValue = imgurl.substring(1);
	window.close();
 }
 
function GetFolder(c,p){

	var cl = document.getElementById(c);
	
	if(cl.firstChild){
		hidemenu(c);
		return;
	}
	
	var oXmlHttp = zXmlHttp.createRequest();
	oXmlHttp.open("GET", "SelMovImg.aspx?id="+c+"&path="+encodeURI(p), true);
	oXmlHttp.onreadystatechange = function(){
		if (oXmlHttp.readyState == 4){
			if (oXmlHttp.status == 200||oXmlHttp.status == 0){
				var ht='<div class="divcontent"></div>';//<div class="divcontent"><div class="imgName">Í¼Æ¬ÁÐ±í</div><br><br><div class="divcontent"></div></div>';
				var oXmlDom = oXmlHttp.responseXML;
				var cl = document.getElementById(c);
				var oRoot = oXmlDom.documentElement;
				var menus = oRoot.getElementsByTagName("menu");
				
				for(var i=0;i<menus.length; i++){
					var menuid,name,thing,overImgs;
					var oCurrentChild = menus[i].firstChild;
					
					do{
						switch (oCurrentChild.tagName) {
							case "id":
								menuid = oCurrentChild.text;
								break;
							case "name":
								name = oCurrentChild.text;
								break;
							case "thing":
								thing = oCurrentChild.text;
								break;
							case "imgs":
								overImgs = oCurrentChild.text;
								break;
							default:
								break;
						}
					}while(oCurrentChild = oCurrentChild.nextSibling);
					
					ht += '<div class="divcontent"><div class="imgName" onMouseOver="itemMouseOver(this)" onMouseOut="itemMouseOut(this)" ' + thing + '><img src="' + overImgs + '" width="13" height="15">&nbsp;&nbsp;&nbsp;' + name + '</div><br><br><div id="c' + menuid + '" class="divcontent"></div></div>';
				}
				setInnerHTML(cl,ht);
			}
		}
	};
	oXmlHttp.send(null);
}

function pic(c){
	var imgValue = showModalDialog("seling.htm", "", "dialogWidth:608px; dialogHeight:535px; status:0;help:0");
	var cl = document.getElementById(c);
	
	if(imgValue != null){
		cl.value = imgValue;
	}
}