//leftmenu.js
var activeMenuItem = new Array();
	
	function isUlInArray(inputObj,ulObj){
		while(inputObj && inputObj.id!='left_menu'){
			if(inputObj==ulObj)return true;
			inputObj = inputObj.parentNode;			
		}		
		return false;
	}
	
	function showHideSub(e,inputObj)
	{
//alert("into showHideSub");
		if(!inputObj)inputObj=this;
//alert("new : "+ inputObj.id);
//alert("new : "+ inputObj.href);
//alert("kkkkkkkkkk : " + inputObj); //http://192.168.17.116:8088/Home/Products/TmaxWindow# ==>level2 node a href address
		var parentObj = inputObj.parentNode;
//alert(parentObj.nodeName); //LI	 class left_menu01_on
//alert(parentObj.id); //LI	 class left_menu01_on
		var ul = parentObj.getElementsByTagName('UL')[0];
		//parentObj.className='left_menu01_on';
//alert("ul : "+ul.id);
//alert("activeMenuItem.length : "+activeMenuItem.length); //return 0		
		if(activeMenuItem.length>0){
			for(var no=0;no<activeMenuItem.length;no++){
				
				//alert("activeMenuItem[0] : "+ activeMenuItem[0].id);
				if(!isUlInArray(ul,activeMenuItem[0]) && !isUlInArray(activeMenuItem[0],ul)){
					//alert("into");
					activeMenuItem[no].parentNode.className='left_menu01';
					activeMenuItem[no].style.display='none';
					activeMenuItem.splice(no,1);
					no--;
				}
			}			
		}
		//alert("ul.offsetHeight : " +ul.offsetHeight);
		//alert(ul.getElementsByTagName('LI').length);
		
		if(ul.offsetHeight == 0){ //
			ul.parentNode.className='left_menu01_on';
			ul.style.display='block'; //see
			inputObj.href = parentObj.id+'/Overview';
			activeMenuItem.push(ul);
		}else{
			parentObj.className='left_menu01';
			inputObj.href = parentObj.id+'/Overview';
			//ul.style.display='none'; //none
		}
	} //showHideSub
	
	function showHidePath(inputObj)
	{
		var startTag = inputObj;
		showHideSub(false,inputObj);
	} //showHidePath
	
	
	
	function initMenu()
	{
		var obj = document.getElementById('left_menu');
		
		var linkCounter=0;
		var aTags = obj.getElementsByTagName('A');
		
		var activeMenuItem = false;
		var activeMenuLink = false;
		
		var fileNameThis;
		var thisLocationArray = location.href.split('/');

		if(thisLocationArray.length==4){
			 fileNameThis ="/"+thisLocationArray[thisLocationArray.length-1];	
		}else if(thisLocationArray.length==5){ //leve2 Focus
			 fileNameThis ="/"+thisLocationArray[thisLocationArray.length-2]+"/"+thisLocationArray[thisLocationArray.length-1];	
		}else if(thisLocationArray.length==6){ //leve3 Focus
			fileNameThis  ="/"+thisLocationArray[thisLocationArray.length-3]+"/"+thisLocationArray[thisLocationArray.length-2]+"/"+thisLocationArray[thisLocationArray.length-1];	
		}else if(thisLocationArray.length==7){ //level4 Focus
			fileNameThis  ="/"+thisLocationArray[thisLocationArray.length-4]+"/"+thisLocationArray[thisLocationArray.length-3]+"/"+thisLocationArray[thisLocationArray.length-2];
			//fileNameThis  ="/"+thisLocationArray[thisLocationArray.length-4]+"/"+thisLocationArray[thisLocationArray.length-3]+"/"+thisLocationArray[thisLocationArray.length-2]+"/"+thisLocationArray[thisLocationArray.length-1];	
		}
		
		if(fileNameThis.indexOf('?')>0)fileNameThis = fileNameThis.substr(0,fileNameThis.indexOf('?'));
		if(fileNameThis.indexOf('#')>0)fileNameThis = fileNameThis.substr(0,fileNameThis.indexOf('#'));//alert(fileNameThis);
		
		for(var no=0;no<aTags.length;no++){
 			if(getStrTrim(aTags[no].parentNode.id)==fileNameThis){
				aTags[no].style.color='#009933';
			}
		
			var parent = aTags[no].parentNode;
			var subs = parent.getElementsByTagName('UL'); 
			if(subs.length>0){ //level2 node
				aTags[no].onclick = showHideSub; //add Event	
				linkCounter++; // increment by level2 node
				//aTags[no].id = 'aLink' + linkCounter; //add id for a tag
				aTags[no].id = 'link_' + linkCounter; //add id for a tag
			}	
			if(aTags[no].href.indexOf(fileNameThis)>=0 && aTags[no].href.charAt(aTags[no].href.length-1)!='#'){ 				
				if(aTags[no].parentNode.parentNode && aTags[no].parentNode.parentNode.id!='left_menu'){								
									
					var parentObj = aTags[no].parentNode.parentNode.parentNode;
					var a = parentObj.getElementsByTagName('A')[0];  //absolute
					if(a.id && !activeMenuLink){	//excute 1 times
						activeMenuLink = aTags[no];//http://192.168.17.116:8088/Products/Overview
						activeMenuItem = a.id;//aLink1
					}
				}
			}
		} //for		

		if(activeMenuItem){
			if(document.getElementById(activeMenuItem))showHidePath(document.getElementById(activeMenuItem));	
		}
		
	} 
	
	
	//initMenu
	
	
function getStrTrim(arg_str) {
 var rtn_str = "";
 var i=0;
 while(arg_str.charAt(i) != "") {
  if(arg_str.charAt(i)!=' ') {
   rtn_str += arg_str.charAt(i);
  }
  i++;
 }
 return rtn_str;
}

