//png 사용 자바스크립트
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 ''; 
}

function over(obj){
	obj.src = obj.src.replace('.gif','_on.gif');
	obj.onmouseout = function(){
		this.src = this.src.replace('_on.gif','.gif');
	}
}


function show_img_sub(obj,num,total){
	var max = document.getElementsByName(total);
	for(var i=1; i<=max.length; i++){
		var txt=max[i-1].src;
		var lastIndex=txt.lastIndexOf("n");
		if(i == num){
			if(txt.substring(lastIndex+1) != '.gif'){
				document.getElementById(obj+i).style.display = 'block';
				max[i-1].src = max[i-1].src.replace(".gif","_on.gif");
				max[i-1].parentNode.className='on';
			}
		}else{
			document.getElementById(obj+i).style.display = 'none';
			max[i-1].src = max[i-1].src.replace("_on.gif",".gif");
			max[i-1].parentNode.className='';
		}
	}
}

//*****************************************************************************
// Description : 유효성 체크
// Parameter:
// Return:
// Usage:
//*****************************************************************************
function CheckValid(String,	space)
{
	 var retvalue	=	false;
	 for (var	i=0; i<String.length;	i++)
	 {		//String이 0(""	이나 null)이면 무조건	false
			if (space	== true)
			{
				 if	(String.charAt(i)	== ' ')
				 {			//String이 0이 아닐때	space가	있어야만 true(valid)
						retvalue = true;
						break;
				 }
			} else {
				 if	(String.charAt(i)	!= ' ')
				 {			//string이 0이 아닐때	space가	아닌 글자가	있어야만 true(valid)
						retvalue = true;
						break;
				 }
			}
	 }
	 return	retvalue;
}
//*****************************************************************************
// Description : 항목이	비어있는지 체크
// Parameter: isFocus:객체에 focusing여부
// Return:
// Usage:
//*****************************************************************************
function isEmpty(field,	error_msg,isFocus)
{
	// error_msg가 ""이면	alert와	focusing을 하지않는다
	if(error_msg ==	"")	{
		if(!CheckValid(field.value,	false))		{
			return true;
		}	else {
			return false;
		}
	}	else {
		if(!CheckValid(field.value,	false))	{
			alert(error_msg);
			if(isFocus!=false) field.focus()	;
			return true;
		}	else {
			return false;
		}
	}
}
//*****************************************************************************
// Description : 메세지 처리후 focusing
// Parameter:
// Return:
// Usage:
//*****************************************************************************
function altFocus(field,error_msg,isFocus)
{
	alert(error_msg);
	if(isFocus!=false) field.focus();
	return false;
}

//*****************************************************************************
// Description :
// Parameter:
// Return:
// Usage:
//*****************************************************************************
function chkPattern(str,type)	//형식 체크
{
  switch(type)
  {
    case "NUM": //숫자만
    pattern = /^[0-9]+$/;
      break;

	case "PHONE" :		// 전화번호 (####-####-####)
		pattern = /^[0-9]{2,4}-[0-9]{3,4}-[0-9]{4}$/;
		break;

	case "MOBILE" :		// 휴대전화 (0##-####-####)
		pattern = /^0[0-9]{2,3}-[0-9]{3,4}-[0-9]{4}$/;
		break;

	case "ZIPCODE" :	// 우편번호 (###-###)
		pattern = /^[0-9]{3}-[0-9]{3}$/;
		break;

    case "EMAIL": //메일
    //pattern = /^[._a-zA-Z0-9-]+@[._a-zA-Z0-9-]+\.[a-zA-Z]+$/;
    pattern = /^[a-zA-Z0-9._-]+@([a-zA-Z0-9.-]+\.)+[a-zA-Z]{2,4}$/;
      break;

    case "DOMAIN": //영자 숫자와	.	다음도 영자
    pattern = /^[.a-zA-Z0-9-]+.[a-zA-Z]+$/;
      break;

    case "ENG": //영자만
      pattern = /^[a-zA-Z]+$/;
      break;

    case "ENGNUM": //영자와	숫자
      pattern = /^[a-zA-Z0-9]+$/;
      break;

	case "KOR" :		// 한글
		pattern = /^[ㄱ-ㅎ|ㅏ-ㅣ|가-힣]+$/;
		break;

    case "ACCOUNT": //숫자	와 '-'
      pattern = /^[0-9-]+$/;
      break;

    case "HOST": //영자	와 '-'
      pattern = /^[a-zA-Z-]+$/;
      break;
    case "ID": //첫글자는 영자 그 뒤엔 영어숫자 4이상 15자리	이하
      //pattern = /^[a-zA-Z]{1}[a-zA-Z0-9_-]{4,15}$/;
      pattern = /^[a-zA-Z]{1}[a-zA-Z0-9]{4,15}$/;
      break;

    case "ID2": //첫글자는	영자 그뒤엔	영어숫자 4이상 15자리	이하
      pattern = /^[a-zA-Z0-9._-]+$/;
      break;

    case "DATE": //	형식 : 2002-08-15
      pattern = /^[0-9]{4}-[0-9]{2}-[0-9]{2}$/;
      break;

	case "JUMIN" :		// 주민등록번호
		//pattern = /^[0-9]{6}-[0-9]{7}$/;
		pattern = /^[0-9]{13}$/;
		break;

    default :
      return false;
  }
	return pattern.test(str);
}
//*****************************************************************************
// Description : 주민등록번호 체크
// Parameter:
// Return:
// Usage:
//*****************************************************************************
function checkSsn(ssn1, ssn2)
{
    //var ssn1 = getobj(ssn1);
    //var ssn2 = getobj(ssn2);
    var ssn1 = ssn1;
    var ssn2 = ssn2;

    // 주민등록번호를 자리수에 맞게 입력했는지 체크
    if (ssn2.value.split(" ").join("") == "") {
        alert ('주민등록번호를 입력하십시오.');
        ssn1.focus();
        return true;
    }
    if (ssn1.value.length!=6) {
        alert ('주민등록번호 앞자리를 정확히 입력하세요.');
        ssn1.focus();
        return true;
    }
    if (ssn2.value.length != 7 ) {
        alert ('주민등록번호 뒷자리를 정확히 입력하세요.');
        ssn2.focus();
        return true;
    }
    if (isNaN(ssn1.value) || isNaN(ssn2.value)) {
        ssn1.value = ""
        ssn2.value = ""
        alert('주민등록번호는 숫자만 가능합니다.');
        return true;
    }

    var chk = 0;
    for (var i = 0; i <=5 ; i++) {
        chk = chk + ((i%8+2) * parseInt(ssn1.value.substring(i,i+1)))
    }
    for (var i = 6; i <=11 ; i++) {
        chk = chk + ((i%8+2) * parseInt(ssn2.value.substring(i-6,i-5)))
    }

    chk = 11 - (chk %11)
    chk = chk % 10

    if (chk != ssn2.value.substring(6,7)) {
        alert ('주민등록번호가 정확하지 않습니다.');
        ssn1.focus();
        return true;
    }
}

