// 공백이 제거된 단어의 길이 추출
function wordLengthExceptBlank(keyword) {
    var st_num, key_len;
    st_num = keyword.indexOf(" ");	

    while (st_num != -1) {
        keyword = keyword.replace(" ", "");
        st_num = keyword.indexOf(" ");
    }

    key_len = keyword.length;
    return key_len;
}

// 알파벳, 숫자, 기호 체크
function checkAlphabetNumber(str)
{ 
	var check = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_-';
	var temp; 
	
	for (var i=0; i<str.length; i++) {
		temp = '' + str.substring(i, i+1); 
		
		if (check.indexOf(temp) == '-1') { 
			return false;
		}
	} 
	
	return true;
}

// 숫자 체크
function checkNumber(str)
{ 
	var check = '0123456789';
	var temp; 
	
	for (var i=0; i<str.length; i++) {
		temp = '' + str.substring(i, i+1); 
		
		if (check.indexOf(temp) == '-1') { 
			return false;
		}
	} 
	
	return true;
}

// 숫자 체크
function onlyNumber(obj)
{ 
	var check = '0123456789';
	var temp; 
	
	for (var i=0; i<obj.value.length; i++) {
		temp = '' + obj.value.substring(i, i+1); 
		
		if (check.indexOf(temp) == '-1') { 
			return false;
		}
	} 
	
	return true;
}

//----------------------------------------------------------------------
//* 내용 : 같은 이름을 갖는 체크박스를 모두 checked(위 입력) 된 상태로 만든다.
//* 입력 :
//*   formname - form name
//*   itemname - item name (check box 의 이름)
//*   checked - 만들고 싶은 상태
//----------------------------------------------------------------------
function selectAllCheck(formname,itemname,checked) {
	if (document.all[formname].elements[itemname]==null) {
	}
	else {
		/*
		항목이 하나일 경우는 해당 항목을 변경하고 여럿일 경우 모두 변경한다.
		*/
		if (document.all[formname].elements[itemname].length==null) {
			if (!document.all[formname].elements[itemname].disabled) document.all[formname].elements[itemname].checked=checked;
		} else {
			for (i=0;i<document.all[formname].elements[itemname].length;i++) {
				if (!document.all[formname].elements[itemname][i].disabled) document.all[formname].elements[itemname][i].checked=checked;
			}
		}
	}
}

function fileDownload(frameName, formName, fileName, div1, div2) {
	eval("document." + formName).action = "/common/lib/file_download_inc.php";
	eval("document." + formName).target = frameName;
	//eval("document." + formName).fileName.value = encodeURIComponent(eval("document." + formName).tempFileName.value);
	//eval("document." + formName).fileName.value = encodeURIComponent(fileName);
	eval("document." + formName).fileName.value = fileName;
	eval("document." + formName).div1.value = div1;
	eval("document." + formName).method = "post";
	eval("document." + formName).submit();
}

//----------------------------------------------------------------------
//	문자열 치환
//----------------------------------------------------------------------
String.prototype.trim = function() {
	return this.replace(/(^\s*)|(\s*$)/gi, "");
}

String.prototype.replaceAll = function(str1, str2) {
    var tempStr = this.trim();
    tempStr = tempStr.replace(eval("/" + str1 + "/gi"), str2);
	return tempStr;
}

//----------------------------------------------------------------------
//* 화면 인쇄
//----------------------------------------------------------------------
var printForHtmlContent; 
var tempPrintId;

function printDiv(printArea) { 
    if (document.all && window.print) { 
        tempPrintId = printArea;
        window.onbeforeprint = beforeDivs; 
        window.onafterprint = afterDivs; 
        window.print(); 
    } 
} 

function beforeDivs() { 
    if (document.all) { 
        var rng = document.body.createTextRange( ); 

        if (rng!=null) { 
            //alert(rng.htmlText); 
            printForHtmlContent = rng.htmlText; 
            rng.pasteHTML("<table border=0 align=center><tr><td>" + eval("document.all['" + tempPrintId + "']").innerHTML + "</td></tr></table>");
        } 
    } 
} 

function afterDivs() { 
    if (document.all) { 
        var rng = document.body.createTextRange( ); 

        if (rng!=null) { 
            rng.pasteHTML(printForHtmlContent); 
        } 
    } 
} 

//----------------------------------------------------------------------
//* 플래시
//----------------------------------------------------------------------
function viewFlash(source,width,height) {
    document.write('<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 + '"><param name="movie" value="' + source + '"><param name="quality" value="high"><param name="wmode" value="transparent"><param name="allowScriptAccess" value="always"><embed src="' + source + '" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" wmode="transparent" type="application/x-shockwave-flash" allowScriptAccess="always" width="' + width + '" height="' + height + '"></embed></object>');
}

//----------------------------------------------------------------------
//* 배너링크
//----------------------------------------------------------------------
function bannerLinkTarget(linkTarget, linkUrl) {
    if (linkTarget == '1') {
    	document.bannerForm.target = "_self";
    } else {
    	document.bannerForm.target = "_blank";
    }

	document.bannerForm.action = "http://" + linkUrl;
	document.bannerForm.method = "post";
    document.bannerForm.submit();
}



