function duplicateValueCheck(arr) {
	var i = 0;
	var tmpA;
	var tmpB;

	for (i = 1; i < arr.length; i++) {
		for (j = 0; j < i ; j++) {
			tmpA = arr[i];
			tmpB = arr[j];

			if (tmpA == tmpB) {
				return false;
				break;
			}
		}
	}
	return true;
}
/**
* random number
* num = 10, result is 0,1,2,3,4,5,6,7,8,9
*/
function getNumOfRandom(num) {

	return Math.floor(Math.random()*num);
}
/**
* image swap
*/
function swapImg(obj, name)
{
	obj.src = name;
}
/**
* open window
*
*/
function openWin(url, winName, top, left, width, height, scrollbar)
{
	var top = (screen.availHeight-width)/2+top;
	var left = (screen.availWidth-width)/2+left;
	var newWin = window.open(url, winName, "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars="+ scrollbar +",resizable=no,copyhistory=no,top="+ top +",left="+ left +",width="+ width +",height="+ height);
	newWin.focus();
}

/**
* http://xavisys.com/using-prototype-javascript-to-get-the-value-of-a-radio-group/#comments
* Returns the value of the selected radio button in the radio group, null if
* none are selected, and false if the button group doesn't exist
*
* @param {radio Object} or {radio id} el
* OR
* @param {form Object} or {form id} el
* @param {radio group name} radioGroup
*/
function $RF(el, radioGroup) {
  if($(el).type && $(el).type.toLowerCase() == 'radio') {
    var radioGroup = $(el).name;
    var el = $(el).form;
  } else if ($(el).tagName.toLowerCase() != 'form') {
    return false;
  }

  var checked = $(el).getInputs('radio', radioGroup).find(
    function(re) {return re.checked;}
  );
  return (checked) ? $F(checked) : null;
}


function getFileExtension(filePath){		// ÆÄÀÏÀÇ È®ÀåÀÚ¸¦ °¡Á®¿Å
	var lastIndex	= -1;
	lastIndex	= filePath.lastIndexOf('.');
	var extension	= "";

	if(lastIndex != -1){
		extension = filePath.substring( lastIndex+1, filePath.len );
	}else{
		extension = "";
	}
  return extension;
}

function fnImg_Check(value){			// ÆÄÀÏ È®ÀåÀÚ Ã¼Å©ÇÏ±â.
	var src = getFileExtension(value);

	if(!((src.toLowerCase() == "gif") || (src.toLowerCase() == "jpg") || (src.toLowerCase() == "jpeg"))){
       alert('gif ¿Í jpg ÆÄÀÏ¸¸ Áö¿øÇÕ´Ï´Ù.');
       //document.all.thumbnail[0].value = "";
       returnValue = "";
  }
  LoadImg(value);
}

function LoadImg(value){
	var imgInfo = new Image();
	imgInfo.onload = img_Load;
	imgInfo.src = value;
}

function img_Load(){
	var imgWidth, imgHeight, imgFileSize;
	var maxFileSize = 5000;		// ÀÌ¹ÌÁö»çÀÌÁî Á¦ÇÑ(5MB)

	imgWidth		= this.width;
	imgHeight		= this.height;
	imgFileSize	= Math.round(this.fileSize/1024);

	if (imgFileSize > maxFileSize){
	  alert("µî·ÏÇÏ½Ç Ã·ºÎÆÄÀÏ ÀÌ¹ÌÁö°¡ ¿ë·®À» ÃÊ°úÇÏ¿´½À´Ï´Ù.");
	  return;
  }

  //ÀÌ¹ÌÁö »çÀÌÁî ÀúÀå
  //document.all.imgWidth.value		= imgWidth;
  //document.all.imgHeight.value	= imgHeight;

	//document.getElementById("IMG_SIZE_W").innerText		= imgWidth;
	//document.getElementById("IMG_SIZE_H").innerText		= imgHeight;
	//document.getElementById("IMG_SIZE").innerText		= imgFileSize;
}

//¾ÕµÚ °ø¹éÁ¦°Å.
String.prototype.trim = function(){
  return this.replace(/(^\s*)|(\s*$)/g, "");
}

//½ºÆ®¸µÀÌ °ø¹é¹®ÀÚ ÀÌ¿ÜÀÇ ¹®ÀÚ¸¦ Æ÷ÇÔÇÏ´ÂÁö¸¦ Ã¼Å© (NullÀÌ¸é True)
function IsNullString(string){
	for(var i=0; i<string.length; i++)
		if(string.charAt(i)!=' ' && string.charAt(i)!='\r' && string.charAt(i)!='\n'
			&& string.charAt(i)!='\t' && string.charAt(i)!='\b') return false;
  return true;
}

//ÆûÀÇ ÀÔ·Â°ªÀÇ ³ÎÀ» Ã¼Å©
function CheckNull(elementName,elementTitle){
	if(IsNullString(elementName.value))
	{
		alert("'" + elementTitle+"'¸¦(À») ÀÔ·ÂÇÏ¼¼¿ä!");
		elementName.value = "";
		elementName.focus();
		return false;
	}
	else return true;
}
