/////////////////////////////////////////////////////////////////////
// Description	: Functions for select lists
//
// Author		: Bent Petz
//
// Creation Date: 4-Jun-2001
//
// Revision History
// Who   When  			What
/* ------------------------------------------------------------------
// SA		18/01/2006	Added selectAll function to select all options in a <select> in a form.
// SA		16/03/2006	Modified selectAll function to skip <selects> that are not multiple
// ------------------------------------------------------------------
*/
/*  Notes:
*/
//////////////////////////////////////////////////////////////////////


var itemColor = '#ffffff';
var itemHighlightColor = '#cccccc';
var selectColor = '#ccccff';
var MOZselectColor = 'rgb(204, 204, 255)';
var selectHighlightColor = '#ffffff';
var MOZselectHighlightColor = 'rgb(255, 255, 255)';

function mouseOver(eSrc)
{
    if (eSrc.style.backgroundColor != selectColor &&
	eSrc.style.backgroundColor != MOZselectColor) 
	eSrc.style.backgroundColor = itemHighlightColor;
}

function mouseOut(eSrc)
{
    if (eSrc.style.backgroundColor != selectColor &&
	eSrc.style.backgroundColor != MOZselectColor) 
    {
	if (eSrc.style.backgroundColor == selectHighlightColor ||
	    eSrc.style.backgroundColor == MOZselectHighlightColor)
	    eSrc.style.backgroundColor = selectColor
	else
	    eSrc.style.backgroundColor = itemColor;
    }
}


function mouseClick(eSrc)
{

    elParent = eSrc.parentElement;
    if (elParent != null)
    {
	var tempColl = elParent.children;
	for (i=0; i<tempColl.length; i++)
	{
	    tempColl[i].style.backgroundColor = itemColor;
	}
    }
    else
    {
	elParent = eSrc.parentNode;
	var tempColl = elParent.childNodes;
	for (i=0; i<tempColl.length; i++)
	{
	    if (tempColl[i].nodeType == 1)
		tempColl[i].style.backgroundColor = itemColor;
	}
    }
    eSrc.style.backgroundColor = selectColor; 
}
// Pass in a form and all <option> in all <select> will be selected. 
// Skips selects that do not have multiple="multiple" (strictly DHTML compliant) attribute.
// also skips item with the attribute omitSelect='true' eg. <select id='blah' name='blah' omitSelectAll='true'>
function selectAll(frm,exception1)
{
	all_selects = frm.getElementsByTagName("select");
	for (var i = 0; i < all_selects.length; i++) {
		if (all_selects[i].getAttribute("multiple") && all_selects[i].name != exception1 && all_selects[i].getAttribute("omitSelectAll")!='true') {
			//alert(all_selects[i].getAttribute("omitSelectAll"));
			all_options = all_selects[i].getElementsByTagName("option");
			for (var j = 0; j < all_options.length; j++) {
				all_options[j].selected=true;
			}
		}
	}
}

