// change ¼¼ÆÃ
function AutoSearch(frm){
	ItemOneCode = frm.ItemOneCode[frm.ItemOneCode.selectedIndex].value; ItemChangeTwo(ItemOneCode, frm);
}

function ItemChangeTwo(ItemOneCode, frm){ var tmp = parseInt(ItemOneCode); j = 1; 
	for(i = frm.ItemTwoCode.length-1; i > -1; i--){ frm.ItemTwoCode.options[i].value = null; frm.ItemTwoCode.options[i] = null; }
	frm.ItemTwoCode.options[0] = new Option("¢Æ¢Æ¢Æ Step 2 Choice ¢Æ¢Æ¢Æ",1); frm.ItemTwoCode.options[0].value = "";
	for(i = tmp * 100; i < tmp * 100 + 99; i++){ if(TwoCode[i] != null){	frm.ItemTwoCode.options[j] = new Option(TwoName[i],1); frm.ItemTwoCode.options[j].value = i; j++; } }
}

// ¼ýÀÚ°ª Ã¼Å©
function isNum(obj, obj1) {
    for (i = obj1; i < obj.value.length; i++) {	if (obj.value.charAt(i) < "0" || obj.value.charAt(i) > "9")	return false;	}	return true;
}

// °ª Ã¼Å©
function isNumChar(obj, obj1) {
    for (i = 0, j = 0; i < obj.value.length; i++){
		if ((obj.value.charAt(i) >= "0" && obj.value.charAt(i) <= "9") || obj.value.charAt(i) == obj1){}else{j++;}	
	}	
	if(j == 0) return true; else return false;
}

// °ªÀ¯È¿ ¿©ºÎ Ã¼Å©
function isFilled(obj) {
    if(obj.value == "" || obj.value == null)	return false;   else return true;
}

// ÇÑ±Û ÀÌ¸§ Ã¼Å©
function CheckNameKor(obj) {
	for (var i=0; i<obj.value.length; i++) { var ch = obj.value.charAt(i);
		if( (ch>="a" && "z">=ch) || ch=="-" || ch=="_" || (ch>="0" && "9">=ch) || (ch>="a" && "z">=ch) || (ch>="A" && "Z">=ch) || ch=="!" || ch=="@" || ch=="$" || ch=="%" || ch=="^" || ch=="&" || ch=="*" )	return false; 
	} return true;
}

// ÀÌ¸ÞÀÏ Ã¼Å©
function isEmail(obj) {
	var goodEmail = obj.value.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.pe.kr)|(\.co.kr)|(\.org)|(\..{2,2}))$)\b/gi);
	if (goodEmail){	   return true	} else {	   return false   }
}

// ¹®ÀÚ°ª Ã¼Å©
function isChar(obj) {
    len = obj.value.length;		ret = true;
    for (i = 0; i < len; i++) {
		if ((obj.value.charAt(i) >= "A" && obj.value.charAt(i) <= "Z") || (obj.value.charAt(i) >= "a" && obj.value.charAt(i) <= "z")); else ret = false;
	} 
	return ret;
}

// ¹®ÀÚ ¹× ¼ýÀÚ ±æÀÌ Ã¼Å©
function isLength(obj, obj1){
    if (obj.value.length < obj1)	return false;	else return true; 
}

// ¹®ÀÚ °Ë·Ä 
function stringFilter(s,t){
	s_i = s.indexOf("@")+1;
	if (s.substring(s_i, s.length) == t) return true; else return false;
}

// ÀÌ¸ÞÀÏ Ã¼Å©
function isEmail(obj) {
	var goodEmail = obj.value.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.pe.kr)|(\.co.kr)|(\.org)|(\..{2,2}))$)\b/gi);
	if (goodEmail){	   return true	} else {	   return false   }
}

// È®ÀåÀÚ Ã¼Å©
function Chk_fileExt(file) {
	var ext = file.substring(file.lastIndexOf(".")+1); ext = ext.toUpperCase();
	if (ext == "JPG" || ext=="JPEG" || ext=="GIF") { return true; }else{ return false; }
}

// Ã·ºÎ»çÁø Ã¼Å©
function CheckImg(frm){ 
	if(!Chk_fileExt(frm)) { alert('Upload File is only gif, jpg, jpeg'); return false; }
}

