//--------------------------------------------------------------------------
//	Generic library functions  
//------------------------------------------------------------------------- 

var days = new Array(8);
days[1] = "Sunday";
days[2] = "Monday";
days[3] = "Tuesday";
days[4] = "Wednesday";
days[5] = "Thursday";
days[6] = "Friday";
days[7] = "Saturday";

var months = new Array(13);
months[1] = "January";
months[2] = "February";
months[3] = "March";
months[4] = "April";
months[5] = "May";
months[6] = "June";
months[7] = "July";
months[8] = "August";
months[9] = "September";
months[10] = "October";
months[11] = "November";
months[12] = "December";


function DateModified(int_Format, str_Text) {
	var dateObj = new Date(document.lastModified)
	var wday = days[dateObj.getDay() + 1];
	var lmonth = months[dateObj.getMonth() + 1];
	var smonth = lmonth.substr(0,3);
	var date = dateObj.getDate();
	var fyear = dateObj.getFullYear();
	
	var fhour = dateObj.getHours();
	var fminute = dateObj.getMinutes();
	
	// change to a 12 hour time 
	if (fhour > 12) {
		fhour = fhour - 12;
		fminute = fminute + " pm";
	} else {
		fminute = fminute + " am";
	}
	
	// check if str_text value passed
	if (str_Text == undefined) {
		str_Text = "Last updated:";
	}

	if (int_Format == 1) {
		document.write(str_Text + " " + date + " " + smonth + " " + fyear);
	}

	if (int_Format == 2) {
		document.write(str_Text + " " + date + " " + smonth + " " + fyear + ", " + fhour + ":" + fminute);
	}

	if (int_Format == 3) {
		document.write(str_Text + " " + date + " " + smonth + " " + fyear + ", " + fhour + ":" + fminute + ", " + wday);
	}
}

//---------------------------------------------------------------------------------
// Purpose:	To control the display of "new" image(s) on a page. The control is 
//		achived by setting an expiry date which is passed as a parameter to 
// 		this function. Any date in the past will not display the link. The 
//		following code is to be added to each location where image is required:
//		<script>checknew("6/01/2001")</script>
// 		
// SYNTAX:	checknew(date)
//		date =	standard date in the following format "mm/dd/yyyy"
//
// Examples:	checknew("2/5/2002")	will display images until the 2/4/2002.
//---------------------------------------------------------------------------------
function checknew(date) {
	var pic = "http://webdev/mslib/video.gif";
	expdate = new Date(date);
	var fday = expdate.getDay();
	var fmonth = expdate.getMonth();
	var fyear = expdate.getYear();
	var ausdate = fday + "/" + fmonth + "/" + fyear 	
	expdate = new Date(ausdate);

	curdate = new Date();
	var cday = curdate .getDay();
	var cmonth = curdate .getMonth();
	var cyear = curdate .getYear();
	var currentDate = cday + "/" + cmonth + "/" + cyear
	curdate = new Date(currentDate);

	if (expdate.getTime() > curdate.getTime())
	document.write("<img src=" + pic + ">");
}

//-------------------------------------------------------------------------------
// Purpose:	Opens upa new window in a specified format. The generic popup 
//		window requireds a number of parameters to be passed down to the 
//		function in order to achieve the apropriate outcome.
//
// SYNTAX:	popUp(URL,WindowName,Width,Height,Scrollbars)
//
// 		URL: 	   url of page which will populate the new window. The following parameters are required:
//				id	- SiteID (eg. 12)
//				winname	- Heading which will appear in new window (eg. CMIS%20News) substitute spaces with "%20"
//				wintype	- 1=News, 2=FAQ and 3=Events
//		Width:      width of new window
//		Height:     height of new window
//		Scrollbars: 1=on 2=off
//
// EXAMPLE:	popUp("http://webdev/mslib/library/docs/popup.asp?id=1&winname=CMIS%20News&wintype=3",'win4',500,450,1)
//
//-------------------------------------------------------------------------------
function popUp(URL,wName,wWidth,wHeight,wScrollbar) {
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(URL,'" + wName + "', 'toolbar=0,scrollbars=" + wScrollbar + ",location=0,statusbar=0,menubar=0,resizable=0,width=" + wWidth + ",height=" + wHeight + "');");
}
