//----------- iframe ¸®»çÀÌÁî °ü·Ã ---------------//

//iframe ¸®»çÀÌÁî-ºÎ¸ðÃ¢
function fnIFrameReSize() {
	var ParentFrame	    =	bzboard.document.body;
	var ContentFrame	=	document.all["bzboard"];
	ContentFrame.style.height = ParentFrame.scrollHeight + (ParentFrame.offsetHeight - ParentFrame.clientHeight);
	ContentFrame.style.width = ParentFrame.scrollWidth + (ParentFrame.offsetWidth - ParentFrame.clientWidth);
	
	window.scrollTo(0,0);
}

//iframe ¸®»çÀÌÁî-¹®¼­
function fnPaperInit_sub() {
    parent.fnIFrameReSize();
}

//----------- ÆË¾÷Ã¢ °ü·Ã ---------------//

function fnWindowPop(cURL, cTarget, nWidth, nHeight){
	var cOpen;
	cOpen = window.open(cURL,cTarget,"toolbar=0,menubar=0,scrollbars=no,resizable=no,width=" + nWidth +",height=" + nHeight + ";")
	cOpen.focus();
}

// »õÃ¢ ¶ç¿ì±â
function fnWindowOpen(cURL, cTarget, nWidth, nHeight, bFlag){
    var cOpen;

	if (bFlag == 0 ) {
		cOpen = window.open(cURL,cTarget,"toolbar=0,menubar=0,scrollbars=no,resizable=no,width=" + nWidth +",height=" + nHeight + ";")
	} else {
		cOpen = window.open(cURL,cTarget,"toolbar=0,menubar=0,scrollbars=yes,resizable=no,width=" + nWidth +",height=" + nHeight + ";")
	}
	cOpen.focus();
}

// »õÃ¢ ¶ç¿ì±â Áß¾Ó
function fnWindowCenter(cURL, cTarget, nWidth, nHeight){
	var cOpen;
	var nWinL = (screen.width-nWidth)/2;
	var nWinT = (screen.height-nHeight)/2;
	cOpen = window.open(cURL,cTarget,"toolbar=0,menubar=0,scrollbars=no,resizable=no,width=" + nWidth +",height=" + nHeight + ",top=" + nWinT + ",left=" + nWinL + ";")

	cOpen.focus();
}

// »õÃ¢ ¶ç¿ì±â ÀüÃ¼
function fnCheckWindowOpen_All(cURL, cTarget) {
	var cOpen;
	cOpen = window.open(cURL, cTarget);
	cOpen.focus();
}

//ÇÃ·¡½¬ ¼­ºê¸Þ´º ³ôÀÌ Á¶Àý
function fnSwfAutoSize(nHeight) {
	var tObj = document.getElementById('swfLeftSub');
	tObj.style.height = nHeight;
}

//============================= °Ô½ÃÆÇ ´ñ±Û ÀÌ¸ðÆ¼ÄÜ ½ºÅ©¸³Æ® =============================//
function fnViewEmoticon() {
	var obj = document.getElementById('bbsCommentEmoticon');
	var bOpen = obj.style.display;	
	
	if (bOpen == "none") obj.style.display = "inline";
	else obj.style.display = "none";
}

function fnSetEmoticon(e,emot) {
	var evt = e || window.event;
	var dw = document.frmWriteComment;
	
	dw.myemot.src = "/images/sShare/" + emot;
	dw.chVar01.value = emot;
	document.getElementById("bbsCommentEmoticon").style.display = "none";
	
	if (evt.stopPropagation) evt.stopPropagation();
	else evt.cancelBubble = true;
}

function fnSetEmoticon2(e,emot) {
	var evt = e || window.event;
	var dw = document.frmWriteComment;
	
	dw.myemot.src = emot;
	dw.chVar01.value = emot;
	document.getElementById("bbsCommentEmoticon").style.display = "none";
	
	if (evt.stopPropagation) evt.stopPropagation();
	else evt.cancelBubble = true;
}

//----------- ±âÅ¸ °øÅë ±â´É °ü·Ã ---------------//
//¿µ¹®ÀÚ Ã¼Å© ¶Ç´Â ¼ýÀÚÃ¼Å©
function fnCheckAlphaNum(chChar) {
	var aChar = chChar.split("\\");
	var chr;
	chChar = aChar[aChar.length-1];
	
	for (var i=0; i<chChar.length; i++) {
		chr = chChar.substr(i, 1);
		
		if(chr != "." && chr != "_" && (chr < '0' || chr > '9') && (chr < 'a' || chr > 'z') && (chr < 'A' || chr > 'Z')) {
			return false;
		}
	}
	
	return true;
}