// ¾ÆÀÌµð Ã¼Å©
function isLoginname(obj) {
    len = obj.value.length;  ret = true;
    if (len < 4) return false;
    if(!((obj.value.charAt(0) >= "a" && obj.value.charAt(0) <= "z") || (obj.value.charAt(0) >= "A" && obj.value.charAt(0) <= "Z")))	ret = false;		
    for (i = 1; i < len; i++) {
		if((obj.value.charAt(i) >= "0" && obj.value.charAt(i) <="9") || (obj.value.charAt(i) >= "a" && obj.value.charAt(i) <= "z") || (obj.value.charAt(i) >= "A" && obj.value.charAt(i) <= "Z"));	else ret = false;
    } return ret;		   
}

// ·Î±×ÀÎ Ã¼Å©
function LogCheck(frm){
	if(!isFilled(frm.mID)){	alert("¾ÆÀÌµð¸¦ ÀÔ·ÂÇÏ¼¼¿ä.!"); frm.mID.focus();
	}else if(!isFilled(frm.mPWD)){	alert("ºñ¹Ð¹øÈ£¸¦ ÀÔ·ÂÇÏ¼¼¿ä!"); frm.mPWD.focus();
	}else{	frm.mode.value="IN"; frm.submit(); 	}
} 

// ·Î±×ÀÎ Ã¼Å©
function LogType(obj){
	var frm = document.frm;
	if(obj == "Y"){
		if(!isFilled(frm.mID)){	alert("¾ÆÀÌµð¸¦ ÀÔ·ÂÇÏ¼¼¿ä.!"); frm.mID.focus();
		}else if(!isFilled(frm.mPWD)){	alert("ºñ¹Ð¹øÈ£¸¦ ÀÔ·ÂÇÏ¼¼¿ä!"); frm.mPWD.focus();
		}else{	frm.mode.value="IN"; frm.action='/include/LogType.html'; frm.target='proc'; frm.method='post'; frm.submit(); 	}
	}else{
		frm.mode.value="OUT"; frm.action='/include/LogType.html'; frm.target='proc'; frm.method='post'; frm.submit(); 	
	}
} 

