if (document.images) {
	goodVersion = true;
} else {
	goodVersion = false;
}
	
// Begin Browser and DHTML detect	
	

isNS4 = (document.layers) ? true : false;
isIE4 = (document.all && !document.getElementById) ? true : false;
isIE5 = (document.all && document.getElementById) ? true : false;
isNS6 = (!document.all && document.getElementById) ? true : false;

if (isNS4) {
	var DHTMLversion = "NS4"
} else if (isIE4) {
	var DHTMLversion = "MSIE4"
} else if (isIE5) {
	var DHTMLversion = "MSIE5"
} else if (isNS6) {
	var DHTMLversion = "NS6"
} else {
	var DHTMLversion = "unknown"
}

//var myObject = document.all[ID].style

//alert("NS4: " + isNS4 + "\nIE4: " + isIE4 + "\nIE5:  " + isIE5 +"\nNS6: " + isNS6 + "\nDHTML Version: " + DHTMLversion)

	
var OSType = "Unknown";
var isWin = false;
var isMac = false;
if (navigator.userAgent.indexOf("Win", 0) > -1) {
	OSType = "Win";
	isWin = true;
} else if (navigator.userAgent.indexOf("Macintosh", 0) > -1) {
	OSType = "Mac";
	isMac = true;
}

function getImage(inputName, divTag) {
	//document.write("About to get Image: " + image_name +"<BR>");
	if ((divTag != null) && (DHTMLversion == "NS4")) {
		var myImage = document[divTag].document [inputName];
	} else {
		var myImage = document [inputName];
	}
	browserName = navigator.appName;
       browserVer = parseInt(navigator.appVersion);
       if (browserName == "Netscape" && browserVer == 3) {
		if (myImage.length) {
			return myImage[myImage.length-1];
		} else return myImage;
	} else {
		return myImage;
	}
}


function imageSwap(which, state, imageType, divTag) {
	// this script needs getImage function and Browser sniffer function
    if (goodVersion) {
	//var thisImage = document.images[which];
	if (divTag != null) {
		var thisImage = getImage(which, divTag);
	} else {
		var thisImage = getImage(which);
	}
	var thisImageSrc = thisImage.src;
	var imageName = thisImageSrc.substring(0,thisImageSrc.indexOf("_o"));
          if (state == 0) {
              thisImage.src = imageName + "_off." + imageType
          } else if (state == 1) {
              thisImage.src = imageName + "_over." + imageType
		   } else {
		       thisImage.src = imageName + "_on." + imageType
        	}
      }
  }
  
 function showHide(ID, state) {
	if (DHTMLversion != "Disabled") {
		if (DHTMLversion.indexOf("MSIE", 0) > -1) {
			if (state == 1){
				document.all[ID].style.visibility = "visible"
			} else {
				document.all[ID].style.visibility = "hidden"
			}
		} else if (DHTMLversion.indexOf("NS6", 0) > -1) {
			if (state == 1){
				document.getElementById(ID).style.visibility = "visible"
			} else {
				document.getElementById(ID).style.visibility = "hidden"
			}
		} else if (DHTMLversion.indexOf("NS4", 0) > -1) {
			if (state == 1) {
				document.layers[ID].visibility = "show";
			} else {
				document.layers[ID].visibility = "hide";
			}
		} else {
			//alert(ID)
			if (state == 1) {
				document.layers[ID].visibility = "show";
				//alert(document.layers[ID].visibility)
			} else {
				document.layers[ID].visibility = "hide";
				//alert(document.layers[ID].visibility)
			}
		}
		//alert("done")
	}
}

function sideNavOnOff(whichNav) {
	showHide("sideNav" + whichNav + "Off", 0)
	showHide("sideNav" + whichNav + "ON", 1)	
}

function preloadImages(filesToPreload) {
	SideImgs = new Array(filesToPreload)
	preloadImgs = new Array()
	for (i=0;i<preloadImgs.length;i++) {
		preloadImgs[i] = new Image()
		preloadImgs[i].src = "../images/side_nav/js_images/" + SideImgs[i]
	}
}
  
  
// eg: moveSmooth('NavOverlay', 0, 66, 20, null, 'document.layers[\'NavMenu\'].layers[\'NavOverlay\']')
// NSDOM is only needed if the layer to be moved is nested inside other DIVs

DivTimeoutIDs = new Array()
DivObjData = new Array()
DivNSDOM = new Array()

