/****************************************************************************************
(1) ½Ã½ºÅÛ¸í 			: WIN4NET 
(2) ÇÁ·Î±×·¥¸í 		: °øÅëÀÚ¹Ù½ºÅ©¸³Æ® ÇÔ¼ö
*****************************************************************************************/

// ¿î¿µÃ¼Á¦
var RequestOs = window.navigator.appVersion;
var OsArray = RequestOs.split(";");
var OS = OsArray[2];

var brower = navigator.userAgent.toUpperCase();


//¸µÅ©Á¡¼¶¾ø¾Ö±â..
function _jsBlur(){ 
	if(event.srcElement.tagName=="A"||event.srcElement.tagName=="IMG") document.body.focus(); 
} 
document.onfocusin=_jsBlur; 


//ÆäÀÌÁöÀÌµ¿.
function _jsGoto(code,subp){
	var folder
	if (code!=null){
		var url = "";
		if (arguments[2]) {	url = arguments[2]; }
		window.location.href="./menucode.php?code="+ code +"&subp=" + subp + url;
	}
}


function _jsGoHome(){
	window.location.href="/?code=main";
}


function _jsOpen(url,name,features){	//À©µµ¿ì¿ÀÇÂ;
	var contWin  = name;
	if( (contWin != null) && (contWin.closed == false) ){contWin.close();}
	contWin=window.open(url,name,features);
	contWin.focus();
}



function _jsFullOpen(url,name){	//À©µµ¿ì¿ÀÇÂ;
	var contWin  = name;
	if( (contWin != null) && (contWin.closed == false) ){contWin.close();}
	var width = screen.availWidth;
	var height = screen.availHeight;
	contWin=window.open(url,name,"width="+width+", height="+height);
	contWin.focus();
}


function _jsModal(URL , name , features){
	window.showModalDialog(URL, window , features);
	//window.showModalDialog(URL, window , "dialogWidth:100px ; dialogHeight:50px;status:no;");
}

function _jsGotoBack(){
	window.history.go(-1);
}

function _jsClose(){ 
	opener = self;
	self.close();
}

function _jsNotReady(gubun){
	alert("¼­ºñ½ºÁØºñÁßÀÔ´Ï´Ù.");
	return;
}


//¿ÞÂÊ¸Þ´º ÃÊ±âÈ­
function _jsLeftMenuInit(code){
	try{		
		if (code > 0){
			var obj_img = document.all["leftnavi"+code] ;
			var img_name = obj_img.name;
			obj_img.src = "./images/"+imgfolder+"/"+img_name+"_over.gif";
			_jsLeftMenuInitTR(code);
		}
	}
	catch (e) {return;}
}

//¿ÞÂÊ¸Þ´º¼­ºê¸Þ´ºº¸¿©ÁÖ±â
function _jsLeftMenuInitTR(code){
	try{		
		if (code > 0){
			var obj_tr = document.all["leftmenu"+ code +"_tr"]; 
			if (typeof(obj_tr)=="object") {
				if (obj_tr.style.display=="none") {
					obj_tr.style.display = "block";
				}
			}
		}
	}
	catch (e) { return;}
}


function _jsFlashObject(url, width, height, strparam) {
	this.wmode = "transparent";
	this.id = "";
	this.quality = "high";
	this.menu = "false";
	this.allowScriptAccess = "sameDomain";

	var flash='';
	flash += '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="'+ width +'" height="'+ height +'"> ';
	flash += '<param name="movie" value="'+ url +'">';
	flash += '<param name="quality" value="'+ this.quality +'">';
	flash += '<param name="menu" value="'+ this.menu +'">';
	flash += '<param name="wmode" value="'+ this.wmode +'">';
	flash += '<param name="FlashVars" value="'+ strparam +'">';
	flash += '<embed src="'+ url +'" quality="'+ this.quality +'" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+ width +'" height="'+ height +'"></embed> ';
	flash += '</object>';

	document.write(flash);
}


