
// compares two dates.
// Receives two strings representing dates ('yyyy-mm-dd') 
// and the delimiter seperating the date values. 
// Returns positive number if first date greater (i.e. later); 
// negative number if second date greater (i.e. later); 
// zero if both dates identical; 
// NOTE : no verification is performed regarding the legality 
// of the date strings; they are assumed to be legal because 
// there is supposed to be no user input, only user selection 
function CompareDates(dt1, dt2, strDelimiterDt) { 
//alert("dt1 = " + dt1 + "\ndt2 = " + dt2);
	var retVal; 
	// extract values of dates (yr, mon, day) 
	var arrDt1 = dt1.split(strDelimiterDt); 
	var arrDt2 = dt2.split(strDelimiterDt); 

	// create date objects and initialize them with date values 
	var oDt1 = new Date(arrDt1[0], arrDt1[1] - 1, arrDt1[2]); 
	var oDt2 = new Date(arrDt2[0], arrDt2[1] - 1, arrDt2[2]); 

	// set return value to difference 
	// between first date and second date 
	retVal = oDt1.valueOf() - oDt2.valueOf(); 

	// free memory 
	oDt1 = null; 
	oDt2 = null; 

	// return result 
	return (retVal); 
} 

// compares two times.
// Receives two strings representing times ('hh:mm') 
// and the delimiter seperating the time values. 
// Returns positive number if first time greater (i.e. later); 
// negative number if second time greater (i.e. later); 
// zero if both times identical; 
// NOTE : no verification is performed regarding the legality 
// of the date strings; they are assumed to be legal.
function CompareTimes(tm1, tm2, strDelimiterTm) { 
//alert("tm1 = " + tm1 + "\ntm2 = " + tm2);
	var retVal; 

	// extract values of times (hr, min) 
	var arrTm1 = tm1.split(strDelimiterTm); 
	var arrTm2 = tm2.split(strDelimiterTm); 

	// set return value to difference 
	// between first hour and second hour 
	retVal = arrTm1[0] - arrTm2[0]; 

	// if hours equal, then set return value
	// to difference between minutes
	if (retVal == 0)
		retVal = arrTm1[1] - arrTm2[1]; 

	// return result 
	return (retVal); 
} 


// returns numeric value of current date & time
function GetTimestamp() {
	var dt = new Date;
	var timestamp = dt.valueOf();

	dt = null;
	return timestamp;
}

// navigates to page specified by parameter
// after appending timestamp to url to ensure
// that page will not be called from cache
function DoNavigate(m_url) {
	var suffix = "&"; // default value

	// verify whether or not url contains parameters. If question
	// mark doesn't appear in string, then assign '?' to 'suffix'.
	if (m_url.indexOf("?") < 0)
		suffix = "?";
				
	top.window.navigate(m_url + suffix + "nocache=" + GetTimestamp());
	return;
}

// displays popup with list of
// users contained in parameter object
function DisplayPopup(objHidden) {
	oPopup = window.createPopup();
	
	var oPopBody = oPopup.document.body;
	
	oPopBody.style.padding = "4";
	oPopBody.style.width = "100";
	oPopBody.style.direction = "RTL";
	oPopBody.style.font_family = "Arial";
	oPopBody.style.font_size = "10";
	oPopBody.style.border = "#FFFFFF 2px outset";
	oPopBody.style.background = "#F3F3F3";
	oPopBody.innerHTML = "<DIV STYLE='width:200' DIR=RTL ID=divUsers>" + objHidden.value + '</DIV>';
	
	// retrieve number of users in list
	var numOfUsers = parseInt(oPopup.document.all.divUsers.children.length);
	// calculate height of popup according to number of users
	var heightPopUp = ((numOfUsers + ((numOfUsers % 2) * 2)) / 2) * 22;
	// display popup
	oPopup.show(event.x, event.y, 200 , heightPopUp, document.body);
}
