/** 
* Author    : MC ½É»õ (ganer9r@naver.com) 
* Make Date : 2008-07-15 
* comment    : 1ÁÙ ÅØ½ºÆ® ·Ñ¸µ ½ºÅ©¸³Æ® 
**/ 
var ScrollControl    = function(objId,options){ 
    this.init(objId,options); 
} 
ScrollControl.prototype    = { 
    stage : {}, 
    options : {}, 
    isover : false, 
    freeze : false, 
    course : 'top', 

    init : function(objId,options){ 
        this.setOptions(options); 
        this.setStage(objId); 
        this.setTrueData(); 

        this.move(); 
    }, 
    setOptions : function(options){ 
        options.inteval    = options.inteval    || 50; 
        options.freeze    = options.freeze    || 1000; 
        options.height    = parseInt(options.height, 10)    || 20; 

        options.cMarginTop    = options.cMarginTop    || (options.height/2) * 0.3; 
        options.cHeight        = options.height - options.cMarginTop; 

        this.options    = options; 
    }, 
    setTrueData : function(){ 
        var cObjs        = this.stage.childNodes; 
        var removes        = []; 

        for(var i=0;i<cObjs.length;i++){ 
            if(!cObjs[i].tagName){ 
                removes.push(cObjs[i]);    //¹Ù·Î »èÁ¦ ½Ã µ¥ÀÌÅÍ ²¿ÀÌ´Âµí ÇÏ¿© ÀÏ´Ü ÅµÇÔ. 
            }else{ 
                cObjs[i].style.margin        = "0"; 

                cObjs[i].style.marginTop    = this.options.cMarginTop; 
                cObjs[i].style.height        = this.options.cHeight; 
            } 
        } 

        // Ã£Àº µ¥ÀÌÅÍ¸¦ »èÁ¦ÇÔ.(FFÀÇ °æ¿ì text ³ëµå°¡ Ã·ºÎµÊ.) 
        for(var i=0;i<removes.length;i++){ 
            this.stage.removeChild(removes[i]); 
        } 

        if(cObjs.length == 1){ 
            this.stage.appendChild( cObjs[0].cloneNode(true) ); 
        } 

    }, 
    setStage : function(objId){ 
        var This    = this; 
        this.stage        = document.getElementById(objId); 

        this.stage.style.height        = this.options.height; 
        this.stage.style.overflow    = "hidden"; 
        this.stage.style.padding    = "0px"; 
        this.stage.style.margin        = "0px"; 

        this.stage.onmouseover=function(){This.isover=true;} 
        this.stage.onmouseout=function(){This.isover=false;} 
    }, 
    setCourse : function(course){ 
        if(this.course != 'down' && course == 'down'){ 
            this.changeChild(); 
            this.stage.scrollTop = this.options.height; 
        }else if(course == 'top' && this.stage.scrollTop >= this.options.height){ 
            this.stage.appendChild(this.stage.childNodes[0]); 
            this.stage.scrollTop = this.stage.scrollTop - this.options.height; 
        } 

        this.course    = course; 
    }, 
    changeChild : function(){ 
        var childCnt    = this.stage.childNodes.length; 

        for(var i=0; i<childCnt-1;i++ ){ 
            this.stage.appendChild( this.stage.childNodes[0] );    // Ç×»ó Ã¹¹øÂ°°ÍÀ» µÚ·Î ÀÌµ¿ 
        } 
    }, 
    actionTop : function(){ 
        this.stage.scrollTop++; 
        if( this.stage.scrollTop >= this.options.height ){ 
            this.stage.appendChild(this.stage.childNodes[0]); 
            this.stage.scrollTop = this.stage.scrollTop - this.options.height; 
            this.freeze            = true; 
        } 
    }, 
    actionDown : function(){ 
        this.stage.scrollTop--; 
        if( this.stage.scrollTop == 0 ){ 
            this.changeChild(); 
            this.stage.scrollTop = this.options.height; 
            this.freeze            = true; 
             
            this.setCourse("top"); 
        } 
    }, 
    move : function(){ 
        if(!this.isover){ 
            if(this.course == 'top')    this.actionTop(); 
            else                        this.actionDown(); 
        } 

        var This    = this; 
        if(this.freeze)    window.setTimeout(function(){This.move()}, this.options.freeze); 
        else            window.setTimeout(function(){This.move()}, this.options.inteval); 
        this.freeze    = false; 
    } 

} 


