//----utils.js-
//Standard Site JS Functions
//-------------------------------------------------
//Global Variables
var thisapppath = "http://shpsrv01/devebusinessmanager/";


//****************************************************************
//* Function Name: openWindow
//*
//* Description: This function accepts parameters and open
//*              open pop up windown 
//* Parameters : - strUrlIn       : the URL to open the asp page
//*              - strWinNameIn   : name of the pop up	 
//*              - strWinAttribute: pop up attributes
//* 
//*	Example	:	onclick="OpenWindow('test.asp','LargeView','width=1,height=1,top=5,left=5,resizable,scrollbars=no,menubar=0'); return false;"
//*				
//****************************************************************
var varChildWindow=null;
function OpenWindow(strUrlIn, strWinNameIn, strWinAttributeIn, formName){
  var openWindow      = null;
  var strUrl          = strUrlIn;
  var strWinName      = strWinNameIn;
  var strWinAttribute = strWinAttributeIn;
  openWindow = window.open(strUrl, strWinName, strWinAttribute);
  varChildWindow = openWindow;
  if (formName != null)
    {
    varFormName = formName;
    }
  return true;
}

//****************************************************************
//* Function Name: ResizeToFit
//*
//* Description: Will Resize a Open Window based on a image height and width
//*			Place the example in the bottom of the page so it will load with the page			
//* Parameters : - w       : the width to add based on the image size
//*		 - h	   : the height to add based on the image size
//*		 - elname : the element name to use a the basis for a resize
//*              
//*	Example	: ResizeToFit(90,50,'imgLarge');
//*						
//****************************************************************
function ResizeToFit(w,h,elname)
{
	var imgWidth
	var imgHeight
	var setWidth  = w;
	var setHeight = h;
	var setElName  = elname;
	
		
	imgWidth = document[setElName].width + setWidth
	imgHeight = document[setElName].height + setHeight
	
	window.resizeTo(imgWidth, imgHeight)
}
//****************************************************************
//* Function Name: getLayer
//*
//* Description: Function Description 
//* Parameters : - name       : info
//*              
//*	Example	:	
//*				
//****************************************************************
function getLayer(name) {
	if (is.ns4)
		return findLayer(name, document);
	if (is.ie && !is.dom)
		return eval('document.all.' + name);
	if (is.dom)
		return document.getElementById(name);
	return null;
}

//****************************************************************
//* Function Name: findLayer
//*
//* Description: Function Description 
//* Parameters : - name       : info
//*              
//*	Example	:	
//*				
//****************************************************************
function findLayer(name, doc) {
	var i, layer;

	for (i = 0; i < doc.layers.length; i++) {
		layer = doc.layers[i];
		if (layer.name == name)
			return layer;
		if (layer.document.layers.length > 0)
			if ((layer = findLayer(name, layer.document)) != null)
				return layer;
	}
	return null;
}

//****************************************************************
//* Function Name: hideLayer
//*
//* Description: Function Description 
//* Parameters : - layer       : Info
//*              
//*	Example	:	
//*				
//****************************************************************
function hideLayer(layer) {
	if (is.ns4){
		layer.visibility = "hide"
	}else{
		layer.style.visibility = "hidden"
	};
}

//****************************************************************
//* Function Name: showLayer
//*
//* Description: Function Description 
//* Parameters : - layer       : Info
//*              
//*	Example	:	
//*				
//****************************************************************
function showLayer(layer) {
	if (is.ns4){
		layer.visibility = "show"
	}else{
		layer.style.visibility = "visible"
	};
}

//****************************************************************
//* Function Name: getVisibility
//*
//* Description: Function Description 
//* Parameters : - layer       : Info
//*              
//*	Example	:	
//*				
//****************************************************************
function getVisibility(layer) {

	if (is.ns4) {
		if (layer.visibility == "show")
			return "visible";
		if (layer.visibility == "hide")
			return "hidden";
		return layer.visibility;
	}else{
		return layer.style.visibility
	};
	return "";
}

//****************************************************************
//* Function Name: moveLayerTo
//*
//* Description: Function Description 
//* Parameters : - layer       	: Info
//*		 - x	       	: Info
//*		 - y	     	: Info	 
//*              
//*	Example	:	
//*				
//****************************************************************
function moveLayerTo(layer, x, y) {
	if (is.ns4){
		layer.moveTo(x, y);
	}else{
		layer.style.left = x;
		layer.style.top  = y
	};
}

