

   function RemoveAllOptions(box)
   {
               
                box.options.length=0;

    }//<====  end function  =====>
	


function ToggleAllSelected(list)
{
	for (i=0; i<(list.options.length +1); i++){

		if (list.options[i] != null){
			if (list.options[i].value != 0){
				list.options[i].selected = true;
			}
		}
	}
}  //<====  end function  =====>


function IsAnyContentsInListBox(field,sMessage)
 {
	if (field.options.length < 1 )
	{
		alert("Required: " + sMessage);field.focus();
		return false;
	}
		return true;
}//<====  end function  =====>


function HowManyItemsInListBox(field)
 {
	return field.options.length;
 }//<====  end function  =====>


function GetListBoxFieldValue(field)
 {
    field = xGetElementById(field);
	return  field.options[field.selectedIndex].value;  

}//<====  end function  =====>


function GetListBoxFieldText(field)
 {
    field = xGetElementById(field);
	return  field.options[field.selectedIndex].text ;  

}//<====  end function  =====>


function ShowListBoxContents2Div(list,div)
 {

 var displayval = '';
 var count;
    
      for (count=0; count < parseInt(list.length) ; count++)
      {
          if (list.options[count].selected == true) 
			{
               if (displayval == '')
					displayval = list.options[count].text;
				else 
					displayval = displayval + ', ' + list.options[count].text;
	        }
      }

    if (displayval != '')
		div.innerText =  displayval;
}


function IsThereAnythingInMultipleListBox(list,sMsg)
 {
 var count;
    
      for (count=0; count < parseInt(list.length) ; count++)
      {
          if (list.options[count].selected == true) 
			{
               return true;
	        }
      }

    alert(sMsg);
    list.focus();
    return false;
}


function HowManyItemsSelected(list)
 {
 var count;
 var cnt;
 cnt=0;
      for (count=0; count < parseInt(list.length) ; count++)
      {
          if (list.options[count].selected == true) 
			{
               cnt++;
	        }
      }
	  return cnt;
}


function GetListBoxContents4ADiv(list)
 {

 var displayval = '';
    
      for (count=0; count < parseInt(list.length) ; count++)
      {
          if (list.options[count].selected == true) 
			{
               if(list.options[count].value==0){displayval='ALL';return displayval;}
               
               if (displayval == '')
					displayval = list.options[count].text;
				else 
					displayval = displayval + ', ' + list.options[count].text;
	        }
      }

 return displayval;
}


function buildXMLfromList(sName,list)
{
var sXML = '';

	for (i=0; i<(list.options.length +1); i++){
		if (list.options[i] != null){
			if (list.options[i].value != 0 && list.options[i].selected == true){
				sXML+=buildXMLSElement(sName,list.options[i].value);
			}
		}
	}
	return sXML;
}  //<====  end function  =====>


function buildSTRfromList(sDel,list, isValue)
{
var sXML = '';

	for (i=0; i<(list.options.length +1); i++)
	{
		if (list.options[i] != null)
		{
			if (list.options[i].selected == true)
			{
				if (sXML == '')
				    if(isValue == 'v')
					    sXML = list.options[i].value;
					else
					     sXML = list.options[i].text;    
				else 
				    if(isValue == 'v')
					    sXML = sXML + sDel + list.options[i].value;
					else
					    sXML = sXML + sDel + list.options[i].text;    
			}
		}
	}
	return sXML;
}  //<====  end function  =====>



function IsListBoxFieldEnteredNoFocus(field,sMessage)
 {
	var inputStr = field.options[field.selectedIndex].value  
	if (inputStr.length < 1 || inputStr == 0)
	{
		errorList.addItem("Required: " + sMessage);
		return false;
	}
		return true;
}//<====  end function  =====>


function IsListBoxFieldEntered(field,sMessage)
 {
	if (field.selectedIndex == -1)
	{
		alert("Required: " + sMessage);field.focus();
		return false;
	}
	
	
	var inputStr = field.options[field.selectedIndex].value  
	if (inputStr.length < 1 || inputStr == 0)
	{
		alert("Required: " + sMessage);field.focus();
		return false;
	}
		return true;
}//<====  end function  =====>