function checkJumin(jumin) {
	var ssn1 = jumin.substring(0, 6);
	var ssn2 = jumin.substring(6);

	if(!chkPattern(jumin, "JUMIN")) {
		return false;
	} else {
		var chk = 0;
		for(var i = 0; i <= 5 ; i++) {
			chk = chk + ((i % 8 + 2) * parseInt(ssn1.substring(i, i + 1)))
		}
		for(var i = 6; i <= 11 ; i++) {
			chk = chk + ((i % 8 + 2) * parseInt(ssn2.substring(i - 6, i - 5)))
		}

		chk = 11 - (chk %11)
		chk = chk % 10

		if (chk != ssn2.substring(6, 7)) {
			return false;
		}
	}
	return true;
}

//*****************************************************************************
// Description : 외국인 등록번호 체크
// Parameter:
// Return:
// Usage:
//*****************************************************************************
function checkForeign(foreign) {
	var foreign1 = foreign.substring(0, 6);
	var foreign2 = foreign.substring(6);

	if(!chkPattern(foreign, "JUMIN")) {
		return false;
	} else {
		var reg_no = foreign1 + foreign2;
		var sum = 0;
		var odd = 0;

		buf = new Array(13);
		for (var i = 0; i < 13; i++) {
			buf[i] = parseInt(reg_no.charAt(i));
		}

		odd = (buf[7] * 10) + buf[8];

		if (odd % 2 != 0) {
			return false;
		}

		if ((buf[11] != 6) && (buf[11] != 7) && (buf[11] != 8) && (buf[11] != 9)) {
			return false;
		}

		multipliers = [2, 3, 4, 5, 6, 7, 8, 9, 2, 3, 4, 5];
		for(var i = 0, sum = 0; i < 12; i++) {
			sum += (buf[i] *= multipliers[i]);
		}

		sum = 11 - (sum % 11);

		if (sum >= 10) {
			sum -= 10;
		}

		sum += 2;

		if (sum >= 10) {
			sum -= 10;
		}

		if ( sum != buf[12]) {
			return false;
		}
	}
	return true;
}
//*****************************************************************************
// Description :
// Parameter: o:
// Return:
// Usage: <input type="checkbox" name="allchk" onclick="AllChk(this.form,'allchk','chkbox');">
//*****************************************************************************
function AllChk(o, pAll, pChk){
	  var value;
	  var tmpChkAll, tmpChk;

	  tmpChkAll = eval("o." + pAll);
	  tmpChk = eval("o." + pChk);

	  if (tmpChkAll.checked==true){
	  		value=true;
	  }else{
	  		value=false;
	  }
	  if ( tmpChk != null ){
		    var olen = eval(tmpChk.length);
		    if ( olen != null ){
		    	for ( var i = 0 ; i < tmpChk.length ; i++ ){
		        	tmpChk[i].checked = value;
		       	}
		    }else{
		      	tmpChk.checked = value;
		    }
	  }
}