//****************************************************************
//* Function Name: getImage
//*
//* Description: Function Description 
//* Parameters : - name       	: Info
//*              
//*	Example	:	
//*				
//****************************************************************
function getImage(name) {
	if (is.ns4){
		return findImage(name, document)
	};
	if (is.ie && !is.dom){
		return eval('document.all.' + name)
	};
	if (is.dom){
		return document.getElementById(name);
	}
	return null;
}

//****************************************************************
//* Function Name: findImage
//*
//* Description: Function Description 
//* Parameters : - name       	: Info
//*		 - doc		: Info
//*              
//*	Example	:	
//*				
//****************************************************************
function findImage(name, doc) {
	var i, img;

	for (i = 0; i < doc.images.length; i++)
		if (doc.images[i].name == name)
			return doc.images[i];
	for (i = 0; i < doc.layers.length; i++)
		if ((img = findImage(name, doc.layers[i].document)) != null) {
			img.container = doc.layers[i];
			return img;
		}
	return null;
}


//****************************************************************
//* Function Name: getImagePageLeft
//*
//* Description: Function Description 
//* Parameters : - img       	: Info
//*              
//*	Example	:	
//*				
//****************************************************************
function getImagePageLeft(img) {
	var x, obj;

	if (is.ns4) {
		if (img.container != null)
			return img.container.pageX + img.x;
		else
			return img.x;
	}else{
		x = 0;
		obj = img;
		while (obj.offsetParent != null) {
			x += obj.offsetLeft;
			obj = obj.offsetParent;
		}
		x += obj.offsetLeft;
		return x;
	};
	return -1;
}

//****************************************************************
//* Function Name: getImagePageTop
//*
//* Description: Function Description 
//* Parameters : - img       	: Info
//*              
//*	Example	:	
//*				
//****************************************************************
function getImagePageTop(img) {
	var y, obj;
	if (is.ns4) {
		if (img.container != null)
			return img.container.pageY + img.y;
		else
			return img.y;
	}else{
		y = 0;
		obj = img;
		while (obj.offsetParent != null) {
			y += obj.offsetTop;
			obj = obj.offsetParent;
		}
		y += obj.offsetTop;
		return y;
	};
	return -1;
}


//****************************************************************
//* Function Name: fnClearFormField
//*
//* Description: Function Description 
//* Parameters : - i       	: Info
//*              
//*	Example	:	
//*				
//****************************************************************
var EmptyFormField = 0; 
function fnClearFormField(i) {
	if (EmptyFormField == 0) {
		i.value = ""
	}
	EmptyFormField = 1;
}

//****************************************************************
//* Function Name: f_bg
//*
//* Description: Function Description 
//* Parameters : - e       	: Info
//*		 _ n		: Info
//*              
//*	Example	:	
//*				
//****************************************************************
function f_bg (e, n){
	if (is.ie) f_bg1(eval(e), n);
}

//****************************************************************
//* Function Name: f_bg1
//*
//* Description: Function Description 
//* Parameters : - e       	: Info
//*		 _ n		: Info
//*              
//*	Example	:	
//*				
//****************************************************************
function f_bg1 (e, n){
	switch (n){
		case 'white': {
			e.style.backgroundColor = 'white';
			e.style.borderTop = '1px solid #999999';
			e.style.borderBottom = '1px solid #999999';
			e.backgroundColor = 'white';
			e.borderTop = '1px solid #999999';
			e.borderBottom = '1px solid #999999';
			break;
		}
		case '#F0F0F0': {
			e.style.backgroundColor = '#F0F0F0';
			e.style.borderTop = '1px solid #F0F0F0';
			e.style.borderBottom = '1px solid #F0F0F0';
			e.backgroundColor = '#F0F0F0';
			e.borderTop = '1px solid #F0F0F0';
			e.borderBottom = '1px solid #F0F0F0';
			break;
		}
		case 'over': {
			e.style.backgroundColor = '#DCDCDC';
			e.style.borderTop = '1px solid #999999';
			e.style.borderBottom = '1px solid #999999';
			e.backgroundColor = '#DCDCDC';
			e.borderTop = '1px solid #999999';
			e.borderBottom = '1px solid #999999';
			break;
		}
	}
}