function _jsRegularExp(chk,frm,msg){	//Á¤±Ô½ÄÀ¸·Î Ã¼Å©ÇÔ.
	var strValue =  frm.value;
	var bitExp = false;

	switch (chk){
		case "id" : 
			if (frm.value.match(/[A-Za-z0-9]{4,15}\w*/g)!=strValue){break;}
			bitExp = true;
		case "email" :
			if (frm.value.match(/[\w\-]+\@[\w\-]+(\.[\w\-]+)+/g)!=strValue){break;}
			bitExp = true;
		case "number" :
			if (frm.value.match(/\d+/g)!=strValue){ break;}
			bitExp = true;
		case "phone" :
			if (frm.value.match(/[0-9]{2,3}\-[0-9]{3,4}\-[0-9]{4}/g)!=strValue){break;}
			bitExp = true;
		case "mphone" :		
			if (frm.value.match(/01[016789]\-[0-9]{3,4}\-[0-9]{4}/g)!=strValue){ break;}
			bitExp = true;
		case "date" :
			if (frm.value.match(/[0-9]{4}\-[0-9]{2}\-[0-9]{2}/g)!=strValue){break;}
			bitExp = true;
		case "homepage" :
			if (frm.value.match(/\w+:\/\/[^#]*/g)!=strValue){		break;}
			bitExp = true;
		case "checked" : 
			if (typeof(frm)=="object"){
				if (typeof(frm.length)=="undefined"){
					if (frm.checked) { bitExp = true; }
				}
				else{
					for (i = 0 ; i < frm.length; i++){
						if (frm[i].checked){	bitExp = true;		}
					}
				}
			}
			
			break;
		case "selected" :
			if (frm.value==""){ break ;}
			bitExp = true;
			
		case "idn1" :
			if (frm.value.match(/[0-9]{6}/g)!=strValue){ break; }
			bitExp = true;
		case "idn2" :
			if (frm.value.match(/[0-9]{7}/g)!=strValue){break; }
			bitExp = true;
		case "company" :
			if (frm.value.match(/[0-9]{3}\-[0-9]{2}\-[0-9]{5}/g)!=strValue){break;}
			bitExp = true;	
		default : //°ø¹éÃ¼Å©;
			if (frm.value.match(/\S/)==null){break;}
			bitExp = true;
	}
	
	if (!bitExp){ if (msg) alert(msg);if ((chk!="checked")&&(chk!="selected")){frm.focus();};	return false;	}
	else{return true;}
	
}


//¼ýÀÚÃ¼Å©
function _jsNumberCheck(f,max,msg){
	if (parseInt(f.value) > max) {
		alert(msg+"Àº(´Â) "+max+" ÀÌ»ó ÀÔ·ÂÇÒ ¼ö ¾ø½À´Ï´Ù.") ;
		f.value = "";
		f.focus();
		return false;
	}
	else {
		return true;
	}
}



//ÇöÀç¼±ÅÃµÈ Radio¹öÆ°ÀÇ VALUE °ª ¸®ÅÏ
function _jsCheckedValue(frm){
	try { 
		var returnvalue;

		if (typeof(frm)=="object"){
			if (typeof(frm.length)=="undefined"){
				if (frm.checked) { returnvalue = frm.value; }

			}
			else{
				for (i = 0 ; i < frm.length; i++){
					if (frm[i].checked){ returnvalue = frm[i].value; }
				}
			}
		}

		return returnvalue;

	}
	catch (e) {
		alert(contErrorMsg + e);
	}


}


function _jsOnlyNum(){
   	if((event.keyCode<48)||(event.keyCode>57))
   	event.returnValue=false;
}





//¼îÇÏÀÌµå 
function _jsShowHide(obj,action){
	obj.style.display = action;
}



function _jsShowHideYN(obj){
	var value = (obj.style.display=="none") ? false : true ;
	return value;
}



function _jsChkAll(f){
	var chkvalue = document.all.item(f);
	if (chkvalue) {
		var chklen = chkvalue.length;
	
		if (chklen==null || chklen==""){
			if(chkvalue.checked) { chkvalue.checked=false; }
			else { chkvalue.checked=true; }
		}
		else{
			for(i=0;i<chklen;i++){
				if(chkvalue[i].type=='checkbox'){
					if(chkvalue[i].checked) { chkvalue[i].checked=false; }
					else {chkvalue[i].checked=true; }
				}
			}
		}
	}
	
}


function _jsChkValue(f,msg){
	var v="" , msg ;
	var chkvalue = document.all.item(f);
	var chklen = chkvalue.length;
	
	if (chklen==null || chklen==""){
		if (chkvalue.checked){
			v=chkvalue.value+",";
		}
	}
	else{
		for(i=0;i<chklen;i++){
			if(chkvalue[i].type=='checkbox'){
				if(chkvalue[i].checked) { 
					v=chkvalue[i].value+","+v
				}
			} else {
				v = chkvalue[i].value +  "," + v
			}
		}
	}
	
	if (v==""){	alert(msg); return false;}
	else{return v;}
}



//¹è¿­¼îÇÏÀÌµå
function _jsShowHideArray(id , num){
	var num , tr = document.all[id] , len = tr.length;

	if (len == null)	{
		(_jsShowHideYN(tr)) ? _jsShowHide(tr,"none") : _jsShowHide(tr,"block")
	}
	else{
		for ( i = 0; i < len ; i++){
			if (i == num){
				(_jsShowHideYN(tr[num])) ? _jsShowHide(tr[num],"none") : _jsShowHide(tr[num],"block")
//				if (tb[num].style.display=="none"){ tb[num].style.display=""; } else { tb[h].style.display="none"; }
			}
			else{
				_jsShowHide(tr[i],"none");
			}
		}
	}
}

//IFRAME ¸®»çÀÌÁî
function _jsResizeFrame(name){
	var frame = parent.document.getElementById(name);
	if (frame){
		frame.style.height=document.body.scrollHeight;
	}
}




function _jsModalResize() {
    // resize window so there are no scrollbars visible
    var dw = window.dialogWidth;
    while (isNaN(dw))  {
      dw = dw.substr(0,dw.length-1);
    }

    difw = dw - this.document.body.clientWidth;
    window.dialogWidth = this.document.body.scrollWidth+difw+'px';

    var dh = window.dialogHeight;
    while (isNaN(dh)) {
      dh = dh.substr(0,dh.length-1);
    }
    difh = dh - this.document.body.clientHeight;
    window.dialogHeight = this.document.body.scrollHeight+difh+'px';
}

function _jsModalInit(){
	_jsModalResize();
}


function goKorean() {
	top.location.href="/?code=main";
}

function gouk() {
	top.location.href="/uk/?code=main";
}

function goEnglish() {
	//top.location.href="/english/?code=main";
	top.location.href="/eng/?code=main";
}

function goSitemap() {
	_jsOpen('/popup/sitemap.html','','width=650,height=490');
}

function openWin(){
	window.open("http://bbs.win4net.com/kr/", "", "width=1024,height=600,scrollbars=yes,toolbar=yes,menubar=yes,location=yes,status=yes,resizable=yes,left=10,top=10");
}


function goAdmin() {
	window.open("./html/member/adminLogin.php", "admin", "width=900,height=650,toolbar=no,menubar=no,location=no,status=yes,left=100,top=50");
}

function goURL(value) {
	if (value=="korean") {
		goKorean();
	} else if (value=="english")	{
		goEnglish(); 
	}
}


function mapOpen(){
	window.open("/html/map.php", "", "width=600 height=680,toolbar=no,menubar=no,location=no,status=yes,left=10,top=10");
}


//DESIGN¿¡ ÇÊ¿äÇÑ ½ºÅ©¸³Æ®

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];}
}
