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_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 MM_findObj(n, d) { //v4.01
  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 && d.getElementById) x=d.getElementById(n); return x;
}

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];}
}

//news list
function open_menu(id){
	i = document.getElementById(id).style.display
	if(i == "none"){
		document.getElementById(id).style.display = "";		
	} else {
		document.getElementById(id).style.display = "none";		
	}
}
function launch_video(){
	window.open('http://www.ustigatewaterplay.co.uk/ustigate_video.php','Ustigate','width=770,height=700,resizable=yes,scrollbars=no,toolbar-no,location=no,directories=no,status=yes,menubar=no,copyhistory=no')
}

//news display
function change_event(id){
	document.getElementById('d1').style.display = "none";
	document.getElementById('d2').style.display = "none";
	document.getElementById('d3').style.display = "none";
	document.getElementById('d4').style.display = "none";
	document.getElementById('d5').style.display = "none";
	document.getElementById('d6').style.display = "none";
	
	document.getElementById(id).style.display = '';
}


/*************************************************************************/
/*
Simple Image Trail script- By JavaScriptKit.com
Visit http://www.javascriptkit.com for this script and more
This notice must stay intact
*/

var trailimage=["", 650, 450] //image path, plus width and height
var offsetfrommouse=[-680,-645] //image x,y offsets from cursor position in pixels. Enter 0,0 for no offset
var displayduration=0 //duration in seconds image should remain visible. 0 for always.
//<div id="trailimage_title" style="background-color:#FFFFFF;color:#333333;width:650px;padding:10px 10px 5px 10px;"><strong>Ustigate Water Play</strong></div><div id="trailimage_desc" style="background-color:#FFFFFF;color:#666666;width:650px;padding:0px 10px 10px 10px;font-size:10px;"><strong>Ustigate Water Play</strong></div>
if (document.getElementById || document.all)
document.write('<div id="trailimageid" style="position:absolute;visibility:visible;left:0px;top:0px;width:1px;height:1px"><div><img id=\"portfolio_image_popup\" src="'+trailimage[0]+'" style="border:2px solid #FFFFFF;" width="'+trailimage[1]+'px" height="'+trailimage[2]+'px"></div></div>')

function gettrailobj(){
if (document.getElementById)
return document.getElementById("trailimageid").style
else if (document.all)
return document.all.trailimagid.style
}