function IsListBoxFieldSelected(box)
 {
	if (box.selectedIndex == -1)
	{
    	return false;
	}
	
	var inputStr = box.options[box.selectedIndex].value  
	if (inputStr.length < 1 || inputStr == 0)
	{
		return false;
	}
		return true;
}//<====  end function  =====>


function SelectFirstOption(box)
 {
	if (box.selectedIndex == -1)
	{
    	box.selectedIndex = 0;
	}
	else
	{
	    UnSelectAll(box);
	    box.selectedIndex = 0;
	}
	
}//<====  end function  =====>


function UnSelectAll(list)
 {
 var count;
 
      for (count=0; count < parseInt(list.length) ; count++)
      {
          if (list.options[count].selected == true) 
			{
               list.options[count].selected == false;
	        }
      }
}//<====  end function  =====>


function UnSelectAllExcept(list,value)
 {
 var count;
 
      for (count=0; count < parseInt(list.length) ; count++)
      {
          if (list.options[count].selected == true && list.options[count].value != value) 
			{
               list.options[count].selected == false;
	        }
      }
}//<====  end function  =====>


function UnSelectValue(list,value)
 {
 var count;
 
      for (count=0; count < parseInt(list.length) ; count++)
      {
          if (list.options[count].selected == true && list.options[count].value == value) 
			{
               list.options[count].selected == false;
	        }
      }
}//<====  end function  =====>


function SelectValue(list,value)
 {
 var count;
 
      for (count=0; count < parseInt(list.length) ; count++)
      {
            if (list.options[count].value == value) 
			{
               list.options[count].selected == true;
               list.selectedIndex = count;
               break;
	        }
      }
}//<====  end function  =====>


function Bind(box,sValue)
 {
           RemoveAllOptions(box); 
            //Get all rows, split using 30 char since this was used as delimit for
            //the results
            var rowArray = sValue.split(String.fromCharCode(30))
            //foreach row
            for(var currentRow=0;currentRow<rowArray.length;currentRow++)
            {
                //split each column for each row, use Char(20)
                var colArray= rowArray[currentRow].split(String.fromCharCode(20))
                box.options[currentRow] =new Option(colArray[1],colArray[0]); 
            }   
            
            SelectFirstOption(box); 
}//<====  end function  =====>



function HaveThisValueInText(list,value)
 {
 var haveit = false;
 
      for (count=0; count < parseInt(list.length) ; count++)
      {
           if (list.options[count].text == value) 
			{
               haveit = true;
                break;
	        }
      }
      
  return haveit;    
}//<====  end function  =====>


function HaveThisValueInValue(list,value)
 {
 var haveit = false;
 
      for (count=0; count <= parseInt(list.length) ; count++)
      {
            if (list.options[count].value == value) 
			{
               haveit = true;
                break;
	        }
      }
  return haveit;    
}//<====  end function  =====>




function GetFromSplit(strToSplit, position)
{
  
         var rowArray = strToSplit.split('|');
         return rowArray[position - 1];
   
}//func


function GetFromTabbedSplit(strToSplit, position)
{
  
         var rowArray = strToSplit.split(String.fromCharCode(20));
         return rowArray[position - 1];
   
}//func


function GetFromRowSplit(strToSplit, position)
{
  
         var rowArray = strToSplit.split(String.fromCharCode(30));
         return rowArray[position - 1];
   
}//func


function HowManyBineableRows(sValue)
 {
   var rowArray = sValue.split(String.fromCharCode(30))
      
   return rowArray.length;
}//<====  end function  =====>


function xDef()
{
  for(var i=0; i<arguments.length; ++i){if(typeof(arguments[i])=='undefined') return false;}
  return true;
}


