//
// The following was is by Macromedia Dreamweaver:
//
//	MM_reloadPage function: 
//						Resets page for Netscape users
//
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

//
//  MM_preloadImages() function: 
//						Preloads all images used in rollover effects
//
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];}}
}

//
// The following was provided by Macromedia Dreamweaver and
// handels all animations for the Rollover effects
//

function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_nbGroup(event, grpName) { //v3.0
  var i,img,nbArr,args=MM_nbGroup.arguments;
  if (event == "init" && args.length > 2) {
    if ((img = MM_findObj(args[2])) != null && !img.MM_init) {
      img.MM_init = true; img.MM_up = args[3]; img.MM_dn = img.src;
      if ((nbArr = document[grpName]) == null) nbArr = document[grpName] = new Array();
      nbArr[nbArr.length] = img;
      for (i=4; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
        if (!img.MM_up) img.MM_up = img.src;
        img.src = img.MM_dn = args[i+1];
        nbArr[nbArr.length] = img;
    } }
  } else if (event == "over") {
    document.MM_nbOver = nbArr = new Array();
    for (i=1; i < args.length-1; i+=3) if ((img = MM_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = (img.MM_dn && args[i+2]) ? args[i+2] : args[i+1];
      nbArr[nbArr.length] = img;
    }
  } else if (event == "out" ) {
    for (i=0; i < document.MM_nbOver.length; i++) {
      img = document.MM_nbOver[i]; img.src = (img.MM_dn) ? img.MM_dn : img.MM_up; }
  } else if (event == "down") {
    if ((nbArr = document[grpName]) != null)
      for (i=0; i < nbArr.length; i++) { img=nbArr[i]; img.src = img.MM_up; img.MM_dn = 0; }
    document[grpName] = nbArr = new Array();
    for (i=2; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = img.MM_dn = args[i+1];
      nbArr[nbArr.length] = img;
  } }
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

//-------------------------------------
// Copyright (c) Tomislav Sereg
// Contact:
//   	mailto:tsereg@net.hr
//   	http://www.inet.hr/~tsereg/
//-------------------------------------
// fsbInit() function: 
//				Controls the scrolling down of the naivgation bar
//				with the page.	
//
var g_eltFsb       = null;
var g_eltBound     = null;
var g_nFsbMargin   = 20;
var g_nWndTop      = null;
var g_nFsbSpeed    = 200;
var g_nFsbTopBound = null;
var g_cyError      = 0;
function fsbInit( strFsbId, strBoundId, nMargin, nSpeed )
{
    // Does the browser support all the objects and properties we use?
    
    bSupportsModel = arguments && document.all && document.body && window && window.setTimeout;
    if( bSupportsModel )
    {
        var nT = 0;
        for( prop in document.body )
        {
            if( 'scrollTop' == prop || 'offsetHeight' == prop ) nT++;
        }
        bSupportsModel = ( 2 == nT );
    }
    if( bSupportsModel )
    {
        g_eltFsb   = document.all[ strFsbId ];
        g_eltBound = document.all[ strBoundId ];
        bSupportsModel = g_eltFsb && g_eltFsb.style;
        if( bSupportsModel )
        {
            var nT = 0;
            for( prop in g_eltFsb )
            {
                if( 'offsetTop' == prop || 'offsetHeight' == prop || 'offsetParent' == prop ) nT++;
            }
            for( prop in g_eltFsb.style )
            {
                if( 'posTop' == prop ) nT++;
            }
            bSupportsModel = ( 4 == nT );
        }
    }

    if( !bSupportsModel ) return;

    if( 3 <= arguments.length ) g_nFsbMargin = nMargin;
    if( 4 <= arguments.length ) g_nFsbSpeed = nSpeed;

    // Pull slider out of the page - it'll move relatively to its current 
    // position.    

    var y1 = offsetTop( g_eltFsb );
    g_eltFsb.style.position = 'relative';
    var y2 = offsetTop( g_eltFsb );
    g_cyError = y2 - y1;

    // Cannot move above it's current position nor below top of the specified
    // static element.
    g_nFsbTopBound = offsetTop( g_eltFsb ) - g_cyError;

    // Assume window is on the top of the doc. If not, this will simulate
    // it jumped down. 
    g_nWndTop = 0;

    // Continously follow movements of the window.
    window.setTimeout( 'fsbFollow();', g_nFsbSpeed );
}
function fsbFollow()
{
    // Nothing to do if the window hasn't moved.
    if( g_nWndTop == document.body.scrollTop ) 
    {
        // Call me next time, too.
        window.setTimeout( 'fsbFollow();', g_nFsbSpeed );
        return;
    }

    // If the slide bar is shorter than window we extend bottom margin so it's
    // just the same height as window.
    var nMarginExtend = 0;
    if( g_eltFsb.offsetHeight + 2 * g_nFsbMargin < document.body.offsetHeight )
    {
        nMarginExtend = document.body.offsetHeight - g_eltFsb.offsetHeight - 2 * g_nFsbMargin;
    }

    g_nWndTop   = document.body.scrollTop;
    var nWndBot = g_nWndTop + document.body.offsetHeight;
    var nFsbTop = offsetTop( g_eltFsb )  - g_cyError;
    var nFsbBot = nFsbTop + g_eltFsb.offsetHeight;

    nBotBound = offsetTop( g_eltBound );
    if( nBotBound < nFsbBot ) nBotBound = nFsbBot;

    var bWndBotIsBelowFsbBot = nFsbBot + g_nFsbMargin + nMarginExtend < nWndBot;
    var bWndTopIsAboveFsbTop = g_nWndTop < nFsbTop - g_nFsbMargin;
    if( bWndBotIsBelowFsbBot )
    {
        var nDelta = nWndBot - ( nFsbBot + g_nFsbMargin + nMarginExtend );
        if( nBotBound < nFsbBot + nDelta )
        {
            g_eltFsb.style.posTop += ( nBotBound - nFsbBot );
        }
        else
        {
            g_eltFsb.style.posTop += nDelta;
        }
    }
    else if( bWndTopIsAboveFsbTop )
    {
        var nDelta = ( nFsbTop - g_nFsbMargin ) - g_nWndTop;
        if( nFsbTop - nDelta < g_nFsbTopBound )
        {
            g_eltFsb.style.posTop = 0;
        }
        else
        {
            g_eltFsb.style.posTop -= nDelta;
        }
    }

    // Call me next time, too.
    window.setTimeout( 'fsbFollow();', g_nFsbSpeed );
}
function offsetTop( elt )
{
	y = elt.offsetTop;
	for( var eltIter = elt.offsetParent; eltIter; eltIter = eltIter.offsetParent )
	{
	    y += eltIter.offsetTop;
	}
  	return y;
}
//-----------------------------------------------
//Form validation Provided by Robert Dominy 
//				http://javascript.about.com/library/scripts/blformvalidate.htm
//------------------------------------------------
//
// isEmailAddr() function:
//					Validates if entry entered into E-mail field
//					is an valid E-mail address 
//
function isEmailAddr(email)
{
  var result = false;
  var theStr = new String(email);
  var index = theStr.indexOf("@");
  if (index > 0)
  {
    var pindex = theStr.indexOf(".",index);
    if ((pindex > index+1) && (theStr.length > pindex+1))
	result = true;
  }
  return result;
}

//  allDigits() function:
//					Validates that numeric entries 
//					do not contain strings			
//
function allDigits(str)
{
	return inValidCharSet(str,"0123456789");
}

function inValidCharSet(str,charset)
{
	var result = true;

	// Note: doesn't use regular expressions to avoid early Mac browser bugs	
	for (var i=0;i<str.length;i++)
		if (charset.indexOf(str.substr(i,1))<0)
		{
			result = false;
			break;
		}
	
	return result;
}

// validRequired() function:
//					Validates that all required entries are 
//					entered
//
function validRequired(formField,fieldLabel)
{
	var result = true;
	
	if (formField.value == "")
	{
		alert('Please enter a value for the "' + fieldLabel +'" field.');
		formField.focus();
		result = false;
	}
	
	return result;
}

//
// validEmail() function:
//					Validates E-mail field
//				
//

function validEmail(formField,fieldLabel,required)
{
	var result = true;
	
	if (required && !validRequired(formField,fieldLabel))
		result = false;

	if (result && ((formField.value.length < 3) || !isEmailAddr(formField.value)) )
	{
		alert("Please enter a complete email address in the form: yourname@yourdomain.com");
		formField.focus();
		result = false;
	}
   
  return result;

}

//  validNum() function:
//					Validates that a field contains
//					only numbers							
//
function validNum(formField,fieldLabel,required)
{
	var result = true;

	if (required && !validRequired(formField,fieldLabel))
		result = false;
  
 	if (result)
 	{
 		if (!allDigits(formField.value))
 		{
 			alert('Please enter a number for the "' + fieldLabel +'" field.');
			formField.focus();		
			result = false;
		}
	} 
	
	return result;
}

//  validInt() function:
//					Validates that a field contains
//					only integers
//
function validInt(formField,fieldLabel,required)
{
	var result = true;

	if (required && !validRequired(formField,fieldLabel))
		result = false;
  
 	if (result)
 	{
 		var num = parseInt(formField.value,10);
 		if (isNaN(num))
 		{
 			alert('Please enter a number for the "' + fieldLabel +'" field.');
			formField.focus();		
			result = false;
		}
	} 
	
	return result;
}

//----------------------------------------------
// Provided by autom DHTML generator found at
// http://www.tamingthebeast.net/generators/dhtmlnavbar.htm
//----------------------------------------------
// The following controlss all elements of the 
// DHTML Navbars
//
function LmOver(elem, clr)
{elem.style.backgroundColor = clr;
elem.children.tags('A')[0].style.color = "#000033";
elem.style.cursor = 'hand'}

function LmOut(elem, clr)
{elem.style.backgroundColor = clr;
elem.children.tags('A')[0].style.color = "#808080";}

function LmDown(elem, clr)
{elem.style.backgroundColor = clr;
elem.children.tags('A')[0].style.color = "#000033";}

function LmUp(path)
{location.href = path;}
	
//----------------------------------------------------------------------------
//	Generated from http://www.superchargedsoftware.com online tools area, authors 
//	Svetlin Staev, Cort Stull, Copyright Shockwave Technologies llc. 
//	This comment must stay intact and untouched 
//	to use this code on your website,its free so, leave it here.
//-------------------------------------------------------------------------------
//	pop(URL) function:
//			Opens a desired HTML page with
//			pre-determined size and co-ordinates
//			with no resize or toolbars
//

function popup(URL, Height){
			window.open(URL,'','toolbar=no,statusbar=no,location=no,scrollbars=no,resizable=no,width=100,height=100,left=110,top=300')
}	

//---------------------------------------------
// All the following functions were created by
//	Jay Robbins.
//---------------------------------------------
// ShwFrm() function:
//			Contolls all elements witin the slide shows
//
function ShwFrm(name, page) {  
			switch(page){
				case 1:	//For Offers on Bookings & Prices page
					document.getElementById('Click').style.visibility  = 'hidden';
					document.getElementById('Diehard').style.visibility  = 'hidden';
					document.getElementById('Pred').style.visibility  = 'hidden';
					document.getElementById('Rambo').style.visibility  = 'hidden';
					document.getElementById('Term').style.visibility  = 'hidden';
					break;
				case 2: //For Maps on Getting There page 
					document.getElementById('Bedford').style.visibility  = 'hidden';
					document.getElementById('Northampton').style.visibility  = 'hidden';
					break;
			}
				document.getElementById(name).style.visibility  = 'visible';
	}


//
// checkBox()function:
//					Controlls all element on Infomation Pack Form for
//					Selecting between Post or Email 
//
function checkBox(id, _y) { 
    if(check[id] == false) //if a value is not true, use this rather than == false, 'cos the first time no value will be set and it will be undefined, not true or false 
        {
		document.getElementById('imgCheck' + _y).src = "Images/Rollover/RadioOff.gif";
		document.getElementById('inputCheck' + _y).value = false;   
        document.getElementById('imgCheck' + id).src = "Images/Rollover/RadioOn.gif"; 
        document.getElementById('inputCheck' + id).value = true; 
        check[id] = true; 
		check[_y] = false;
		if (id == 1){ //Change form fields to accept only E-mail entry
			document.getElementById('Fname').style.backgroundColor = "white";
			document.getElementById('Fname').disabled = false;
			document.getElementById('Lname').style.backgroundColor = "white";
			document.getElementById('lname').disabled = false;
			document.getElementById('Line1').style.backgroundColor = "white";
			document.getElementById('Line1').disabled = false;
			document.getElementById('Line2').style.backgroundColor = "white";
			document.getElementById('Line2').disabled = false;
			document.getElementById('County').style.backgroundColor = "white";
			document.getElementById('County').disabled = false;
			document.getElementById('Pst').style.backgroundColor = "white";
			document.getElementById('Pst').disabled = false;
			document.getElementById('EMail').style.backgroundColor = "#cccccc";
			document.getElementById('EMail').disabled = true;
		}else{ //Change form fields to accept all Post entries
			document.getElementById('Fname').style.backgroundColor = "#cccccc";
			document.getElementById('Fname').disabled = true;
			document.getElementById('Lname').style.backgroundColor = "#cccccc";
			document.getElementById('lname').disabled = true;
			document.getElementById('Line1').style.backgroundColor = "#cccccc";
			document.getElementById('Line1').disabled = true;
			document.getElementById('Line2').style.backgroundColor = "#cccccc";
			document.getElementById('Line2').disabled = true;
			document.getElementById('County').style.backgroundColor = "#cccccc";
			document.getElementById('County').disabled = true;
			document.getElementById('Pst').style.backgroundColor = "#cccccc";
			document.getElementById('Pst').disabled = true;
			document.getElementById('Email').style.backgroundColor = "white";
			document.getElementById('Email').disabled = false;
		}
     } 
}

//
//animate() function:
//				Controlls animation for prices images on 
//				Home Page
//
var count=0;
function animate() {
		if (count == 0){ 
			document.getElementById('Prices').src = "Images/Rollover/PricesOn.gif";
			count =1;
			setTimeout("animate()", 500);
		}else{
			document.getElementById('Prices').src = "Images/Rollover/PricesOff.gif";
			count =0;
			setTimeout("animate()", 2000);
		}
				
}		



