// JavaScript Document
// Controls the drop down menu in IE as IE doesn't full support
	// the :hover pseudo-class.
	sfHover = function() {
	var sfEls = document.getElementById("nav").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);


function newwindow(url,width, height)
{
// Set width and height
var winWidth = width;
var winHeight = height;
// Set Window position
var winTop = 0;
var winLeft = 0;
// Set other attributes
var toolbar = "no";
var location = "no";
var directories = "no";
var status = "no";
var menubar = "no";
var scrollbar = "no";
var resizable = "no";
var atts="width="+winWidth+",height="+winHeight+",top="+winTop+",screenY="+winTop+",left="+winLeft+",screenX="+winLeft;
// open the window
window.open(url,'',atts);
}

//Function for edit user
function submit_add(userName, roleName)
{
	document.process.command.value = "add";
	document.process.userRole.value = roleName;
	document.process.userEdit.value = userName;
	alert(userRole);
	alert(userEdit);
	alert(command);
	//document.process.submit();
}
function submit_remove(userName, roleName)
{
	document.process.command.value = "remove";
	document.process.userRole.value = roleName;
	document.process.userEdit.value = userName;
	alert(userRole);
	alert(userEdit);
	alert(command);
	//document.process.submit();	
}
function submit_role(role)
{
	document.process.userRole.value = role;
	alert(userRole);
	//document.process.submit();	
}


// Validation for the login page
function loginValidate(loginForm) {
	var username = document.topLoginForm.loginUsername.value;
	var pass = document.topLoginForm.loginPass.value;
	
	
	
	if (username == "") {
		alert("Please enter your username!");
		return false;
	}
	
	if (pass == "") {
		alert("Please enter your password!");
		return false;
	}
	
	
}

function showItemOnMap(theid, objLayer) {
	document.showDataOnMap.theid.value = theid;
	document.showDataOnMap.objectLayer.value = objLayer;
	document.showDataOnMap.submit();
}

function init () {
  timeDisplay = document.createTextNode ("");
  document.getElementById("clock").appendChild (timeDisplay);
}


function updateClock () {
  var currentTime = new Date ();
  
  var day = currentTime.getDay();
  var weekday=new Array(7);
  weekday[0]="Sunday";
  weekday[1]="Monday";
  weekday[2]="Tuesday";
  weekday[3]="Wednesday";
  weekday[4]="Thursday";
  weekday[5]="Friday";
  weekday[6]="Saturday";
  
  var dayDate = currentTime.getDate();
  var month = currentTime.getMonth();
  var months=new Array(12);
  months[0]="January";
  months[1]="February";
  months[2]="March";
  months[3]="April";
  months[4]="May";
  months[5]="June";
  months[6]="July";
  months[7]="August";
  months[8]="September";
  months[9]="October";
  months[10]="November";
  months[11]="December";
  
  var year = currentTime.getFullYear();
  var currentHours = currentTime.getHours ();
  var currentMinutes = currentTime.getMinutes ();

  // Pad the minutes with leading zeros, if required
  currentMinutes = (currentMinutes < 10 ? "0" : "") + currentMinutes;

  // Choose either "AM" or "PM" as appropriate
  var timeOfDay = (currentHours < 12) ? "AM" : "PM";

  // Convert the hours component to 12-hour format if needed
  currentHours = (currentHours > 12) ? currentHours - 12 : currentHours;

  // Convert an hours component of "0" to "12"
  currentHours = (currentHours == 0) ? 12 : currentHours;

  // Compose the string for display
  var currentTimeString = weekday[day] + ", " + dayDate + " " + months[month] + " " + year + " " + currentHours + ":" + currentMinutes + " " + timeOfDay;

  // Update the time display
  document.getElementById("clock").firstChild.nodeValue = currentTimeString;
}