function moveSmooth(ID, finalX, finalY, totalFrames, callback, NSDOM) {
	//alert("Arguments:" + ID +" "+ finalX +" "+ finalY +" "+ totalFrames +" "+ callback +" "+ NSDOM)
	if (DHTMLversion != "Disabled") {
		//alert(DHTMLversion.indexOf("MSIE"))
		if (DHTMLversion.indexOf("MSIE") > -1) {
			var myObject = document.all[ID].style
		} else if (DHTMLversion.indexOf("NS6") > -1) {
			var myObject = document.getElementById(ID).style
		} else {
			if (DivNSDOM[ID] != null) {
				var myObject = DivNSDOM[ID]
			} else if (NSDOM != null) {
				var myObject = eval(NSDOM)
			} else {
				var myObject = document.layers[ID]
			}
			DivNSDOM[ID] = myObject
		}
		
		var nowX = parseInt(myObject.left)
		var nowY = parseInt(myObject.top)

		if (finalX != "tween") {
			// Object data needs initialization
			//alert("Initializing object data for ID " + ID)
			
			if (DivTimeoutIDs[ID] > 0) {
				clearTimeout(DivTimeoutIDs[ID])
			}
			
			var ObjData = new Array()
			var currFrame = 1
			ObjData["currFrame"] = currFrame
			ObjData["initialX"] = nowX
			ObjData["initialY"] = nowY
			ObjData["finalX"] = finalX
			ObjData["finalY"] = finalY
			if (OSType == "Mac") {
				// Macs are slow. Reduce number of frames
				ObjData["totalFrames"] = Math.round(totalFrames /2)
			} else {
				ObjData["totalFrames"] = totalFrames
			}
			ObjData["callback"] = callback
			
			DivObjData[ID] = ObjData
		} else {
			//alert("Loading data for ID " + ID)
			var ObjData = DivObjData[ID]
			ObjData["currFrame"] = ObjData["currFrame"] +1
		}
					
		var currFrame = ObjData["currFrame"]
		var initialX = ObjData["initialX"]
		var initialY = ObjData["initialY"]
		finalX = ObjData["finalX"]
		finalY = ObjData["finalY"]
		totalFrames = ObjData["totalFrames"]
	
		// alert("finalY: '" + finalY + "' finalX: '" + finalX + "'")
		//alert("Current Frame: " + ObjData["currFrame"])
	
		if (currFrame >= totalFrames) {
			var done = true
			myObject.left = finalX
			myObject.top = finalY
		} else {
			var done = false
			
			var frameFraction = currFrame / totalFrames
			//alert("frameFraction '" +frameFraction + "'")
			var frameRadians = frameFraction *1.5708
			//alert("frameRadians '" +frameRadians + "'")
			var frameFinalFraction = Math.sin(frameRadians)
			//alert("frameFinalFraction '" +frameFinalFraction + "'")
			
			var nextX = Math.round((finalX - initialX) *frameFinalFraction +initialX)
			var nextY = Math.round((finalY - initialY) *frameFinalFraction +initialY)
			
			//alert("Next position: " +nextX+ ", " +nextY)
			myObject.left = nextX
			myObject.top = nextY
		}
		
		if (done == false) {
			var callStr = 'moveSmooth("'+ ID +'", "tween")'
			if (DivTimeoutIDs[ID] > 0) {
				clearTimeout(DivTimeoutIDs[ID])
			}
			DivTimeoutIDs[ID] = window.setTimeout(callStr, 25)
		} else {
			if (DivTimeoutIDs[ID] > 0) {
				clearTimeout(DivTimeoutIDs[ID])
			}
			DivTimeoutIDs[ID] = 0
			if (ObjData["callback"] != null) {
				eval(ObjData["callback"])
			}
		}
	}
}

var ballTimeout = 0;


function sideNavOver(imgID, imgType, ballPosition, divTag) {
	//var imageID = "'" + imgID + "'";
	//var imageType = "'" + imgType + "'"
	//imageSwap(imgID, 1, imgType, divTag);
	clearTimeout(ballTimeout);
	moveSmooth('sideNavBall', 118, ballPosition, 10, null);
}

function sideNavOut(imgID, imgType, ballPosition, divTag) {
	//var imageID = "'" + imgID + "'";
	//var imageType = "'" + imgType + "'"
	//imageSwap(imgID, 0, imgType, divTag);
	myFunctionCall = "moveSmooth('sideNavBall', 118, " + ballPosition + ", 10, null)"
	ballTimeout=setTimeout(myFunctionCall, 1000);
}

