<!-- hide me 


//Central Javascript Include File


/*******************
Date Function 
Returns today's date
*******************/

function getDate()
{
	// Days
	var dayNames = new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")
	// Months
	var monthNames = new Array("January","February","March","April","May","June","July","August","September","October","November","December")
	var now = new Date()
	return(dayNames[now.getDay()] + " " + now.getDate() + " " + monthNames[now.getMonth()] + " " + now.getYear())
}


/*****************************************
This is the pop up window function.
With arguements for the URL, width, height
and whether or not to display scrollbars
*****************************************/

var s='no';
var popUpWindow = null;
var undefinedVariable;
var undefType = typeof undefinedVariable;

function pop(url,w,h,s){
   if (popUpWindow!=null) {
     var windowHasBeenClosed = (typeof popUpWindow.location == undefType ) ;
     if (!windowHasBeenClosed ){
     	 popUpWindow.close();
   	 }
   }
   settings="resizable=yes,toolbar=no,location=no,scrollbars=" + s + ", width=" + w + ",height=" + h + ",status=no";
   popUpWindow = open(url,"g", settings);

   if ( navigator.appVersion.indexOf("MSIE")==-1 ) {
     popUpWindow.resizeTo(w, h);
   }

}

	 



/***************************
login form function checks
something has been submitted
***************************/

function loginForm() 
{
	if (document.login.username.value == ''){ 
		alert("You must enter a valid username and password, or register with us") 
	}
	else { 
		document.login.submit() 
	}
}

/**************************
clears default login values
**************************/

function clearTxt()
{
	document.login.username.value=""
	document.login.password.value=""
}

/******************
Validation Routines
******************/

var emailregex = /^([0-9,a-z,A-Z]+)([.,_,-]([0-9,a-z,A-Z]+))*@([0-9,a-z,A-Z]+)([.,_,-]([0-9,a-z,A-Z]+))*\.[a-z]{2,4}$/i


/***********************
Email Address validation
***********************/

function validateEmail(field) 
{
	var email = field.value
	if (emailregex.test(email)){
		return true
	}
	else{
		alert("This is not a valid E-mail Address: "+email)
		field.focus()
		return false
	}
}

/*********************
Check for Empty Values
*********************/

function isEmpty(field)
{
	var val = field.value
	
	if ((val==null) || (val=="")){
		return true
	}
	else{
		return false
	}
} 

/***********************
Get Required Field Names
***********************/

function getRequired(str) 
{
	var strLength, fields
	strLength = str.length
	
	if (strLength==0){
		fields = ""
	}
	else{
		fields = str.split(",")
	}
	return fields
}


/******************************
Validate fields and send Form
if OK or display alert message
******************************/

//Arguements: form, field containing list of required fields, field for email validation
function validateForm(which, required, email) {

	var vals = getRequired(required.value)
	var n    = vals.length
	var e    = which.length
	var msg  = ""
	
	for(i=0;i<e;++i) {
		var ele = which.elements[i]
		for(x=0;x<n;++x) {
			var nme = vals[x]
			if ((ele.name == nme) && (isEmpty(ele))){
				msg += ("Field "+ele.name+" must not be left blank\n")
			}
		}
	}
	
	//Display Errors
	if (msg != ""){
		alert(msg)
		return false
	}
	
	//Check Email
	if(email!=null){
		if(!validateEmail(email)){
			return false
		}
	}
	
	return true
}

/*************
Deletion Alert
*************/ 

function deleteAlert(str) {
	if (confirm(str)) {
		return true
	}
	else return false	
}


/************************************
Function to empty another input field
************************************/

function emptyField(fieldId){
	fld = document.getElementById(fieldId);
	if(fld){
		fld.value = "";
	}
	
}


function popup(file) {
  window.open(file,"popup","height=500,width=640,menubar=no,location=no,scrollbars=auto,status=no,resize=yes");
}

function showSection(s) {
	
	// Hide all sections
	hide   = document.getElementById('desc');
	button = document.getElementById('desc_button');
	hide.className   = 'hide';
	button.className = 'show';
	
	hide   = document.getElementById('photos');
	button = document.getElementById('photos_button');
	hide.className   = 'hide';
	button.className = 'show';
	
	hide   = document.getElementById('virtual_tours');
	button = document.getElementById('virtual_tours_button');
	if (hide){
		hide.className   = 'hide';
		button.className = 'show';
	}
	
	hide   = document.getElementById('extra_details');
	button = document.getElementById('extra_details_button');
	hide.className   = 'hide';
	button.className = 'show';
	
	// Show selected section
	if (s=="all"){
		// Show Brochure
		show   = document.getElementById('desc');
		show.className       = 'showSection';
		show   = document.getElementById('extra_details');
		show.className       = 'showSection';
		
		//Print Page
		window.print();
	}
	else {
		show       = document.getElementById(s);
		showButton = document.getElementById(s+'_button');
		show.className       = 'showSection';
		showButton.className = 'menuOn';
	}
    
}

function moveForward(){
		pp = document.getElementById("photopointer");
		pp.value++;
		
		np = document.getElementById("numberofphotos");		
		
		// If it's not already visible show the 'previous' link
		tmp = document.getElementById("previousbutton");
		if (tmp.className == 'hide') tmp.className = 'show';
		
		// If last image then hide 'next' button
		if (pp.value == np.value){
			tmp = document.getElementById("nextbutton");
			if (tmp.className == 'show') tmp.className = 'hide';
		}
}

function moveBackward(){
		pp = document.getElementById("photopointer");
		pp.value--;

		// If it's not already visible show the 'next' link
		tmp = document.getElementById("nextbutton");
		if (tmp.className == 'hide') tmp.className = 'show';
		
		// If last image then hide 'previous' button
		if (pp.value == 1){
			tmp = document.getElementById("previousbutton");
			if (tmp.className == 'show') tmp.className = 'hide';
		}	
}

function changePhoto(way){
	
	strFiles     = document.getElementById("photofiles");
	strFiles	 = strFiles.value;
	strWidths    = document.getElementById("widths");
	strWidths	 = strWidths.value;
	strHeights   = document.getElementById("heights");
	strHeights   = strHeights.value;

    var photofiles   = new Array();
    var photowidths  = new Array();
    var photoheights = new Array();
    
	photofiles   = strFiles.split(/,/);
	photowidths  = strWidths.split(/,/);
	photoheights = strHeights.split(/,/);
		
	if (way=='forward'){
		moveForward();	
	}
	else {
		moveBackward();
	}
	
	tmp     = document.getElementById("photoFrame");
	pointer = document.getElementById("photopointer");
	pointer = pointer.value;
	pointer--;
	
	tmp.src    = "/images/dot.gif";
	tmp.width  = photowidths[pointer];
	tmp.height = photoheights[pointer];
	tmp.src    = photofiles[pointer];
	

}


// end hiding -->