// °Ô½ÃÆÇ
function Check(frm, obj) {
	if(obj == 'B'){
		if(!isFilled(frm.title)){			alert("Please fill up the Title.");				frm.title.focus();
		}else if(!isFilled(frm.writer)){	alert("Please fill up the Writer.");			frm.writer.focus();
		}else if(!isFilled(frm.email)){		alert("Please fill up the E-mail.");			frm.email.focus();
		}else if(!isFilled(frm.contents)){	alert("Please fill up the Contents.");			frm.contents.focus();
		}else{ frm.submit(); }
	}else if(obj == 'E'){
		if(!isFilled(frm.ItemOneCode)){			alert("Please choice the Step 1.");			frm.ItemOneCode.focus();
		}else if(!isFilled(frm.ItemTwoCode)){	alert("Please choice the Step 2.");			frm.ItemTwoCode.focus();
		}else if(!isFilled(frm.file1)){		alert("Please upload the Large Image.");			frm.file1.focus();
		}else if(!Chk_fileExt(frm.file1.value)){alert("Upload Large Image is only gif, jpg, jpeg"); frm.file1.focus();
		}else if(!isFilled(frm.file2)){		alert("Please upload the Small Image.");			frm.file2.focus();
		}else if(!Chk_fileExt(frm.file2.value)){alert("Upload Small Image is only gif, jpg, jpeg"); frm.file2.focus();
		}else if(frm.view.checked == true && !isFilled(frm.file3)){		alert("Please upload the Main Image.");			frm.file3.focus();
		}else if(!isFilled(frm.title)){	alert("Please fill up the Title.");			frm.title.focus();
		}else if(!isFilled(frm.memo)){	alert("Please fill up the Memo.");			frm.memo.focus();
		}else if(!isFilled(frm.rank)){	alert("Please fill up the Rank.");			frm.rank.focus();
		}else{ frm.submit(); }
	}else if(obj == 'F'){
		if(!isFilled(frm.ItemOneCode)){			alert("Please choice the Step 1.");			frm.ItemOneCode.focus();
		}else if(!isFilled(frm.ItemTwoCode)){	alert("Please choice the Step 2.");			frm.ItemTwoCode.focus();
		}else if(isFilled(frm.file1) && !Chk_fileExt(frm.file1.value)){alert("Upload Large Image is only gif, jpg, jpeg"); frm.file1.focus();
		}else if(isFilled(frm.file2) && !Chk_fileExt(frm.file2.value)){alert("Upload Small Image is only gif, jpg, jpeg"); frm.file2.focus();
		}else if(!isFilled(frm.title)){	alert("Please fill up the Title.");			frm.title.focus();
		}else if(!isFilled(frm.memo)){	alert("Please fill up the Memo.");			frm.memo.focus();
		}else if(!isFilled(frm.rank)){	alert("Please fill up the Rank.");			frm.rank.focus();
		}else{ frm.submit(); }
	}else if(obj == 'C'){
		if(!isFilled(frm.title)){			alert("Please fill up the Title.");				frm.title.focus();
		}else if(!isFilled(frm.writer)){	alert("Please fill up the Writer.");			frm.writer.focus();
		}else if(!isFilled(frm.file1)){		alert("Please upload the File 1.");				frm.file1.focus();
		}else if(!Chk_fileExt(frm.file1.value)){alert("Upload File is only gif, jpg, jpeg"); 		frm.file1.focus();
		}else if(isFilled(frm.file2) && !Chk_fileExt(frm.file2.value)){	alert("Upload File is only gif, jpg, jpeg"); frm.file2.select();
		}else if(isFilled(frm.file3) && !Chk_fileExt(frm.file3.value)){	alert("Upload File is only gif, jpg, jpeg"); frm.file3.focus();
		}else if(isFilled(frm.file4) && !Chk_fileExt(frm.file4.value)){	alert("Upload File is only gif, jpg, jpeg"); frm.file4.focus();
		}else if(isFilled(frm.file5) && !Chk_fileExt(frm.file5.value)){	alert("Upload File is only gif, jpg, jpeg"); frm.file5.focus();
		}else if(isFilled(frm.file6) && !Chk_fileExt(frm.file6.value)){	alert("Upload File is only gif, jpg, jpeg"); frm.file6.focus();
		}else if(!isFilled(frm.contents)){	alert("Please fill up the Contents.");			frm.contents.focus();
		}else{ frm.submit(); }
	}else if(obj == 'D'){
		if(!isFilled(frm.title)){			alert("Please fill up the Title.");				frm.title.focus();
		}else if(!isFilled(frm.writer)){	alert("Please fill up the Writer.");			frm.writer.focus();
		}else if(isFilled(frm.file1) && !Chk_fileExt(frm.file1.value)){	alert("Upload File is only gif, jpg, jpeg"); frm.file1.select();
		}else if(isFilled(frm.file2) && !Chk_fileExt(frm.file2.value)){	alert("Upload File is only gif, jpg, jpeg"); frm.file2.select();
		}else if(isFilled(frm.file3) && !Chk_fileExt(frm.file3.value)){	alert("Upload File is only gif, jpg, jpeg"); frm.file3.focus();
		}else if(isFilled(frm.file4) && !Chk_fileExt(frm.file4.value)){	alert("Upload File is only gif, jpg, jpeg"); frm.file4.focus();
		}else if(isFilled(frm.file5) && !Chk_fileExt(frm.file5.value)){	alert("Upload File is only gif, jpg, jpeg"); frm.file5.focus();
		}else if(isFilled(frm.file6) && !Chk_fileExt(frm.file6.value)){	alert("Upload File is only gif, jpg, jpeg"); frm.file6.focus();
		}else if(!isFilled(frm.contents)){	alert("Please fill up the Contents.");			frm.contents.focus();
		}else{ frm.submit(); }
	}else{
		//if(!isFilled(frm.country)){			alert("Please choice the Country.");			frm.country.focus();
		if(!isFilled(frm.country)){			alert("Please fill up the Country.");			frm.country.focus();
		}else if(!isFilled(frm.contact)){	alert("Please fill up the Contact Person.");	frm.contact.focus();
		}else if(!isFilled(frm.tel)){		alert("Please fill up the Telephone.");			frm.tel.focus();
		}else if(!isFilled(frm.email)){		alert("Please fill up the E-mail.");			frm.email.focus();
		}else if(!isFilled(frm.subject)){	alert("Please fill up the Subject.");			frm.subject.focus();
		}else if(!isFilled(frm.message)){	alert("Please fill up the Message.");			frm.message.focus();
		}else{ frm.submit(); }
	}
}

