//ÆË¾÷Ã¢ ½ºÅ©¸³Æ® - ½ºÅ©·Ñ¹Ù ¾ø´Â °Í
function popwindow(pop,width,height)
{
	var url = pop;  
	var wd = width;
	var he = height;
	
	window.open(url,"","toolbar=0,menubar=0,scrollbars=no,resizable=no,width=" + wd +",height=" + he + ";")
}

//ÆË¾÷Ã¢ ½ºÅ©¸³Æ® - ½ºÅ©·Ñ¹Ù ÀÖ´Â °Í
function popwindow2(pop,width,height)
{
	var url = pop;  
	var wd = width;
	var he = height;
	
	window.open(url,"","toolbar=0,menubar=0,scrollbars=yes,resizable=no,width=" + wd +",height=" + he + ";")
}

function clearText(thefield){
if (thefield.defaultValue==thefield.value)
        thefield.value = ""
} 

 /**  ¸µÅ©½Ã »ý±â´Â Á¡¼±¶óÀÎ ¾ø¾Ö±â **/
function allblur() {
    for (i = 0; i < document.links.length; i++)
        document.links[i].onfocus = document.links[i].blur;
}


// ----------------------------------------------------------------------------------------------------------------------

// DHTML ¿¡µðÅÍ·Î ÀÛ¼ºµÈ ±ÛÀÐ±âÈ­¸é¿¡¼­ ÀÌ¹ÌÁö Å¬¸¯½Ã ÆË¾÷Ã¢¿¡ ÀÌ¹ÌÁö¸¦ ¶ç¿ò.
function popview(imgname) {
	window.open("/portal/include/popviewer.asp?imgname=" + imgname, "popwin","directories=no,location=no,menubar=no,resizable=yes,scrollbars=yes,status=no,titlebar=no,toolbar=no,width=560,height=470");
}

// ¿¡µðÅÍ ÀÌ¹ÌÁö¿¡ ´ëÇØ¼­ setTimeout ÇÔ¼ö¿¡ ÀÇÇØ ½ÇÇà
// ºí·Î±× ¸®½ºÆ®¿¡´Â ¿©·¯°³ÀÇ ÀÌ¹ÌÁö°¡ id°ªÀ¸·Î À¯ÀÏÇÏ°Ô ÁöÁ¤µÇ¾îÀÖ´Ù.
function resizeImage(num)
{
  var width = eval('document.all.userImg'+num+'.width');
  if( width > 500 )
  {
    eval('document.all.userImg'+num+'.width = 500');
  }
}

// À§Ã³·³ ÀÌ¹ÌÁö°¡ ¸®½ºÆ®·Î ¿©·¯Àå º¸¿©Áö´Â ÆäÀÌÁö°¡ ¾Æ´Ñ..
// ÇÑÆäÀÌÁö¿¡ ÇÏ³ªÀÇ ÀÌ¹ÌÁö°¡ º¸¿©Áú¶§ onload ÀÌº¥Æ®¿¡ ÀÌ ÇÔ¼ö¸¦ È£Ãâ½ÃÄÑÁØ´Ù.
// ÀÎ¼ö´Â ÀÌ¹ÌÁöÀÇ nameÀÌ´Ù.
function resizeImage2(imgname)
{
  var width = eval('document.all.'+imgname+'.width');
  if( width > 500 )
  {
    eval('document.all.'+imgname+'.width = 500');
  }
}

function resizeImage_photogallery(imgname)
{
  var width = eval('document.all.'+imgname+'.width');
  if( width > 560 )
  {
    eval('document.all.'+imgname+'.width = 560');
  }
}

