//CLEAR THE INFO IN THE STATUS BAR
function fNStat(){
	window.top.status='';
	return true;
}

//SET THE TEXT IN THE STATUS BAR
function fTStat(strtext) {
	window.top.status=strtext;
	return true;
}

//SET THE TEXT IN THE STATUS BAR TO DONE
function fDStat(){
	window.top.status="Done";
	return true;
}

//VERIFY FORM INFORMATION
function fCheckThisForm(FormName, FormTarget, FormAction, SubmitForm, DoForm, AlertText){
	for(i=0;i<document.forms[FormName].length;i++){
		var elname = document.forms[FormName].elements[i].name;
		var elsArray = elname.split("__");
		if(elsArray[0] == "R"){
			if(document.forms[FormName].elements[i].value == "" || document.forms[FormName].elements[i].value == "-"){
				alert(AlertText)
				document.forms[FormName].elements[i].focus();
				return false;
			}
		}
	}
	if(document.forms[FormName].vdo && DoForm != ""){
		document.forms[FormName].vdo.value=DoForm;
	}
	if(FormTarget != ""){
		document.forms[FormName].target=FormTarget;
	}
	if(FormAction != ""){
		document.forms[FormName].action=FormAction;
	}
	if(SubmitForm == 1){
		document.forms[FormName].submit();
	}
	return true;
}


//CONFIRMATION CHECK
function fConfirmThisForm(FormName, FormTarget, FormAction, SubmitForm, DoForm, ConfirmText){
	if(confirm(ConfirmText)){
		if(document.forms[FormName].vdo && DoForm != ""){
			document.forms[FormName].vdo.value=DoForm;
		}
		if(FormTarget != ""){
			document.forms[FormName].target=FormTarget;
		}
		if(FormAction != ""){
			document.forms[FormName].action=FormAction;
		}
		if(SubmitForm == 1){
			document.forms[FormName].submit();
		}
		return true;
	}
	else{
		return false;
	}	
}

//FUNCTION TO SELECT ALL CHECK BOXES
function fSelAll(FormName){
	for(i=0;i<document.forms[FormName].length;i++){
		el = document.forms[FormName].elements[i].name;
		val = document.forms[FormName].elements[i].value;
		partel = el.split("_");
		partel2 = el.split("[");
		if(partel[0] == 'cb'){
			document.getElementById(el).checked = true;
		}
		else if(partel2[0] == 'linkcb'){
			document.forms[FormName].elements[i].checked = true;
		}
	}
	if(document.forms[FormName].selall){
		document.forms[FormName].selall.value='1';
	}
	if(document.forms[FormName].selaop){
		document.forms[FormName].selaop.value='0';
	}
}

//FUNCTION TO SELECT ALL CHECK BOXES ON CURRENT PAGE
function fSelPage(FormName){
	for(i=0;i<document.forms[FormName].length;i++){
		el = document.forms[FormName].elements[i].name;
		val = document.forms[FormName].elements[i].value;
		partel = el.split("_");
		partel2 = el.split("[");
		if(partel[0] == 'cb'){
			document.getElementById(el).checked = true;
		}
		else if(partel2[0] == 'linkcb'){
			document.forms[FormName].elements[i].checked = true;
		}
	}
	if(document.forms[FormName].selaop){
		document.forms[FormName].selaop.value='1';
	}
	if(document.forms[FormName].selall){
		document.forms[FormName].selall.value='0';
	}
}

//FUNCTION TO DESELECT ALL CHECK BOXES
function fSelNone(FormName){
	for(i=0;i<document.forms[FormName].length;i++){
		el = document.forms[FormName].elements[i].name;
		val = document.forms[FormName].elements[i].value;
		partel = el.split("_");
		partel2 = el.split("[");
		if(partel[0] == 'cb'){
			document.getElementById(el).checked = false;
		}
		else if(partel2[0] == 'linkcb'){
			document.forms[FormName].elements[i].checked = false;
		}
	}
	if(document.forms[FormName].selaop){
		document.forms[FormName].selaop.value='0';
	}
	if(document.forms[FormName].selall){
		document.forms[FormName].selall.value='0';
	}
}

//MOVE DIRECTION SCRIPT FOR MULTI SELECT BOXES
function ClearList(OptionList, TitleName){
	OptionList.length = 0;
}
			
function movedirection(side,vel1,vel2){
	var temp1 = new Array();
	var temp2 = new Array();
	var tempa = new Array();
	var tempb = new Array();
	var current1 = 0;
	var current2 = 0;
	var y=0;
	var attribute;
				
	//assign what select attribute treat as attribute1 and attribute2
	if (side == "right"){
		attribute1 = document.getElementById(vel1);
		attribute2 = document.getElementById(vel2);
	}
	else{
		attribute1 = document.getElementById(vel2);
		attribute2 = document.getElementById(vel1);
	}
				
	//fill an array with old values
	for (var i = 0; i < attribute2.length; i++){
		y=current1++
		temp1[y] = attribute2.options[i].value;
		tempa[y] = attribute2.options[i].text;
	}
			
	//assign new values to arrays
	for (var i = 0; i < attribute1.length; i++){
		if ( attribute1.options[i].selected ){
			y=current1++
			temp1[y] = attribute1.options[i].value;
			tempa[y] = attribute1.options[i].text;
		}
		else{
			y=current2++
			temp2[y] = attribute1.options[i].value; 
			tempb[y] = attribute1.options[i].text;
		}
	}
				
	//generating new options 
	for (var i = 0; i < temp1.length; i++){
		attribute2.options[i] = new Option();
		attribute2.options[i].value = temp1[i];
		attribute2.options[i].text =  tempa[i];
		attribute2.options[i].selected = true;
	}
				
	//generating new options
	ClearList(attribute1,attribute1);
	if (temp2.length>0){
		for (var i = 0; i < temp2.length; i++){
			attribute1.options[i] = new Option();
			attribute1.options[i].value = temp2[i];
			attribute1.options[i].text =  tempb[i];
		}
	}
}

function fConfirmLister(Fn){
	var FNele = document.getElementById(Fn);
	var ConfirmFNbtn = document.getElementById('Confirm__'+Fn);
	var ClearFNbtn = document.getElementById('Confirm__'+Fn);
	if(FNele){
		if(FNele.length > 0){
			for(var i=0;i<FNele.length;i++){
				FNele.options[i].selected = true;
			}
		}
		else{
			FNele.options.length = 0;
		}
	}
	if(ConfirmFNbtn){
		ConfirmFNbtn.disabled = true;
	}
}

function fClearLister(Fn){
	var FNele = document.getElementById(Fn);
	var ConfirmFNbtn = document.getElementById('Confirm__'+Fn);
	var ClearFNbtn = document.getElementById('Clear__'+Fn);
	if(FNele){
		for(var i=0;i<FNele.length;i++){
			movedirection('left',Fn+'__Lister',Fn);
		}
		ClearList(FNele,FNele);
		
		FNele.options[0] = new Option();
		FNele.options[0].value = '';
		FNele.options[0].text =  '';
		FNele.options[0].selected = true;
	}
	if(ConfirmFNbtn){
		ConfirmFNbtn.disabled = false;
	}
}	