
//파일다운로드.
function download(code,fname){
	location.href="/download/edu_download.asp?idx=" + code +'&fname='+fname;
	
}

//파일다운로드.
function download2(code,fname){
	location.href="/download/edu_download2.asp?idx=" + code +'&fname='+fname;
	
}

//에듀플레이어 팝업.
function EDUPOPUP(code){
		var strTimeline , strLoop ,strURL , EName, Str, StrSize;
		strURL="/emanual/edu_Edudownload.asp?idx="+code;
		EName= "Sample_"+code;
		if (window.ActiveXObject) StrSize = "width=900,height=619"; // IE
		else StrSize = "width=300,height=300";
		Str = "top=20,left=20,"+StrSize+",resizable=yes,status=no,scrollbars=no,toolbar=no,menubar=no"; //


		window.open(strURL,EName,Str);

}


function EDUPlay(code){

		var strTimeline , strLoop ,strURL , EName, Str;
		strURL="/download/edu_EduPlayer2.asp?idx="+code;
		EName= "eduSample_"+code;
		Str = "top=20,left=20,width=300,height=300,toolbar=no,menubar=no,status=no,scrollbars=no,resizable=yes";
		window.open(strURL,EName,Str);
}

//Resize
function autoResizePopup() {

      var winW, winH;
	  //var sizeToW, sizeToH;
      if ( parseInt(navigator.appVersion) > 3 ) {
         if ( navigator.appName=="Netscape" ) {
            winW = window.innerWidth;
            winH = window.innerHeight;
         }

         if ( navigator.appName.indexOf("Microsoft") != -1 ) {
            winW = document.body.scrollWidth;
            winH = document.body.scrollHeight;
         }


      }
      sizeToW = 0;
      sizeToH = 0;

      if ( winW > 1024 ) {
         sizeToW = 1024 - document.body.clientWidth;
      } else if ( Math.abs(document.body.clientWidth - winW ) > 3 ) {
         sizeToW = winW - document.body.clientWidth;		 
      }else{
		sizeToW = winW - document.body.clientWidth;		
	  }


      if ( winH > 768 ) {
         sizeToH = 768 - document.body.clientHeight; 
      } else if ( Math.abs(document.body.clientHeight - winH) > 4 ) {
         sizeToH = winH - document.body.clientHeight;
      }
	 
      if ( sizeToW != 0 || sizeToH != 0 )
		window.resizeBy(sizeToW, sizeToH);  
	
}
//이메일 체크
function emailCheck(strEmail) {
    var exclude=/[^@\-\.\w]|^[_@\.\-]|[\._\-]{2}|[@\.]{2}|(@)[^@]*\1/;
    var check=/@[\w\-]+\./;
    var checkend=/\.[a-zA-Z]{2,3}$/;

    if(((strEmail.search(exclude) != -1)||(strEmail.search(check)) == -1)||(strEmail.search(checkend) == -1))
        return false;
    else
        return true;
}
//getCookies
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 ""; 
}
function setCookie(name, value, expiredays) {
    var todayDate = new Date(); 
    todayDate.setDate(todayDate.getDate() + expiredays); 
    document.cookie = name + "=" + escape(value) + "; path=/; expires=" + todayDate.toGMTString() + ";" 
}


//영어+숫자 입력값 체크
function chrCheck(value){
    var pattern = /(^[a-zA-Z0-9\-_]+$)/;
    if(!pattern.test(value)){
        return false;
    }else{
        return true;
    }
}
//숫자 입력값 체크
function numberCheck(value){
	var pattern=/[^0-9]/gi;
	if(!pattern.test(value)){
        return false;
    }else{
        return true;
    }
}




// 주민등록번호 체크
function residentno_chk(RegNo1,RegNo2) {
    No1  = parseInt(RegNo1.substring(0,1))
    No2  = parseInt(RegNo1.substring(1,2))
    No3  = parseInt(RegNo1.substring(2,3))
    No4  = parseInt(RegNo1.substring(3,4))
    No5  = parseInt(RegNo1.substring(4,5))
    No6  = parseInt(RegNo1.substring(5,6))

    No7  = parseInt(RegNo2.substring(0,1))
    No8  = parseInt(RegNo2.substring(1,2))
    No9  = parseInt(RegNo2.substring(2,3))
    No10 = parseInt(RegNo2.substring(3,4))
    No11 = parseInt(RegNo2.substring(4,5))
    No12 = parseInt(RegNo2.substring(5,6))
    No13 = parseInt(RegNo2.substring(6,7))

    tot = (No1*2)+(No2*3)+(No3*4)+(No4*5)+(No5*6)+(No6*7)+(No7*8)+(No8*9)+(No9*2)+(No10*3)+(No11*4)+(No12*5);
    rst = ""+(11-(tot-(parseInt(""+(tot/11))*11)))

    if(parseInt(rst) >= 10)
        rst = ""+(parseInt(rst)-10)

    if(rst != No13)
        return false;
    else
        return true;
}

