/****************************************************************************************************/
//ÀÏ¹ÝÇÔ¼ö
/****************************************************************************************************/
function popWindow(theURL,winName,Width,Height,Status,Scrollbars,Resizable,LeftPos,TopPos)
{
	var XP_MSIE = window.navigator.userAgent.indexOf('MSIE');

	if(!Scrollbars) Scrollbars = 0;
	if(!Status)     Status     = 0;
	if(!Resizable)  Resizable  = 0;

	Height = (!Status && XP_MSIE && window.navigator.userAgent.indexOf('SV1') > XP_MSIE) ? parseInt(Height)+29 : Height;
	WindowPOP = window.open(theURL, winName, "width=" + Width + ", height=" + Height + ", status=" + Status +", scrollbars=" + Scrollbars +", resizable=" + Resizable + ", left=" + LeftPos + ", top=" + TopPos);
}


/****************************************************************************************************/
//ÄíÅ°ÇÔ¼ö
/****************************************************************************************************/
function SetCookie( name, value, expiredays )
{
	var todayDate = new Date();
	todayDate.setDate( todayDate.getDate() + expiredays );
	document.cookie = name + "=" + escape( value ) + "; path=/; expires=" + todayDate.toGMTString() + ";"
}

function GetCookie( name )
{
	var nameOfCookie = name + "=";
	var x = 0;
	while ( x <= document.cookie.length )
	{
		var y = (x+nameOfCookie.length);
		if ( document.cookie.substring( x, y ) == nameOfCookie ) {
			if ( (endOfCookie=document.cookie.indexOf( ";", y )) == -1 )
				endOfCookie = document.cookie.length;
			return unescape( document.cookie.substring( y, endOfCookie ) );
		}
		x = document.cookie.indexOf( " ", x ) + 1;
		if ( x == 0 )
			break;
	}
	return "";
}


/****************************************************************************************************/
// ¸¶ÀÌ½ºÅ¸
/****************************************************************************************************/

function OpenMyStarTrans(Cafe_ID,Section,ListNo)
{
	var CheckMSIE = window.navigator.userAgent.indexOf('MSIE');
	var SetW = 1000;
	var SetH = (CheckMSIE && window.navigator.userAgent.indexOf('SV1') > CheckMSIE) ? 632 : 657;
	var PosX = (screen.width -SetW) / 2;
	var PosY = (screen.height - SetH) / 2;

	if(isNull(Cafe_ID)) return;
	if(isNull(Section)) Section = "";
	if(isNull(ListNo))  ListNo  = "";

	var theURL = "http://mymax.mnet.com/byeol/TransOpenMyStar.php?Trans_ID="+Cafe_ID+"&UshowHome="+Section+"&ShowListNo="+ListNo;
	popWindow(theURL, "StartMyStar", SetW, SetH, 0, 0, 0, PosX, PosY);
}


/****************************************************************************************************/
//À¯Æ¿ÇÔ¼ö
/****************************************************************************************************/

//³ÎÃ¼Å©
function isNull(str)
{
	return ((str == null || str == "" || str == "<undefined>" || str == "undefined") ? true:false);
}

// °ø¹é¹®ÀÚ¸¦ Á¦°ÅÇÏ´Â ÇÔ¼ö
function trim(str)
{
	return endEnc(firstEnc(str));
}

//¾ÕÀÚ¸®°ø¹éÁ¦°Å
function firstEnc(str)
{
	var len = str.length;
	var i = 0;

	for(i = 0; str.charAt(i) == ' '; i++);
	str = str.substring(i, len);

	return str;
}

//µÞÀÚ¸®°ø¹éÁ¦°Å
function endEnc(str)
{
	var i = 0;
	var len = str.length;

	for(i = (len - 1); (str.charAt(i) == ' '); i--);
	str = str.substring(0, i + 1);

	return str;
}

//URL Ã¼Å©
function Chk_Url(url)
{
	if((url.indexOf("http://") >= 0)||(url.indexOf(".") < 1)) return  false;
	return true;
}

//'",; ±ÝÁö
function Chk_Text(text)
{
	var chr,i;
	for(i=0;i<text.length;i++)
	{
		chr = text.substr(i,1);
		if((chr == '\'') || (chr == '\"') || (chr == '\,') || (chr == '\;')) return false;
	}

	return true;
}

//ÀÔ·Â¹®ÀÚ ±æÀÌ
function getByteLength(input)
{
	var byteLength = 0;
	for (var inx = 0; inx < input.value.length; inx++) {
		var oneChar = escape(input.value.charAt(inx));
		if ( oneChar.length == 1 ) {
			byteLength ++;
		} else if (oneChar.indexOf("%u") != -1) {
			byteLength += 2;
		} else if (oneChar.indexOf("%") != -1) {
			byteLength += oneChar.length/3;
		}
	}
	return byteLength;
}

// ÀÔ·ÂµÈ °ªÀÌ ¼ýÀÚÀÎÁö¸¦ È®ÀÎ
function isInteger(number) 
{
	if(number == "") {
		return false;
	}
	for(var i= 0; i < number.length; i++) 
	{
		if(!((number.charAt(i) >= "0" && number.charAt(i) <= "9") ? true:false))
		{
			return false; 
		}
	}
	return true;
}

// ·Ñ ¿À¹öÀÌ¹ÌÁö
function DoRollOverImg(argObj, argImg)
{
	argObj.src = argImg;
}

// ½ºÅ¸ÀÏ ¿À¹ö Àû¿ë
function DoStyleSetOver(argThis, argClass)
{
	if (document.all || document.getElementById)
	{
		argThis.classBackup = argThis.className;
		argThis.className   = argClass;
	}
}

// ½ºÅ¸ÀÏ ¾Æ¿ô Àû¿ë
function DoStyleSetOut(argThis)
{
	if (document.all || document.getElementById)
	{
		argThis.className = argThis.classBackup;
	}
}



