/*** prototpe ***/
String.prototype.trim = function()
{
	return this.replace(/(^\s*)|(\s*$)/g, '');
}

String.prototype.isNumeric = function() {
	var result = true;
	if(this.length > 0) {
		for(var i = 0; i < this.length; i++) {
			if(isNaN(this.substr(i, 1))) {
				result = false;
				break;
			}
		}
	} else {
		result = false;
	}
	return result;
}

Array.prototype.indexOf = function(arg) {
	var result = -1;
	for(var i = 0; i < this.length; i++) {
		if(this[i] == arg) {
			result = i;
			break;
		}
	}
	return result;
}

Array.prototype.contains = function(arg) {
	return this.indexOf(arg) >= 0 ? true : false;
}


/*** Windows onload ÀÌº¥Æ® ÇÚµé·¯ ÀÏ°ý Ã³¸® ***/
/*var eventHandlers = [];
window.onload = function() {
	if(eventHandlers.length > 0) {
		for(var i = 0; i < eventHandlers.length; i++) {
			eventHandlers[i]();
		}
	}
}*/

/*** Modal window ***/
var naverSearchOn = false;
var oWinRef = null;
window.onunload = function() {
	if(oWinRef != null) {
		oWinRef.close();
		oWinRef = null;
	}
}

/*** Open a window and move it to the center ***/

// Å« ÀÌ¹ÌÁö º¸±â
function viewPic(code, file) {
	var url = "/board/viewimage.php?code="+code+"&file="+file;
	window.open(url, "pic", "width=800,height=600,scrollbars=yes");
}
function popupWindow(url, id, width, height) {
	var params = "top=" + getPopupPosition(height, "h") + ",left=" + getPopupPosition(width, "w") + ",width=" + width + ",height=" + height + ",toolbar=0,menubar=0,status=0"
	oWinRef = window.open(url, id, params);
}

function getPopupPosition(size, arg) {
	return (arg == "w") ? ((window.screen.width / 2) - (size / 2)) : ((window.screen.height / 2) - (size / 2));
}

function setBackground(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 '';  
}

function viewOnAir(href, gubun, height) {
	var params = "top=0, left=0, width=349, height=";
	params += height + ", toolbar=no, directories=no, scrollbars=no, status=no, resize=no, menubar=no";
	window.open(href,gubun,params)
}

function loadSiteMap(url) {
	popupWindow(url, "sitemap", 828, 562)
}

function getInternetExplorerVersion()
// Returns the version of Internet Explorer or a -1
// (indicating the use of another browser).
{
  var rv = -1; // Return value assumes failure.
  if (navigator.appName == 'Microsoft Internet Explorer')
  {
    var ua = navigator.userAgent;
    var re  = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
    if (re.exec(ua) != null)
      rv = parseFloat( RegExp.$1 );
  }
  return rv;
}

function getCrossBrowserPosition(obj) {
	var ver  = getInternetExplorerVersion();
	var left = parseInt(obj.style.left);
	if(ver == -1) {
		left -= 55;
	} else if(ver == 6) {
		//left -= 65;
		left += 5;
	} else if(ver == 7) {
		left = left + 0;
	}
	return left;	
}


function loadMovie(url) {
	window.open("http://www.knn.co.kr/news/pop_health.asp", "movie", "left=0,top=0,width=662,height=580,scrollbars=no");
	document.location.href = url;
}

