﻿function chk(sender, args) 
{
    if (document.getElementById('aspnetForm').jobcatelog.length <= 0) 
	{ 
		for(i=0;i<document.getElementById('aspnetForm').jobcatelog.length;i++)
		{
		    if (!document.getElementById('aspnetForm').jobcatelog.options[i].selected)
		        document.getElementById('aspnetForm').jobcatelog.options[i].selected = true;
		}
		args.IsValid = false; 
	}
	else
	{ 
		args.IsValid = true; 
	} 
} 

function SelectAll()
{

    for (i = 0; i < document.getElementById('aspnetForm').jobcatelog.length; i++)
        {
            if (!document.getElementById('aspnetForm').jobcatelog.options[i].selected)
                document.getElementById('aspnetForm').jobcatelog.options[i].selected = true;
       }

}

//添加工作崗位
//mbox資料源的母集物件
//fbox資料源物件
//tbox目標物件
function move(mbox,fbox,tbox) {

	if(typeof(fbox.options[fbox.selectedIndex])=="unknown"){
        alert("系統提示:請選擇您想要添加的資料項!");
        fbox.focus();
		return;
    }
	
	if(tbox.length==3){
		alert("最多只能選擇3個工作崗位");
		return;
	}
//-----------------------確定選中是否為大類
	var isMainCatelog=false;
	var s=fbox.options[fbox.selectedIndex].value;
	var ss=s.substr(2,3);
	if(ss=="000"){
		isMainCatelog=true;
	}
//==
	var no = new Option();
	no.value = fbox.options[fbox.selectedIndex].value;
	no.text = fbox.options[fbox.selectedIndex].text;
	if(isMainCatelog)
	{
		no.text=mbox.options[mbox.selectedIndex].text;
	}
	
	if(tbox.length!=0)
	{
		for (var j=0; j<tbox.options.length; j++)//檢查是否有重複選項
		{
			if((tbox.options[j].value==no.value) && (tbox.options[j].text==no.text)){
			alert("您已經選擇該選項了，不能重選！");
			return;
			}
		}
	}

	//tbox.add(new Option(no.text, no.value));
	no = new Option(no.text, no.value);
	if (isFirefox = navigator.userAgent.indexOf("Firefox") > 0) {
	    tbox.appendChild(no);
	}
	else if (navigator.userAgent.indexOf("MSIE") > 0) {
	    tbox.add(no);
	}
	else {
	    tbox.add(no);
	}
}
// End -->

//移除核取方塊中選中的選項函數
function multiSelect_removeitem(Object){
    //alert(Object);
    if(typeof(Object.options[Object.selectedIndex])=="unknown"){
        alert("系統提示:請選擇您想要移除的資料項!");
        Object.focus();
    }
	
    if(Object.selectedIndex>-1){
        Object.remove(Object.selectedIndex);
    }
}

