// JavaScript Document


var mImg = 4;
var cImg = 0, iId;

                function image_change() {

                                $('.rotator_image img').each(function(){

                                                if ($(this).is(':visible')) $(this).fadeOut(2000);

                                });

                                if (cImg==(mImg-1)) cImg = -1;

                                cImg++;

                                var ci = 0;

                                var clicked = cImg;

                                $('.rotator_image img').each(function(){

                                                if (clicked==ci) $(this).fadeIn(2000);

                                                ci++;

                                });

                }

                setInterval('image_change();',4000);  
				
				
$(function(){ 
		$('.email').click(function(){
		if($('#contact_form').is(':hidden')){
			$('#contact_form').slideDown();}
		else {$('#contact_form').slideUp();}
								   });	
		
		$('#email_submit').click(function(){
										  var email  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
										  
		if ($('#form_name').attr('value')=='Name') {
			alert('You must enter your name');
			$('#form_name').focus();
			return false;
		}
		if (!$('#form_email').attr('value').match(email)) {
			alert('You must enter your email address');
			$('#form_email').focus();
			return false;
		}
		if ($('#form_phone').attr('value')=='Phone') {
			alert('You must enter your Phone Number');
			$('#form_phone').focus();
			return false;
		}
		if ($('#form_message').val()=='Message') {
			alert('You must enter a message');
			$('#form_message').focus();
			return false;
		}
										  
										  var data = {name:$('#form_name').attr('value'),email:$('#form_email').attr('value'),phone:$('#form_phone').attr('value'), message:$('#form_message').val()};
		$.post('contact.php',data,function(){alert('Email successfully sent.');$('#contact_form').stop(true,true).slideUp();});
								  });
});



$(function(){
	$('#contact_form form input:text').events({
		focus: function(){ if(this.value == this.defaultValue) this.value = "" },
		blur: function(){ if(this.value == "") this.value = this.defaultValue; }
	});
	$('#contact_form form textarea').events({
		focus: function(){ if(this.value == this.defaultValue) this.value = "" },
		blur: function(){ if(this.value == "") this.value = this.defaultValue; }
	});
});

jQuery.fn.events = function(o){
    for (var i in o) {
        this.bind(i, o[i]);
    }
    return this;
}

