function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
	d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
	if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
	obj.visibility=v; }
}
//-->

function OpenWin(file_, width_, height_)
{
	var win_width = width_;
	var win_height = height_;
	var left = "50";
	var top = "50";
	var file = file_;
    var win_name = "popup";
	var win_opt = "toolbar=no,width=" + win_width + ",height=" + win_height + ",left=" + left + ",top=" + top + ",status=no,scrollbars=no,resizable=no";
	window.open(file, win_name, win_opt);
}

function MoveMenu(html)
{
	parent.location.href = html + ".html";
}

function ToggleOpt(strObj, strImgObj)
{
	var objMenu = document.getElementById(strObj);

	if( objMenu.style.display == "inline" )
	{
		objMenu.style.display = "none";
	}
	else
	{
		objMenu.style.display = "inline";
	}
}

function GetAllSelectedValue_InSelectBox(strOpt)
{
	var strBuf = "";
	var targetTag = document.getElementById(strOpt);

	for( var i=0; i< targetTag.length; i++ ) {
		if(targetTag.options[i].selected){
			strBuf += targetTag.options[i].value + ",";
		}
	}

	if(strBuf != "") {
		strBuf = strBuf.substring(0, parseInt(strBuf.length-1));
	}

	return strBuf;
}

function GetAllSelectedText_InSelectBox(strOpt)
{
	var strBuf = "";
	var targetTag = document.getElementById(strOpt);

	for( var i=0; i< targetTag.length; i++ ) {
		if(targetTag.options[i].selected){
			strBuf += targetTag.options[i].text + ",";
		}
	}
	if(strBuf != "") {
		strBuf = strBuf.substring(0, parseInt(strBuf.length-1));
	}

	return strBuf;
}


function RemoveSelectedItem_InSelectBox(strOpt)
{
	var targetTag = document.getElementById(strOpt);
	var bSelected = false;
	for( var i=0; i< targetTag.length; i++ ) {
		if(targetTag.options[i].selected){
			targetTag.options[i] = null;
			i--;
			bSelected = true;
		}
	}
	return bSelected;
}

function GetValue_InSelectBox(strOpt,cDel)
{
	var strBuf='';
	var targetTag = document.getElementById(strOpt);

	if(cDel == null || cDel == "") cDel = ",";

	for( var i=0; i< targetTag.length; i++ ) {
		strBuf += targetTag.options[i].value + cDel;
	}

	if(strBuf != "") {
		strBuf = strBuf.substring(0, parseInt(strBuf.length-1));
	}

	return strBuf;
}

function GetSelectedText_InSelectBox(strOpt)
{
	var targetTag = document.getElementById(strOpt);

	for( var i=0; i< targetTag.length; i++ ) {
		if(targetTag.options[i].selected){
			return targetTag.options[i].text;
		}
	}
	return '';
}

function AddItem_InSelectBox(strOpt, strValue, strText)
{
	var targetTag = null;

	if(typeof(strOpt) == "object") {
		targetTag = $(strOpt).options;
	} else if(typeof(strOpt) == "string") {
		targetTag = document.getElementsByName(strOpt)[0].options;
	} else {
		return;
	}

	var newOption = document.createElement("option");
	newOption.text = strText;
	newOption.value = strValue;
	targetTag.add(newOption);

	return newOption;
}

function GetSelectedValue_InSelectBox(strOpt)
{
	var strBuf = "";
	var targetTag = document.getElementById(strOpt);

	for( var i=0; i< targetTag.length; i++ ) {
		if(targetTag.options[i].selected){
			return targetTag.options[i].value;
		}
	}

	return strBuf;
}

function RemoveAllItem_InSelectBox(strOpt)
{
	var targetTag = document.getElementById(strOpt);

	for( var i=0; i< targetTag.length; i++ ) {
		targetTag.options[i] = null;
		i--;
	}
}