function moveDiv(ID, finalLeft, finalTop) {
	if (DHTMLversion != "Disabled") {
		//alert(DHTMLversion.indexOf("MSIE"))
		if (DHTMLversion.indexOf("MSIE") > -1) {
			var myObject = document.all[ID].style
		} else if (DHTMLversion.indexOf("NS6") > -1) {
			var myObject = document.getElementById(ID).style
		} else {
			var myObject = document.layers[ID]
		}
		myObject.left = finalLeft
		myObject.top = finalTop
	}
}

function openWindow (url, name, widgets) {
	popupWin = window.open (url,name,widgets);
	// popupWin.focus();
}


function enableContactDetails (state) {
	document.getElementById('contactName').disabled = state
	document.getElementById('contactPhone').disabled = state
	document.getElementById('contactFax').disabled = state
}
	
	
function formCheck(formName, checkString) {
  //---------------------------------------------------------------------------------------
  //      Name:  formCheck()
  //   Purpose:  Return Errors if form check tests do not pass
  //     Usage:  -Ensure all HTML names and values have quotes around them.  Eg. name="city"
  //			 -To use form check use: onSubmit="JavaScript: return formCheck('nameOfForm','homePhone=true=phone')"
  //			 -Pass a string to the formCheck function containing the
  //	 	      ordered arguments: nameOfField=checkType=true=ErrorDisplayMessage
  //             -Seperate ordered arguments with an ampersand (&)
  //			 -If a field is optional then  don't include =true
  //			 -Example:
  //				Validate optional email field:
  //					email=email (will flag user only if an incorrect email entered)
  //				Validate a manditory email field:
  //					email=email=true (will flag if incorrect email or no value entered)
  //				Validate that a value has been typed into the fname field:
  //					fname=true
  // Check Type:    Description:
  // 1. true		Make sure a field has a value other than spaces
  // 2. false       Make sure a field is left blank with no spaces
  // 3. email		Validate proper email
  // 4. credit		Validate proper American Express, Visa, Master Card number
  // 5. code		Validate proper Postal Code or American Zip Code & reformat.
  // 6. image		Make sure a field contains a .jpg or .gif extention.
  // 7. phone		make sure an areacode + number is submitted and reformat.
  //
  // Other Functions:
  //    
  //---------------------------------------------------------------------------------------
  
  
  //---------------------------------------------------------------------------------------
  //Error codes to be displayed to the end user:
  //---------------------------------------------------------------------------------------
  var errorText = new Array();
  var errorTextCode;
  var errorExists = false;  
  
  //Field not filled in that should be filled in.
  	errorText[0] = "Check the following entries for omissions and errors:\n\n";
  //Email not the correct format.
  	errorText[1] = "-Please enter a valid email address.\n";
  //Credit Card format not correct.
    errorText[2] = "-Enter a valid credit card number.\n";
  //Uploaded file is not an image file:
    errorText[3] = "-Ensure that the file you are uploading\n  is an image file with a .gif or .jpg extention.\n";
  //Postal/Zip Code format not correct.
    errorText[4] = "-Enter a valid Postal/ZIP code.\n";
  //Phone number and area code not valid.
    errorText[5] = "-Enter Area Code and Phone Number (xxx.xxx.xxxx)\n  or leave the field blank if it is not manditory.";
  
  //---------------------------------------------------------------------------------------

  
  
  
  //Generate array or ordered commands
  var checkArray = checkString.split("&");
  var checkArrayLen = checkArray.length;
  
  //Declare variables
  var subCheckArray;
  var subCheckArrayLen;
  var fieldTrue;
  var fieldFalse;
  var listOfErrorFields= "";
  listOfErrorFields = listOfErrorFields + errorText[0];
 
  

  
  
  //If no array passed then return true;
  if (checkArray[0] != "no") {
	
	//loop through array:
	for (i = 0; i < checkArrayLen; i++){

   	    //alert("There Are: " + checkArrayLen + " elements in the checkArray");		
		
		//Create a new array for the ordered arguments within each CheckArrey element.
		subCheckArray = checkArray[i].split("=");
		subCheckArrayLen = subCheckArray.length;

		//----------------------------------------------
		//  STEP 1. Check for true or false argument   -
		//----------------------------------------------
		
		//set whether field is true or false to false to start off with
		var fieldTrue = false;
		var fieldFalse = false;
		var checkFormatting = false;
		var formatVarified = false;
		var formatLocation;
		var formatType = "";
		var testString = "";
		
  //---------------------------------------------------------------------------------------
		//Loop through subArray and check if field required, and if formatting is needed.
		//Fields that are not set to true but require formatting will only be checked
		//if a value has been entered.
  //---------------------------------------------------------------------------------------
		
		for (y = 0; y < subCheckArrayLen; y++) {
		  if (subCheckArray[y] == "true") {
		    fieldTrue = true;
		  } else if (subCheckArray[y] == "false") {
		    fieldFalse = true;
		  } else  if (subCheckArray[y] == "email" || subCheckArray[y] == "credit" || subCheckArray[y] == "code" || subCheckArray[y] == "date" || subCheckArray[y] == "image" || subCheckArray[y] == "phone") {
		  	checkFormatting = true;
			formatType = subCheckArray[y];
			//alert("Format Type: " + formatType);
		  } else {
		  	errorDisplayMsg = subCheckArray[y];
		  }
		 }

  //---------------------------------------------------------------------------------------
		  
		
		
  //---------------------------------------------------------------------------------------
  //  Get the value of the field being checked:
  //---------------------------------------------------------------------------------------
		  var fieldValue = getFormFieldValue(formName, subCheckArray[0]);
		  //alert("Form Name: " + formName + "\n Field Name: " + subCheckArray[0] + "\nValue of Field: " + fieldValue + "\nFormat Type: " + formatType);
		  
		//Determin if the form field meets true condition
		if (fieldTrue && fieldValue == "null") {
		   if (errorDisplayMsg == "") {
		  		listOfErrorFields = listOfErrorFields + "  - " + subCheckArray[0] + "\n";
			} else {
				listOfErrorFields = listOfErrorFields + "  - " + errorDisplayMsg + "\n";
			}
		   errorExists = true;
		}
		if (fieldValue != "null" && checkFormatting) {
			//-----------------------------------------------------------------------------
			//Check for various types of formatting:
			//-----------------------------------------------------------------------------
			if (formatType == "email") {
				formatVarified = varifyEmail(fieldValue);
				if (!formatVarified) {
					listOfErrorFields = listOfErrorFields + errorText[1] + "\n";
					errorExists = true;
				}
			}
			if (formatType == "credit") {
				cardType = validateCard(fieldValue);
				if (cardType == "unknownCard") {
					listOfErrorFields = listOfErrorFields + errorText[2] + "\n";
					errorExists = true;
				}
			}
			if (formatType == "code") {
				codeType = validateCode(fieldValue);
				if (codeType == "unknownCode") {
					listOfErrorFields = listOfErrorFields + errorText[4] + "\n";
					errorExists = true;
				}
				else {
				//Set the field value to the new improved formatted code
				eval("document." + formName + "." + subCheckArray[0] + ".value = codeType");
				}
			}
			if (formatType == "image") {
				if (fieldValue.indexOf(".gif") < 0 && fieldValue.indexOf(".jpg") < 0) {
					listOfErrorFields = listOfErrorFields + errorText[3] + "\n";
					errorExists = true;
				}

			}
			if (formatType == "phone") {
				//validate phone number
				phoneNumber = validatePhone(fieldValue);
				//alert("The phone number returned is: " + phoneNumber);
				if (phoneNumber == "unknownNumber") {
					listOfErrorFields = listOfErrorFields + errorText[5] + "\n";
					errorExists = true;
				}
				else {
					eval("document." + formName + "." + subCheckArray[0] + ".value = phoneNumber");
				}
			}
			
			
			
			//-----------------------------------------------------------------------------
		}
		  

	}
	//End loop through Array

  }
  //---------------------------------------------------------------------------------------  
  //Check to see if an error was detected, and display errors.
  //---------------------------------------------------------------------------------------
  if (errorExists) {
  	alert(listOfErrorFields);
	return false;
  }	
  return true
  //---------------------------------------------------------------------------------------
}


