
//highlight: navigation rollovers --------------------------------------------------
function highlight(sImg,sSrc) {
	var oImg = getObj(sImg);
	oImg.src = sSrc;
}


//setCookie: creates a cookie ------------------------------------------------------
function setCookie(sName,sValue,sExpires) 
{
	if (sExpires == null) 
	{
		//if not expiration date is provided, set the expiration date
		//to a long time from now
		var dExpires = new Date("12/31/2010");
	} else
	{
		dExpires = new Date(sExpires);
	}
	var sCookieString = sName + "=" + escape(sValue) + "; expires=" + dExpires.toUTCString();
	document.cookie = sCookieString;
}

//getCookie: retrieves a cookie ------------------------------------------------------
function getCookie(sName) 
{
  	// cookies are separated by semicolons
  	var aCookie = document.cookie.split("; ");
  	var iCookieLength = aCookie.length;
  	for (var i=0; i < iCookieLength; i++)
  	{
    	// a name/value pair (a crumb) is separated by an equal sign
    	var aCrumb = aCookie[i].split("=");
		if (sName == aCrumb[0]) 
		{
    	  return unescape(aCrumb[1]);
		}
  	}
  	//return null if a cookie with the requested name does not exist
  	return null;
}

//getFullYear: returns the full four-digit year
function getFullYear(d)
{
	var y = d.getYear(d);
	if (y < 1000)
	{
		y += 1900;
	}
	return y;
}

//isValidDate: validates whether a date is a real date
function isValidDate(d,sFieldName)
{
	if (isNaN(d))
	{
		alert("The " + sFieldName + " is not valid");
		return false;
	}
	return true;
}

//getLastDateOfMonth: returns the date representing the last date of the month
function getLastDateOfMonth(dDate)
{
	var iDay = dDate.getDate();
	var iMonth = dDate.getMonth();
	var iYear = dDate.getFullYear();
	if (mBrowser.isNS4)
	{
		var aDates = new Array(31,30,29,28);
		var iDatesLength = aDates.length;
		
		for (var i=0; i < iDatesLength; i++) 
		{
			var dNewDate =  new Date(iYear,iMonth,aDates[i]);
			if (dNewDate.getMonth() == iMonth)
			{
				return dNewDate;
			}
		}
	}
	else
	{
		var dNewDate =  new Date(iYear,iMonth + 1,0);
		return dNewDate;
	}
}

//isPositive: determines whether iNumber is a number and is greater than zero
function isPositive(iNumber)
{
 	//check whether iNumber is a number and is greater than zero
	if (isNaN(iNumber/iNumber) || iNumber < 0)
	{
		return false
	}
	else
	{
		return true;
	}
}

//compareDates: compares two dates and returns false if the FROM date isn't <= TO date
function compareDates(dFromDate,dToDate)
{
	//make sure the TO date is after the FROM date
	if (dToDate.getTime() - dFromDate.getTime() < 0)
	{
		alert("The TO date must be equal to or after the FROM date");
		return false;
	}
	else
	{
		return true;
	}
}

//setOptions: adds options to a select box
function setOptions(oSelect,oOptions)
{
	var iNumOptions = oSelect.length;
	
	if (!mBrowser.isNS4)
	{
		//initialize the list
		for (var i=0; i < iNumOptions; i++) 
		{
			oSelect.options.remove(0);
		}
		
		//add the new options
		var iNumOptions = oOptions.length;
		for (var i=0; i < iNumOptions; i++) 
		{
			var oOption = document.createElement("OPTION");
			oOption.text = oOptions[i].text;
			oOption.value = oOptions[i].value;
			oOption.defaultSelected = oOptions[i].defaultSelected;
			oSelect.options.add(oOption);
		}
	}
	else
	{
		//initialize the list
		for (var i=0; i < iNumOptions; i++) 
		{
			oSelect.options[0] = null;
		}
		
		//add the new options
		var iNumOptions = oOptions.length;
		for (var i=0; i < iNumOptions; i++) 
		{
			oSelect.options[i-1] = new Option(oOptions[i].text,oOptions[i].value,oOptions[i].defaultSelected,false);
		}
	}
}

//isEnterKey: determines whether the Enter key was pressed
function isEnterKey()
{
	if (!mBrowser.isNS4)
	{
		if (window.event.keyCode == 13)   
		{
			return true;
		}
		return false;
	}
	return null;
}