// JavaScript Document

// image slide show

var browserName = navigator.appName;
var browserVer = parseInt(navigator.appVersion);
var browserOK = (((browserName == "Netscape") && (browserVer >= 3)) || 
	((browserName == "Microsoft Internet Explorer") && (browserVer >= 4)));

// URLs of images in slide show
var slideURL = Array("images/facilities/facilities.jpg", "images/facilities/facilities1.jpg", "images/facilities/facilities2.jpg", "images/facilities/facilities3.jpg", "images/facilities/facilities4.jpg", "images/facilities/facilities5.jpg", "images/facilities/facilities6.jpg");
// delay between slides (in milliseconds)
var slideDelay = 3000;
// Index of the current slide
var curSlide = -1;
// timeout id for the current setTimeout command
var curTimeout;

function showSlide() {
	if (browserOK) {
		// alert(slideURL.length);
		curSlide = ((curSlide + 1) % slideURL.length);
		// alert(curSlide);
		document.images["slideImg"].src = slideURL[curSlide];
		curTimeout = setTimeout("showSlide()", slideDelay);
	} else {
		// show an error message for older browsers
		alert("This page requires Netscape 3.0+ or IE 4.0+");
	}
}

// image slide show for Harbour Master

var browserName = navigator.appName;
var browserVer = parseInt(navigator.appVersion);
var browserOK = (((browserName == "Netscape") && (browserVer >= 3)) || 
	((browserName == "Microsoft Internet Explorer") && (browserVer >= 4)));

// URLs of images in slide show
var slideURLH = Array("images/harbourmaster/master.jpg", "images/harbourmaster/master3.jpg", "images/harbourmaster/master1.jpg", "images/harbourmaster/master2.jpg", "images/harbourmaster/master4.jpg", "images/harbourmaster/master7.jpg");
// delay between slides (in milliseconds)
var slideDelayH = 3000;
// Index of the current slide
var curSlideH = -1;
// timeout id for the current setTimeout command
var curTimeout;

function showSlideHarbour() {
	if (browserOK) {
		// alert(slideURLH.length);
		curSlideH = ((curSlideH + 1) % slideURLH.length);
		// alert(curSlideH);
		document.images["slideImgHarbour"].src = slideURLH[curSlideH];
		curTimeout = setTimeout("showSlideHarbour()", slideDelayH);
	} else {
		// show an error message for older browsers
		alert("This page requires Netscape 3.0+ or IE 4.0+");
	}
}



// This empties textarea in the contact and registration form

function empty() {
document.contact.question.value = ""
}

//Contact Validation


function validat(){
at = document.contact.email.value.indexOf("@");
dot = document.contact.email.value.indexOf(".");

	if (document.contact.firstname.value == ""){
		alert("Please enter your First Name")
			document.contact.firstname.focus();
		return false;
	}
	
	if (document.contact.lastname.value == ""){
		alert("Please enter your Surname")
			document.contact.lastname.focus();
		return false;
	}
	
	if (document.contact.contactmethod.value == "select"){
		alert("Please select your Preffered Method of Contact")
			document.contactmethod.lastname.focus();
		return false;
	}

	if (document.contact.contactmethod.value == "Email"){
		if (document.contact.email.value == "") {
				alert("You have request to be contact Email but did not enter an address in the box, please enter a Valid Email Address")	
				return false;
		}
		 else if(at==-1){
			alert("This is not a valid Email Address you are Missing the @ symbol")
				return false;
			}
		 else if(dot==-1){
			alert("This is not a valid Email Address you are missing the . symbol")
				return false;
			}
	}

	if (document.contact.contactmethod.value == "Mobile Phone"){ 
		if (document.contact.mobilenumber.value == "") {
				alert("You have requested to be contacted by Mobile Phone but did not enter a Phone Number in the box, please enter a Valid Mobile Phone Number")	
				return false;
		}
			
			var num = document.contact.mobilenumber.value;
			if(num.indexOf(" ")>0){
				
				telArr = num.split(' ');
				num="";
			
				for (i=0;i<telArr.length;i++){
					num=num+telArr[i];		
				}
			
				document.contact.mobilenumber.value = num;
			}
			
			if(isNaN(num) == true){
				alert("Your Mobile Number, must be a numeric value");
				return (false);
			}
		}

	if (document.contact.contactmethod.value == "Home Phone"){ 
		if (document.contact.homenumber.value == "") {
				alert("You have requested to be contacted by Home Phone but did not enter a Phone Number in the box, please enter a Valid Home Phone Number")	
				return false;
		}
			var num = document.contact.homenumber.value;
			if(num.indexOf(" ")>0){
				
				telArr = num.split(' ');
				num="";
			
				for (i=0;i<telArr.length;i++){
					num=num+telArr[i];		
				}
			
				document.contact.homenumber.value = num;
			}
			
			if(isNaN(num) == true){
				alert("your Home Number, must be a numeric value");
				return (false);
			}
		}

	if (document.contact.contactmethod.value == "Work Phone"){ 
		if (document.contact.worknumber.value == "") {
				alert("You have requested to be contacted by Work Phone but did not enter a Phone Number in the box, please enter a Valid Work Phone Number")	
				return false;
		}
			var num = document.contact.worknumber.value;
			if(num.indexOf(" ")>0){
				
				telArr = num.split(' ');
				num="";
			
				for (i=0;i<telArr.length;i++){
					num=num+telArr[i];		
				}
			
				document.contact.worknumber.value = num;
			}
			
			if(isNaN(num) == true){
				alert("your Work Number, must be a numeric value");
				return (false);
			}
		}

	if (document.contact.question.value == "Please enter your question or comment in here!" || document.contact.question.value == ""){
		alert("Please enter your Question")
			document.contact.question.focus();
		return false;
		}
	
	document.contact.submit();
	return true;
}



