function chkDateTime1(valueSearch){
	var tmpval="";
	with(document.cscform){
		var valueSearch1=valueSearch.split("-");
		if(valueSearch1.length==3){
			if(valueSearch1[1].length==1){
				valueSearch1[1]="0"+valueSearch1[1];
			}
			if(valueSearch1[0].length==1){
				valueSearch1[0]="0"+valueSearch1[0];
			}
			valueSearch1[2]=parseInt(valueSearch1[2]);
			return valueSearch=valueSearch1[2]+"-"+valueSearch1[1]+"-"+valueSearch1[0];
		}
	}
}

function addOption(objOption,objList) {
	//alert(">>>>>"+objOption+":"+objList);
   	addToOption(objOption,objList) ;     
} // End of addOption()

function addToOption(objOption,destList) { 	
	//alert(objOption+":"+destList);
  	var lengthAll = parseInt(objOption.length)+parseInt(destList.options.length);
	newDestList = new Array(lengthAll);
	var clen=0;
	for(len=0; len<destList.options.length; len++) {
		if (destList.options[len] != null) {
			newDestList[ len ] = new Option( destList.options[ len ].text, destList.options[ len ].value, destList.options[ len ].defaultSelected, destList.options[ len ].selected );
			clen++;
		}
	}

	for ( var j = 0 ; j < objOption.length; j++ ) {
		if ( objOption[ j ] != null ) {
			newDestList[ clen ] = objOption[ j ];
			clen++;
		}
	}

	//newDestList.sort( compareOptionValues ); 
	for( var i = destList.options.length - 1; i >= 0; i-- )  { 
		if ( destList.options[i] != null  ) {
			destList.options[i]  = null;
		}
	}
		  
	for ( var j = 0; j < newDestList.length; j++ )  {
		if ( newDestList[ j ] != null ) {
			destList.options[ j ] =new Option(newDestList[ j ].text,newDestList[ j ].value);
		}
	}
} // End of addToOption()

function findKey(objOption,myList){
	//alert("in findKey:>"+objOption+":"+myList);
	for ( var j = 0 ; j < objOption.length; j++ ) {
		for(var i=0;i < myList.length;i++){
			if(objOption[j].value == myList.options[i].value){
				alert(myList.options[i].value+" "+MyCode[83]);
				return true;
			}//if
		}//for					
	}	//for
	return false;
}

function goHelp(helpName,inputName,listName){
	var helpReturn;
	var key;
	var tdesc="tdesc",edesc="edesc";
	
	if (listName=='') {
		helpReturn = inputName+":employeeid"
		linkHelp_Return(helpName,helpReturn,"");
	} else {	
		if (inputName=="bu1" ) {
			helpReturn="bu1";
			key="bu1id";
		} else if (inputName=="bu2" ) {
			helpReturn="bu2";
			key="bu2id";
		} else if (inputName=="bu3" ) {
			helpReturn="bu3";
			key="bu3id";
		} else if (inputName=="bu4" ) {
			helpReturn="bu4";
			key="bu4id";
		} else if (inputName=="bu5" ) {
			helpReturn="bu5";
			key="bu5id";
		} else if (inputName=="branch" ) {
			helpReturn="branch";
			key="branchid";
		} else if (inputName=="position" ) {
			helpReturn="position";
			key="positionid";
		} else if (inputName=="salatype" ) {
			helpReturn="salatype";
			key="codeid";
			} else if (inputName=="workarea" ) {
			helpReturn="workarea";
			key="workareaid";
			} else if (inputName=="emp_level" ) {
			helpReturn="emp_level";
			key="levelid";
		} else if (inputName=="employee" ) {
			helpReturn="employeeid";
			key="employeeid";
			tdesc="fullname";
			edesc="";
		}
		with(document.cscform){
			if (__fixCon.value!="") 
				__fixCon.value=__fixCon.value;
			var param="PRU086.jsp?__helpName="+helpName+"&__helpReturn="+helpReturn
			+"&__pageCall="+__screen.value+"&__fixCon="+__fixCon.value+"&__checkVerify=off"		
			+"&__listName="+listName+"&__key="+key+"&__edesc="+edesc+"&__tdesc="+tdesc;
			window.open(param,"Help","left=150,top=150,width=600,height=400,toolbar=no,status=yes,scrollbars=yes,resizable=yes");
		}
	}	 
}

function listDblClick(objmyList){
	for(i=objmyList.length;i > 0;i--){
		if(objmyList.options[i-1].selected==true){
			bCon=confirm(MyCode[84]+" "+objmyList.options[i-1].text+" ?");
			if (bCon==true){			
				objmyList.options[i-1]  = null;
			}
		}
	}
}