//--------------------------------------------------------------
//Build Tree Node VB Functions are need for these functions
//Find the reference vb files in incCommon.asp
//--------------------------------------------------------------
//****************************************************************
//* Function Name: ToggleDisplay
//*
//* Description: Function Description 
//* Parameters : - oButton       	: Info
//*		 _ oItems		: Info
//*		 _ oItemBgCg		: Info
//*              
//*	Example	:	
//*				
//****************************************************************

function ToggleDisplay(oButton, oItems, oItemBgCg) {

	if ((oItems.style.display == "") || (oItems.style.display == "none")) {
		oItems.style.display = "block";
		oButton.src = thisapppath + "graphics/btn_minus.gif";
		oItemBgCg.style.background = "#EFEFDE";
		oItemBgCg.style.bordercolor = "black";

		
	}else{
		oItems.style.display = "none";
		oButton.src = thisapppath + "graphics/btn_plus.gif";
		oItemBgCg.style.background = "white";
		oItemBgCg.style.bordercolor = "blue";
	}

	return false;

}

//****************************************************************
//* Function Name: HideDisplay
//*
//* Description: Function Description 
//* Parameters : - oButton       	: Info
//*              
//*	Example	:	
//*				
//****************************************************************
function HideDisplay(oItems) {

	oItems.style.display = "none";

}


//****************************************************************
//* Function Name: ShowDisplay
//*
//* Description: Function Description 
//* Parameters : - oButton       	: Info
//*              
//*	Example	:	
//*				
//****************************************************************
function ShowDisplay(oItems) {

	oItems.style.display = "block";

}


//****************************************************************
//* Function Name: findInPage
//*
//* Description: Function Description 
//* Parameters : - str       	: Info
//*              
//*	Example	:	
//*				
//****************************************************************
var NS4 = (document.layers);
var IE4 = (document.all);

var win = this;
var n   = 0;

function findInPage(str) {
 var thewindow = window;
 var txt, i, found;
 if (str == "")
  return false;
 if (NS4) {
  if (!thewindow.find(str))
   while(thewindow.find(str, false, true))
    n++;
  else
   n++;
  if (n == 0) alert(str + " was not found on this page.");
  }
 if (IE4) {
  txt = thewindow.document.body.createTextRange();
  for (i = 0; i <= n && (found = txt.findText(str)) != false; i++) {
   txt.moveStart("character", 1);
   txt.moveEnd("textedit");
   }
  if (found) {
   txt.moveStart("character", -1);
   txt.findText(str);
   txt.select();
   txt.scrollIntoView();
   n++;
   }
  else {
   if (n > 0) {
    n = 0;
    findInPage(str);
    }
   else
    alert(str + " was not found.");
   }
  } return false;
}

//****************************************************************
//* Function Name: buttonClickHandler
//*
//* Description: Function Description 
//* Parameters : - e       	: Info
//*              
//*	Example	:	
//*				
//****************************************************************
function buttonClickHandler (e) {
  if (!this.disabled)
    this.oldOnClick (e);
}

//****************************************************************
//* Function Name: disableButton
//*
//* Description: Function Description 
//* Parameters : - b       	: Info
//*              
//*	Example	:	
//*				
//****************************************************************
function disableButton (b) {
  b.oldOnClick = b.onclick;
  b.disabled = true;
  b.onclick = buttonClickHandler;
}
//****************************************************************
//* Function Name: enableButton
//*
//* Description: Function Description 
//* Parameters : - b       	: Info
//*              
//*	Example	:	
//*				
//****************************************************************
function enableButton (b) {
  b.disabled = false;
}

//****************************************************************
//* Function Name: showtr
//*
//* Description: Function Description 
//* Parameters : - target       	: Info
//*              
//*	Example	: Will Show and hide table arrays in PM
//*				
//****************************************************************
function toggle(target)
  {
     obj=(document.all) ? document.all[target] : document.getElementById(target);
     obj.style.display=(obj.style.display=='none') ? 'inline' : 'none';
  }
  