//*****************************************************************************
// Description :
// Parameter: o:
// Return:
// Usage: <input type=checkbox name=chkbox value="" onclick="chkBox(this.form,'allchk','chkbox');">
//*****************************************************************************
function chkBox(o, pAll, pChk){
	  var value;
	  var tmpChkAll, tmpChk;

	  tmpChkAll = eval("o." + pAll);
	  tmpChk = eval("o." + pChk);
	  value = true;

	  if ( tmpChk != null ){
	 	  var olen = eval(tmpChk.length);
	      if ( olen != null ){
	      		for ( var i = 0 ; i < tmpChk.length ; i++ ){
	        		if (tmpChk[i].checked == false){
	          			value=false;
	         			break;
	        		}
	      		}
	      }else{
	      		if (tmpChk.checked == false){
	          		value=false;
	      		}
	      }
	  }
	  tmpChkAll.checked=value;
}

//*****************************************************************************
// Description : CheckBox Check All
// Parameter:
// Return:
// Usage:
//*****************************************************************************
function checkAll(form, flag, chk) {
	var dtlCheck = form.chk;

	if(typeof(dtlCheck) != "undefined") {
		if(dtlCheck == null) return;

		if(typeof(dtlCheck[0]) == "undefined") {
			if(flag) {
				dtlCheck.checked = true;
			} else {
				dtlCheck.checked = false;
			}
		} else {
			var checkLength = dtlCheck.length;
			for(var i = 0; i < checkLength; i++) {
				if(flag) {
					dtlCheck[i].checked = true;
				} else {
					dtlCheck[i].checked = false;
				}
			}
		}
	}
}

//*****************************************************************************
// Description : 체크박스 체크된갯수 반환
// Parameter: o:
// Return:
// Usage: getCheckBoxCnt(document.form.checkbox)
//*****************************************************************************
function getCheckBoxCnt(checkBoxArray)
{
	var checkBox_Check_Cnt = 0;
	if(checkBoxArray.length == null){
		if(checkBoxArray.checked)
			checkBox_Check_Cnt = 1;
	}
	else{
		for (var i=0; i < checkBoxArray.length; i++)
		{
			if(checkBoxArray[i].checked) checkBox_Check_Cnt++;
		}
	}
	return checkBox_Check_Cnt;
}

//*****************************************************************************
// Description : 체크박스 체크된 값  반환
// Parameter: o:
// Return:
// Usage: getCheckBoxValue(document.form.checkbox)
//*****************************************************************************
function getCheckBoxValue(checkBoxArray)
{
	var checkBox_Check_Value = '';
	if(checkBoxArray.length == null){
		if(checkBoxArray.checked)
			checkBox_Check_Value = checkBoxArray.value;
	}
	else{
		for (var i=0; i < checkBoxArray.length; i++)
		{
			if(checkBoxArray[i].checked) checkBox_Check_Value = checkBox_Check_Value +'|'+ checkBoxArray[i].value;
		}
	}
	return checkBox_Check_Value;
}

//*****************************************************************************
// Description :
// Parameter: o:
// Return:
// Usage: <textarea name=content onkeyup="cal_byte(this,$('length_plus'),'left');" maxbytes="200"></textarea>
//*****************************************************************************
function cal_byte( obj_content, obj_display1, typeDisplay )
{
    var max_bytes = parseInt( obj_content.getAttribute( "maxbytes" ) != null ? obj_content.getAttribute( "maxbytes" ) : 0 );
    var tmpStr;
    var temp = 0;
    var temp2 = 0;
    var temp3 = 0;
    var isCapture = false;
    var onechar;
    var tcount;
    tcount = 0;

    tmpStr = new String( obj_content.value );
    temp = tmpStr.length;

    for( k = 0; k < temp; k++ )
    {
        onechar = tmpStr.charAt( k );

        if( escape( onechar ).length > 4 ) tcount += 2;
        else if( onechar != '\r' )         tcount++;

        if( !isCapture && tcount > max_bytes )
        {
            temp2 = k;
            temp3 = tcount;
            isCapture = true;
        }
    }

    if( tcount > max_bytes )
    {
        tmpStr = tmpStr.substring( 0, temp2 );
        obj_content.blur();
        obj_content.value = tmpStr;

        reserve = tcount - max_bytes;
        alert( "메시지 내용은 " + max_bytes + "바이트 이상은 전송하실 수 없습니다.\r\n입력하신 메세지는 " + reserve + "바이트가 초과되었습니다.\r\n초과된 부분은 자동으로 삭제됩니다." );

        tcount = temp3 - 1;
    }

    if( typeDisplay != null )
    {
        if( typeDisplay == "left" )
        {
            if( obj_display1.value ) obj_display1.value = ( max_bytes - tcount ) / 2;
            else                     Element.update( obj_display1, ( max_bytes - tcount ) / 2 );
        }
        else if( typeDisplay == "left2" )
        {
            if( obj_display1.value ) obj_display1.value = max_bytes - tcount;
            else                     Element.update( obj_display1, max_bytes - tcount );
        }
        else if( typeDisplay == "kr" )
        {
            if( obj_display1.value ) obj_display1.value = tcount / 2;
            else                     Element.update( obj_display1, tcount / 2 );
        }
    }
    else if( obj_display1 != null )
    {
        if( obj_display1.value ) obj_display1.value = tcount;
        else                     Element.update( obj_display1, tcount );
    }
    obj_content.focus();
}