// ÆË¾÷À©µµ¿ì¸¦ È­¸éÁß¾Ó¿¡ ¶ç¿öÁÖ±â À§ÇÑ ¿É¼Ç½ºÆ®¸µÀ» ¸®ÅÏÇÑ´Ù.
// ÀÎ¼ö·Î ÆË¾÷À©µµ¿ìÀÇ width, height°ªÀ» ¹Þ´Â´Ù.
function center_position(widht_value, height_value) {

	var w = widht_value;
	var h = height_value;
		
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
		
	var winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars=no, toolbars=no'
	return winprops;
}
	function setImageSize(minWidth, image) {
		var newX;
		var newY;
		var newHeight;
		var newWidth;
		var maxWidth = minWidth;
		var maxHeight = minWidth;
		var newImg = new Image();

		newImg.src = image.src;
		imgw = newImg.width;
		imgh = newImg.height;

		if(imgw > maxWidth || imgh > maxHeight) {
			if(imgw > imgh) {
				if (imgw > maxWidth)
					newWidth = maxWidth;
				else
					newWidth = imgw;
				newHeight = Math.round((imgh * newWidth) / imgw);
			}
			else {
				if (imgh > maxHeight)
					newHeight = maxHeight;
				else
					newHeight = imgh;
				newWidth = Math.round((imgw * newHeight) / imgh);
			}
		}
		else {
			newWidth = imgw;
			newHeight = imgh;
		}

		newX = maxWidth / 2 - newWidth / 2;
		newY = maxHeight / 2 - newHeight / 2;

		image.onload = null;
		image.src = newImg.src;
		image.width = newWidth;
		image.height = newHeight;
	}	
	
	function DownLoad(bbsid,filename) {
	var url;
	url = "/portal/include/DownLoad.asp?bbsid=" + bbsid + "&filename="+filename;
	document.location.href = url;
	}	

///¼ýÀÚ¸¸ °¡´É
function ChkNum(Num){
	NumTF = false;
	for (var i=0; i<Num.length; i++){
		var wordForUse ="0123456789-";
		if(wordForUse.indexOf(Num.charAt(i)) == -1){
			NumTF = true;
		}
	}
	return NumTF;
}

///ÀÌ¸ÞÀÏ À¯È¿¼ºÃ¼Å©
function IsEmail(str) {
	var supported = 0;
	if (window.RegExp) {
		var tempStr = "a";
		var tempReg = new RegExp(tempStr);
		if (tempReg.test(tempStr)) supported = 1;
	}
	if (!supported) 
		return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
	var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
	var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
	return (!r1.test(str) && r2.test(str));
}

/*
function popview1(url){
   
   window.open("/main/imageZoom.jsp?url=" + url,"mainview","scrollbars=yes,width=100,height=100");
   //window.open("/main/imageZoom.jsp?url=" + url,"mainview","scrollbars=yes,width=100,height=100");
}
*/



// ¾Æ·¡ º¸¿ÏÇØ¾ßÇÔ.
// °ø¹éÁ¦°ÅÇÔ¼ö
function trim(str) {
	str = str.replace(/^\s*/, '').replace(/\s*$/, '');
	return str;
}



/*
ÀÚ¸´¼ö Á¦ÇÑ --> ¼öÁ¤ÇØ¾ßÇÔ..
function textCounter(field, maxlimit) { 

	if (field.value.length > maxlimit) // if too long...trim it!
	field.value = field.value.substring(0, maxlimit); 
	// otherwise, update 'characters left' counter 
	else 
	countfield.value = maxlimit - field.value.length; 

}
*/
	
function getCookie(name) { 
	var Found = false;
	var start, end;
	var i = 0;
	 
	while(i <= document.cookie.length) { 
		start = i ;
		end = start + name.length ;
		 
		if(document.cookie.substring(start, end) == name) { 
			Found = true ;
			break ;
		} 
		i++ ;
	} 
	 
	if(Found == true) { 
		start = end + 1 ;
		end = document.cookie.indexOf(";", start) ;
		if(end < start) 
			end = document.cookie.length ;
		return document.cookie.substring(start, end) ;
	} 
	return "" ;
}

function setCookie( name, value, expiredays ) 
{ 
	var todayDate = new Date(); 
	todayDate.setDate( todayDate.getDate() + expiredays ); 
	document.cookie = name + "=" + escape( value ) + "; path=/; expires=" + todayDate.toGMTString() + ";" 
} 

