//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 ENABLE OR DISABLE SUBMIT BUTTON BASED ON I AGREE OR NOT
function fDoAgree(FormName, FieldName, FieldValue){
	if(document.forms[FormName].elements[FieldName]){
		vRadio = document.forms[FormName].elements[FieldName];
		for(var i=0;i<vRadio.length;i++){
			if(vRadio[i].value == FieldValue){
				vRadio[i].checked = true;
			}
			else{
				vRadio[i].checked = false;
			}
		}
		
		if(FieldValue == "T"){
			document.forms[FormName].btnSubmit.disabled = false;
		}
		else{
			document.forms[FormName].btnSubmit.disabled = true;
		}
		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;
	}
}

//MACROMEDIA FUNCTIONS
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

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_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

//PROPERTY FUNCTIONS
function fKF(Formname){
	for(i=0;i<document.forms[Formname].length;i++){
		var elname = document.forms[Formname].elements[i].name;
		if(elname != 'R1' && elname != 'R2' && elname != 'R3' && elname != 'R4' && elname != 'R5'){
			if(document.forms[Formname].elements[i]){
				document.forms[Formname].elements[i].value='';
			}
		}
	}
}

function fKR5(Formname){
	if(document.forms[Formname].R5){
		document.forms[Formname].R5.value='';
	}
}

function fKR4(Formname){
	if(document.forms[Formname].R4){
		document.forms[Formname].R4.value='';
	}
	if(document.forms[Formname].R5){
		document.forms[Formname].R5.value='';
	}
}

function fKR3(Formname){
	if(document.forms[Formname].R3){
		document.forms[Formname].R3.value='';
	}
	if(document.forms[Formname].R4){
		document.forms[Formname].R4.value='';
	}
	if(document.forms[Formname].R5){
		document.forms[Formname].R5.value='';
	}
}

function fKR2(Formname){
	if(document.forms[Formname].R2){
		document.forms[Formname].R2.value='';
	}
	if(document.forms[Formname].R3){
		document.forms[Formname].R3.value='';
	}
	if(document.forms[Formname].R4){
		document.forms[Formname].R4.value='';
	}
	if(document.forms[Formname].R5){
		document.forms[Formname].R5.value='';
	}
}