function validatePhone(number) {
	//Step 1 remove all non-numerical characters
	var validChr = "0123456789";
	var tempNumber = "";
	for (cn = 0; cn < number.length; cn++) {
		if (validChr.indexOf(number.charAt(cn)) > -1) {
			tempNumber = tempNumber + number.charAt(cn);
		}
	}
	number = tempNumber;
	
	//check to see if 10 digits long
	if (number.length != 10) {
		return "unknownNumber";
	}
	else {
	  number = "" + number.substr(0,3) + "" + "." + number.substr(3,3) + "." + number.substr(6);
	}
	return number;	

}


function validateCode(code) {
	//Validate postal code for M9B 3V3 or 90210-2030 or 90210 format:
	//if Valid returns formatted code
	//if Not Valid returns Null
	
	codeType = "unknownCode"
	alert("code: " + code);
	//Remove all spaces and - ( ) characters added to the number field
	var newCode = "";
	for (cp = 0; cp < code.length; cp++) {
		if (code.charAt(cp) != " " && code.charAt(cp) != "-" && code.charAt(cp) != "(" && code.charAt(cp) != ")" ) {
			newCode = newCode + code.charAt(cp);
		}
	}
	code = newCode.toUpperCase();
	alert("code: " + code);
	
	var validChrCan = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
	var validChrUS = "01234567890";
	
	//  Validate the Canadian Postal Code
	if (validChrCan.indexOf(code.charAt(0)) >= 0) {
		codeType = "can";
		alert("Valid Can Character! " + code);
		
		//Check to see if has 6 characters:
		if (code.length != 6) {
			return "unknownCode";
		}
		var position = 0;
		for (cc = 0; cc < code.length; cc = cc + 2) {
			if (validChrCan.indexOf(code.charAt(cc)) < 0 || validChrUS.indexOf(code.charAt(cc+1)) < 0) {
				 return "unknownCode";
				 alert("position: " + position + "," + cc + "  Current Character: " + code.charAt(0));
			}
		}
		codeType = code.substring(0,3) + " " + code.substr(3);
	
	}
	
	//  Validate the American Zip Code
	if (validChrUS.indexOf(code.charAt(0)) >= 0) {
		codeType = "us";
		alert("Valid US Character! " + code );
		
		//step one check all values are numbers
		for (cc = 0; cc < code.length; cc++) {
			if (validChrUS.indexOf(code.charAt(cc)) < 0) {
			  return "unknownCode";
			}
		}
		//step 2, check the length is either 5 or 9 characters
		if (code.length != 5 && code.length != 9) {
			return "unknownCode";
		}
		
		//format code properly
		if (code.length == 9) {
			codeType = code.substring(0,5) + "-" + code.substring(5);
		}
		else {
			codeType = code;
		}
		
		
	}

	return codeType;
	
}

