function breakframe(){
	if (top.location != location) {top.location.href = document.location.href;}
}

function goSSL(){
	if (document.URL.toLowerCase().indexOf("https") < 0 ){
		var newURL = "https" + document.URL.substr(4);
		location = newURL;}
	}

function refreshAdmin(){
	window.location.reload( true );
}

function doLoad_1(){
	setTimeout("refreshAdmin()", 60000);
}
function doLoad_3(){
	setTimeout("refreshAdmin()", 180000);
	}
function doLoad_10(){
	setTimeout("refreshAdmin()", 600000);
}

function externalLinks() { 
 if (!document.getElementsByTagName) return; 
 var anchors = document.getElementsByTagName("a"); 
 for (var i=0; i<anchors.length; i++) { 
   var anchor = anchors[i]; 
   if (anchor.getAttribute("href") && 
       anchor.getAttribute("rel") == "external") 
     anchor.target = "_blank"; 
 } 
}

function changeDept(selected_dept){
	var newdept = selected_dept.value
	location.href = "/bldgmgr/fnx_switchdept.asp?dept=" + newdept
}

function selectDept(selected_dept){
	var newdept = selected_dept.value
	location.href = "/bldgmgr2/fnx_switchdept.asp?dept=" + newdept
}

function changeBmDept(pages,selected_dept){
	var redirect = pages
	var newdept = selected_dept.value
	location.href = "/" + redirect + "/switchdept.asp?dept=" + newdept
}

function selectBmgr2DateRange(selected_range){
	var dtrange = selected_range.value
	location.href = "/bldgmgr2/?dr=" + dtrange
}

function selectBmgr2SearchDateRange(selected_range,search_field,search_val,duplicate_yn){
	var dtrange = selected_range.value
	var searchfield = search_field
	var searchvalue = search_val
	var searchduplicate = duplicate_yn
	location.href = "/bldgmgr2/?action=find&dr=" + dtrange + "&param=" + searchfield + "&val=" + searchvalue + "&dup=" + searchduplicate
}

function selectBmgr3DateRange(selected_range){
	var dtrange = selected_range.value
	location.href = "/bldgmgr3/?dr=" + dtrange
}
function selectBmgr3SearchDateRange(selected_range,search_field,search_val,duplicate_yn){
	var dtrange = selected_range.value
	var searchfield = search_field
	var searchvalue = search_val
	var searchduplicate = duplicate_yn
	location.href = "/bldgmgr3/?action=find&dr=" + dtrange + "&param=" + searchfield + "&val=" + searchvalue + "&dup=" + searchduplicate
}

// This is the new date range control for BLDGMGR3
// Keeps control in one function irregardless of which portal and action it is called from (using action and pages parameters)
function selectSearchDateRange(selected_range,action,search_field,search_val,duplicate_yn,pages){
	var dtrange = selected_range.value
	var operation = action
	var searchfield = search_field
	var searchvalue = search_val
	var searchduplicate = duplicate_yn
	var pagesclass = pages
	if (pagesclass == "vcu.asp") {
		location.href = "/" + pagesclass + "?action=" + operation + "&dr=" + dtrange + "&param=" + searchfield + "&val=" + searchvalue + "&dup=" + searchduplicate }
	else {
		location.href = "/" + pagesclass + "/?action=" + operation + "&dr=" + dtrange + "&param=" + searchfield + "&val=" + searchvalue + "&dup=" + searchduplicate }
	}


function getDate(){
	var ReqDate = document.forms[0].reqdate;
  var today = new Date();
  var day = today.getDate();
  var month = today.getMonth() + 1;
  var year = today.getFullYear().toString();
  if ( ( month /10 ) < 1 )  { month=("0" + month).toString(); }
  if ( (day/10)<1)  { day=("0" + today.getDate()).toString(); }
//	Remove comments to populate ReqDate field with current date and time
//	ReqDate.value = month + "/" + day + "/" + year;
	var DisplayDate = month + "/" + day + "/" + year;
}

function changeDiv(the_div,the_change){
  var the_style = getStyleObject(the_div);
  if (the_style != false)  { the_style.display = the_change; }
}

function switchDiv(div_id){
  var style_sheet = getStyleObject(div_id);
  if (style_sheet) {
    hideMainForm();
    changeObjectVisibility(div_id,"visible");
  }
  else { alert("sorry, this only works in browsers that do Dynamic HTML"); }
}

function hideWelcome() { changeDiv("welcome","none"); }
function hideNews() { changeDiv("news","none"); }
function hideStatus() { changeDiv("status","none"); }
function hideChangepass() { changeDiv("changepass","none"); }
function hideUpdatePass() { changeDiv("update_pass","none"); }
function hideMessage() { changeDiv("message","none"); }

