
/**
 * 화면 중앙에 창 뛰우는 스크립트
 * 
 * @param {Object} url
 * @param {Object} wname
 * @param {Object} wopt
 */
function openWinCenter(url, wname, wopt) {
			
	var newopt = "", wHeight = 0, wWidth = 0;
	if (wopt != undefined) {
		var woptlist = wopt.replaceAll(" ", "").split(",");
		try{
			for (var i in woptlist) {
				if (woptlist[i].match(/^height=/i)) {
					wHeight = parseInt(woptlist[i].substr(7),10);
					if (!isNaN(wHeight)) newopt += "top=" + Math.floor((screen.availHeight - wHeight) / 2) + ",";
				}
				if (woptlist[i].match(/^width=/i)) {
					wWidth = parseInt(woptlist[i].substr(6),10);
					if (!isNaN(wWidth)) newopt += "left=" + Math.floor((screen.availWidth - wWidth) / 2) + ",";
				}
				
			}
		
		}catch(e){}
	}
	return window.open(url, wname, newopt + wopt);
			
} 

function isDigit(str) { 	
	if ( str == null || str.length < 1 ) 
		return false ;
		
	for(var i=0;i< str.length;i++){          
	   var c=str.charCodeAt(i);       
	   if( !(  0x30 <= c && c <= 0x39 ) ) {         
	    return false ;       
	   }
	 }      
	return true ;
}

function makeInt(str) { 	
	
	if( isDigit(str) ){
		return parseInt(str, 10);
	}else{
		return 0;
	}
}

//숫자만 입력
function numKeyOnly( Ev ){
	if (!event) event = window.event;
    var target = event.target || event.srcElement;
	
	var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode; 
    var evCode = ( window.netscape ) ? Ev.which : event.keyCode ;
    	/* FF일 경우 Ev.which 값을,
        IE을 경우 event.keyCode 값을 evCode에 대입 */
    if ( ! ( keyCode == 0 || keyCode == 8 || ( keyCode > 47 && keyCode < 58 ) ) ) {
    /* 눌러진 키 코드가 숫자가 아닌 경우
        ( '0'은 FF에서 Tab 키,
          '8'은 FF에서 BackSpace가 먹히지 않아 삽입)    */
        if(window.event){
    		window.event.returnValue = false;
   		}else{
			//event.stopPropagation(); 
       		event.preventDefault();
   		}
    }
}


// 현재 날짜부터의 차를 구한다.
function getDateGap( day  ){
	var date = new Date();
	if( day != null){
		date.setDate(date.getDate() + day );
	}
	return date ;
}

function getDateString(delim, date  ){
	if( date == null ){
		date = new Date();
	}
	var year = date.getFullYear();
	var month = date.getMonth() + 1;
	var day = date.getDate() ;
	
	var monthStr = month+"";
	if(month < 10){
		monthStr ="0"+monthStr;
	}
	
	var dayStr = day+"";
	if(day < 10){
		dayStr ="0"+dayStr;
	}
	
	
	return year + delim + monthStr + delim + dayStr ;
}

function defaultIncludeProcess(id){
	var elem= document.getElementById(id);
	$('.popUpWindowOpen', elem).bind('click',popUpWindowOpenBind);
						
	$(".isFlash",elem ).each(function(i){
			var src = $(this).text();
			$(this).empty();
			var width=$(this).css('width');
			var height=$(this).css('height');
			$(this).flash({ 
			src: src,
			width: width,
			height: height,
			wmode:"transparent"
			},
			{ expressInstall: true }
		);
	});
	
}


//파일을 읽어 들인다.
function getInclude(url,id,afterProcess){
	url=url +"&dmy="+new Date().getTime();
	$.get(url,function(data){
     		$('#'+id).html( data );
			defaultIncludeProcess(id);
			
			if(afterProcess){
				afterProcess();
			}
   	});
}


