﻿
// Flash 전용 호출함수 id_name : ID또는Name 값, swf_name : 쇼크웨이브파일 경로(이름,GET값포함), wdith: 넓이값, height: 높이값 
function swf_func(id_name,swf_name,width,height){ 
document.writeln("<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='/asset/flash/swflash.cab#version=8,0,0,0' width='"+width+"' height='"+height+"' id='"+id_name+"' align='middle'>");
document.writeln("<param name='allowScriptAccess' value='always'>");
document.writeln("<param name='movie' value='"+swf_name+"'>");
document.writeln("<param name='quality' value='high'>");
document.writeln("<param name='bgcolor' value='#ffffff'>");
document.writeln("<param name='wmode' Value='Transparent'>");
document.writeln("<EMBED src='"+swf_name+"' width='"+width+"' height='"+height+"' type='application/x-shockwave-flash' wmode='transparent'></EMBED>");
document.writeln("</object>");
}


//동영상 전용 호출함수
function mov_func(id,name,width,height){
document.writeln("<OBJECT classid='clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95' width='"+width+"' height='"+height+"' id='"+id+"'>");
document.writeln("<PARAM NAME='Filename' VALUE='" +name +"'>");
document.writeln("<PARAM NAME='Showcontrols' VALUE='false'>");
document.writeln("<PARAM NAME='Autostart' VALUE='false'>");
document.writeln("<PARAM NAME='uimode' VALUE='false'>");
document.writeln("<PARAM NAME='Volume' VALUE='-1000'>");
document.writeln("<EMBED src='"+ name +"' width='" + width + "' height='" + (Number(height)+60)  + "' id='" + id + "' autostart='0' controller='0' volume='-1000'></EMBED>");
document.writeln("</OBJECT>");
}

// 이미지 자동 축소(게시판 넓이에 맞춤)
function imageChange(imgSize) {
	for(i = 0;i < document.images.length; i++){
		if(document.images[i].id == "userIMAGE"){
			if(document.images[i].width > imgSize){
				document.images[i].height = document.images[i].height / (document.images[i].width / imgSize);
				document.images[i].width = imgSize;
			}
		}
	}
}

//한글인지 검사
function Check_onlyKorean(str){
	for ( var i=0; i < str.length; i++ ) {
		if ( str.charCodeAt(i) < 0xAC00 || str.charCodeAt(i) > 0xD7A3){
			if (( str.charCodeAt(i) < 12593 || str.charCodeAt(i) > 12643 ) && ( str.charCodeAt(i) != 32)) {
				return true;
			}
		}
	}	
	return false;
}

//기능 : 팝업창을 화면 중앙에 띄우는 함수
//사용법 : openPopup('auth_write.asp','auth',667,500,'scrollbars=yes,width=667,height=500')
function openPopup( url, name, width, height, features) {
    var left= ( screen.width   - width ) / 2;
    var top = ( screen.height   - height ) / 2;
    return window.open(url, name, features + ',left=' + left + ', top=' + top);
}

/*
기능 : 필드에 숫자만 입력할수 있는 함수 
사용법 : onkeyup="onlyNumber(this);"
*/
 
function onlyNumber(el) {
  el.value = el.value.replace(/\D/g,'');
}

//문자열의 공백제거 (양측)
function Trim( str ) {
		
	var resultStr = "";
		
	resultStr = TrimLeft(str);
	resultStr = TrimRight(resultStr);
	
	return resultStr;
}

//문자열의 공백제거 (좌측)
function TrimLeft( str ) {
	var resultStr = "";
	var i = len = 0;	
	if (str+"" == "undefined" || str == null) return null;	
	str += "";
	
	if (str.length == 0) resultStr = "";
	else {	
		len = str.length;					
  		while ((i <= len) && (str.charAt(i) == " "))i++;   	
  		resultStr = str.substring(i, len);
  	}

  	return resultStr;
} 

//문자열의 공백제거 (우측)
function TrimRight( str ) {
	var resultStr = "";
	var i = 0;	
	
	if (str+"" == "undefined" || str == null) return null;
	str += "";
		
	if (str.length == 0) resultStr = "";
	else {
  		i = str.length - 1;
  		while ((i >= 0) && (str.charAt(i) == " "))
 			i--;
	  		resultStr = str.substring(0, i + 1);
	  	}
	  	
	  	return resultStr;  	
}

/*
기능 : 필드에 숫자만 입력할수 있는 함수 
사용법 : onkeyup="onlyNumber(this);"
*/
 
function onlyNumber(el) {
  el.value = el.value.replace(/\D/g,'');
}

/*
기능 : 공통 Input Box Blank Check함수
사용법1 : setInputAlert(form1.field, fieldName);
*/
function setInputAlert(field, fieldName) {	
	if(Trim(field.value) == "") {
		alert(fieldName +" 입력해주세요.");
		field.focus();
		return false;
	}else{
		return true;
	}
}

/*
기능 : 공통 Select Box Blank Check함수
사용법1 : setSelectAlert(form1.field, fieldName);
*/
function setSelectAlert(field, fieldName) {	
	if(Trim(field.value) == "") {
		alert(fieldName +" 선택해주세요.");		
		field.focus();
		return false;
	}else{
		return true;
	}
}

/*
기능 : 공통 Check Box Blank Check함수
사용법1 : setCheckAlert(form1.field, fieldName);
*/
function setCheckAlert(field, fieldName) {	
	var temp = 0;
	for(i = 0; i < field.length; i++){
		if(field[i].checked == true){
			temp = temp + 1;
		}
	}
	
	if(temp == 0){
		alert(fieldName+" 선택해주세요.");
		return false;
	}else{
		return true;
	}
}

/*
기능 : 팝업리사이즈
사용법1 : popresize()
*/
function popresize(){
	scrollheight = parseInt(document.body.scrollHeight);
	scrollwidth	 = parseInt(document.body.scrollWidth);

	clientheight = parseInt(document.body.clientHeight);
	clientwidth = parseInt(document.body.clientWidth);

	height = scrollheight - clientheight
	width = scrollwidth - clientwidth	
	
	this.resizeBy(width,height);
}

/*
기능 : 좌측 KeyWord
*/


function openKey(){

    if (document.getElementById("keyWord").currentStyle.display == "none"){
        document.getElementById("keyWord").style.display = "block";
    }else{
        document.getElementById("keyWord").style.display = "none";
    }

}


/* 이미지 기본 롤오버* obj : 객체(this), chk : 불린값 true - over, false - out*/

function imgOver(obj,chk){
    if(chk){
        
        obj.src = obj.src.replace(/_off/gi,"_on")

    }else{
    
        obj.src = obj.src.replace(/_on/gi,"_off")

    }

}

function scrollTop(){

if(document.all("defaultInBox"))
    document.all("defaultInBox").scrollTop=0;
else if(document.all("defaultInBox02"))
    document.all("defaultInBox02").scrollTop=0;

this.scroll(0)

}
