
//********************************************************
// ÀÚÀ¯°Ô½ÃÆÇ
//********************************************************

function sendit() {	
	
	fn=document.frm_write;	

	if (fn.subject.value=="") {
		alert("Á¦¸ñÀ» ÀÔ·ÂÇÏ¼¼¿ä.");
		fn.subject.focus();
		return false;
	}

	if (fn.name.value=="") {
		alert("ÀÌ¸§À» ÀÔ·ÂÇÏ¼¼¿ä.");
		fn.name.focus();
		return false;
	}
	
	if (fn.email.value=="") {
		alert("ÀÌ¸ÞÀÏÀ» ÀÔ·ÂÇÏ¼¼¿ä.");
		fn.email.focus();
		return false;
	}
	
	email = fn.email.value;
	if ( email.search(/(\S+)@(\S+)\.(\S+)/) == -1 ) {
		alert("ÀÌ¸ÞÀÏ ÁÖ¼Ò¸¦ ¹Ù¸£°Ô ÀÔ·Â ÇÏ¼¼¿ä!"); 
		fn.email.focus();
		return false;
	}

	if(fn.pwd.value=="") {
		alert("ºñ¹Ð¹øÈ£¸¦ ÀÔ·ÂÇÏ¿© ÁÖ¼¼¿ä.\n\nºñ¹Ð¹øÈ£¸¦ ÀÔ·ÂÇÏ¼Å¾ß ¼öÁ¤/»èÁ¦¸¦ ÇÒ ¼ö ÀÖ½À´Ï´Ù.");
		fn.pwd.focus();
		return false;
	} 
	if(fn.pwd.value.length < 6) {
		alert("ºñ¹Ð¹øÈ£´Â 6ÀÚ¸¦ ÀÔ·ÂÇØ ÁÖ¼Å¾ß ÇÕ´Ï´Ù.");
		fn.pwd.focus();
		return false;
	}
	
	if (fn.name.value=="¿î¿µÀÚ" || fn.name.value=="°ü¸®ÀÚ") {
		alert("ÇØ´ç ÀÌ¸§Àº »ç¿ëÇÏ½Ç ¼ö ¾ø½À´Ï´Ù.");
		fn.name.focus();
		return false;
	}
	//document.frm_write.submit();
	return true;
}


function deleteit() {	
	
	fn=document.frm_delete;	

	if(fn.pwd.value=="") {
		alert("ºñ¹Ð¹øÈ£¸¦ ÀÔ·ÂÇÏ¿© ÁÖ¼¼¿ä.\n\nºñ¹Ð¹øÈ£¸¦ ÀÔ·ÂÇÏ¼Å¾ß »èÁ¦¸¦ ÇÒ ¼ö ÀÖ½À´Ï´Ù.");
		fn.pwd.focus();
		return false;
	} 
	if(fn.pwd.value.length < 6){
		alert("ºñ¹Ð¹øÈ£´Â 6ÀÚ¸¦ ÀÔ·ÂÇØ ÁÖ¼Å¾ß ÇÕ´Ï´Ù.");
		fn.pwd.focus();
		return false;
	}
	//document.frm_delete.submit();
	return true;
}



function doDetail(no,idx){
	var obj = document.getElementById("tr"+no);
	if(obj.style.display == "none"){
		obj.style.display = "block";
	} else {
		obj.style.display = "none";
	}
}





//ÆË¾÷ÀÌ¹ÌÁö ¿øº»º¸±â
function iwopen( boardTitle, url, width, height ) {
  window.open("/board/pop_imgView.php?it="+boardTitle+"&is="+url+"&iw="+width+"&ih="+height, "photo_slide_view", "status=no, toolbar=no, left=0, top=0, resizable=yes, scrollbars=yes, width="+width+", height="+height);
}

//ÆË¾÷ÀÌ¹ÌÁö ¿øº»º¸±â
function page_resize(page_content){
	try{

		if(this.window.name!='') 
		{
			page_content=(page_content==null)?'page_content':page_content;
			var dataobj=document.getElementById(page_content) ;
			dataobj.style.top=0 ;
			dataobj.style.left=0 ;
			var iframe_main;
			if(iframe_main=parent.document.getElementById(this.window.name)) {
				iframe_main.height=dataobj.offsetHeight ;
			}
		}
	}
	catch(e){}
}

/**
 * example:
 *  fitPopupSize( [doMove] );                  <- ID°¡ 'page_content'ÀÎ objectÀÇ clientWidth, clientHeight °ª¿¡ µû¶ó »çÀÌÁî Á¶Àý
 *  fitPopupSize( object, [doMove] );          <- ÁÖ¾îÁø objectÀÇ clientWidth, clientHeight°ª¿¡ µû¶ó »çÀÌÁî Á¶Àý
 *  fitPopupSize( "pageOuter", [doMove] );     <- ID°¡ 'pageOuter'ÀÎ objectÀÇ clientWidth, clientHeight °ª¿¡ µû¶ó »çÀÌÁî Á¶Àý
 *  fitPopupSize( 300, 400, [doMove] );        <- ÆË¾÷ Å©±â¸¦ 300 x 400À¸·Î Á¶Àý
 */