/* »ç¿ë¹ý Start*/ 
//    var scroll    = new ScrollControl('html element id',options); 
// 
//    options Ç×¸ñ 
//    inteval : Àç±ÍÈ£Ãâ ½Ã°£ °£°Ý 1/1000ÃÊ(±âº»°ª 50) 
//    freeze : Àá½Ã ¸ØÃç ÀÖ´Â ½Ã°£ °£°Ý 1/1000 ÃÊ(±âº»°ª 1000) 
//    height : °´Ã¼ ³ôÀÌ(±âº»°ª 20) 
//    cMarginTop : ÀÚµ¿À¸·Î ±¸ÇØÁÖ³ª, ±ÛÀÚ Å©±â¿Í °´Ã¼ ³ôÀÌ µîÀ¸·Î ÀÎÇØ, ÀÇµµÇÑ ³ôÀÌ°¡ ³ª¿ÀÁö ¾ÊÀ» ¼ö ÀÖ±â ¶§¹®¿¡ »ç¿ëÀÚ°¡ °­Á¦ ÀÔ·ÂÇÔ. 
//     
/* »ç¿ë¹ý End */ 

function bookmark(){
//	alert("222");
	window.external.AddFavorite("http://www.achae.co.kr", "¿ì¸®¿Ê¾ÆÃ¤");
}

function chkForm(f)
{ 
	var i,currEl;

	for(i = 0; i < f.elements.length; i++){ 
		currEl = f.elements[i]; 
		//ÇÊ¼ö Ç×¸ñÀ» Ã¼Å©ÇÑ´Ù.  
		if (currEl.getAttribute("required") != null) { 
			if(currEl.type == "TEXT" || currEl.type == "text" || 
			   currEl.tagName == "SELECT" || currEl.tagName == "select" || 
			   currEl.tagName == "TEXTAREA" || currEl.tagName == "textarea" || currEl.type == "file" || currEl.type == "FILE"){ 
				if(!chkText(currEl,currEl.hname)) return false; 

			} else if(currEl.type == "PASSWORD" || currEl.type == "password"){ 
				if(!chkText(currEl,currEl.hname)) return false; 

			} else if(currEl.type == "CHECKBOX" || currEl.type == "checkbox"){ 
				if(!chkCheckbox(f, currEl,currEl.hname)) return false; 

			} else if(currEl.type == "RADIO" || currEl.type == "radio"){ 
				if(!chkRadio(f, currEl,currEl.hname)) return false; 

			}
		}
		// ÀÔ·Â ÆäÅÏÀ» Ã¼Å©ÇÑ´Ù.
		if(currEl.getAttribute("option") != null && currEl.value.length > 0){ 
			if(!chkPatten(currEl,currEl.option,currEl.hname)) return false; 
		} 
	}
} 

function chkPatten(field,patten,name)
{ 
	var regWidth =/^[0-9-%]+$/; 
	var regNum =/^[0-9]+$/; 
	var regTid = /^[a-zA-Z]{1}[a-zA-Z0-9_-]{5,9}$/; 
	var regPhone =/^[0-9]{2,3}-[0-9]{3,4}-[0-9]{4}$/; 
	var regMail =/^[_a-zA-Z0-9-]+@[._a-zA-Z0-9-]+\.[a-zA-Z]+$/; 

	patten = eval(patten); 
	if(!patten.test(field.value)){ 
		alert(name + "\n\nÇ×¸ñÀÇ Çü½ÄÀÌ ¿Ã¹Ù¸£Áö ¾Ê½À´Ï´Ù."); 
		field.focus(); 
		return false; 
	} 
	return true; 
} 

function chkText(field, name)
{ 
	if(field.value.length < 1){ 
		alert(name); 
		field.focus(); 
		return false; 
	} 
	return true; 
}

function chkCheckbox(form, field, name)
{
	fieldname = eval(form.name+'.'+field.name);
	if (!fieldname.checked){
		alert(name); 
		field.focus(); 
		return false; 
	}
	return true; 
}

function chkRadio(form, field, name)
{
	fieldname = eval(form.name+'.'+field.name);
	for (i=0;i<fieldname.length;i++) {
		if (fieldname[i].checked)
			return true; 
	}
	alert(name); 
	field.focus(); 
	return false; 
}



// °øÁö»çÇ× º¸±â
function Notice_List() {
	var window_left = (screen.width-640)/2;
	var window_top = (screen.height-480)/2;
	window.open('./sub/notice.php',"Notice_List",'width=500,height=480,status=yes,scrollbars=yes,top=' + window_top + ',left=' + window_left + '');
}

function Notice_View(no) {
	var window_left = (screen.width-640)/2;
	var window_top = (screen.height-480)/2;
	window.open('./sub/notice.php?mode=view&no='+no,"Notice_Veiw",'width=500,height=480,status=yes,scrollbars=yes,top=' + window_top + ',left=' + window_left + '');
}
