
 

function changecolor(nid){
	var ee = eval("window." + nid);
	ee.className="AdminRowOver";
	return
}

function changecolorback(nid){
	var ee = eval("window." + nid);
	ee.className="AdminRowOut";
return
}
 
function PopupPicResize(sPicURL,WindowName) { 
   
     window.open( "popupResize.asp?"+sPicURL, WindowName,  
     "resizable=1,HEIGHT=200,WIDTH=200"); 
   } 
 
function GetLocalDate ()
 {
	var d = new Date()
	//document.write(d.getDate())
	//document.write(".")
	//document.write(d.getMonth() + 1)
	//document.write(".")
	//document.write(d.getFullYear())
    LocalDate = d.getDate() + "/" + (d.getMonth() + 1) + "/" + d.getFullYear()
	return LocalDate
}

function GetLocalTime ()
 {
	var d = new Date()
	//document.write(d.getHours())
	//document.write(".")
	//document.write(d.getMinutes())
	//document.write(".")
	//document.write(d.getSeconds())
	LocalTime= d.getHours() + ":" + (d.getMinutes() + 1) + ":" + d.getSeconds()
	return LocalTime
	
}
 
	//Make sign graphic fit in to 100x100 space
	function makeFit(theImg, maxW, maxH){
	   var oldH, oldW, newH, newW, ratio
	   oldH = theImg.height;
	   oldW = theImg.width;
	   ratio = oldH/oldW;
	   max_ratio = maxH/maxW;
	   if(oldH > maxH || oldW > maxW){
	        if(ratio >max_ratio){
	        newH = maxH;
	        newW = newH/ratio;
	        }
	        else{
	        newW = maxW;
	        newH = newW*ratio;
	        }
	        }
	   else{
	   newW = oldW;
	   newH = oldH;
	   } 
	    newW = Math.round(newW);
	   newH = Math.round(newH);
	   theImg.height = newH;
	   theImg.width =  newW;
	}
	 


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://localhost/staging_test/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://localhost/staging_test/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 + "');");
}

//-------------------------------------------------------------------------------
// new pop up
//popUp2('FooterpopUp.asp?sid=<%=int_Siteid%>&winname=Copyright','win5','scrollbars=yes','750','450','true')">
function popUp2(theURL,winName,features, myWidth, myHeight, isCenter) { //v3.0
  if(window.screen)if(isCenter)if(isCenter=="true"){
    var myLeft = (screen.width-myWidth)/2;
    var myTop = (screen.height-myHeight)/2;
    features+=(features!='')?',':'';
    features+=',left='+myLeft+',top='+myTop;
  }
  window.open(theURL,winName,features+((features!='')?',':'')+'width='+myWidth+',height='+myHeight);
}

function daysInMonth(month,year) {
	var dd = new Date(year, month, 0);
	return dd.getDate();
}

function AdjustEndDate(iDay,iMonth,iYear) {
	
	var thisDate = new Date();
	thisDate.setYear(iYear);
	thisDate.setMonth(iMonth-1);
	thisDate.setDate(iDay);
	
	var iDays = 6;
	strDate = Date.parse(thisDate);
	strDate = parseInt(strDate, 10);
	strDate = strDate + iDays*(24*60*60*1000);
	strDate = new Date(strDate);
	
	//var iTempMonth = strDate.getMonth();
	
	//if (iTempMonth == iMonth) {
		timesheet.Eday.value = strDate.getDate();
	//} else {	
	//	timesheet.Eday.value = strDate.getDate()-1;
	//}	
	
	timesheet.Emonth.selectedIndex = strDate.getMonth();
	timesheet.Eyear.value = strDate.getFullYear();
}