//****************************************************************
//* Function Name: moveSelected
//*
//* Description: Function Description 
//* Parameters : - select       	: Info
//*		 - down
//*              
//*	Example	: Will Show and hide table arrays in PM
//*				
//****************************************************************
function moveSelected (select, down) {
  if (select.selectedIndex != -1) {
    if (down) {
      if (select.selectedIndex != select.options.length - 1)
        var i = select.selectedIndex + 1;
      else
        return;
    }
    else {
      if (select.selectedIndex != 0)
        var i = select.selectedIndex - 1;
      else
        return;
    }
    var swapOption = new Object();
    swapOption.text = select.options[select.selectedIndex].text;
    swapOption.value = select.options[select.selectedIndex].value;
    swapOption.selected = select.options[select.selectedIndex].selected;
    swapOption.defaultSelected = select.options[select.selectedIndex].defaultSelected;
    for (var property in swapOption)
      select.options[select.selectedIndex][property] = select.options[i][property];
    for (var property in swapOption)
      select.options[i][property] = swapOption[property];
  }
}

//****************************************************************
//* Function Name: MoveElements
//*
//* Description: Function Description 
//* Parameters : - FromCombo       	: Info
//*		 - ToCombo
//*              
//*	Example	: Will move data from one combo to another
//*				
//****************************************************************
function MoveElements(FromCombo,ToCombo)
{
bFlag="True";
var to_remove_counter=0; 
for (var i=0;i<FromCombo.options.length;i++)
{
	if (FromCombo.options[i].selected==true)
	{
		var addtext=FromCombo.options[i].text;
		var addvalue=FromCombo.options[i].value;
		ToCombo.options[ToCombo.options.length]=new Option(addtext,addvalue);
		FromCombo.options[i].selected=false;
		++to_remove_counter;
	}
	else
	{
		FromCombo.options[i-to_remove_counter].selected=false;
		FromCombo.options[i-to_remove_counter].text=FromCombo.options[i].text;
		FromCombo.options[i-to_remove_counter].value=FromCombo.options[i].value;
	}
}

	//now cleanup the last remaining options 
	var numToLeave=FromCombo.options.length-to_remove_counter;
	for (i=FromCombo.options.length-1;i>=numToLeave;i--) 
	{ 
		FromCombo.options[i]=null;
	}
}
//****************************************************************
//* Function Name: trimLead
//*
//* Description: Function Description 
//* Parameters : - obj       	: Info
//*		 - 
//*              
//*	Example	: trims all leading spaces
//*				
//****************************************************************

function trimLead(obj){
while(''+obj.value.charAt(0)==' ')
obj.value=obj.value.substring(1,obj.value.length);
}
//****************************************************************
//* Function Name: trimTrail
//*
//* Description: Function Description 
//* Parameters : - obj       	: Info
//*		 - 
//*              
//*	Example	: trims all trailing spaces
//*				
//****************************************************************

function trimTrail(obj){
while(''+obj.value.charAt(obj.value.length-1)==' ')
obj.value=obj.value.substring(0,obj.value.length-1);
}
//****************************************************************
//* Function Name: trimLeadTrail
//*
//* Description: Function Description 
//* Parameters : - obj       	: Info
//*		 - 
//*              
//*	Example	: trims both leading and trailing spaces
//*				
//****************************************************************
//
function trimLeadTrail(obj){
trimLead(obj);
trimTrail(obj);
}

