$(document).ready(function(){
	
	//apply ui tabs
	if($('ul#service-tabs').length > 0 ){ // check if element is on page
		$('ul#service-tabs').tabs({ fx: { height: 'toggle', opacity: 'toggle' } });
	}
	
	if($('form div.input').length > 0 ){ // check if element is on page
		//apply form field effect
		$('form div.input').inputfocus({
			bgColourFocus:'#EFFCFF',
			bgColour:'#FFFFFF',			
			animate:true
		});
	}
	
	//custom validation rule - text only   5:     
	$.validator.addMethod("notLabelText",
			
		function(value, element) {
			//alert($(element).val());
			//alert($(element).attr('id'));
			//alert($('label[for=' + $(element).attr('id') + ']').text());
			var result = ($(element).val() == $('label[for=' + $(element).attr('id') + ']').text()) ? false : true;
			return result;
		} 		
	);
	
	if($('#FormContact').length > 0 ){ // check if element is on page
		
		
		$("#FormContact").validate({
			highlight: function(element, errorClass) {
				$(element).animate({
					opacity: 0.9
				}, 400, function () {
					$(element).css('background-color','#FBE3E4'); //red background for invalid data
					$(element).css('border-color','#FBC2C4'); //red border for invalid data
				});
			},
			unhighlight: function(element, errorClass) {
				$(element).animate({
					opacity: 1.0
				}, 400, function () {
					$(element).css('background-color','#E6EFC2'); //green background for valid data
					$(element).css('border-color','#C6D880'); //green border for valid data
				});
			},
			rules: {
				"data[FormContact][firstname]": {  
						required: true,  
						notLabelText: true            
				},
				"data[FormContact][surname]": {  
						required: true,  
						notLabelText: true            
				},
				"data[FormContact][email]": {
					required: true,
					email: true
				}
			},
			messages: {
				"data[FormContact][firstname]": "Please enter your firstname.",
				"data[FormContact][surname]": "Please enter your surname.",
				"data[FormContact][email]": "Please enter your email address."
			}
		});
	}

	if($('#FormSignup').length > 0 ){ // check if element is on page
		$("#FormSignup").validate({
			highlight: function(element, errorClass) {
				$(element).animate({
					opacity: 0.9
				}, 400, function () {
					$(element).css('background-color','#FBE3E4'); //red background for invalid data
					$(element).css('border-color','#FBC2C4'); //red border for invalid data
				});
			},
			unhighlight: function(element, errorClass) {
				$(element).animate({
					opacity: 1.0
				}, 400, function () {
					$(element).css('background-color','#E6EFC2'); //green background for valid data
					$(element).css('border-color','#C6D880'); //green border for valid data
				});
			},
			rules: {
				"data[FormSignup][email]": {
					required: true,
					email: true
				}
			},
			messages: {
				"data[FormSignup][email]" : "Please enter your email address."
			}
		});
	}
	
	if($('#FormAppointment').length > 0 ){ // check if element is on page
		$("#FormAppointment").validate({
			highlight: function(element, errorClass) {
				$(element).animate({
					opacity: 0.9
				}, 400, function () {
					$(element).css('background-color','#FBE3E4'); //red background for invalid data
					$(element).css('border-color','#FBC2C4'); //red border for invalid data
				});
			},
			unhighlight: function(element, errorClass) {
				$(element).animate({
					opacity: 1.0
				}, 400, function () {
					$(element).css('background-color','#E6EFC2'); //green background for valid data
					$(element).css('border-color','#C6D880'); //green border for valid data
				});
			},
			rules: {				
				"data[FormAppointment][name]":{  
						required: true,  
						notLabelText: true            
				},				
				"data[FormAppointment][tel]":{  
						required: true,  
						notLabelText: true            
				},
				"data[FormAppointment][email]":{
					required: true,
					email: true
				},				
				"data[FormAppointment][enquiry]":{  
						required: true,  
						notLabelText: true            
				}
			},
			messages: {				
				"data[FormAppointment][name]": "Please enter your name.",
				"data[FormAppointment][tel]": "Please enter your telephone number.",
				"data[FormAppointment][email]" : "Please enter your email address.",
				"data[FormAppointment][enquiry]": "Please enter your enquiry."
			}
		});
	}
	
	if($('#home #main-outer-wrapper #main #main-panel #main-panel-left #main-info h4.message').length > 0 ){ // check if element is on page
		$("#home #main-outer-wrapper #main #main-panel #main-panel-left #main-info h4.message").hide().css({top:'187px'}).slideToggle(2000).animate({top:'220px'},1000);
	}
});