// JavaScript Document
	
jQuery('#hero').cycle({ 
	fx:     'scrollVert'
});

jQuery(document).ready(function($){
																
	$("a[rel='gallery']").colorbox();
	
	$("#nav-one").dropmenu({});
	
	$('#tabs-menu li').click(function() {
		$('#tabs-menu li').removeClass("active");
		$(this).addClass("active");
		
		if($(this).text() == 'Latest News') {
			$('.tab-content-events').hide();
			$('.tab-content-news').show();
		}
		else {
			$('.tab-content-events').show();
			$('.tab-content-news').hide();
		}
	});
	
	
		$('#of_contact_form #name').focus(function() {   
				if ($.trim(this.value) == this.defaultValue){   
						this.value = '';   
				}   
		});  

		$('#of_contact_form #name').blur(function() {   
				if ($.trim(this.value) == ''){   
						this.value = (this.defaultValue ? this.defaultValue : '');   
				}   
		});
		
		$('#of_contact_form #message').focus(function() {   
				if ($.trim(this.value) == this.defaultValue){   
						this.value = '';   
				}   
		});  

		$('#of_contact_form #message').blur(function() {   
				if ($.trim(this.value) == ''){   
						this.value = (this.defaultValue ? this.defaultValue : '');   
				}   
		});  
		
		$('#of_contact_form #email').focus(function() {   
				if ($.trim(this.value) == this.defaultValue){   
						this.value = '';   
				}   
		});  

		$('#of_contact_form #email').blur(function() {   
				if ($.trim(this.value) == ''){   
						this.value = (this.defaultValue ? this.defaultValue : '');   
				}   
		});  
						

    $.validator.addMethod("defaultInvalid", function(value, element) { 
     switch (element.name) { 
      case "name":
       if (element.value == "Your Name") 
          return false; 
			 else
			 	return true;
			break;

      case "message":
       if (element.value == "Your Message") 
          return false; 
			 else
			 	return true;
			break;

     } 
    });

//------------------------------------------------------------------------
		$("#of_contact_form").validate({
			rules: {
					name: { defaultInvalid: true },
					email: { required: true, email: true },
					message: { defaultInvalid: true }
					},
					
			messages: {
					name: "",
					email: "",
					message: ""
					},

 			submitHandler: function(form) {
					var form = this;
            		var fdata = 'name=' + $('#of_contact_form #name').val() +
								'&email=' + $('#of_contact_form #email').val() +
								'&message=' + $('#of_contact_form #message').val() +
								'&ts=' +  $('#of_contact_form #sugar').val() ;
								//alert(fdata);

					$.ajax({
							url: '_p/send_message.php',
							data: fdata,
                        	type: 'post',
                        	success: function (html) { 
									$('#of_contact_form #name').val('');  
									$('#of_contact_form #email').val('');
									$('#of_contact_form #message').val('');
									$('#thanks').hide();
									$('#thanks').html(html);
									$('#of_contact_form').fadeOut('normal', function(){ 
												$('#thanks').fadeIn('normal');
												}); } 
							 //,error: function (html, code) { alert( html + ' -> ' + code); }
                    		});

 					} // submit handler
			}); // validate
	


//------------------------------------------------------------------------

}); // end doc ready