//****************************************************************
//* Function Name: compareText
//*
//* Description: Function Description 
//* Parameters : - option1       	: Info
//*		 - option2
//*              
//*	Example	: 
//*				
//****************************************************************
function compareText (option1, option2) {
  return option1.text < option2.text ? -1 :
    option1.text > option2.text ? 1 : 0;
}
//****************************************************************
//* Function Name: compareValue
//*
//* Description: Function Description 
//* Parameters : - option1       	: Info
//*		 - option2
//*              
//*	Example	: 
//*				
//****************************************************************
function compareValue (option1, option2) {
  return option1.value < option2.value ? -1 :
    option1.value > option2.value ? 1 : 0;
}
//****************************************************************
//* Function Name: compareTextAsFloat
//*
//* Description: Function Description 
//* Parameters : - option1       	: Info
//*		 - option2
//*              
//*	Example	: 
//*
//****************************************************************				
function compareTextAsFloat (option1, option2) {
  var value1 = parseFloat(option1.text);
  var value2 = parseFloat(option2.text);
  return value1 < value2 ? -1 :
    value1 > value2 ? 1 : 0;
}
//****************************************************************
//* Function Name: compareValueAsFloat
//*
//* Description: Function Description 
//* Parameters : - option1       	: Info
//*		 - option2
//*              
//*	Example	: 
//*
//****************************************************************
function compareValueAsFloat (option1, option2) {
  var value1 = parseFloat(option1.value);
  var value2 = parseFloat(option2.value);
  return value1 < value2 ? -1 :
    value1 > value2 ? 1 : 0;
}
//****************************************************************
//* Function Name: sortSelect
//*
//* Description: Function Description 
//* Parameters : - select       	: Info
//*		 - compareFunction
//*              
//*	Example	: 
//*
//****************************************************************
function sortSelect (select, compareFunction) {
  if (!compareFunction)
    compareFunction = compareText;
  var options = new Array (select.options.length);
  for (var i = 0; i < options.length; i++)
    options[i] = 
      new Option (
        select.options[i].text,
        select.options[i].value,
        select.options[i].defaultSelected,
        select.options[i].selected
      );
  options.sort(compareFunction);
  select.options.length = 0;
  for (var i = 0; i < options.length; i++)
    select.options[i] = options[i];
}

//****************************************************************
//* Function Name: getSelectedValues
//*
//* Description: You simply loop through the options array and collect the selected 
//*		 options values or texts or indices. The following provides three 
//*		 functions doing that and an example form with two example select elements:
//* 
//* Parameters : - select       	: Info
//*		 - 
//*              
//*	Example	: 
/*		<FORM NAME="formName">
			<SELECT NAME="select1" MULTIPLE>
			<OPTION VALUE="15">Larry Dyke</option>
			<OPTION VALUE="16">Larry Dyke</option>
			<OPTION VALUE="17">Larry Dyke</option>
			</SELECT>
		<BR>

		<INPUT TYPE="button" VALUE="show selected values" ONCLICK="this.form.output.value = getSelectedValues(this.form.select1);">
		<INPUT TYPE="text" NAME="output" SIZE="80">
		</form>
*/
//*
//****************************************************************
function getSelectedValues (select) {
  var r = new Array();
  for (var i = 0; i < select.options.length; i++)
    if (select.options[i].selected)
      r[r.length] = select.options[i].value;
  return r;
}
//****************************************************************
//* Function Name: getSelectedTexts
//*
//* Description: You simply loop through the options array and collect the selected 
//*		 options values or texts or indices. The following provides three 
//*		 functions doing that and an example form with two example select elements: 
//*
//* Parameters : - select       	: Info
//*		 - replacedel		: Can replace a string
//*              - replacewithstr	: replace with what
//*	Example	: 
/*		<FORM NAME="formName">
			<SELECT NAME="select1" MULTIPLE>
			<OPTION VALUE="15">Larry Dyke</option>
			<OPTION VALUE="16">Larry Dyke</option>
			<OPTION VALUE="17">Larry Dyke</option>
			</SELECT>
		<BR>

		<INPUT TYPE="button" VALUE="show selected values" ONCLICK="this.form.output.value = getSelectedTexts(this.form.select1);">
		<INPUT TYPE="text" NAME="output" SIZE="80">
		</form>
*/
//* 
//*
//****************************************************************
function getSelectedTexts (select,replacestr,replacewithstr) {
  var r = new Array();
  for (var i = 0; i < select.options.length; i++)
    if (select.options[i].selected)
      if (!replacestr) {
      	r[r.length] = select.options[i].text;
      }else{
      	var s = select.options[i].text;
      	var m = replacestr;
      	var l = replacewithstr;
      	r[r.length] = s.replace(m, l)
      }
  return r;
}
//****************************************************************
//* Function Name: getSelectedIndices
//*
//* Description: You simply loop through the options array and collect the selected 
//*		 options values or texts or indices. The following provides three 
//*		 functions doing that and an example form with two example select elements: 
//* 
//* Parameters : - select       	: Info
//*		
//*              
//*	Example	: 
/*		<FORM NAME="formName">
			<SELECT NAME="select1" MULTIPLE>
			<OPTION VALUE="15">Larry Dyke</option>
			<OPTION VALUE="16">Larry Dyke</option>
			<OPTION VALUE="17">Larry Dyke</option>
			</SELECT>
		<BR>

		<INPUT TYPE="button" VALUE="show selected values" ONCLICK="this.form.output.value = getSelectedIndices(this.form.select1);">
		<INPUT TYPE="text" NAME="output" SIZE="80"> This is to hold the container for the select list
		</form>
*/
//* 
//*
//****************************************************************
function getSelectedIndices (select) {
  var r = new Array();
  for (var i = 0; i < select.options.length; i++)
    if (select.options[i].selected)
      r[r.length] = i;
  return r;
}