//*****************************************************************************
// Description :
// Parameter: o:
// Return:
// Usage: <textarea name=content onkeyup="cal_byte(this,$('length_plus'),'left');" maxbytes="200"></textarea>
//*****************************************************************************
function getTextNode( domObj, strTag, seq )
{
	if( domObj.getElementsByTagName( strTag )[ ( seq != null ? seq : 0 ) ].childNodes.length > 0 )
		return domObj.getElementsByTagName( strTag )[ ( seq != null ? seq : 0 ) ].firstChild.nodeValue;
	else return "";
}


//*****************************************************************************
// Description :
// Parameter: o:
// Return:
// Usage:
//*****************************************************************************
function resizeImageContents( obj, targetObj, isIframe, max_width )
{
    var arr_img = targetObj.getElementsByTagName( "IMG" );

    for( i = 0; i < arr_img.length; i++ )
    {
        var parent_width = ( max_width == null ? arr_img[ i ].parentNode.getWidth() : max_width ); /* max_width없이는 잘 작동하지 않음 */
        var obj_width    = arr_img[ i ].width;
        var orig_img     = new Image();
        orig_img.src     = arr_img[ i ].src;

        if( parent_width >= obj_width && orig_img.width <= obj_width ) continue;

        arr_img[ i ].style.cursor  = "pointer";

        arr_img[ i ].source_width  = orig_img.width;
        arr_img[ i ].source_height = orig_img.height;


        if( isIframe )
			arr_img[ i ].onclick = sendShowOriginalImage.bindAsEventListener( arr_img[ i ] );
	    else
			arr_img[ i ].onclick = showOriginalImage.bindAsEventListener( arr_img[ i ] );
    }

    var rtn_html = "\
<div id=\"fororiginalimagearea\" style=\"display:none; padding:0px; margin:0px; width:100%; height:100%; top:0px; left:0px;position:absolute; border:0px; overflow:hidden;\" onmousemove=\"drag_fororiginalimage($('fororiginalimageareabg'),event);\" onselectstart=\"return false\" ondragstart=\"return false\">\
	<div id=\"fororiginalimageareabg\" style=\"z-index:1001; background-color:#FFFFFF; width:100%; height:100%; top:0px; left:0px;position:relative; padding:20px 10px 10px 10px; border:8px solid #DDDDDD;\" ondblclick=\"closeOriginalImage();\" onmousemove=\"drag_fororiginalimage($('fororiginalimageareabg'),event);\">\
		<img src=\"/adminroot/images/blank.gif\" alt=\"original image\" border=\"0\" id=\"fororiginalimage\" style=\"z-index:1002;\" onmousedown=\"dragBegin_fororiginalimage($('fororiginalimageareabg'),event);\" onmousemove=\"drag_fororiginalimage($('fororiginalimageareabg'),event);\" onmouseup=\"dragEnd_fororiginalimage($('fororiginalimageareabg'),event);\" />\
		<img src=\"/adminroot/images/original_image_box_close.gif\" alt=\"close original image\" border=\"0\" style=\"position:absolute; right:8px; top:5px; cursor:pointer; width:50px; height:12px; z-index:1003;\" onclick=\"closeOriginalImage();\" id=\"closeOriginalImageBtn\"/>\
	</div>\
</div>";

    if( isIframe ) new Insertion.Bottom( parent.document.getElementsByTagName( "BODY" )[ 0 ], rtn_html );
    else           new Insertion.Bottom( $$( "BODY" )[ 0 ], rtn_html );
}


function sendShowOriginalImage( event )
{
    parent.showOriginalImage( event );
}


function showOriginalImage( event )
{
	var obj = ( event == null ? null : Event.element( event ) );

    Element.show( "fororiginalimagearea" );

    $( "fororiginalimage" ).style.margin = "0px 0px 0px 0px";
    $( "fororiginalimage" ).style.cursor = "move";
    $( "fororiginalimage" ).src = obj.src;

    $( "fororiginalimageareabg" ).style.width  = obj.source_width  + "px";
    $( "fororiginalimageareabg" ).style.height = obj.source_height + "px";

    $( "fororiginalimagearea" ).style.left   = document.documentElement.scrollLeft + "px";
    $( "fororiginalimagearea" ).style.top    = document.documentElement.scrollTop + "px";
    $( "fororiginalimagearea" ).style.width  = document.documentElement.offsetWidth + "px";
    $( "fororiginalimagearea" ).style.height = document.documentElement.offsetHeight + "px";
/*
    var x = parseInt( ( $( "fororiginalimagearea" ).getWidth()  - obj.source_width  ) / 2, 10 );
    var y = parseInt( ( $( "fororiginalimagearea" ).getHeight() - obj.source_height ) / 2, 10 );

    $( "fororiginalimageareabg" ).style.left = ( x < 0 ? 0 : x );
    $( "fororiginalimageareabg" ).style.top  = ( y < 0 ? 0 : y );
*/
    $( "fororiginalimageareabg" ).style.left = "0px";
    $( "fororiginalimageareabg" ).style.top  = "0px";

    var sel_list = $$( "SELECT" );
    for( var i = 0; i < sel_list.length; i++ ) sel_list[ i ].style.visibility = "hidden";

    Event.observe( window, "scroll", closeOriginalImage );
    Event.observe( window, "resize", closeOriginalImage );

    $( "fororiginalimageareabg" ).style.visibility = "visible";
}