function NewWinPic(w_url, w_title, w_width, w_height, w_resizable, w_scrollbars){
	var option = "alwaysRaised,toolbar=0,status=0,menubar=0";
	
	var w_left = (screen.width)?(screen.width-w_width)/2:100;
	var w_top = (screen.height)?(screen.height-w_height)/2:100;
	
	//width ¿Í height °¡ ÀÖÀ»¶§¸¸ È­¸éÀÇ °¡¿îµ¥¿¡ Ç¥½ÃÇÑ´Ù
	if (w_width) option = option + ",width=" + w_width + ",left=" + w_left;
	if (w_height) option = option + ",height=" + w_height + ",top=" + w_top;
	//Ã¢Å©±â Á¶Àý°¡´É°ú ½ºÅ©·Ñ¹Ù Ç¥½Ã´Â ±âº»ÀûÀ¸·Î º¸ÀÌÁö ¾ÊÀ¸¸ç, ÁöÁ¤ÇÒ¶§¸¸ º¸ÀÎ´Ù
	if (w_resizable == true) option = option + ",resizable=1";
	if (w_scrollbars == true) option = option + ",scrollbars=1";

	var new_instance = window.open(w_url,w_title,option,"");
	new_instance.focus();
}


// ÀÌ¹ÌÁö È®´ë
function view(obj) { 
	var imgwin = window.open("",'WIN','scrollbars=no,status=no,toolbar=no,resizable=1,location=no,menu=no,width=0,height=0'); imgwin.focus(); 
	imgwin.document.open(); 
	imgwin.document.write("<html><head><title>È®´ëÈ­¸é</title><script>"); 
	imgwin.document.write("function resize() {"); 
	imgwin.document.write("pic = document.il;"); 
	imgwin.document.write("if (eval(pic).height) { var name = navigator.appName;"); 
	imgwin.document.write("  if (name == 'Microsoft Internet Explorer') { myHeight = eval(pic).height + 30; myWidth = eval(pic).width + 12;"); 
	imgwin.document.write("  } else { myHeight = eval(pic).height + 30; myWidth = eval(pic).width; }"); 
	imgwin.document.write("  clearTimeout();"); 
	imgwin.document.write("  var height = screen.height;"); 
	imgwin.document.write("  var width = screen.width;"); 
	imgwin.document.write("  var leftpos = width / 2 - myWidth / 2;"); 
	imgwin.document.write("  var toppos = height / 2 - myHeight / 2;"); 
	imgwin.document.write("  self.moveTo(leftpos, toppos);"); 
	imgwin.document.write("  self.resizeTo(myWidth, myHeight);"); 
	imgwin.document.write("}else setTimeOut(resize(), 100);}"); 
	imgwin.document.write("</script></head>"); 
	imgwin.document.write("<body topmargin=0 leftmargin=0 oncontextmenu='return false' ondragstart='return false'>"); 
	imgwin.document.write("<img border=0 src='"+ obj +"' xwidth=100 xheight=9 name=il onload='resize();' onclick='window.close();' title='´Ý±â' style='cursor:hand;'>"); 
	imgwin.document.write("</body></html>"); 
	imgwin.document.close(); 
}

// ÀÚµ¿ ½ºÅ©·Ñ //////////////////////////////////////////////////////////////////////////////////////////////////////////////
var isDOM = (document.getElementById ? true : false);  
var isIE4 = ((document.all && !isDOM) ? true : false); 
var isNS4 = (document.layers ? true : false);  

function getRef(id) { 
	if (isDOM) return document.getElementById(id); 
	if (isIE4) return document.all[id]; 
	if (isNS4) return document.layers[id]; 
}  

var isNS = navigator.appName == "Netscape";  

function moveRightEdge() { 
	var yMenuFrom, yMenuTo, yOffset, timeoutNextCheck;  

	if (isNS4) { 
		yMenuFrom   = divMenu.top; 
		yMenuTo     = windows.pageYOffset + 260; 
	} else if (isDOM) { 
		yMenuFrom   = parseInt (divMenu.style.top, 10); 
		yMenuTo     = (isNS ? window.pageYOffset : document.body.scrollTop) + 260; 
	} 
	timeoutNextCheck = 30;  

	if (yMenuFrom != yMenuTo) { 
		yOffset = Math.ceil(Math.abs(yMenuTo - yMenuFrom) / 20); 
		if (yMenuTo < yMenuFrom) yOffset = -yOffset; 
		if (isNS4) divMenu.top += yOffset; else if (isDOM) divMenu.style.top = parseInt (divMenu.style.top, 10) + yOffset; 

		timeoutNextCheck = 5; 
	} 
	setTimeout ("moveRightEdge()", timeoutNextCheck); 
} 