function fitPopupSize( arg1, arg2, arg3 ) {
	var toWidth = null;
	var toHeight = null;
	var objOut = null;
	var positionRequired = true;

	var typeArg1 = typeof(arg1);
	var typeArg2 = typeof(arg2);
	var typeArg3 = typeof(arg3);
	
	if( typeArg1 == "undefined" || typeArg1 == "boolean" ) {
		objOut = document.getElementById("page_content");
		if( typeArg1 == "boolean" ) {
			positionRequired = arg1;
		}
	}
	if( typeArg1 == "string" ) {
		objOut = document.getElementById(arg1);
		if( objOut == null ) { return; }
				
		if( typeArg2 == "boolean" ) {
			positionRequired = arg2;
		}
	}

	if( typeArg1 == "object" ) {
		objOut = arg1;
				
		if( typeArg2 == "boolean" ) {
			positionRequired = arg2;
		}
	}
	
	if( objOut != null ) {	
		toWidth = objOut.clientWidth;
		toHeight = objOut.clientHeight;
	}

	if( typeArg1 == "number" && typeof(arg2) == "number" ) {
		toWidth = arg1;
		toHeight = arg2;
		
		if( typeArg3 == "boolean" ) {
			positionRequired = arg3;
		}
	}

	if( toWidth == null && toHeight == null ) { return; }

	if( positionRequired ) {
		fitPopupSize_adjustPosition( toWidth, toHeight );
	}
	
	fitPopupSize_resize( toWidth, toHeight );
}

function fitPopupSize_adjustPosition( toWidth, toHeight ) {
	var posLeft = (window.screenLeft) ? window.screenLeft : window.screenX;
	var posTop = (window.screenTop) ? window.screenTop : window.screenY;

	var adjustLeft = 0; 	var marginWidth = 0;
	var adjustTop = 0;	    var marginHeight = 0;
	var movingRequired = false;

	if( posTop + toHeight + marginHeight > screen.availHeight ) {
		adjustTop = -(posTop + toHeight + marginHeight - screen.availHeight);
		movingRequired = true;
	}
	if( posLeft + toWidth + marginWidth > screen.availWidth ) {
		adjustLeft = -(posLeft + toWidth + marginWidth - screen.availWidth);
		movingRequired = true;
	}
	if(adjustTop<0) adjustTop=0;
	if( movingRequired ) {
		window.moveBy( adjustLeft, adjustTop );
	}
}

function fitPopupSize_resize( toWidth, toHeight ) {
	var oBody = document.body;
	if( oBody == null ) { return; }

	if( typeof(window.innerHeight) != "undefined" && typeof(window.innerWidth) != "undefined"  && !isOpera && !isSafari ) {
		//ff
		window.innerHeight = toHeight;
		window.innerWidth = toWidth;
	} else {
		//ie
		var diffX = toWidth - oBody.clientWidth;
		var diffY = toHeight - oBody.clientHeight;
		
		//if(diffY<0) diffY=0;
		//alert("resizeX "+diffX);
		//alert("resizeY "+diffY);		
		window.resizeBy( diffX, diffY );
	}
/*	
	var posLeft = (window.screenLeft) ? window.screenLeft : window.screenX;
	var posTop = (window.screenTop) ? window.screenTop : window.screenY;

	if( oBody.clientHeight > screen.availHeight ) {
		var adjustHeight = screen.availHeight - (oBody.clientHeight + 50);
		window.moveTo(posLeft, 0);
		window.resizeBy( 0, adjustHeight );
	}
*/	
}

function fitPopupSizeEx() {
	var oBody = document.body;
	if( oBody == null ) { return; }
	
	var idPrefix = "page_content";
	var objId = "";
	var chkResult = false;
	var objChk = null;
	
	for( var i=65; i<=90; i++ ) {
		objId = idPrefix + String.fromCharCode(i);
		objChk = document.getElementById(objId);
		if( objChk == null ) { break; }
	}
	if( objChk != null ) { return; }

	var objOut = window.document.createElement("<div id='" + objId + "' style='position:absolute;left:0;top:0;'>");

	var existNodeList = window.document.body.childNodes;
	while( existNodeList.length > 0 ) {
		objOut.appendChild( existNodeList[0] );
	}
	document.body.appendChild( objOut );

	var toWidth = objOut.clientWidth;
	var toHeight = objOut.clientHeight;
	if( toWidth == null && toHeight == null ) { return; }

	fitPopupSize_adjustPosition( toWidth, toHeight );

	fitPopupSize_resize( toWidth, toHeight );
}
