function validateEmail(str) {	
	var at	="@"
	var dot="."
	var lat=str.indexOf(at)
	var lstr=str.length
	var ldot=str.indexOf(dot)
	if (str.indexOf(at)==-1){
	   alert(INVALID_EMAIL_ADDRESS)
	   return false
	}

	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
	   alert(INVALID_EMAIL_ADDRESS)
	   return false
	}

	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
	    alert(INVALID_EMAIL_ADDRESS)
	    return false
	}

	 if (str.indexOf(at,(lat+1))!=-1){
	    alert(INVALID_EMAIL_ADDRESS)
	    return false
	 }

	 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
	    alert(INVALID_EMAIL_ADDRESS)
	    return false
	 }

	 if (str.indexOf(dot,(lat+2))==-1){
	    alert(INVALID_EMAIL_ADDRESS)
	    return false
	 }
	
	 if (str.indexOf(" ")!=-1){
	    alert(INVALID_EMAIL_ADDRESS)
	    return false
	 }

	 return true					
}

function expandChildMenu(parentId){	
	if($("#" + parentId + " + ul").is(":visible")){
		$("#" + parentId + " + ul").slideUp("slow");
	}else{
		$("#" + parentId + " + ul").slideDown("slow");
	}
}

function changeSectionColour(){	
	$(document).ready(function () {
		$("h1,h2,h3,h4, .introPara").css("color", "#FF6600");		
		$("#website #leftContent2").addClass("design");
		//$("#website #leftContent2 #inlineSubMenu.inlineSubMenu").addClass("design");
		//$("#website #leftContent2 #inlineSubMenu.inlineSubMenu").attr("class", "design");
		
		$("#leftContent2 h3").addClass("design");		
	});	
}

function setupMiromanagerGallery(){
	$(document).ready(function () {
		$(function() {
			$(".gallery a.lightbox").lightBox({fixedNavigation:true}); // Select all links that contains lightbox in the attribute rel			
		});
	});
}
function setupHealthCheckForm () {
	$(document).ready(function() {
		$("a#healthCheckButton").click(function(){
			$("div#healthCheckFormContainer").animate({
				height: "510px"
			})
			.animate({
				height: "510px"
			}, "slow");
			$("div#healthCheckButtonContainer").css("display", "none");
			$("div#onlineForm").css("display", "block");
			$("div#healthCheckCloseButtonContainer").css("display", "block");
			$("div#healthCheckFormTitle").css("display", "block");
			$("div#healthCheckFormContainer").css("padding", "20px");
			$("div#healthCheckFormContainer").css("border", "1px solid #3399FF");			
		});	
		
		$("a#healthCheckCloseButton").click(function(){
			$("div#healthCheckFormContainer").animate({
				height: "0px"
			}, "slow");
			$("div#healthCheckFormContainer").animate({
				border: "0px"
			}, "slow");
			$("div#healthCheckCloseButtonContainer").css("display", "none");			
			$("div#healthCheckButtonContainer").css("display", "block");
			$("div#healthCheckFormTitle").css("display", "none");
			$("div#healthCheckFormContainer").css("padding", "0");			
			$("div#onlineForm").css("display", "none");			
		}	   
	 );			
	});
}
function openHealthCheckForm () {
	$(document).ready(function() {					
		$("div#healthCheckFormContainer").animate({
			height: "510px"
		})
		.animate({
			height: "510px"
		}, "slow");
		$("div#healthCheckButtonContainer").css("display", "none");
		$("div#onlineForm").css("display", "block");
		$("div#healthCheckCloseButtonContainer").css("display", "block");
		$("div#healthCheckFormTitle").css("display", "block");
		$("div#healthCheckFormContainer").css("padding", "20px")
		$("div#healthCheckFormContainer").css("border", "1px solid #3399FF")
		$("a#healthCheckCloseButton").click(function(){
	 		$("div#healthCheckFormContainer").animate({
				height: "0px"
			}, "slow");
			$("div#healthCheckFormContainer").animate({
				border: "0px"
			}, "slow");
	   		$("div#healthCheckCloseButtonContainer").css("display", "none");
			$("div#healthCheckButtonContainer").css("display", "block");
			$("div#healthCheckFormTitle").css("display", "none");
			$("div#healthCheckFormContainer").css("padding", "0");
			$("div#onlineForm").css("display", "none");			
	  }	   
	 );		
	});
}

function setupHomePage(){
	$(document).ready(function() {
		$("div.homeBox.callsToAction a img").mouseover(function() {
			var srcImg = $(this).attr("src");
			srcImg = srcImg.replace(".gif", "-on.gif");
			$(this).attr("src", srcImg);
		});
		$("div.homeBox.callsToAction a img").mouseout(function() {
			var srcImg = $(this).attr("src");			
			srcImg = srcImg.replace("-on.gif", ".gif");
			$(this).attr("src", srcImg);
		});
	});
}