function closeOriginalImage( event )
{
    if( Element.visible( "fororiginalimagearea" ) )
    {
        var sel_list = $$( "SELECT" );
        for( var i = 0; i < sel_list.length; i++ ) sel_list[ i ].style.visibility = "visible";

        Element.hide( "fororiginalimagearea" );
        $( "fororiginalimageareabg" ).style.visibility = "hidden";

        Event.stopObserving( window, "scroll", closeOriginalImage );
        Event.stopObserving( window, "resize", closeOriginalImage );
        Event.unloadCache();
    }
}


function dragBegin_fororiginalimage( element, event )
{
    element.dragging = true;
    element.diffx    = Event.pointerX( event ) - element.offsetLeft;
    element.diffy    = Event.pointerY( event ) - element.offsetTop;
    element.diffw    = element.offsetLeft + element.getWidth()  - Event.pointerX( event );
    element.diffh    = element.offsetTop  + element.getHeight() - Event.pointerY( event );
}


function drag_fororiginalimage( element, event )
{
    if( element.dragging )
    {
        element.style.left = Event.pointerX( event ) - element.diffx + "px";
        element.style.top  = Event.pointerY( event ) - element.diffy + "px";
    }
}


function dragEnd_fororiginalimage( element, event )
{
    element.dragging = false;
}

//*****************************************************************************
// Description : POPUP
// Parameter:
// Return:
// Usage:
//*****************************************************************************
function openWindow(isCenter,vWidth,vHeight,vUrl,vOpt) {
	var	mdWindow = null;
	var	x	=	0
	var	y	=	0;
	if(isCenter==true){
		x	=	(screen.width  - vWidth)/2;
		y	=	(screen.height - vHeight)/2;
	}else{
		x	=	100;
		y	=	100;
	}
	var	opt;
	if (vOpt ==	"" ||	vOpt ==	null)	vOpt = 0;
	opt	=			"width=" + vWidth	+	",height=" + vHeight;
	opt	=	opt	+	",scrollbars=" + vOpt	+	",toolbar=0,menubars=0,locationbar=0,historybar=0,statusbar=0";
	opt	=	opt	+	",outerWidth=" + vWidth	+	",outerHeight="	+	vHeight	+	",resizable=0";
	opt	=	opt	+	",left=" + x + ",top=" + y;
	opt	=	opt	+	",channelmode=no,	titlebar=no";
	var	mdWindow = window.open(vUrl, "", opt,	false);
}
//*****************************************************************************
// Description : POPUP Post 미사용
// Parameter:
// Return:
// Usage:
//*****************************************************************************
function fn_openWinPost(isCenter,vWidth,vHeight,vUrl,vOpt){
	var	mdWindow = null;
	var	x	=	0
	var	y	=	0;
	if(isCenter==true){
		x	=	(screen.width	-	vWidth)/2;
		y	=	(screen.height - vHeight)/2;
	}else{
		x	=	100;
		y	=	100;
	}
	var	opt;
	if (vOpt ==	"" ||	vOpt ==	null)	vOpt = 0;
	opt	=			"width=" + vWidth	+	",height=" + vHeight;
	opt	=	opt	+	",scrollbars=" + vOpt	+	",toolbar=0,menubars=0,locationbar=0,historybar=0,statusbar=0";
	opt	=	opt	+	",outerWidth=" + vWidth	+	",outerHeight="	+	vHeight	+	",resizable=0";
	opt	=	opt	+	",left=" + x + ",top=" + y;
	opt	=	opt	+	",channelmode=no,	titlebar=no";
	var frm=document.getElementById("frm");
	frm.cnt_id.value=frm.kb_bi_idx.value;
	if(!isEmpty(frm.kb_bi_name,"게시판명을 입력해주세요")){
		var	win = window.open("about:blank", "openWinPost", opt,	false);
		win.focus();
		frm.target="openWinPost";
		frm.action=vUrl;
		frm.method="post";
		frm.submit();
	}
}
//*****************************************************************************
// Description :
// Parameter:
// Return:
// Usage:
//*****************************************************************************
function fn_coverSts(){
    window.status='어서오세요';
	return true;
}

//*****************************************************************************
// Description : 특수 문자 체크
// Parameter:
// Return:
// Usage:
//*****************************************************************************
function chkSpeChar(oInputCtrl) {
	//var speChar = "`~!#$%^&*+=|\\[]{}:;-,<>/?'\"";
	var speChar = "`%^|\\{};<>'\"";
	for(var iCnt = 0; iCnt < speChar.length; iCnt++) {
		special = speChar.substr(iCnt, 1);
		if(oInputCtrl.value.indexOf(special) != -1) {
			alert("특수문자[" + special + "]를 입력 할 수 없습니다.");
			return true;
		}
	}
	return false;
}