// ÀÌ¹ÌÁö ¸®»çÀÌÁî
function fnViewImageResize(nMaxWidth) {
	// DivContents ¿µ¿ª¿¡¼­ ÀÌ¹ÌÁö°¡ maxsize º¸´Ù Å©¸é ÀÚµ¿ ¸®»çÀÌÁî ½ÃÄÑÁÜ
	var obj = document.getElementById("divViewArea");
	
	for(var i=0;i<obj.childNodes.length;i++){
		var p=obj.childNodes[i];
		if(p.tagName=="IMG") {
			if (p.offsetWidth > nMaxWidth) {
				var imgHeight = p.height*nMaxWidth/p.width;
				
				p.style.width=nMaxWidth + 'px';
				p.style.height=parseInt(heightSize) + 'px';
			}
		}
	}
} 

//----------- ¹Ì´Ï Ä¶¸°´õ °ü·Ã ---------------//
// ¹Ì´Ï Ä¶¸°ÅÍ 
function fnCheckCalendarPosition(chLayerName, bVisible) {
	var obj=document.all[chLayerName];

	if (bVisible == 'visible') {	
		obj.style.posLeft = event.clientX-160;
		obj.style.posTop = event.clientY+15;
		obj.style.visibility = bVisible;
	} else {
		obj.style.visibility = bVisible;
	}
}

function fnInputDay(chFormName, nYear, nMonth, nDay, chType) {
	var dw = document.all[chFormName];
	
	if (chType == 'start') {
		dw.dStart.value = nYear + "." + nMonth + "." + nDay;
	} else {
		dw.dEnd.value = nYear + "." + nMonth + "." + nDay;
	}
	
	calendar.location.href = "/common/pMiniCalendar.php?chType=" + chType;
	fnCheckCalendarPosition('viewcalendar', 'hidden');
}

function fnShowCalendar(chFormName, chType, bVisible) {
	calendar.location.href = "/common/pMiniCalendar.php?chFormName=" + chFormName + "&chType=" + chType;
	fnCheckCalendarPosition('viewcalendar', bVisible);
}

function fnDeleteDate(chFormName, chType) {
	var dw = document.all[chFormName];
	
	if (chType == 'start') {
		dw.dStart.value = "";
	} else {
		dw.dEnd.value = "";
	}		
}
// °ø¹é Ã¼Å©
function fnCheckSpace(chChar) {
	var aChar = chChar.split("\\");
	var chr;
	chChar = aChar[aChar.length-1];
	
	
	if((/[\s]/).test(chChar)) {
		return false;
	} else {
		return true;
	}
}

// html check;
function fnIsHTMLComment(bCheck) {
	if (bCheck == true) {
		html_editor.style.display = "";
		comment_editor.style.display = "none";
	} else {
		html_editor.style.display = "none";
		comment_editor.style.display = "";
	}
}

// ÀÌ¸ÞÀÏ Ã¼Å©
function fnCheckEmail(strEmail) {	
	var arrMatch = strEmail.match(/^(\".*\"|[A-Za-z0-9_-]([A-Za-z0-9_-]|[\+\.])*)@(\[\d{1,3}(\.\d{1,3}){3}]|[A-Za-z0-9][A-Za-z0-9_-]*(\.[A-Za-z0-9][A-Za-z0-9_-]*)+)$/);

	if (arrMatch == null) {
		return false;
	}

	var arrIP = arrMatch[2].match(/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/);

	if (arrIP != null) {
		for (var i = 1; i <= 4; i++) {
			if (arrIP[i] > 255) {
				return false;
      		}
   		}
	}
	return true;
}
	
function fnCheckDaum(chEmail) { 
	var aEmail = chEmail.split("@"); 
	
	if(aEmail[1] == 'hanmail.net' || aEmail[1] == 'daum.net') { 
		alert("ÇÑ¸ÞÀÏÀº ¾ÈµË´Ï´Ù. ´Ù¸¥ E-mailÀ» Àû¾îÁÖ½Ã±â ¹Ù¶ø´Ï´Ù."); 
		return false;
	} else {
		return true;
	}
} 

// ÀÌ¹ÌÁö Å©°Ô º¸±â
function fnImageView(chSrc) {
	var cOpen;
	cOpen = 	window.open('/pPhoto.php?chFile=' + chSrc, 'photo', 'width=100, height=100, scrollbars=yes');
	cOpen.focus();
}

function fnScrollTop() {
	window.scrollTo(0,0);
}