function validateCard(cardNumber) {
	//Validate only for Master Card, Visa, and American Express
	//This function will determin the type of credit card and return the name of the card if it is validated
	//Otherwise "unknownCard" will be returned.
	
	var cardType = "unknownCard";
	var checkType = "";
	
	//Remove all spaces added to the number field
	var newCardNumber = "";
	for (cp = 0; cp < cardNumber.length; cp++) {
		if (cardNumber.charAt(cp) != " ") {
			newCardNumber = newCardNumber + cardNumber.charAt(cp)
		}
	}
	cardNumber = newCardNumber;
	
	
	if (cardNumber.charAt(0) == "5") {
		//Proceed with validation of a Master Card Number
		cardType = "MasterCard";

		if (cardNumber.length != 16) {
			alert (cardNumber.length + "  Card Number: " + cardNumber);
			return "unknownCard";
		}
		
		//Check for valid Master Card Prefix
		prefix = cardNumber.substring(0,2);
		if (prefix != 51 && prefix != 52 && prefix != 53 && prefix != 54 && prefix != 55) {
			alert("Card Prefix: " + prefix);
			return "unknownCard";
		} 

		//Check for MOD 10 Alogorhythm: (returns true or false)
		mod10 = checkMod10(cardNumber);
		if (!mod10) {
			return "unknownCard";
		}
	}


	if (cardNumber.charAt(0) == "4") {
		//Proceed with validation of a Visa Card Number
		cardType = "Visa";
		if (cardNumber.length != 16 && cardNumber.length != 13) {
			return "unknownCard";
		}
		
		//Check for Mod 10 Alogorhythm: (regurns true of false);
		mod10 = checkMod10(cardNumber);
		if (!mod10) {
			return "unknownCard";
		}
		
		
	}


	if (cardNumber.charAt(0) == "3") {
		//Proceed with validation of an American Express Card Number
		cardType = "AmericanExpress";
		
		prefix = cardNumber.substring(0,2);
		if (prefix != 34 && prefix != 37) {
			alert("Card Prefix: " + prefix);
			return "unknownCard";
		} 
		
		//Check length is 15;
		if (cardNumber.length != 15) {
			return "unknownCard";
		}
		
		//Check for Mod 10 Alogorhythm: (regurns true of false);
		mod10 = checkMod10(cardNumber);
		if (!mod10) {
			return "unknownCard";
		}

	}
	
	//If no errors nave caused a prior RETURN then return the cardType.
	return cardType;

}