//숫자입력만 리턴 
function onlyNumber(obj){
	val = obj.value;
	pattern=/[^0-9]/gi;
	obj.value=val.replace(pattern,"");

}


// 이미지 스왑 by jseo
function swap_image ( objImg, str_find, str_replace ){
	
	objImg.src = objImg.src.replace(str_find,str_replace);
}

var reqAjax;
// Ajax 호출 함수
function retrieveURL(url,rFunc) {
	if (window.ActiveXObject) { // IE
		reqAjax = new ActiveXObject("Microsoft.XMLHTTP");
		if (reqAjax) {
			reqAjax.onreadystatechange = rFunc;
			reqAjax.open("GET", url, true);
			reqAjax.send();
		}
	} else if (window.XMLHttpRequest) { // Non-IE browsers
		reqAjax = new XMLHttpRequest();
		reqAjax.onreadystatechange = rFunc;
		try {
			reqAjax.open("GET", url, true);
		} catch (e) {
			alert(e);
		}
		reqAjax.send(null);
	} else {
		return ;
	}
}

// Ajax 다운 상태 확인 함수
function processStateChange() {
	if (reqAjax.readyState == 4) { // Complete
		if (reqAjax.status == 200) { // OK response
			return true;
		} else {
			alert("Problem: " + reqAjax.statusText);
			return false;
		}
	}
}

// IE용 Flash Rewrite 함수
function IE_HtmlRewrite(objParent) {
	if (window.ActiveXObject && objParent) {
		objParent.innerHTML = objParent.innerHTML;
	}
}



//사업자 번호 구성체크
function isBizInteger(st,maxLength) {
	if (st.length == maxLength) {
		for (j=0; j>maxLength; j++)   
			 if (((st.substring(j, j+1) < "0") || (st.substring(j, j+1) > "9"))) {
     				return false;
  			}
 		}
 	else {
  		return false;
 	}
 	return true;
}

//사업자 등록번호 체크
function BizCheck(obj1, obj2, obj3) {
 	biz_value = new Array(10);
 
 	if (isBizInteger(obj1.value,3) == false) {
	  	obj1.focus();
	  	obj1.select();
  		return false;
 	}
 	if (obj1.value=="000") {
	  	obj1.focus();
	  	obj1.select();
  		return false;
 	}
	 if (isBizInteger(obj2.value,2) == false) {
	  	obj2.focus();
	  	obj2.select();
	  	return false;
	 }
 	if (obj2.value=="00") {
	  	obj2.focus();
	  	obj2.select();
  		return false;
 	}
	
	 if (isBizInteger(obj3.value,5) == false) {
		  obj3.focus();
		  obj3.select();
		  return false;
	 }
	
	 var objstring = obj1.value +"-"+ obj2.value +"-"+ obj3.value;

	 //추가 2007-09
	 if (objstring == "444-44-44444" || objstring == "888-88-88888") {
		obj1.focus();
	  	obj1.select();
  		return false;	
	 }	

	 var li_temp, li_lastid;
	
	 if ( objstring.length == 12 ) {
		  biz_value[0] = ( parseFloat(objstring.substring(0 ,1)) * 1 ) % 10;
		  biz_value[1] = ( parseFloat(objstring.substring(1 ,2)) * 3 ) % 10;
		  biz_value[2] = ( parseFloat(objstring.substring(2 ,3)) * 7 ) % 10;
		  biz_value[3] = ( parseFloat(objstring.substring(4 ,5)) * 1 ) % 10;
		  biz_value[4] = ( parseFloat(objstring.substring(5 ,6)) * 3 ) % 10;
		  biz_value[5] = ( parseFloat(objstring.substring(7 ,8)) * 7 ) % 10;
		  biz_value[6] = ( parseFloat(objstring.substring(8 ,9)) * 1 ) % 10;
		  biz_value[7] = ( parseFloat(objstring.substring(9,10)) * 3 ) % 10;
		  li_temp = parseFloat(objstring.substring(10,11)) * 5 + "0";
		  biz_value[8] = parseFloat(li_temp.substring(0,1)) + parseFloat(li_temp.substring(1,2));
		  biz_value[9] = parseFloat(objstring.substring(11,12));
		  li_lastid = (10 - ( ( biz_value[0] + biz_value[1] + biz_value[2] + biz_value[3] + biz_value[4] + biz_value[5] + biz_value[6] + biz_value[7] + biz_value[8] ) % 10 ) ) % 10;
		   if (biz_value[9] != li_lastid) {
			    obj1.focus();
			    obj1.select();
			    return false;
		   }
		   else
		    	return true;
	 }
	 else {
		  obj1.focus();
		  obj1.select();
		  return false;
	 }
}
