//  THIS FILE CONTAINS THE FOLLOWING FUNCTIONS:

//

var ext = ".gif";

var curImg = "";


//  ROLL OVER IMAGE FUNCTION
function imageOver(imageName){
	document.images[imageName].src = imageDir + imageName + "_ov" + ext;
}

//  ROLL OFF IMAGE FUNCTION
function imageOff(imageName){
	if(imageName != curImg){
		document.images[imageName].src = imageDir + imageName + ext;
	}
}


//  ROLL OVER IMAGE FUNCTION
function curImgOn(imageName){
	curImg = imageName;
	imageOver(curImg);
}


function topImageOver(imageNum){
	document.images["top" + imageNum].src = imageDir + "top_contact_ov" + ext;
}

function topImageOut(imageNum){
	document.images["top" + imageNum].src = imageDir + "top_contact" + ext;
}

var extjpg = ".jpg";

//  ROLL OVER IMAGE FUNCTION
function imageOverjpg(imageName){
	document.images[imageName].src = imageDir + imageName + "_ov" + extjpg;
}

//  ROLL OFF IMAGE FUNCTION
function imageOffjpg(imageName){
	document.images[imageName].src = imageDir + imageName + extjpg;
}


//  POP UP WINDOW FUNCTION
function windowOpener(what_url,winheight,winwidth) {
	options="toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no width=" + winwidth + ",height=" + winheight;

	popwin = window.open(what_url,'pop_win',options);
	popwin.focus();
}

function windowOpenery(what_url,winheight,winwidth) {
	options="toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no width=" + winwidth + ",height=" + winheight;

	popwin = window.open(what_url,'pop_win',options);
	popwin.focus();
}

function openWindow(postcode) {
  newWindow = window.open('http://www.nhs.uk/localnhsservices/map.asp?postcode=' + postcode + '&zoom=2', 'newWin', 'menubar=yes, toolbar=no, location=no, scrollbars=no, width=420, height=500');
}


//  Open URL in main window and close pop up
function loadParentUrl(url) {
	window.opener.document.location = url;
	window.close();
}


//Container for preloaded images
var preloadArray = new Array();

// Preload an image
function preloadImage(imgSrc){
    var i = preloadArray.length;
    preloadArray[i] = new Image();
    preloadArray[i].src = imgSrc;
}



function makeExclusive(boxRef){
	document.loginForm.loginAsStaff.checked = 0;
	document.loginForm.loginAsTrust.checked = 0;
	boxRef.checked = 1;
}

//  DROP DOWN MENU FUNCTION
function dropdownnewpage()
{
  pos=window.document.forms[0].menulist.selectedIndex;
  newpage=window.document.forms[0].menulist.options[pos].value; 
   
  if(newpage!= "")
  {
     window.open(newpage); 
  }
}

function dropdown()
{
  pos=window.document.forms[0].menulist.selectedIndex;
  newpage=window.document.forms[0].menulist.options[pos].value;

  if(newpage!= "")
  {
     parent.location.href=newpage;
  }
}

//	Write out the date
//		Used for the date in the top right corner of the page
function writeDate(){
	var today = new Date();
	var monthArray = new Array();
	monthArray[0] = "January";
	monthArray[1] = "February";
	monthArray[2] = "March";
	monthArray[3] = "April";
	monthArray[4] = "May";
	monthArray[5] = "June";
	monthArray[6] = "July";
	monthArray[7] = "August";
	monthArray[8] = "September";
	monthArray[9] = "October";
	monthArray[10] = "November";
	monthArray[11] = "December";
	
	dayArray = new Array();
	dayArray[0] = "Sunday";
	dayArray[1] = "Monday";
	dayArray[2] = "Tuesday";
	dayArray[3] = "Wednesday";
	dayArray[4] = "Thursday";
	dayArray[5] = "Friday";
	dayArray[6] = "Saturday";
	document.write(" " + dayArray[today.getDay()] + ", " + today.getDate() + " " + monthArray[today.getMonth()] + " " + today.getYear());
}
//	Check that the declaration has been checked by the end user.
//		This is for the forms on the GP sites
function checkradio() {
	if (!(form1.accept.checked)) {
		alert('You must read the disclaimer and click the acceptance box to proceed.');
		event.returnValue=false;
	}
}


