//////////////////////////////////////////////////////////////////////////////////

/* ÀüÃ¼¿¡ »ç¿ëÇÏ´Â °ø¿ë À¯Æ¿ºÎºÐÀ» Á¤ÀÇÇÔ
   ¾Õ¿¡ suffix ·Î UTIL_ ¸¦ »ç¿ëÇÏ°í  prefix ´Â ´ë¼Ò¹®ÀÚ·Î Ç¥½ÃÇÑ´Ù.
*/

//////////////////////////////////////////////////////////////////////////////////

// UTIL_posY(nHeight)
// UTIL_posX(nWidth)


//////////////////////////////////////////////////////////////////////////////////

/* nHeight ³ôÀÌ¸¦ °¡Áø °´Ã¼ÀÇ À§Ä¡¸¦ ¸¶¿ì½º Å¬¸¯ À§Ä¡¸¦ ±âÁØÀ¸·Î
   È­¸é ¾È¿¡ À§Ä¡°¡ µÇµµ·Ï º¸Á¤ÇÏ¿© Y ÁÂÇ¥°ªÀ» ¸®ÅÏ
   nHeight	: °´Ã¼³ôÀÌ
   nBodyHeight	: 
*/

function UTIL_posY(nHeight)
{
	var nBodyHeight	= document.body.clientHeight;
	var nScrollTop	= document.body.scrollTop
	var nPosition	= (nScrollTop + nBodyHeight) - nHeight;
	if (nPosition > nScrollTop+event.clientY) {
		nPosition = nScrollTop+event.clientY;
	}
	return nPosition;
}

//////////////////////////////////////////////////////////////////////////////////

function UTIL_posX(nWidth)
{
	var nBodyWidth	= document.body.clientWidth;
	var nPosition	= nBodyWidth - nWidth;
	if (nPosition > event.clientX) {
		nPosition = event.clientX;
	}
	return nPosition;
}

//////////////////////////////////////////////////////////////////////////////

function UTIL_centX(nw) {
	var nx = (screen.availWidth-nw)/2;
	return nx;
}

//////////////////////////////////////////////////////////////////////////////////

function UTIL_centY(nh) {
	var ny = (screen.availHeight-nh)/2;
	return ny;
}

//////////////////////////////////////////////////////////////////////////////////

function UTIL_validSel(cobj) {
	var str = cobj.options[cobj.selectedIndex].value;
	if (str == "" || str == null) return false;

	return true;
}

//////////////////////////////////////////////////////////////////////////////////

function UTIL_openPhoto(url) {

	win1 = window.open("","","width=450,height=450,toolbar=no,menubar=no,scrollbars=yes");
	win1.document.open();
	win1.document.writeln("<html><head>");
	win1.document.writeln("<title>½ºÆ¿ÄÆ</title>");
	win1.document.writeln("<script language=JavaScript>\n");
	win1.document.writeln("<!--\n");
	win1.document.writeln("function winFit(){\n");
	win1.document.writeln("var w = document.img1.width+30;\n");
	win1.document.writeln("var h = document.img1.height+40;\n");
	win1.document.writeln("window.resizeTo(w,h+19);\n");
	win1.document.writeln("}\n");
	win1.document.writeln("// -->\n");
	win1.document.writeln("</script>\n");
	win1.document.writeln("</head>");
	win1.document.writeln("<body topmargin=0 leftmargin=0 rightmargin=0 onload=winFit()>");
	win1.document.writeln("<a href=javascript:window.close()>");
	win1.document.writeln("<img name=img1 src='"+url+"' border=0 alt=\"CLOSE\"></a>");
	win1.document.writeln("</body>");
	win1.document.writeln("</html>");
	win1.document.close();

	return false;
}

//////////////////////////////////////////////////////////////////////////////////

function UTIL_openPopup(nw,nh) {
	var opt,args = UTIL_openPopup.arguments;
	opt = "width="+nw+",height="+nh+",scrollbars=auto,resizable=yes"+
		( (args.length>2)?",left="+args[2]:"")+
		( (args.length>3)?"top="+args[3]:"");
	return window.open("about:blank","",opt);
}

//////////////////////////////////////////////////////////////////////////////////

function UTIL_openPopup2(nw,nh) {
	var opt,args = UTIL_openPopup2.arguments;
	opt = "width="+nw+",height="+nh+",scrollbars=yes,resizable=yes"+
		( (args.length>2)?",left="+args[2]:"")+
		( (args.length>3)?"top="+args[3]:"");
	return window.open("about:blank","",opt);
}

//////////////////////////////////////////////////////////////////////////////////

function UTIL_radioValue(fld) {
	var cobj = document.getElementsByName(fld);
	for (var i=0; i<cobj.length; i++) {
		if (cobj[i].checked) return cobj[i].value;
	}
	return "";
}

//////////////////////////////////////////////////////////////////////////////////

function UTIL_checkboxValue(fld) {
	var temp = 0;
	var cobj = document.getElementsByName(fld);
	for (var i=0; i<cobj.length; i++) {
		if (cobj[i].checked) temp += Number(cobj[i].value);
	}
	return temp;
}

//////////////////////////////////////////////////////////////////////////////////

function UTIL_openVod(intIdx) {
	var objWin = window.open("about:blank","","width=400,height=450,scrollbars=auto,resizable=yes");
	objWin.location.href="/player/vod.asp?idx="+intIdx;
	return false;
}

//////////////////////////////////////////////////////////////////////////////////

function UTIL_openSingo(idx) {
	var objWin = window.open("about:blank","_open_singo","width=700,height=350,scrollbars=auto,resizable=yes");
	objWin.location.href="/popup_singo.asp?tp=today&idx="+idx;
	return false;
}

//////////////////////////////////////////////////////////////////////////////////

function UTIL_checkform(theForm,fld,s)
{
	var str = eval("theForm."+fld+".value");
	if (!s || s == "") return true;
	for(var i=0; i<s.length; i++) {
		if (str.indexOf( s.substring(i, i+1)) >= 0) {
			alert("»ç¿ëÇÒ ¼ö ¾ø´Â ¹®ÀÚ°¡ ÀÖÀ¾´Ï´Ù.["+s.substring(i, i+1)+"]");
			return false;
		}
	}
	return true;
}

//////////////////////////////////////////////////////////////////////////////////

function UTIL_checkform2(theForm,fld,s)
{
	var str = eval("theForm."+fld+".value");
	if (!s || s == "") return true;
	for(var i=0; i<s.length; i++) {
		if (str.indexOf( s.substring(i, i+1)) >= 0) {
			alert("Invalid character ["+s.substring(i, i+1)+"]");
			return false;
		}
	}
	return true;
}

//////////////////////////////////////////////////////////////////////////////////