function checkMod10(cardNumber) {
	var tempString = "";
	var position = 0;
	for (cm = cardNumber.length - 1; cm > -1; cm = cm - 1) {
		if (position == 0) {
			newValue = cardNumber.charAt(cm);
			position = 1;
		}
		else {
			newValue = 2 * cardNumber.charAt(cm);
			position = 0;
		}		
  		tempString = tempString + newValue;
	}
	alert("Double Value String: " + tempString);
	//Tally all characters in the string:
	var tally = 0;
	for (cm = 0; cm < tempString.length; cm++) {
	 tally = tally + eval(tempString.charAt(cm));
	}
	
	//Check to see if the last digit in the tally is a "0" so that Mod10 will be true;
	testString = "" + tally;
	zeroPosition = testString.length - 1;
	testCharacter = testString.charAt(zeroPosition);
	
	if (testCharacter == "0") {
		return true;
	}
	return false;
}

function varifyEmail(email) {
//email must be at least 6 characters
//@ must be in the second or greater position
//a . must be eight 2 or 3 positions from the string end.
// The following characters must not be present:  / > ! # ?

	emailOk = true;
	domain1 = email.length - 3;
	domain2 = email.length - 4;
	if (email.length < 6) {
		emailOk = false;
	}
	if (email.indexOf("@") < 1) {
		emailOk = false;
	}
	if (email.charAt(domain1) != "." && email.charAt(domain2) != ".") {
		emailOk = false;
	}
	if (email.indexOf("/") >= 0) {
		emailOk = false;
	}
	if (email.indexOf("!") >= 0) {
		emailOk = false;
	}
	if (email.indexOf("?") >= 0) {
		emailOk = false;
	}
	if (email.indexOf(">") >= 0) {
		emailOk = false;
	}
	if (emailOk) {
		return true;
	}
	else {
	 	return false;
	}
}


function getFormFieldValue(formName, fieldName) {
 //set formValue variable to either true, false, or some string value
 var formValue = "null";
 var formElementType = getElementType(formName, fieldName);

 
 //Get the number of elements in the form
 var numOfElements = eval("document." + formName + ".elements.length");
 //alert("Elements in Form: " + numOfElements)
 
 //Depending on element type check to see what the value is.
 if (formElementType == "text" || formElementType == "password" || formElementType == "file" || formElementType =="textarea") {
   formValue = eval("document." + formName + "." + fieldName + ".value");
   
   
   
   //alert("Form Name: " + formName + "\nField Name: " + fieldName + "\nForm Value: " + formValue);
   //determin if 0 length string
   //determin if longer string is only 'space characters'
   if (formValue.length == 0) {
     formValue = "null";
    }
	if (formValue.length >= 1) {
	 isBlankEntry = isBlankSpace(formValue);
	 if (isBlankEntry) {
	   formValue = "null";
	 }
	}
 }
 if (formElementType.indexOf("select") >= 0) {
 	isSelected = eval("document." + formName + "." + fieldName + ".selectedIndex");
      if (isSelected <= 0) {
	  formValue = "null";
	}
	else {
    	  formValue = eval("document." + formName + "." + fieldName + ".options[" + isSelected + "].value")
	}
	//If an element has been selected then loop through the form elements and get the value


 }
 if (formElementType == "radio") {
	//alert(fieldName + " Is a Radio Button " + numOfElements);
      //loop through form elements where name = formName and see if any are checked.
      for (a=0; a < numOfElements; a++) {
	  var elementName = eval("document." + formName + ".elements[" + a + "].name");
	  if (elementName == fieldName) {
	    //alert("Element Name: " + elementName);
	    if (eval("document." + formName + ".elements[" + a + "].checked")) {
		formValue = eval("document." + formName + ".elements[" + a + "].value")
	    }
        }
	}
 }
 if (formElementType == "checkbox") {
	//alert(fieldName + " Is a CheckBox " + numOfElements);
	//Loop through elements and if none checked return "null"
	//Otherwise return a comma delineated list of elements checked.
	formValue = "";
	var numChecked = 0;

      for (a=0; a < numOfElements; a++) {
	  var elementName = eval("document." + formName + ".elements[" + a + "].name");
	  if (elementName == fieldName) {
	    //alert("Element Name: " + elementName);
	    if (eval("document." + formName + ".elements[" + a + "].checked")) {
		formValue = formValue + eval("document." + formName + ".elements[" + a + "].value") + ","
		numChecked++;
	    }
        }
	}
	if (numChecked == 0) {
	  formValue = "null";
	}
	else {
	  var formValueChopAt = formValue.length - 1;
	  formValue = formValue.substring(0,formValueChopAt);
	}
 }

//Complete if there is a reason for testing the value of the submit button 
 if (formElementType == "submit") {
 }

  return formValue
}