// function getStyleObject(string) -> returns style object
//  given a string containing the id of an object
//  the function returns the stylesheet of that object
//  or false if it can't find a stylesheet.  Handles
//  cross-browser compatibility issues.
//
function getStyleObject(objectId) {
  // checkW3C DOM, then MSIE 4, then NN 4.
  //
  if(document.getElementById && document.getElementById(objectId)) { return document.getElementById(objectId).style;  }
  else if (document.all && document.all(objectId)) { return document.all(objectId).style;  } 
  else if (document.layers && document.layers[objectId]) { return document.layers[objectId]; } 
  else { return false; }
}

function changeObjectVisibility(objectId, newVisibility) {
  // first get a reference to the cross-browser style object 
  // and make sure the object exists
  var styleObject = getStyleObject(objectId);
  if(styleObject){
		styleObject.visibility = newVisibility;
		return true;
	} 
	else { return false; }
}

function hoverTD(color) {
	document.all['hovercell'].style.background = '#' + color;
}

var count=11;
var countlayer;
function panelcounter(){
	count--; 
	changelayer_content(count);
	if (count>0){ Id = window.setTimeout("countdown()",1000); } 
}

function changelayer_content(counter){
	msgstring="<font class=tiny_bold_white><i>" + counter + " ...</i></font>";
	if(document.layers){
		//thisbrowser="NN4";
		countlayer = document.layers[0];
		countlayer.document.open();
		countlayer.document.write(msgstring);
		countlayer.document.close();
	}
	if(document.all){
		//thisbrowser="ie"
		countlayer = document.all["count"];
		countlayer.innerHTML=msgstring;
	}
	if(!document.all && document.getElementById){
		//thisbrowser="NN6";
		countlayer = document.getElementById("count");
		countlayer.innerHTML =msgstring;
	}
}

function toForm() {
		document.creq.DesiredDate.focus();
	}

function textCounter(field, countfield, maxlimit) {
		if (field.value.length > maxlimit) { field.value = field.value.substring(0, maxlimit);  }
		else { countfield.value = maxlimit - field.value.length;	}
}

function passText(passedvalue) {
	if (passedvalue != "") {
	  var problemValue = passedvalue.slice(7,47);
		document.creq.req_dsc.value = problemValue.toLowerCase();
	}
}


<!-- Random number generator from _Numerical Recipes_
function random() {
  random.seed = (random.seed * random.a + random.c) % random.m;
  return random.seed / random.m;
}
random.m=714025; random.a=4096; random.c=150889;
random.seed = (new Date()).getTime()%random.m;
//   End Random number script -->

//   JavaScript by Stevie G. copyright 1997 http://www.visi.com/~sgrantz
//   Permission is granted by the
//   G-Man to reuse the randomPageColor function 
//   provided I am credited in the source code and my comments  
//   are included. -Steve Grantz, 08/20/97

function NumToHexString(hexnumber) {
// takes a number as sole argument, returns the hex value. Will make
// the return value at leats two places long by adding zeroes.
// I.e., NumToHexString(10)=="0a".
   var hexstring="";
   var hexchar;
   var hexones;
   var i=0;

   hexnumber=Math.floor(hexnumber);
   while (hexnumber != 0) {
       i++;
       hexones=hexnumber % 16;
       hexnumber -= hexones;
       hexnumber /= 16;

       if (hexones>9) {
	  if (hexones==10) hexchar="a";
	  if (hexones==11) hexchar="b";
	  if (hexones==12) hexchar="c";
	  if (hexones==13) hexchar="d";
	  if (hexones==14) hexchar="e";
	  if (hexones==15) hexchar="f";
       }
       else hexchar=hexones;

      hexstring = hexchar + hexstring;
   }

   for (;i<2;i++) {
      hexstring="0"+hexstring;
   }

   return hexstring;
}

function randomPageColor() {
// Writes the "body" tag to a document (opening tag only)
// including a random background color, and text and link colors
// that should have good contrast against the background color.

   var bg_red=Math.floor(256*random());
   var bg_green=Math.floor(256*random());
   var bg_blue=Math.floor(256*random());
   var text_color;
   var vlink_color;
   var bg_RGB;

   // Here, decide whether the text colors should be light or dark.
   // Rudimentary color analaysis at best; does not try to calculate
   // brightness but estimate it instead.
   if ((bg_red+bg_blue+bg_green)<300 || bg_red < 40
	  || bg_green < 40) {
	       text_color="#ffffff";
	       vlink_color="#cfcfcf";
      }
   else {
               text_color="#000000";
               vlink_color="#303030";
        }

   bg_RGB=NumToHexString(bg_red);
   bg_RGB+=NumToHexString(bg_green);
   bg_RGB+=NumToHexString(bg_blue);

//   document.write('<body bgcolor="'+bg_RGB+'"');
//   document.write('text="'+text_color+'" ');
//   document.write('link="'+text_color+'" ');
//   document.write('vlink="'+vlink_color+'">');


   // In case you want to save the body color for future use
   return bg_RGB;
}


// var currentRGB = randomPageColor();

// End of randomPageColor scripting -->

