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 ViewMap(){
	var winpops=window.open("images/MapLarge.gif","","width=458,height=557,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 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;' + dayname     + '&#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+12;   }

   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('Header_Clock').innerHTML = "<span class='DateTime'><b>" +  getCalendarDate() + "&nbsp&nbsp</b><b>" +  getClockTime() + "</b></span>";
}


function samplegraph(){
	hideLayer('scrollingContent');
	hideLayer('SectionImage');
	showLayer('SampleGraph');
}

function init(currentPage){

	if(currentPage != 'AboutUs'){
		document.getElementById('Menu_AboutUs').onmouseover = function () { document.getElementById('Menu_AboutUs').src='images/Menu_AboutUs_On.gif'};
		document.getElementById('Menu_AboutUs').onmouseout = function () { document.getElementById('Menu_AboutUs').src='images/Menu_AboutUs.gif'};
		document.getElementById('Menu_AboutUs').onclick = function () { NavigateTo('AboutUs')};						
	}else{
		document.getElementById('Menu_AboutUs').src='images/Menu_AboutUs_On.gif'
		document.getElementById('Menu_AboutUs').onclick = function () { NavigateTo('AboutUs')};						
	}

	if(currentPage != 'News'){
		document.getElementById('Menu_News').onmouseover = function () { document.getElementById('Menu_News').src='images/Menu_News_On.gif'};
		document.getElementById('Menu_News').onmouseout = function () { document.getElementById('Menu_News').src='images/Menu_News.gif'};
		document.getElementById('Menu_News').onclick = function () { NavigateTo('News')};						
	}else{
		document.getElementById('Menu_News').src='images/Menu_News_On.gif'
	}

	if(currentPage != 'Team'){
		document.getElementById('Menu_Team').onmouseover = function () { document.getElementById('Menu_Team').src='images/Menu_Team_On.gif'};
		document.getElementById('Menu_Team').onmouseout = function () { document.getElementById('Menu_Team').src='images/Menu_Team.gif'};
		document.getElementById('Menu_Team').onclick = function () { NavigateTo('Team')};						
	}else{
		document.getElementById('Menu_Team').src='images/Menu_Team_On.gif'
	}

	

	if(currentPage != 'Home'){
		document.getElementById('Menu_Home').onmouseover = function () { document.getElementById('Menu_Home').src='images/Menu_Home_On.gif'};
		document.getElementById('Menu_Home').onmouseout = function () { document.getElementById('Menu_Home').src='images/Menu_Home.gif'};
		document.getElementById('Menu_Home').onclick = function () { NavigateTo('default')};						
	}else{
		document.getElementById('Menu_Home').src='images/Menu_Home_On.gif'
	}

	if(currentPage != 'Contact'){
		document.getElementById('Menu_Contact').onmouseover = function () { document.getElementById('Menu_Contact').src='images/Menu_Contact_On.gif'};
		document.getElementById('Menu_Contact').onmouseout = function () { document.getElementById('Menu_Contact').src='images/Menu_Contact.gif'};
		document.getElementById('Menu_Contact').onclick = function () { NavigateTo('Contact')};						
	}else{
		document.getElementById('Menu_Contact').src='images/Menu_Contact_On.gif'
	}
	
}

function hideSubMenu(){
	hideLayer('SubMenuHolder');	
}

function hideLayer(layerToHide){
	document.getElementById(layerToHide).style.visibility = 'hidden';
}
function showLayer(layerToShow){
	document.getElementById(layerToShow).style.visibility = 'visible';
}

function NavigateTo(page){
	document.location.href= page + "." + "aspx";
}




function Map() { 

var txt='<img src=images/map_Large.gif>';


winStats='toolbar=no,location=no,directories=no,menubar=no,'
   winStats+='scrollbars=yes,width=520,height=690'
   if (navigator.appName.indexOf("Microsoft")>=0) {
      winStats+=',left=10,top=25'
    }else{
      winStats+=',screenX=10,screenY=25'
    }
   floater=window.open("","",winStats)    
   
   floater.document.open();
   floater.document.write(txt);
  
}  