function setCondition(){
	var obj_bu1List=document.cscform.bu1List;	
    for(i=obj_bu1List.length;i >0;i--){
		document.cscform.__condition$bu1Select.value+=obj_bu1List.options[i-1].value+",";			
	}
	var obj_bu2List=document.cscform.bu2List;	
    for(i=obj_bu2List.length;i >0;i--){
		document.cscform.__condition$bu2Select.value+=obj_bu2List.options[i-1].value+",";
	}
	var obj_bu3List=document.cscform.bu3List;	
    for(i=obj_bu3List.length;i >0;i--){
		document.cscform.__condition$bu3Select.value+=obj_bu3List.options[i-1].value+",";
	}
	var obj_bu4List=document.cscform.bu4List;	
    for(i=obj_bu4List.length;i >0;i--){
		document.cscform.__condition$bu4Select.value+=obj_bu4List.options[i-1].value+",";
	}
	var obj_bu5List=document.cscform.bu5List;	
    for(i=obj_bu5List.length;i >0;i--){
		document.cscform.__condition$bu5Select.value+=obj_bu5List.options[i-1].value+",";
	}
	var obj_employeeList=document.cscform.employeeList;	
    for(i=obj_employeeList.length;i >0;i--){
		document.cscform.__condition$employeeSelect.value+=obj_employeeList.options[i-1].value+",";
	}
	var obj_positionList=document.cscform.positionList;	
    for(i=obj_positionList.length;i >0;i--){
		document.cscform.__condition$positionSelect.value+=obj_positionList.options[i-1].value+",";
	}
	var obj_branchList=document.cscform.branchList;	
    for(i=obj_branchList.length;i >0;i--){
		document.cscform.__condition$branchSelect.value+=obj_branchList.options[i-1].value+",";
	}
	var obj_salatypeList=document.cscform.salatypeList;	
    for(i=obj_salatypeList.length;i >0;i--){
		document.cscform.__condition$salatypeSelect.value+=obj_salatypeList.options[i-1].value+",";
	}
	var obj_workareaList=document.cscform.workareaList;	
    for(i=obj_workareaList.length;i >0;i--){
		document.cscform.__condition$workareaSelect.value+=obj_workareaList.options[i-1].value+",";
	}
	var obj_emp_levelList=document.cscform.emp_levelList;	
    for(i=obj_emp_levelList.length;i >0;i--){
		document.cscform.__condition$emp_levelSelect.value+=obj_emp_levelList.options[i-1].value+",";
	}
	
	with(document.cscform){
		for(i=0;i<elements.length;i++){
			if(elements[i].type=="checkbox"){
				if (elements[i].checked){
					elements[i].value="1";
				} else elements[i].value="0";
		   	}
		}
	}
	
	if (document.cscform.__condition$startDate.value.length>0) {
		var sData = chkDateTime1(document.cscform.__condition$startDate.value);
		document.cscform.__condition$startDate.value = sData;
	}
		
	if (document.cscform.__condition$endDate.value.length>0) {
		var eData = chkDateTime1(document.cscform.__condition$endDate.value);
		document.cscform.__condition$endDate.value = eData;
	}
			
	//check (empStart-empEnd)+employeeSelect
	if ((document.cscform.empStart.value.length>0)&&(document.cscform.empEnd.value.length>0)){
		document.cscform.__condition$employeeBetween.value = "(employeeid between '"+document.cscform.empStart.value+"' and '"+document.cscform.empEnd.value+"')";
	} else if ((document.cscform.empStart.value.length>0)&&(document.cscform.empEnd.value.length==0)){
		document.cscform.__condition$employeeBetween.value = "(employeeid between '"+document.cscform.empStart.value+"' and '"+document.cscform.empStart.value+"')";
	} else if ((document.cscform.empStart.value.length==0)&&(document.cscform.empEnd.value.length>0)){
		document.cscform.__condition$employeeBetween.value = "(employeeid between '"+document.cscform.empEnd.value+"' and '"+document.cscform.empEnd.value+"')";
	}
	
	
}

function clearCondition(){
	with(document.cscform){
		__condition$employeeSelect.value="";
		__condition$positionSelect.value="";
		__condition$bu1Select.value="";
		__condition$bu2Select.value="";
		__condition$bu3Select.value="";
		__condition$bu4Select.value="";
		__condition$bu5Select.value="";
		__condition$branchSelect.value="";
		__condition$salatypeSelect.value="";
		__condition$workareaSelect.value="";
		__condition$emp_levelSelect.value="";
		__condition$cmdValue.value="";
	}
}