//sliding.js
function up2(obj){ 
	obj.style.display ='block';
}
function down2(obj){
	obj.style.display ='none';
}

function link(obj,url){
	obj.href=url;
}

function bchmenu(){
	var a = $('1')
	var b = $('2');
	
	b.style.display='none';
	a.style.display='block';
}

function achmenu(){
	var a = $('1')
	var b = $('2');
	
	a.style.display='none';
	b.style.display='block';	
}
//Contact.js
function phoneInit(cel){
	for(var i =0; i<6;i++){
		if(document.inq.phone1.options[i].value == cel){
			document.inq.phone1.selectedIndex = i;
		}	
	}
		
}
	
function sendINQ(){
	if(document.getElementById('title').value =="") {
		alert("제목을 입력해 주세요.");
		return false;
	}
	if(document.getElementById('content').value =="") {
		alert("내용을 입력해 주세요.");
		return false;
	}
	if(document.getElementById('content').value.length > 4000) {
		alert("글자수는 영문 4000, 한글 2000자로 제한됩니다.!");
		document.getElementById('content').value = document.getElementById('content').value.substring(0,4000);
		document.getElementById('content').focus();
		return false;
	}else {
		document.getElementById('feedurl2').value = document.URL;
		document.inq.action ='/servlet/InsertInquiry';
		document.inq.submit();
	}
	
}


function sendAns(){
	document.ans.action ='/servlet/InsertAnswer';
	document.ans.submit();
}


function clearINQ(){
	
	document.inq.phone1.selectedIndex = 0;
	document.getElementById('phone2').value = "";
	document.getElementById('phone3').value = "";
	document.getElementById('company').value = "";
	document.getElementById('title').value = "";
	document.getElementById('content').value = "";
	
	return false;
	
}
//validator.js
function noRefresh(ev){
	
	if(window.netscape) {
		if (ev.which == 116) {
			ev.which = 0;
			return false;
		}
	}else {
		if (ev.keyCode == 116) {
			ev.keyCode = 0;
			return false;
		}
	}

}

function noEnglish(ev) {
	
	if(window.netscape) {
		if(ev.which == 0)
			return true;
		if(ev.which == 8)
			return true;
		if ( (ev.which <48) || (ev.which>57)) {
			
			ev.preventDefault(); 
			return false;
		}
	}else {
		if(ev.keyCode == Event.KEY_TAB)
			return true;
		if ((ev.keyCode<48) || (ev.keyCode>57)) {
			ev.returnValue=false;
			return false;
		}
	}
}

function noSpecial(ev) {

	if(window.netscape) {

		if(ev.which == 8)
			return true;
		if(ev.which == 0)
			return true;
		if(ev.which == 46) 
			return true;
		if(ev.which == 95)
			return true; 
		if(ev.which == 63)
			return true;
		if(ev.which == 33)
			return true;	
		if( (ev.which > 32 && ev.which < 48) || 
  			(ev.which > 57 && ev.which < 65) ||
  			(ev.which > 90 && ev.which < 97) ){
   	
   			ev.preventDefault(); 
   			return false;
   			alert("특수문자는 입력할 수 없습니다.");
		}

	}else{
	
		if(ev.keyCode == Event.KEY_TAB)
			return true;
		if(ev.keyCode == 46)
			return true;
		if(ev.keyCode == 95)
			return true;
		if(ev.keyCode == 63)
			return true;
		if(ev.keyCode == 33)
			return true;
		if( (ev.keyCode > 32 && ev.keyCode < 48) || 
  			(ev.keyCode > 57 && ev.keyCode < 65) ||
  			(ev.keyCode > 90 && ev.keyCode < 97) ){
   	
   			ev.returnValue=false;
   			alert("특수문자는 입력할 수 없습니다.");
		}
	}

}

function noSpecialForBlog(ev) {

	if(window.netscape) {
		if(ev.which == 47)
			return true;
		if(ev.which == 32) {
			ev.preventDefault(); 
   			return false;
			alert("공백은 입력할 수 없습니다.");
		}else {
			noSpecial(ev);
		}
	}else {
		if(ev.keyCode == 47)
			return true;
		if(ev.keyCode == 32) {
			ev.returnValue=false;
			alert("공백은 입력할 수 없습니다.");		
		}else {
			noSpecial(ev);
		} 
			
	}
	
}

function noSpecialForContact(ev) {
	
	if(window.netscape) {

		if(ev.which == 0)
			return true;
		if(ev.which == 8)
			return true;
		if(ev.which == 46) 
			return true;
		if(ev.which == 95)
			return true; 
		if(ev.which == 63)
			return true;
		if(ev.which == 33)
			return true;	
		if( (ev.which > 32 && ev.which < 48) || 
  			(ev.which > 57 && ev.which < 65) ||
  			(ev.which > 90 && ev.which < 97) ){
   	
   			ev.preventDefault(); 
   			return false;
   			alert("특수문자는 입력할 수 없습니다.");
		}

	}else{
	
		if(ev.keyCode == Event.KEY_TAB)
			return true;
		if(ev.keyCode == 46)
			return true;
		if(ev.keyCode == 95)
			return true;
		if(ev.keyCode == 63)
			return true;
		if(ev.keyCode == 33)
			return true;
		if( (ev.keyCode > 32 && ev.keyCode < 48) || 
  			(ev.keyCode > 57 && ev.keyCode < 65) ||
  			(ev.keyCode > 90 && ev.keyCode < 97) ){
   	
   			ev.returnValue=false;
   			alert("특수문자는 입력할 수 없습니다.");
		}
	}
	
}

