function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function ShowRegion(r){
	alert(r)
	
}

function ViewMap(){
	var winpops=window.open("Map.aspx","","width=638,height=470,scrollbars,resizable")
}

function ViewAGMMap(){
	var winpops=window.open("images/MapAGMLarge.gif","","width=458,height=557,scrollbars,resizable")
}

function fieldError(control){
	document.getElementById(control).style.backgroundColor = '#F85757';
	document.getElementById(control).focus();
}

function fieldActive(control){
	document.getElementById(control).style.backgroundColor = '#7CD182';
}

function fieldOK(control){
	document.getElementById(control).style.backgroundColor = '#FFFFFF';
}
function msg(msg){
	//alert(msg)
}

function CheckEmail(who) {
	/* With RegExp */
	var email=/^[A-Za-z0-9]+([_\.-][A-Za-z0-9]+)*@[A-Za-z0-9]+([_\.-][A-Za-z0-9]+)*\.([A-Za-z]){2,4}$/i;
	return(email.test(who));
}


//******************************************************
//
//	Check Login Form 
//
//******************************************************


function CheckLiteratureRequestForm(){

if(document.getElementById('txtForename').value == ""){

	fieldError('txtForename')
	msg('Required Field: Forename')
	return false;
}

if(document.getElementById('txtsurname').value == ""){

	fieldError('txtSurname')
	msg('Required Field: Surname')
	return false
}
if(document.getElementById('txtEmailAddress').value == ""){

	fieldError('txtEmailAddress')
	msg('Required Field: Email')
	return false
}

//check the validity of the email address
if(!(CheckEmail(document.getElementById('txtEmailAddress').value))){
	fieldError('txtEmailAddress')
	alert('Please enter a valid email address')
	return false;
}

if(document.getElementById('txtSubject').value == ""){

	fieldError('txtSubject')
	msg('Required Field: Subject')
	return false
}
return true;
}


function clock() {
	
	var digital = new Date();
	var month = digital.getMonth()
	var year = digital.getYear() - 2000
	var day = digital.getDate();
	var hours = digital.getHours();
	var minutes = digital.getMinutes();
	var seconds = digital.getSeconds();
	var amOrPm = "AM";
		if (hours > 11) amOrPm = "PM";
		if (hours > 24) hours = hours = 1;
		if (hours == 0) hours = 12;

		 //if (hours   < 10)  hours   =  hours+12;    
		if (minutes <= 9) minutes = "0" + minutes;
		if (seconds <= 9) seconds = "0" + seconds;

	var months=new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October","November", "December")

		dispTime =  '<span class="DateTimeBold">' + hours + ":" + minutes  + '</span>   '  + day + ' ' + months[month] + ' 200' + year + ' &nbsp&nbsp             ' //":" //+ seconds + " " //+ amOrPm;

	document.getElementById('Date').innerHTML = dispTime 	
	setTimeout("clock()", 60000);


}

function toggleLayer(whichLayer)
{
if (document.getElementById)
{
// this is the way the standards work
var style2 = document.getElementById(whichLayer).style;
style2.display = style2.display? "":"block";
}
else if (document.all)
{
// this is the way old msie versions work
var style2 = document.all[whichLayer].style;
style2.display = style2.display? "":"block";
}
else if (document.layers)
{
// this is the way nn4 works
var style2 = document.layers[whichLayer].style;
style2.display = style2.display? "":"block";
}
}






function validateEmail(Address){

	var Validate = Address.value.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.co.uk)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\..{2,2}))$)\b/gi);

	return Validate
}

function getCalendarDate()
{

   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 months = new Array(13);
   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 now         = new Date();
   var monthnumber = now.getMonth();
   var monthname   = months[monthnumber];
   var daynumber     = now.getDay();
   var dayname     = weekday[daynumber];
   var monthday    = now.getDate();
   var year        = now.getYear();
   if(year < 2000) { year = year + 1900; }
   var dateString = '&#32;&#32;'      + '&#32;' + 
		    monthday +
                    '&#32;' +
                    monthname +
                    ' ' +
                    year;
   return dateString;
} // function getCalendarDate()

function getClockTime()
{
   var now    = new Date();
   var hour   = now.getHours();
   var minute = now.getMinutes();
   var second = now.getSeconds();
   var ap = "am";
   if (hour   > 11) { ap = "pm";             }
   if (hour   > 12) { hour = hour - 12;      }
   if (hour   == 0) { hour = 12;             }
//no leading 0 for hour
   if (hour   < 10) { hour   =  hour;   }

   if (minute < 10) { minute = "0" + minute; }
   if (second < 10) { second = "0" + second; }
   var timeString = hour + ':' +  minute //+ ap;
   return timeString;
} // function getClockTime()


function DateTime(){
	document.getElementById('Date').innerHTML = "<b>" +  getClockTime() + "</b>&nbsp" +  getCalendarDate() + "&nbsp&nbsp</b></span>";
}

function checkFields(){
	//if username contains data then the user has been remembered so set password field as default
	if(document.getElementById('txtUsername').value.length > 0){
		InitSelectedField('txtPwd')
	}
}