function MultiSelectHighlight(select){
	var loopiter=select.length-1;
	for(var i=0;i<=loopiter;i++)
	{
	select.options[i].selected=true;
	}
}

//****************************************************************
//* Function Name: MultiSelectHighlight
//*
//* Description: Will select all the options form a select list
//*		 
//* Parameters : - select       	: Info
//*		
//*	Example	:	MultiSelectHighlight(this.form.selsubjects);
//****************************************************************
function MultiSelectHighlight(select){
	var loopiter=select.length-1;
	for(var i=0;i<=loopiter;i++)
	{
	select.options[i].selected=true;
	}
}


//--------------------------------------------------------------
//Added on 3/17/2003
//--------------------------------------------------------------

//****************************************************************
//* Function Name: GetScreenWidth()
//*
//* Description: Will get the screen resolution
//*		 
//* Parameters : - select       	: Info
//*		
//*	Example	:	GetScreenWidth();
//****************************************************************
// -------------------------------------------------------------------
// selectUnselectMatchingOptions(select_object,regex,select/unselect,true/false)
//  This is a general function used by the select functions below, to
//  avoid code duplication
// -------------------------------------------------------------------
function selectUnselectMatchingOptions(obj,regex,which,only) {
	if (window.RegExp) {
		if (which == "select") {
			var selected1=true;
			var selected2=false;
			}
		else if (which == "unselect") {
			var selected1=false;
			var selected2=true;
			}
		else {
			return;
			}
		var re = new RegExp(regex);
		for (var i=0; i<obj.options.length; i++) {
			if (re.test(obj.options[i].value)) {
				obj.options[i].selected = selected1;
				}
			else {
				if (only == true) {
					obj.options[i].selected = selected2;
					}
				}
			}
		}
	}
		
// -------------------------------------------------------------------
// selectMatchingOptions(select_object,regex)
//  This function selects all options that match the regular expression
//  passed in. Currently-selected options will not be changed.
// -------------------------------------------------------------------
function selectMatchingOptions(obj,regex) {
	selectUnselectMatchingOptions(obj,regex,"select",false);
	}
// -------------------------------------------------------------------
// selectOnlyMatchingOptions(select_object,regex)
//  This function selects all options that match the regular expression
//  passed in. Selected options that don't match will be un-selected.
// -------------------------------------------------------------------
function selectOnlyMatchingOptions(obj,regex) {
	selectUnselectMatchingOptions(obj,regex,"select",true);
	}
// -------------------------------------------------------------------
// unSelectMatchingOptions(select_object,regex)
//  This function Unselects all options that match the regular expression
//  passed in. 
// -------------------------------------------------------------------
function unSelectMatchingOptions(obj,regex) {
	selectUnselectMatchingOptions(obj,regex,"unselect",false);
	}
	
//------------------------------------------------------------
// selectAllOptions(select_object)
//  This function takes a select box and selects all options (in a 
//  multiple select object). This is used when passing values between
//  two select boxes. Select all options in the right box before 
//  submitting the form so the values will be sent to the server.
// -------------------------------------------------------------------
function selectAllOptions(obj) {
	for (var i=0; i<obj.options.length; i++) {
		obj.options[i].selected = true;
		}
	}
	


// -------------------------------------------------------------------
// moveAllOptions(select_object,select_object[,autosort(true/false)[,regex]])
//  Move all options from one select box to another.
// -------------------------------------------------------------------
function moveAllOptions(from,to) {
	selectAllOptions(from);
	if (arguments.length==2) {
		moveSelectedOptions(from,to);
		}
	else if (arguments.length==3) {
		moveSelectedOptions(from,to,arguments[2]);
		}
	else if (arguments.length==4) {
		moveSelectedOptions(from,to,arguments[2],arguments[3]);
		}
	}