//*****************************************************************************
// Description : 특수 문자 체크
// Parameter: 체크필드,메세지
// Return:
// Usage:
//*****************************************************************************
function checkSpeChar(oInputCtrl,alert_msg) {
	var speChar = "`%\|\\{};<>+'\"";
	for(var iCnt = 0; iCnt < speChar.length; iCnt++) {
		special = speChar.substr(iCnt, 1);
		if(oInputCtrl.value.indexOf(special) != -1) {
			alert(alert_msg+"에 특수문자[" + special + "]를 입력 할 수 없습니다.");
			return true;
		}
	}
	return false;
}

String.prototype.trim = function() {
    return this.replace(/(^\s*)|(\s*$)/gi, "");
}

function fn_filedownX(path, name, saveName){
	var frm = document.getElementById("downForm");
	frm.filePath.value = path;
	frm.fileRealName.value = "/" + name;
	frm.fileSaveName.value = saveName;
	frm.action = 'http://www.hankook.com/common/fileDownload.do';
	frm.submit();
}

function pQry(q) {
        if(q.length > 1) this.q = q.substring(1, q.length);
        else this.q = null;
        this.keyValuePairs = new Array();
        if(q) {
                for(var i=0; i < this.q.split("&").length; i++) {
                        this.keyValuePairs[i] = this.q.split("&")[i];
                }
        }
        this.getKeyValuePairs = function() { return this.keyValuePairs; }
        this.getValue = function(s) {
                for(var j=0; j < this.keyValuePairs.length; j++) {
                        if(this.keyValuePairs[j].split("=")[0] == s)
                                return this.keyValuePairs[j].split("=")[1];
                }
                return -1;
        }
        this.getParameters = function() {
                var a = new Array(this.getLength());
                for(var j=0; j < this.keyValuePairs.length; j++) {
                        a[j] = this.keyValuePairs[j].split("=")[0];
                }
                return a;
        }
        this.getLength = function() { return this.keyValuePairs.length; }
}

function openLoginWindow(){
	window.open('/login.do', '_blank', 'width=457,height=420,scrollbars=no');
}