function truebody(){
return (!window.opera && document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function hidetrail(){
gettrailobj().visibility="hidden"
document.onmousemove=""
}

function followmouse(e){
var xcoord=offsetfrommouse[0]
var ycoord=offsetfrommouse[1]
if (typeof e != "undefined"){
xcoord+=e.pageX
ycoord+=e.pageY
}
else if (typeof window.event !="undefined"){
xcoord+=truebody().scrollLeft+event.clientX
ycoord+=truebody().scrollTop+event.clientY
}
var docwidth=document.all? truebody().scrollLeft+truebody().clientWidth : pageXOffset+window.innerWidth-15
var docheight=document.all? Math.max(truebody().scrollHeight, truebody().clientHeight) : Math.max(document.body.offsetHeight, window.innerHeight)
if (xcoord+trailimage[1]+3>docwidth || ycoord+trailimage[2]> docheight)
gettrailobj().display="none"
else 
gettrailobj().display=""
gettrailobj().left=xcoord+"px"
gettrailobj().top=ycoord+"px"
}
function showtrail(img,title,desc){
gettrailobj().visibility=""
//document.getElementById('trailimage_title').innerHTML = title;
//document.getElementById('trailimage_desc').innerHTML = desc;
document.getElementById('portfolio_image_popup').src = img;
document.onmousemove=followmouse
}
gettrailobj().visibility="hidden"
if (displayduration>0)
setTimeout("hidetrail()", displayduration*1000)


function change_dot(id){
	document.getElementById(id).src = "_include/img/FlashingDot.gif";	
}
function change_dot_bk(id){
	document.getElementById(id).src = "_include/img/dot.gif";	
}



function change_map_rollover(id){
	var timerID = 0;
	var tStart  = null;
	Stop();
	Reset();
	if(id==0){
		//document.getElementById('map_loader').style.display = "none";
		//document.getElementById('map_link').style.display = "none";
		//document.getElementById('map_rollover').style.display = "";
		//document.getElementById('map1').style.display = "";
		document.getElementById('main_map').src = "_include/img/FullMap.gif";	
	} else {
		document.getElementById('main_map').src = "_include/img/Rollover"+id+".gif";
		Start(id);
	}
	
}

var timerID = 0;
var tStart  = null;

function UpdateTimer(id) {
   if(timerID) {
      clearTimeout(timerID);
      clockID  = 0;
   }
   if(!tStart)
      tStart   = new Date();
   var   tDate = new Date();
   var   tDiff = tDate.getTime() - tStart.getTime();
   tDate.setTime(tDiff);
   if(tDate.getSeconds() == 1){
   	Reset();
	get_rollover(id,1);
   } else {
   	timerID = setTimeout("UpdateTimer("+id+")", 1000);   
   }
}
function Start(id) {
   tStart   = new Date();
   timerID  = setTimeout("UpdateTimer("+id+")", 1000);
}
function Stop() {
   if(timerID) {
      clearTimeout(timerID);
      timerID  = 0;
   }
   tStart = null;
}
function Reset() {
   tStart = null;
}


/**********************************************************
Phone Number Check
***********************************************************/

// Declaring required variables
var digits = "0123456789";
// non-digit characters which are allowed in phone numbers
var phoneNumberDelimiters = "()- ";
// characters which are allowed in international phone numbers
// (a leading + is OK)
var validWorldPhoneChars = phoneNumberDelimiters + "+";
// Minimum no of digits in an international phone no.
var minDigitsInIPhoneNumber = 10;

function isInteger(s)
{   var i;
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function stripCharsInBag(s, bag)
{   var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character isn't whitespace.
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function checkInternationalPhone(strPhone){
s=stripCharsInBag(strPhone,validWorldPhoneChars);
return (isInteger(s) && s.length >= minDigitsInIPhoneNumber);
}


function check_contact(){
	
	document.getElementById("name_error").style.display = "none";
	document.getElementById("company_error").style.display = "none";
	document.getElementById("address_error").style.display = "none";
	document.getElementById("postcode_error").style.display = "none";
	//document.getElementById("message_error").style.display = "none";
	document.getElementById("hear_error").style.display = "none";
	
	var t = true;
	var e = true;
	var name = document.contact.name.value;
	var company = document.contact.company.value;
	var address = document.contact.address.value;
	var postcode = document.contact.post.value;
	//var message = document.contact.message.value;
	var hear = document.contact.how.value;
	
	if(name == ""){
		document.getElementById("name_error").style.display = "";
	}
	if(company == ""){
		document.getElementById("company_error").style.display = "";
	}
	if(address == ""){
		document.getElementById("address_error").style.display = "";
	}
	if(postcode == ""){
		document.getElementById("postcode_error").style.display = "";
	}
	
	//if(message == ""){
	//	document.getElementById("message_error").style.display = "";
	//}
	if(document.contact.how.options[document.contact.how.selectedIndex].value=="N/A"){
		document.getElementById("hear_error").style.display = "";
	}
	
	if(name == "" || company == "" || address == "" || postcode == "" || t == false || e == false || document.contact.how.options[document.contact.how.selectedIndex].value=="N/A"){
		return false;
	} else {
		document.contact.submit();	
	}
	
		
}


function video_load(id){
	if(id=='mov'){
		document.getElementById('video').innerHTML = '<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="http://www.apple.com/qtactivex/qtplugin.cab" height="500" width="740"> 	<param name="src" value="clips/Splashpad Showreel.mov">	<param name="autoplay" value="true">	<param name="type" value="video/quicktime" height="500" width="740">	<embed src="clips/Splashpad Showreel.mov" height="500" width="740" autoplay="true" type="video/quicktime" pluginspage="http://www.apple.com/quicktime/download/">	</object>';	
	} else {
		document.getElementById('video').innerHTML = '<embed src="clips/Splashpad Showreel.wmv" width="740" height="500" AUTOPLAY="true" CONTROLLER="true" KIOSKMODE="true" style="background:#000000;"></embed>';	
	}
}
