/*	Cookie Manipulation functions 
		Original Source: http://tech.irt.org/articles/js064/index.htm
*/
function Get_Cookie(name) 
{
		var start = document.cookie.indexOf(name+"=");
		var len = start+name.length+1;
		
		if ((!start) && (name != document.cookie.substring(0,name.length))) return null;
		
		if (start == -1) return null;
		
		var end = document.cookie.indexOf(";",len);
		if (end == -1) end = document.cookie.length;
		
		return unescape(document.cookie.substring(len,end));
}


function Set_Cookie(name,value,expires,path,domain,secure) 
{
	document.cookie = name + "=" + escape(value) +
			( (expires) ? ";expires=" + expires.toGMTString() : "") +
			( (path) ? ";path=" + path : "") + 
			( (domain) ? ";domain=" + domain : "") +
			( (secure) ? ";secure" : "");
}


function Delete_Cookie(name,path,domain) 
{

	if (Get_Cookie(name)) document.cookie = name + "=''" +
			( (path) ? ";path=" + path : "") +
			( (domain) ? ";domain=" + domain : "") +
			";expires=Thu, 31 Dec 2099 23:59:59 GMT;";
}
	
	
function TodaysDate() {
	today = new Date();

	var year = today.getFullYear();
	var monthnum = today.getMonth();
	var date = today.getDate();
	var day = today.getDay();
	
	var week = new Array();
	week[0] = "Sunday";
	week[1] = "Monday";
	week[2] = "Tuesday";
	week[3] = "Wednesday";
	week[4] = "Thursday";
	week[5] = "Friday";
	week[6] = "Saturday";
	
	var month = new Array();
	month[0] = "January";
	month[1] = "Febuary";
	month[2] = "March";
	month[3] = "April";
	month[4] = "May";
	month[5] = "June";
	month[6] = "July";
	month[7] = "August";
	month[8] = "September";
	month[9] = "October";
	month[10] = "November";
	month[11] = "December";

	document.write((week[day]) +", " + (month[monthnum]) +" "+ (date) + ", "+ (year));
}

function newWindow(webpage,name,options) {	
	
	newWin = window.open( webpage, name, options);
	
	newWin.focus();
}


// Clears the list of options in a select tag.
function ClearSelect(obj)
{
    // krb: Fixed 'Microsoft JScript runtime error: 'options' is null or not an object
	for(var i = (obj.options.length-1); i >= 0; i--) 
	{
		obj.options[i] = null;
		// obj.options.remove(i);  only IE
	}
}


// Loads option items into a Select
// obj = Select object to add options
// list = a list of text|value paired strings separated with |
// ie "Select|0|First Choice|1|Second Choice|2"
function LoadSelect(obj, list, clear, selectedItem)
{

	// Check clear Select option 
	if (clear  && clear==true)
		ClearSelect(obj);
		
	// Split list into an array
	var items = list.split("|");

	// Loop through array to add options
	for (var i=0; i < items.length; i=i+2) 
	{
		obj.options.add( new Option(items[i],items[i+1]) );
	}
	
	//Set selectedItem
	if (selectedItem)
		obj.selectedIndex = selectedItem;
		
}