//*****************************************************************************
// Description : 탑메인 메뉴 이동
//logo.  로그 클릭시
//  m_1 ~ 4. 상단메뉴 클릭시
//  q_1 ~ 7. 퀵메뉴 클릭시. q_7은 로그아웃. 나머지는 순서되로.
//  gate2_1~7. gatemenu. community 순서되로.
//  gate3_1~7. gatemenu. company 순서되로.
//*****************************************************************************
function menulink(m){
	//alert(m);



	//홈
	if("logo" == m){location.href = "/"; }

	//gate1
	if("gate1" == m){ window.open("http://gate.hankook.com"); }

	//gate2
	if("gate2" == m){ window.open("http://joy.hankook.com"); }
	if("gate2_1" == m){ window.open("http://joy.hankook.com"); }

	//gate3
	if("gate3" == m){ window.open("http://group.hankook.com"); }
	if("gate3_1" == m){ window.open("http://group.hankook.com/hankook/hankookIntro.do"); }
	if("gate3_2" == m){ window.open("http://group.hankook.com/living/livingIntro.do"); }
	if("gate3_3" == m){ window.open("http://group.hankook.com/brandstory/brandInfo.do"); }
	if("gate3_4" == m){ window.open("http://group.hankook.com/cyber/cyber_list.do?gubun=brd_2"); }
	if("gate3_5" == m){ window.open("http://group.hankook.com/wanted/wantedPeople.do"); }
	if("gate3_6" == m){ window.open("http://group.hankook.com/agency/agency1.do"); }
	if("gate3_7" == m){ window.open("http://group.hankook.com/custom/customHand.do"); }



	//명품브랜드
	if("m_1" == m){location.href = "/catalog/catalogList.do?gubun=Brand&cate1=10079&cate2=&page=1&order_cd=&searchvalue=&lines_per_page=24"; }
	//베스트
	if("m_2" == m){location.href = "/catalog/catalogList.do?gubun=Special&specialgubun=90001&cate1=90001&page=1&order_cd=PO0001&searchvalue=&lines_per_page=24&cate2=90001"; }
	//기획전
	if("m_3" == m){ location.href="/event/event_list.do?gubun=1";	}
	//이벤트
	if("m_4" == m){ location.href="/event/event_list.do?gubun=2";	}
	//이벤트
	if("m_5" == m){ location.href="/plan/planList.do?category_seq=80292";   }

	//회사소개
	if (m == "footer_1" ){ 	window.open("http://group.hankook.com");	}
	//제휴/입점안내
	if (m == "footer_2" ){ 	location.href = "/info/footer_01.do"; 	}
	//이용약관
	if (m == "footer_3" ){ 	openWindow(true,700,500,"http://www.hankook.com/agreement.do","no");	}
	//개인정보보호정책
	if (m == "footer_4" ){ 	openWindow(true,700,500,"http://www.hankook.com/policy.do","no")	}
	//포장서비스
	if (m == "footer_5" ){ 	location.href = "/info/footer_03.do";	}

	//로그인
	if (m == "q_1" ){ 	openLoginWindow();	}
	//회원가입
	if (m == "q_2" ){ 	window.open("https://www.hankook.com/member/memberUserJoin.do");	}
	//주문/배송조회
	if (m == "q_3" ){ 	location.href = "/mypage/mypageOrderList.do";	}
	//마이페이지
	if (m == "q_4" ){ 	location.href = "/mypage/mypageOrderList.do";	}
	//고객센터
	if (m == "q_5" ){ 	location.href = "/help/help_main.do";	}
	//사이트맵
	if (m == "q_6" ){ 		}
	//로그아웃
	if (m == "q_7" ){ 	location.href = "/logoutProc.do";	}

	//help_faq
	if (m == "help_1") { location.href = "/help/faq_list.do";	}
	//help_대량구매상담
	if (m == "help_2") { location.href = "/help/buy_inquirefrm.do";	}
	//help_1:1문의하기
	if (m == "help_3") { location.href = "/help/help_inquirefrm.do";	}
	//help_공지사항
	if (m == "help_4") { location.href = "/help/board_list.do?gubun=notice_1";	}
	//help_이벤트공지
	if (m == "help_5") { location.href = "/help/board_list.do?gubun=event_1";	}
	//help_이용안내
	if (m == "help_6") { location.href = "/help/use_info_01.do";	}
	//help_고객보상제
	if (m == "help_7") { location.href = "/help/use_info_02.do";	}
	//help_대리점안내
	if (m == "help_8") { alert("준비중");}

	//mypage_주문배송조회
	if (m == "mypage_1") { location.href = "/mypage/mypageOrderList.do";	}
	//mypage_배송지정보관리
	if (m == "mypage_2") { location.href = "/mypage/mypageAddressForm.do";	}
	//mypage_쿠폰내역
	if (m == "mypage_3") { location.href = "/mypage/mypageCouponList.do";	}
	//mypage_상품평
	if (m == "mypage_4") { location.href = "/mypage/GoodRatingList.do";	}
	//mypage_1:1문의내역
	if (m == "mypage_5") { location.href = "/mypage/mypageConsultList.do";	}
	//mypage_상품문의
	if (m == "mypage_6") { location.href = "/mypage/mypageQnaList.do";	}
	//mypage_개인정보변경
	if (m == "mypage_7") { window.open("https://www.hankook.com/member/memberUserModForm.do");	}

	//faq
	//회원정보
	if (m == "help_qna_1") { location.href = "/help/faq_list.do?gubun=1";	}
	//입금/결제
	if (m == "help_qna_2") { location.href = "/help/faq_list.do?gubun=2";	}
	//배송
	if (m == "help_qna_3") { location.href = "/help/faq_list.do?gubun=3";	}
	//교환/반품/AS
	if (m == "help_qna_4") { location.href = "/help/faq_list.do?gubun=4";	}
	//취소/환불
	if (m == "help_qna_5") { location.href = "/help/faq_list.do?gubun=5";	}
	//쿠폰/포인트
	if (m == "help_qna_6") { location.href = "/help/faq_list.do?gubun=6";	}
	//이벤트/기타
	if (m == "help_qna_7") { location.href = "/help/faq_list.do?gubun=7";	}


}

function goHome(){
	location.href = "/index.do";
}

if(self.location.href == "http://buy.hankook.com/index.html"){
	location.href = "http://buy.hankook.com/"+location.href;
}

function makeFrame(){
//	if(self.name != "mainFrm"){
//		setURL(location.href);
//		top.location.href="/";
//	}
//	document.onkeydown=_detectReload;
//	setTimeout("makeFrame()", 1009);

}

function _detectReload() {
	if(event.keyCode!=116) return;
	setURL(location.href);
}

function setAutoURL(uri){
	setAutoCookie("redirectURL",uri,0,"buy.hankook.com");
}

function getAutoURL(){
	return getAutoCookie("redirectURL");
}

function getAutoCookie(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 "";
}
function setAutoCookie(Name, value, expires, pathordomain)
{
	var str= Name + "=" + escape(value).replace(/\x2b/g,"%"+"2B");
	if(expires)
	{
		if(expires.setTime)
		{
			str += "; expires=" + expires.toGMTString();
		}
		else
		{
			var exp=new Date;
			exp.setTime(exp.getTime()+expires*1000);
			str += "; expires=" + exp.toGMTString();
		}
	}

	var p=pathordomain;
	if(!p)
		str+="; path=/; domain=buy.hankook.com";
	else if(pathordomain=='./' || pathordomain=='.');
	else
	{
		if(p.substr(0,7)=="http://")
		{
			if(p.charAt(p.length-1)!='/') p+='/';
			var ip		= p.indexOf('/',7);
			str+="; path="+p.substr(ip)+"; domain="+p.substring(7,ip);
		}
		else if(p.charAt(p.length-1)=='/')
		{
			str+="; path="+p;
		}
		else
		{
			str+="; path=/; domain="+p;
		}
	}

	document.cookie = str;
}