/// ÆË¾÷ ¼³Á¤ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function getCookie( name ){ 
	var nameOfCookie = name + "="; var x = 0; 
	while(x <= document.cookie.length){ var y = (x+nameOfCookie.length); 
		if(document.cookie.substring(x, y) == nameOfCookie){ 
			if((endOfCookie=document.cookie.indexOf( ";", y )) == -1) endOfCookie = document.cookie.length; 
			return unescape(document.cookie.substring(y, endOfCookie)); 
		} x = document.cookie.indexOf(" ", x) + 1; if(x == 0) break; 
	} return ""; 
} 


// Flash ¼³Á¤ ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
function mEmGET(arrayKey, arrayValue, Value) { 
    count = arrayKey.length; 
    for(i=0;i<count;i++) { 
        if(arrayKey[i]==Value) { return arrayValue[i]; break; } 
    } 
} 

// ie ativeX Ãâ·Â º¯°æ ÇÔ¼ö 
function mEmbed() { 
	var emtype; var key = new Array(); var value = new Array(); 
    for(i=0;i<mEmbed.arguments.length;i++) { 
        data = mEmbed.arguments[i].split('='); key[i] = data[0]; value[i] = data[1]; 
    } 

    contents = ''; srcdata = mEmGET(key,value,'src').toLowerCase();
    
	if(/\.(swf)$/.test(srcdata)) { 
			classid = 'clsid:D27CDB6E-AE6D-11cf-96B8-444553540000'; 
			codebase = 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0'; 
			emtype="flash"; 
	} else if(/\.(wmv|wma|asf|avi|wav|asx|mpeg|mp3|midi|aiff|au|wpl|wm|wmx|wmd|wmz)$/.test(srcdata)){//media 
			classid = 'CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95'; 
			codebase = 'http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701'; 
			emtype="media"; 
	} 
    if(classid && codebase) { 
        contents += '<object'; 
        if(classid) { contents += ' classid="' + classid + '"'; } 
        if(codebase) { contents += ' codebase="' + codebase + '"';  } 
        count = key.length; 
        for(i=0;i<count;i++) { 
            if(value[i]!='') { 
				if(key[i]!='src') {  contents += ' ' + key[i] + '="' + value[i] + '"';  } 
            } 
        } 
        contents += '>'; 
		if(emtype=='flash'){ contents += '<param value="transparent" name="wmode">'; }
        for(i=0;i<count;i++) { 
            if(value[i]!='') { 
                if(emtype=='flash' && key[i]=='src') { 
                    contents += '<param name="movie" value="' + value[i] + '">'; contents += '<param name="quality" value="high">'; 
                } 
				if(emtype=='media' && key[i]=='src') { 
                    contents += '<param name="filename" value="' + value[i] + '">'; 
                }  
            } 
        } 
    } 
    contents += '<embed'; 
    for(i=0;i<count;i++) { 
        if(value[i]!='') { contents += ' ' + key[i] + '="' + value[i] + '"'; } 
    } 
    contents += '>'; contents += '</embed>'; 
	if(classid && codebase) { contents += '</object>';  } 
    document.write(contents);
} 

function flashWrite( id, flashUri, vWidth, vHeight, winMode ) {
	var _obj_ = "";

 
	_obj_ = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="' + vWidth + '" height="' + vHeight + '" id="' + id + '" align="middle">';
	_obj_ += '<param name="movie" value="' + flashUri + '" />';
	_obj_ += '<param name=allowScriptAccess value=always />';
	_obj_ += '<param name="quality" value="high" />';
	_obj_ += '<param name="wmode" value="' + winMode + '" />    ';
	_obj_ += '<param name="bgcolor" value="#ffffff" />        ';
	_obj_ += '<embed src="' + flashUri + '" quality="high" wmode="' + winMode + '" bgcolor="#ffffff" width="' + vWidth +'" height="' + vHeight + '" id="' + id + '" align="middle" allowscriptaccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></embed>    ';
	_obj_ += '</object>';
	document.writeln( _obj_ );
}