function xGetElementById(e)
{
  if(typeof(e)!='string') return e;
  if(document.getElementById) e=document.getElementById(e);
  else if(document.all) e=document.all[e];
  else e=null;
  return e;
}


function xVisibility(e, bShow)
{
  if(!(e=xGetElementById(e))) return null;
  if(e.style && xDef(e.style.visibility)) {
    if (xDef(bShow)) e.style.visibility = bShow ? 'visible' : 'hidden';
    return e.style.visibility;
  }
  return null;
}


function xVisibilityStyle(e, bShow)
{
  if(!(e=xGetElementById(e))) return null;
  if(e.style) 
    {
        if (!bShow) 
            e.style.display = 'none';
        else
            e.style.display = 'block';
    }
  return null;
}


function xGetElementsByTagName(t,p)
{
  var list = null;
  t = t || '*';
  p = p || document;
  if (xIE4 || xIE5) {
    if (t == '*') list = p.all;
    else list = p.all.tags(t);
  }
  else if (p.getElementsByTagName) list = p.getElementsByTagName(t);
  return list || new Array();
}


function xHide(e){return xVisibility(e,0);}


function xInnerHtml(e,h)
{
  if(!(e=xGetElementById(e)) || !xStr(e.innerHTML)) return null;
  var s = e.innerHTML;
  if (xStr(h)) {e.innerHTML = h;}
  return s;
}


function xCreateElement(sTag)
{
  if (document.createElement) return document.createElement(sTag);
  else return null;
}


function formatNum(expr,decplaces) {
	var str = (Math.round(parseFloat(expr) * Math.pow(10,decplaces))).toString()
	while (str.length <= decplaces) {
		str = "0" + str
	} 
	var decpoint = str.length - decplaces
	return str.substring(0,decpoint) + "." + str.substring(decpoint,str.length)
} //<====  end function  =====>



function IsFieldEntered(field,sMessage) {
	var inputStr = field.value
if (inputStr.length <1){
alert("Required: " + sMessage);field.focus();
		return false;
}
	return true;
} //<====  end function  =====>


function IsFieldEnteredNoFocus(field,sMessage) {
	var inputStr = field.value
if (inputStr.length <1){
errorList.addItem("Required: " + sMessage);
		return false;
}
	return true;
}//<====  end function  =====>


function IsFieldEnteredBasic(field) {
	var inputStr = field.value
if (inputStr.length <1)
	return false;
else
    return true;
}//<====  end function  =====>


function trimstring(instring){
a = instring.value
var outstring;
var startpos;
var endpos;
var ch;
//where do we start?
startpos = 0;
ch = instring.value.charAt(startpos);
while ((ch == " ") || (ch =="\b") ||  (ch =="\f") || (ch =="\n") ||  (ch == "\r") ||(ch == "\n") ){
    startpos++;
ch = instring.value.charAt(startpos);
}
// where do we end?
endpos = instring.value.length - 1;
ch = instring.value.charAt(endpos);
while ((ch == " ") || (ch =="\b") ||  (ch =="\f") || (ch =="\n") ||  (ch == "\r") ||(ch == "\n") ){
endpos--;
ch = instring.value.charAt(endpos);
}
//get the string
outstring = instring.value.substring(startpos, endpos + 1);
return outstring;
}//<====  end function  =====>


var xOp7Up,xOp6Dn,xIE4Up,xIE4,xIE5,xNN4,xUA=navigator.userAgent.toLowerCase();
if(window.opera){
  var i=xUA.indexOf('opera');
  if(i!=-1){
    var v=parseInt(xUA.charAt(i+6));
    xOp7Up=v>=7;
    xOp6Dn=v<7;
  }
}
else if(navigator.vendor!='KDE' && document.all && xUA.indexOf('msie')!=-1){
  xIE4Up=parseFloat(navigator.appVersion)>=4;
  xIE4=xUA.indexOf('msie 4')!=-1;
  xIE5=xUA.indexOf('msie 5')!=-1;
}
else if(document.layers){xNN4=true;}
xMac=xUA.indexOf('mac')!=-1;