// ÀÌ¹ÌÁö ¸®»çÀÌÁî ÇÔ¼ö
function image_resize(obj,img_width,img_height)
{
	if(obj.width>img_width)
	{
		obj.style.width=img_width;
	}

	if(obj.height>img_height)
	{
		obj.style.height=img_height;
	}
}

function image_over(obj,over_img,dir)
{
	obj.src="/admin/upload/"+dir+"/"+over_img;
}

// ¼ýÀÚ¸¸ µî·Ï
function checkNum()
{
	if(event.keyCode <48 || event.keyCode >57)
	{
		 event.keyCode = null;
	}
}

// Æ¯¼ö¹®ÀÚ ¹æÁö
function special_key()
{
	if((event.keyCode >= 33 && event.keyCode <= 47) || (event.keyCode >= 58 && event.keyCode <= 64) || (event.keyCode >= 91 && event.keyCode <= 96) || (event.keyCode >= 123 && event.keyCode <= 126) )
	{
		event.keyCode = null;
	}	// if( (event.keyCode >= 33 && event.keyCode <= 47) || (event.keyCode >= 58 && event.keyCode <= 64) || (event.keyCode >= 91 && event.keyCode <= 96) || (event.keyCode >= 123 && event.keyCode <= 126) )
}


// »õÃ¢¶ç¿ì±â
function win_open(url,width,height,TopPos,LeftPos) {
	window.open(url,'','width='+width+',height='+height+',fullscreen=no,menubar=no,status=yes,toolbar=no,titlebar=no,location=no,scrollbars=no,top=' + TopPos + ',left=' + LeftPos);
}

// ½ºÅ©·Ñ¹Ù ÀÖ´Â »õÃ¢¶ç¿ì±â
function win_open2(url,width,height) {
	window.open(url,'','width='+width+',height='+height+',fullscreen=no,menubar=no,status=no,toolbar=no,titlebar=no,location=no,scrollbars=yes');
}

function new_window(Url,Wsize,Hsize,WinName,isScroll) {
	window.open(Url,WinName,'width=' + Wsize + ',height=' + Hsize + ',fullscreen=no,menubar=no,status=no,toolbar=no,titlebar=no,location=no,scrollbars=' + isScroll);
}


// ÀÌº¥Æ®ÇÚµé·¯ ÀÌ¹ÌÁö ±³Ã¼
function change_image(obj,imgUrl)
{
	obj.src = imgUrl;
}

function change_bgcolor(obj,color)
{
	obj.style.backgroundColor = color;
}

// ±×·¡ÇÁ ¿òÁ÷ÀÌ´Â ÇÔ¼ö
function UpGraph(objId,graphNum,limit,speed)
{
	var obj = document.all(objId);
	var numObj = document.all(graphNum);
	var objWidth = obj.width - 1;
	numObj.value =  Math.floor(objWidth/speed);
	obj.width = eval(objWidth) + eval(speed);
	timer = setTimeout("UpGraph('"+objId+"','"+graphNum+"',"+limit+","+speed+")",15);
	limit = limit - 1;
	if(objWidth > limit)
	{
		clearTimeout(timer);
	}	// if(objWidth > limit)

}

// 3ÀÚ¸®¸¶´Ù ÄÞ¸¶ Âï±â
function number_format(Num)
{
	var reg = /(^[+-]?\d+)(\d{3})/;   // Á¤±Ô½Ä
	Num += '';                          // ¼ýÀÚ¸¦ ¹®ÀÚ¿­·Î º¯È¯

	while (reg.test(Num))
	{
		Num = Num.replace(reg, '$1' + ',' + '$2');
	}	// while (reg.test(Num))]
	
	return Num;
}


// png24 Åõ¸íÃ³¸®
function setPng24(obj) {
	obj.width=obj.height=1;
	obj.className=obj.className.replace(/\bpng24\b/i,'');
	obj.style.filter =
	"progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+ obj.src +"',sizingMethod='image');"
	obj.src='';
	return '';
}



// ¾ç ¿·Ä­¿¡ ºóÄ­ ¾ø¾Ö±â
String.prototype.trim = function ()
{
    return this.replace(/^ *| *$/g, "");
}

// ÄíÅ° »ðÀÔ
function setCookie(name, value, expiredays)
{
    var todayDate = new Date();
    todayDate.setDate( todayDate.getDate() + expiredays );
    document.cookie = name + "=" + escape( value ) + "; path=/; expires=" + todayDate.toGMTString() + ";"
}


function change_input_border(obj,border_color)
{
	obj.style.border = "2px solid " + border_color;
}


String.prototype.toInteger = function() {
 return this.replace(/[^0-9]/g, '') * 1;
}

function follow_banner(div_id, origin_top, limit_top, margin_top) {
	var d, t, s, g, target_height;
	origin_top *= 1;
	limit_top *= 1;
	margin_top *= 1;

	d = document.getElementById(div_id);
	s = document.documentElement.scrollTop + "";

	target_height = (s * 1) + (margin_top * 1);

	if(target_height < limit_top) {
		target_height = origin_top;
	}
 
	t = d.style.top.split("px");
	t = t[0];
	
	if(t != target_height) {
		g = Math.ceil((t - target_height) / 5);
		if(g > 1000) {
			g = 50;
		}
		else if (g < -50) {
			g = -50;
		}
		d.style.top = (t - g) + "px";
	}
	
	setTimeout("follow_banner('" + div_id + "', " + origin_top + ", " + limit_top + ", " + margin_top + ");", 20);
}

function add_flash(WidthSize,HeightSize,SwfSrc,Title) {
	var flash_tag = "";
	flash_tag ='<embed src="'+SwfSrc+'" type="application/x-shockwave-flash"  WIDTH="'+WidthSize+'" HEIGHT="'+HeightSize+'" wmode="transparent" scale="exactfit"></embed>'
	document.write(flash_tag);
}

function swapImage(Obj,OriUrl,ImgUrl) {
	Obj.src = ImgUrl;

	Obj.onmouseout = function() {
		Obj.src = OriUrl;
	}
}

var Browser = {
	a : navigator.userAgent.toLowerCase()
}


function bookmarksite(title,url) { 
	if (window.sidebar) {
		window.sidebar.addPanel(title, url, ""); 
	}

	else if(window.opera && window.print) {
		var elem = document.createElement('a'); 
		elem.setAttribute('href',url); 
		elem.setAttribute('title',title); 
		elem.setAttribute('rel','sidebar'); 
		elem.click(); 
	} 

	else if(document.all) {
		window.external.AddFavorite(url, title);
	}


}

function logout() {
	location.href = "/login/logout.php";
}

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

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

function checkBlank(o,m){
	if (typeof o=='undefined') return true;
	if (o.value.trim() == '') {
		window.alert(m+' ÀÔ·ÂÇÏ¼¼¿ä');
		try { o.focus(); } catch (ex) { }
		return false;
	}
	return true;
}