//팝업 가운데 정렬..
function wndMoveCenter(){
	window.moveTo((screen.width-document.body.scrollWidth)/2,(screen.height-document.body.scrollHeight)/2);
}

//팝업 윈도우 사이즈 조절
function reSizeWindow(width, height){
	window.resizeTo(width, height);
}


String.prototype.popupView = function () {

    var img_view = this;
    var x = x + 20 ;
    var y = y + 30 ;
    htmlz = "<html><head><title>이미지크게보기</title><style>body{margin:0;cursor:hand;}</style></head><body scroll=auto onload='width1=document.all.Timage.width;if(width1>1024)width1=1024;height1=document.all.Timage.height;if(height1>768)height1=768;top.window.resizeTo(width1+20,height1+95);' onclick='top.window.close();'><img src='"+img_view+"'  title='클릭하시면 닫힙니다.' name='Timage' id='Timage'></body></html>"
    imagez = window.open('', "image", "width="+ 100 +", height="+ 100 +", top=0,left=0,scrollbars=auto,resizable=1,toolbar=0,menubar=0,location=0,directories=0,status=1");
    imagez.document.open();
    imagez.document.write(htmlz)
    imagez.document.close();
}

//*****************************************************************************
// Description : 플래쉬 IE패치
// Parameter:
// Return:
// Usage:
//*****************************************************************************
function swfWrite(variable)
{
	var features = variable.split("|");
	var url = features[0].trim();
	var width = features[1].trim();
	var height = features[2].trim();
	var swfTags;

	if(navigator.appName.indexOf('Microsoft') >= 0){
		swfTags = "<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 + "'>";
	    swfTags = swfTags + "<param name='movie' value='" + url + "'>";
	    swfTags = swfTags + "<param name='quality' value='high'>";
		swfTags = swfTags + "<param name='wmode' value='transparent' >";
	    swfTags = swfTags + "<embed src='" + url + "' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width='" + width + "' height='" + height + "'></embed></object>";
	}else{
		swfTags = "<object type='application/x-shockwave-flash' data='" + url + "' width='" + width + "' height='" + height + "'>";
	    swfTags = swfTags + "<param name='movie' value='" + url + "'>";
	    swfTags = swfTags + "<param name='quality' value='high'>";
		swfTags = swfTags + "<param name='wmode' value='transparent'>";
		swfTags = swfTags + "</object>";
	}

	document.write(swfTags);
}

//*****************************************************************************
// Description : 문자열의 Byte Return
// Parameter: 문자열
// Return :
// Usage : getByteLength(str)
//*****************************************************************************
function getByteLength(str) {
	var length = 0;
	if(str != null) {
		for (var i = 0; i < str.length; i++) {
			var character = escape(str.charAt(i));

			if(character.length == 1) {
				length++;
			} else if(character.indexOf("%u") != -1) {
				length += 2;
			} else if(character.indexOf("%") != -1) {
				length += character.length / 3;
			}
		}
	}
	return length;
}


//*****************************************************************************
// Description : 메인 롤링 이벤트 관련 함수
// Parameter: 문자열
// Return :
// Usage :
//*****************************************************************************
var roll;//
var arrow;//
var lenR;
var lenA;
var btns;
var imgs;
var nowEvent=0;
function rollingEvent(){
	arrow=document.getElementById("arrows");
	btns=arrow.getElementsByTagName("img");
	lenA=btns.length;
	btns[0].onclick=prevEvent;
	btns[1].onclick=nextEvent;
}
function getEventRolling(){
	roll=document.getElementById("eventRolling");
	imgs=roll.getElementsByTagName("img");
	lenR=imgs.length;
}
function nextEvent(){
	getEventRolling();
	nowEvent=nowEvent+1;
	if(nowEvent==lenR) { nowEvent=0;}
	for(i=0; i<lenR; i++){
		if(nowEvent==i) {
			imgs[i].style.display="block";
			nowEvent=i;
		}else{
			imgs[i].style.display="none";
		}
	}
}
function prevEvent(){
	getEventRolling();
	if(nowEvent==0) nowEvent=lenR;
	nowEvent=nowEvent-1;
	for(i=lenR-1; i>=0; i--){
		if(nowEvent==i) {
			imgs[i].style.display="block";
			nowEvent=i;
		}else{
			imgs[i].style.display="none";
		}
	}
}
function roll(){
	setInterval(nextEvent,3000);
}

//*****************************************************************************
// Description : 제일하단 부분에 놓아주세요 (찾기쉽게...)
//*****************************************************************************
//전화번호 앞자리
var gbl_phone_number="02,031,032,033,041,042,043,0502,0505,051,052,053,054,055,061,062,063,064";
//핸드폰번호 앞자리
var gbl_mobile_number="010,011,013,016,017,018,019,0502,0505,0506";