function getElementType(formName, fieldName) {
 //alert("Getting Element Type for: " + fieldName)
 //loop through elements and get the number of the element with thie formName
 var formElementLen = eval("document." + formName + ".elements.length");
 var z = 0;

 for (u = 0; u < formElementLen; u++) {
   elementName = eval("document." + formName + ".elements[" + u + "].name");
   if (elementName == fieldName) {
     z = u
   }
 }
 elementType = eval("document." + formName + ".elements[" + z + "].type");
 
 return elementType
}



function isBlankSpace(formValue) {
	for (a=0; a < formValue.length; a++) {
	  var c = formValue.charAt(a);
	  //alert("Character(" + a + ") >" + c + "<");
	  if ((c != ' ') && (c != '\n') && (c != '/t')) return false;
	}
	return true;
}

// Ensure no https://
checkURLStart = "https://"
//checkURLStart = "http://redcliffdev."
if (location.href.substring(0,checkURLStart.length) == checkURLStart) {
	if ((location.href.indexOf("/admin")) == -1) {
		location.href = "http://" + location.href.substring(checkURLStart.length,location.href.length)
	}
}

//Script for home page DHTML

var linkTimeout = 0;

function showLinks(whichLinks) {
	//un-hide the relevant div tag
	
	//image swap the relevant ball to its over state
	clearTimeout(linkTimeout);
	imageSwap(whichLinks + 'Ball',1,'gif');
	imageSwap(whichLinks + 'Line',1,'gif');
	showHide(whichLinks + 'Links', 1);
	showHide(whichLinks + 'NavBall', 1);
}

function hideLinks(whichLinks) {
	functionCallString = "timedHideLinks('" + whichLinks + "')";
	linkTimeout=setTimeout(functionCallString, 2000);
}

function timedHideLinks(whichLinks) {
	//hide the relevant div tag
	
	showHide(whichLinks + 'Links', 0);
	showHide(whichLinks + 'NavBall', 0);
	
	//imageswap the relevant ball back to it's original state
	
	imageSwap(whichLinks + 'Ball',0,'gif');
	imageSwap(whichLinks + 'Line',0,'gif');
}

var homeBallTimeout = 0;

function homeNavOver(whichNav, whichItem, vBallPosition, ballPosition) {
	clearTimeout(homeBallTimeout);
	clearTimeout(linkTimeout);
	imageSwap(whichItem,1,'gif');
	moveSmooth(whichNav+'NavBall', vBallPosition, ballPosition, 10, null);
}

function homeNavOut(whichNav, whichItem, vBallPosition, ballPosition) {
	imageSwap(whichItem,0,'gif');
	myFunctionCall = "moveSmooth('" + whichNav + "NavBall', " + vBallPosition + ", " + ballPosition + ", 10, null)";
	homeBallTimeout=setTimeout(myFunctionCall, 350);
	hideLinks(whichNav);
}

var leasingSearchTimeout = 0;

function ShowLeasingSubNav(leasingSection, hideLeasingSection) {
	showHide(hideLeasingSection + 'DropDown', 0);
	clearTimeout(leasingSearchTimeout);
	showHide(leasingSection+'DropDown', 1);
}

function HideLeasingSubNav(leasingSection) {
	myFunctionCall = "showHide('" + leasingSection + "DropDown', 0)";
	leasingSearchTimeout=setTimeout(myFunctionCall, 350);
}




