$(function()
	{
		$("#facilitiesInclude_list>ul>li>a>span").wrap('<span class="darkBrown"><\/span>');
		
		//ajax_facilitiesInclude_gallery.php
		$('.facilitiesInclude_link').live('click', function()
			{ 
				$("#facilitiesInclude_img img").css("display","none");
				$("#facilitiesInclude_img").html(" ");
				/*
					.facilitiesInclude_gallery_link span.selected
						{
							font-weight:bold !important;
						}
				*/
				//alert(this.id);
				//alert("facilitiesInclude_link_"+this.rel);
				$('.facilitiesInclude_link').removeClass('fi_selected');
				$("#facilitiesInclude_link_"+this.rel).addClass('fi_selected');

				
				//alert(this.rel);
				//$('#addAJAXContentBox').load("ajax.php");
				$("#facilitiesInclude_img").css("background-image","url('images_new/facilitiesInclude/loading.gif')");
				$("#facilitiesInclude_img").html(" ");
				$("#facilitiesInclude_img").load("ajax_facilitiesInclude_gallery.php?section="+this.rel, function() 
					{
						$("#facilitiesInclude_img").css("background-image","url('images_new/spacer.gif')");
						//alert('Load was performed.');
					}
				);
				return false; 
			} 
		);		
		
		/*
		$(".facilitiesInclude_gallery_link").click(function()
			{
				//$('#add_articlecomment').load("ajax_comments.php");
				//$('#add_articlecomment').slideToggle('fast');
				//alert(this.rel);
				
				//$("#facilitiesInclude_img").css("background-color");
				$("#facilitiesInclude_img").css("background-image","url('images_new/facilitiesInclude/loading.gif')");

				$('#facilitiesInclude_img').load("ajax_facilitiesInclude_gallery.php");
				
				return false;
			}
		);
		*/
	}
);

/*
function pause(milliseconds) 
	{
		var dt = new Date();
		while ((new Date()) - dt <= milliseconds) {	 }
	}
function preStuff() 
	{
		alert('This is before the 3-second pause');
	}
function postStuff() 
	{
		alert('This is after the pause; it should have been paused for 3 seconds');
	}		
//<input type="button" onclick="javascript: preStuff(); pause(3000); postStuff();" value="Do a 3-second pause">
*/
function onBefore() 
	{
		//pause(2000);
		//var timeout = 1100;
		//$('#output').html("Scrolling image:<br>" + this.src);
		//$('#header_right h1').fadeOut('fast');
		//$('#header_right h2').fadeOut('fast');
		/*
		if ((this.alt == "header_01") || (this.alt == "header_03") || (this.alt == "header_05"))
			{
				$('#header_right h1').css("background-position","-130px 0px");
				$('#header_right h2').css("color","#000");
			}
		else if ((this.alt == "header_02") || (this.alt == "header_04"))
			{
				$('#header_right h1').css("background-position","-130px -54px");
				$('#header_right h2').css("color","#d4d0bd");
			}
		*/
	}
function onAfter()
	{
		//pause(500);
		//var timeout = 1100;
		//$('#output').html("Scroll complete for:<br>" + this.src);
		//.append('<h3>' + this.alt + '< /h3>');
		//alert(this.alt);
		//$('#header_right h1').fadeOut('fast');
		//$('#header_right h2').fadeOut('fast');
		//alert(this.id);
		if ((this.id == "header_01") || (this.id == "header_03") || (this.id == "header_05") || (this.id == "header_06") || (this.id == "header_07") || (this.id == "header_08"))
			{
				$('#header_right h1').css("background-position","-130px 0px");
				//$('#header_right h1').css("background-position-x","-130px");
				//$('#header_right h1').css("background-position-y","0px");
				$('#header_right h2').css("color","#000");
			}
		else if ((this.id == "header_02") || (this.id == "header_04"))
			{
				$('#header_right h1').css("background-position","-130px -54px");
				//$('#header_right h1').css("background-position-x","-130px");
				//$('#header_right h1').css("background-position-y","-54px");
				$('#header_right h2').css("color","#d4d0bd");
			}
		//$('#header_right h1').fadeIn('fast');
		//$('#header_right h2').fadeIn('fast');
		//alert(this.alt);
	}

function trim(stringToTrim)
	{
		return stringToTrim.replace(/^\s+|\s+$/g,"");
	}


$(document).ready(function() 
	{
		$('#header_img').cycle(
			{
				fx: 'fade', // choose your transition type, ex: fade, scrollUp, shuffle, etc...
				//before: onBefore,
				after: onAfter
				//timeout: 1100
			}
		);
		
		
		
		
		/*
		$("#registerForm textarea").blur(function()
			{
				text = jQuery.trim(this.value);
				document.getElementById(this.id).value = text;
			}
		);
		*/
		
		$("#contactus_form .required").blur(function()
			{
				text = jQuery.trim(this.value);
				if (this.id == "F_email")
					{
						for (i=0; i<=100; i++) { text = text.replace(" ", ""); }
						text = text.toLowerCase();
					}
				else
					{
						for (i=0; i<=100; i++) { text = text.replace("  ", " "); }
					}
				for (i=0; i<=100; i++) { text = text.replace("\n ", "\n"); }
				for (i=0; i<=100; i++) { text = text.replace("\n\n\n", "\n\n"); }
				
				document.getElementById(this.id).value = text;
				/*
				if (text == "")
					{
						document.getElementById(this.id+'_req').innerHTML = '(Required)';
					}
				else
					{
						document.getElementById(this.id+'_req').innerHTML = '';
					}
				*/
				return false;					
			}
		);
		
		/*
		$('.requirede').blur(function()
			{
				alert(this.value);
				//var value = document.getElementById(this.id).value;
				document.getElementById(this.id).value = trim(this.value);
			}
		);
		
		$('#contactus_form').submit(function()
			{
				//alert($('#F_name').value()+'123');
				//alert(document.getElementById("F_name").value);
				
				var F_name = trim(document.getElementById('F_name').value);
				var F_email = trim(document.getElementById('F_email').value);
				var F_message = trim(document.getElementById('F_message').value);
				
				//alert(F_name);
				//alert(F_email);
				//alert(F_message);
				
				if (F_name == "")
					{
						alert("Please enter your name.");
						document.getElementById('F_name').focus();
						return false;
					}
				if (F_email == "")
					{
						alert("Please enter your email address.");
						document.getElementById('F_email').focus();
						return false;
					}
				if (F_message == "")
					{
						alert("Please enter your message.");
						document.getElementById('F_message').focus();
						return false;
					}
				
				
				return false;
			}
		);
		*/
		
		
	}
);