// warehouse images popup window

function displaypopupwarehouse(windo){
var popup=window.open(windo,"","width=500,height=400,left=0,top=0,scrollbars=yes,resizable=yess")
}

// Map location on contact page

function displaypopuplocation(windo){
var popup=window.open(windo,"","width=750,height=600,left=0,top=0,scrollbars=yes,resizable=yess")
}


// Get today's current date.

function dispDate(dateVal) {
DaystoAdd=dateVal
TodaysDate = new Date();
TodaysDay = new Array('Sunday', 'Monday', 'Tuesday','Wednesday', 'Thursday', 'Friday', 'Saturday');
TodaysMonth = new Array('January', 'February', 'March','April', 'May','June', 'July', 'August', 'September','October', 'November', 'December');
DaysinMonth = new Array('31', '28', '31', '30', '31', '30', '31', '31', '30', '31', '30', '31');
function LeapYearTest (Year) {
if (((Year % 400)==0) || (((Year % 100)!=0) && (Year % 4)==0)) {
return true;
}
else {
return false;
}
}
CurrentYear = TodaysDate.getYear();
if (CurrentYear < 2000) 
CurrentYear = CurrentYear + 1900;
currentMonth = TodaysDate.getMonth();
DayOffset = TodaysDate.getDay();
currentDay = TodaysDate.getDate();
month = TodaysMonth[currentMonth];
if (month == 'February') {
if (((CurrentYear % 4)==0) && ((CurrentYear % 100)!=0) || ((CurrentYear % 400)==0)) {
DaysinMonth[1] = 29;
}
else {
DaysinMonth[1] = 28;
}
}
days = DaysinMonth[currentMonth];
currentDay += DaystoAdd;
if (currentDay > days) {
if (currentMonth == 11) {
currentMonth = 0;
month = TodaysMonth[currentMonth];
CurrentYear = CurrentYear + 1
}
else {
month =
TodaysMonth[currentMonth+1];
}
currentDay = currentDay - days;
}
DayOffset += DaystoAdd;
function offsettheDate (offsetCurrentDay) {
if (offsetCurrentDay > 6) {
offsetCurrentDay -= 6;
DayOffset = TodaysDay[offsetCurrentDay-1];
offsettheDate(offsetCurrentDay-1);
}
else {
DayOffset = TodaysDay[offsetCurrentDay];
return true;
}
}
offsettheDate(DayOffset);TheDate = DayOffset + ', ';
TheDate += month + ' ';
TheDate += currentDay + ', '; 
if (CurrentYear<100) CurrentYear="19" + CurrentYear;
TheDate += CurrentYear;
document.write(' '+TheDate);
}


// Navigation

function determineLayer(number) {
	blanklayer();
	
	if (document.all) {
		document.all['layer'+number].style.display = '';
		document.all['top'+number].style.display = '';
	}
	else if (document.getElementById) {
		document.getElementById('layer'+number).style.display = "";
		document.getElementById('top'+number).style.display = "";
	}
}

function blanklayer() {
	if (document.all)
		document.all['first'].style.display = 'none';
	else if (document.getElementById)
		document.getElementById('first').style.display="none";

	for (i = 1; i < 7; i++) {
		if (document.all) {
			document.all['layer'+i].style.display="none";
			document.all['top'+i].style.display="none";
		}
		else if (document.getElementById) {
			document.getElementById('layer'+i).style.display="none";
			document.getElementById('top'+i).style.display="none";
		}
	}
}


function MM_jumpMenu(targ,topObj,restore){
  window.open (topObj.options[topObj.topectedIndex].value);
  if (restore) topObj.selectedIndex=0;
}





// Code for warehouse image slideshow

function next() {
a = 1
}

// Set the slideshow speed
var SlideShowSpeed = 3000;

// Set the duration for fade
var CrossFadeDuration = 2;

var photo = new Array();
var title = new Array();
var showHot = false;


photo[1]  = 'images/warehouse/warehouse(1).jpg';
photo[2]  = 'images/warehouse/warehouse(3).jpg';
photo[3]  = 'images/warehouse/warehouse(5).jpg';
photo[4]  = 'images/warehouse/warehouse(7).jpg';
photo[5]  = 'images/warehouse/warehouse(9).jpg';
photo[6]  = 'images/warehouse/warehouse(11).jpg';
photo[7]  = 'images/warehouse/warehouse(13).jpg';
photo[8]  = 'images/warehouse/warehouse(15).jpg';
photo[9]  = 'images/warehouse/warehouse(17).jpg';


title[1]  = "";
title[2]  = "";
title[3]  = "";
title[4]  = "";
title[5]  = "";
title[6]  = "";
title[7]  = "";
title[8]  = "";
title[9]  = "";


var tss;
var iss;
var jss = 0;
var pss = photo.length-1;

var preLoad = new Array();
for (iss = 1; iss < pss+1; iss++){
preLoad[iss] = new Image();
preLoad[iss].src = photo[iss];}

function control(how){
if (showHot){
if (how=="H") jss = 1;
if (how=="F") jss = jss + 1;
if (how=="B") jss = jss - 1;
if (jss > (pss)) jss=2;
if (jss < 1) jss = pss;
if (document.all){
document.images.photoBox.style.filter="blendTrans(duration=2)";
document.images.photoBox.style.filter="blendTrans(duration=CrossFadeDuration)";
document.images.photoBox.filters.blendTrans.Apply();}
document.images.photoBox.src = preLoad[jss].src;
if (document.getElementById) document.getElementById("titleBox").innerHTML= title[jss];
if (document.all) document.images.photoBox.filters.blendTrans.Play();
	}
}
