function slideSwitch() {
	var $nextdot = ($('#slideControls li.active').next().length > 0) ? $('#slideControls li.active').next() : $('#slideControls li:first');
	$('#slideControls li.active').removeClass('active');
	$nextdot.addClass('active');	
	
	var $next = ($('#slides li.active').next().length > 0) ? $('#slides li.active').next() : $('#slides li:first');
	$('#slides li.active').removeClass('active').hide();
	$next.css({opacity: 0})
	.addClass('active')
	.animate({opacity: 1}, 600);
}

$(document).ready(function(){
	$.fn.pause = function(duration){
		$(this).animate({dummy: 1}, duration);
		return this;
	};
	
	t = setInterval("slideSwitch()", 4500);
	$('#slideshow').hover(function(){
		window.clearInterval(t);
	}, function(){
		window.clearInterval(t);
		t = setInterval("slideSwitch()", 6500);
	});
	
	//form input focus/blur
	$("input[@type=password], input[@type=text], textarea").focus(function() {
		val = $(this).attr('def');
		if ($(this).val() == val) $(this).val('');
		$(this).blur(function(){
			if ($(this).val() == '') $(this).val(val);
		});
	});
	
	if ($('#gallery-pg').length > 0) $('.gallery a').lightBox();
	
	//contact submit
	$('#contactForm .form-submit').click(function(){
		if (!$('#fname').val() || $('#fname').val() == "Full Name"){
			alert('Please enter your name');
			$('#fname')[0].focus();
			return false;
		} if ($('#fphone').val() == "Phone Number"){
			alert('Please enter your phone number');
			$('#fphone')[0].focus();
			return false;
		} else if ($('#fphone').val().length < 8 || isNaN($('#fphone').val().charAt(0))){
			alert('Please enter a valid phone number');
			$('#fphone')[0].focus();
			return false;
		}
		if (!$('#fmessage').val() || $('#fmessage').val() ==  "Message"){
			alert('Please enter your message');
			$('#fmessage')[0].focus();
			return false;
		}
	});
});