// -------------------------------------------------------------------
// copyAllOptions(select_object,select_object[,autosort(true/false)])
//  Copy all options from one select box to another, instead of
//  removing items. Duplicates in the target list are not allowed.
// -------------------------------------------------------------------
function copyAllOptions(from,to) {
	selectAllOptions(from);
	if (arguments.length==2) {
		copySelectedOptions(from,to);
		}
	else if (arguments.length==3) {
		copySelectedOptions(from,to,arguments[2]);
		}
	}

// -------------------------------------------------------------------
// swapOptions(select_object,option1,option2)
//  Swap positions of two options in a select list
// -------------------------------------------------------------------
function swapOptions(obj,i,j) {
	var o = obj.options;
	var i_selected = o[i].selected;
	var j_selected = o[j].selected;
	var temp = new Option(o[i].text, o[i].value, o[i].defaultSelected, o[i].selected);
	var temp2= new Option(o[j].text, o[j].value, o[j].defaultSelected, o[j].selected);
	o[i] = temp2;
	o[j] = temp;
	o[i].selected = j_selected;
	o[j].selected = i_selected;
	}
	
// -------------------------------------------------------------------
// moveOptionUp(select_object)
//  Move selected option in a select list up one
// -------------------------------------------------------------------
function moveOptionUp(obj) {
	// If > 1 option selected, do nothing
	var selectedCount=0;
	for (i=0; i<obj.options.length; i++) {
		if (obj.options[i].selected) {
			selectedCount++;
			}
		}
	if (selectedCount!=1) {
		return;
		}
	// If this is the first item in the list, do nothing
	var i = obj.selectedIndex;
	if (i == 0) {
		return;
		}
	swapOptions(obj,i,i-1);
	obj.options[i-1].selected = true;
	}

// -------------------------------------------------------------------
// moveOptionDown(select_object)
//  Move selected option in a select list down one
// -------------------------------------------------------------------
function moveOptionDown(obj) {
	// If > 1 option selected, do nothing
	var selectedCount=0;
	for (i=0; i<obj.options.length; i++) {
		if (obj.options[i].selected) {
			selectedCount++;
			}
		}
	if (selectedCount != 1) {
		return;
		}
	// If this is the last item in the list, do nothing
	var i = obj.selectedIndex;
	if (i == (obj.options.length-1)) {
		return;
		}
	swapOptions(obj,i,i+1);
	obj.options[i+1].selected = true;
	}

// -------------------------------------------------------------------
// removeSelectedOptions(select_object)
//  Remove all selected options from a list
//  (Thanks to Gene Ninestein)
// -------------------------------------------------------------------
function removeSelectedOptions(from) { 
	for (var i=(from.options.length-1); i>=0; i--) { 
		var o=from.options[i]; 
		if (o.selected) { 
			from.options[i] = null; 
			} 
		} 
	from.selectedIndex = -1; 
	} 

// -------------------------------------------------------------------
// removeAllOptions(select_object)
//  Remove all options from a list
// -------------------------------------------------------------------
function removeAllOptions(from) { 
	for (var i=(from.options.length-1); i>=0; i--) { 
		from.options[i] = null; 
		} 
	from.selectedIndex = -1; 
	}
// -------------------------------------------------------------------
// isCheckBoxesChecked(form_object,checkbox_object)
//  Will loop thru the page elements to see if the checkboxes are checked
//
//
/* Sample:
	var bTrue = isCheckBoxesChecked(document.frmAffiliates,'chkSample')
	
	if (bTrue==true) {alert(bTrue);}
*/
// ------------------------------------------------------------------- 

function isCheckBoxesChecked(dml,chkName){
	len = dml.elements.length;
	var i=0;
	for( i=0 ; i<len ; i++) {
		if ((dml.elements[i].name==chkName) && (dml.elements[i].checked==1)) return true
	}
	//alert("You not chosen any records to preform this action")
return false;
} 
//--------------------------------------------------------------
//End
//--------------------------------------------------------------
