/* 
 * vim60: ts=4 syntax=javascript
 */

function OpenWin(uri, target, width, height, scrollbars, resize, pos)
{
	var xy_pos = "";
	if (pos)
	{
		xy_pos  = ",left=" + (Math.round(screen.width/2) - Math.round(width/2));
		xy_pos += ",top="  + (Math.round(screen.height/3) - Math.round(height/3));
	}
	var remote = window.open(uri, target, "width=" + width +
				",height=" + height +
				",scrollbars=" + scrollbars +
				",resizable=" + resize +
				xy_pos +
				",toolbar=no,location=no" +
				",directories=no,mebar=no");
	remote.focus();
	return remote;
}

function AlertWindow (form, title, message)
{
	// ÀÔ·Â ¿À·ù½Ã º¸¿©ÁÙ °æ°íÃ¢
	if (form != false)
	{
		form.focus();
	}
	// alert(title + " : " + message);	return;
	var new_message = "";
	for (var i = 0; i < message.length; i++)
	{
		// "\n" -> "<BR>"
		if (message.charAt(i) == "\n")
		{
			new_message = new_message + "<BR>";
		}
		else
		{
			new_message = new_message + message.charAt(i);
		}
	}
	//var alert_window = OpenWin("../conf/alert.php?" + "&title=" + title +
	var alert_window = alert(title  + new_message);
	//							"&message=" + new_message,
	//							"", 100, 100, "no", "yes", true);
}

function FirstFieldFocus (form)
{
	// ÇØ´ç ÀÔ·Â¾ç½ÄÀÇ Ã¹¹øÂ° TEXT Ç×¸ñ ¶Ç´Â PASSWORD Ç×¸ñ¿¡
	// ÀÚµ¿À¸·Î Æ÷Ä¿½º¸¦ ³Ö¾îÁÖ´Â ÇÔ¼ö
	if (typeof(form) == 'undefined') return;
	var count = form.elements.length;
	for (var i=0; i<count; i++)
	{
    	if (form.elements[i].type == "text" || form.elements[i].type == "password")
		{
			if (form.elements[i].value.length == 0) form.elements[i].focus();
			return;
		}
	}
}

function GetSelectedValue (select)
{
	// ÇöÀç ¼±ÅÃµÈ SELECT Ç×¸ñÀÇ ¼±ÅÃ°ªÀ» ¾ò´Â ÇÔ¼ö
	if (select == null) return null;
	return select.options[select.selectedIndex].value;
}

function SetSelected (select, mode, value)
{
	// SELECT Ç×¸ñÁß Æ¯Á¤ OPTION Ç×¸ñÀ» ±âº»ÀûÀ¸·Î ¼±ÅÃ(SELECTED)µÇµµ·Ï ÇÏ´Â ÇÔ¼ö
	if (select == null) return false;
	if (mode == "number")
	{
		select.selectedIndex = value;
		return true;
	}
	else
	{
		for (var i=0; i<select.options.length; i++)
		{
			if ((mode == "value" && select.options[i].value == value) ||
				 (mode == "text" && select.options[i].text == value))
			{
				select.selectedIndex = i;
				return true;
			}
		}
	}
	return false
}
function SetSelectedIndexByValue (select, value) { return SetSelected(select, "value", value); }
function SetSelectedIndexByText (select, value) { return SetSelected(select, "text", value); }
function SetSelectedIndexNumber (select, value) { return SetSelected(select, "number", value); }

function CheckboxCheck(form, mode)
{
	for (var i=0; i<form.elements.length; i++)
	{
		var e = form.elements[i];
		if (e.type == "checkbox")
		{
			if (mode == 1) e.checked = true;
			if (mode == 2) e.checked = false;
			if (mode == 3) e.checked = !e.checked;
		}
	}
}
function CheckboxAllCheck(form) { CheckboxCheck(form, 1); }
function CheckboxAllUnCheck(form) { CheckboxCheck(form, 2); }
function CheckboxReverseCheck(form) { CheckboxCheck(form, 3); }

// ###########################################################################
// ItsClient À©µµ¿ì °´Ã¼ È¹µæ
var ItsClientFrame = top["itsclient"];
