	$(document).ready(function() {
		
		$('#name').watermark('Enter Name');
		$('#email').watermark('Enter Email');
		$('#telephone').watermark('Enter Telephone');
		$('#message').watermark('Enter Message');
		
		$('#name2').watermark('Enter Name');
		$('#email2').watermark('Enter Email');
		$('#telephone2').watermark('Enter Telephone');
		$('#message2').watermark('Enter Message');
		
		//book now
		$('#yourName').watermark('Name and Surname');
		$('#yourSurname').watermark('Surname');
		$('#address').watermark('Address');
		$('#tel').watermark('Telephone');
		$('#mob').watermark('Mob');
		$('#coo').watermark('Country of Origin');
		$('#hotel').watermark('Accommodation in Malta');
		$('#pcode').watermark('Post Code');
		
		
		$('#yourDOB').watermark('Date of Birth');
		$('#contactNumber').watermark('Contact Number');
		$('#yourEmail').watermark('Email');
		$('#certificationNumber').watermark('Certification Level');
		$('#cardNumber').watermark('Card Number');
		$('#stayInMalta').watermark('Date of Stay in Malta');
		$('#comments').watermark('Other Comments');
		//$('#blog').watermark('Type your message..'); //booknow
		
		//Set default open/close settings
		$('.acc_container').hide(); //Hide/close all containers
		$('.acc_trigger:first').addClass('active').next().show(); //Add "active" class to first trigger, then show/open the immediate next container

		//On Click
		$('.acc_trigger').click(function(){
			if( $(this).next().is(':hidden') ) { //If immediate next container is closed...
				$('.acc_trigger').removeClass('active').next().slideUp(); //Remove all "active" state and slide up the immediate next container
				$(this).toggleClass('active').next().slideDown(); //Add "active" state to clicked trigger and slide down the immediate next container
			}
			return false; //Prevent the browser jump to the link anchor
		});
		
		$('.tabs .tab-active').show(); // show default content
		$('.tabs .header ul a').click(function(){
			$('.tabs .header ul li').removeClass('active');
			$(this).parent().addClass('active'); // make clicked tab active
			$('.tabs .tab').hide(); // hide all content
			$('.tabs').find('#' + $(this).attr('rel')).show(); // and show content related to clicked tab
			return false;
		});
		
		$("a.lightview").fancybox({'overlayShow': true, overlayOpacity:0.9, width:600, height:400 });
		$("a.lightviewvideo").fancybox({'overlayShow': true, overlayOpacity:0.9, width:600, height:400, hideOnContentClick:false });
		
		$("a").focus(function () {
        	$(this).blur();
		});
		$("img.rollover").hover(function () {
			newsrc=$(this).attr('src').replace('.jpg','-over.jpg').replace('.png','-over.png');
        	$(this).attr('src',newsrc);
		},function () {
			newsrc=$(this).attr('src').replace('-over.jpg','.jpg').replace('-over.png','.png');
        	$(this).attr('src',newsrc);
		});
		
		$('.accordion .head').click(function() {
			$(this).next().toggle();
			return false;
		}).next().hide();
		
		$('.accordion .head').click(function() {
			$(this).next().toggle('slow');
			return false;
		}).next().hide();
		
	});
	
	function sendEmail() {
		$('#sendbutton').val('sending...');
		$('#sendbutton').attr("disabled","true");
		$.post('contact-form.php?r='+Math.random(),{
			v_name: $('#name').val(),
			v_email: $('#email').val(),
			v_telephone: $('#telephone').val(),
			v_message: $('#message').val()
		},
		function (data) {
			$('#contactForm').html("");
			$('#sendStatus').html("<br /><p>Your message has been sent, we will reply as soon as possible.<br /><br />Thank you,<br />Water Colours</p>");
			$('#sendbutton').val('Send Message');
			$('#sendbutton').attr("disabled",false);
		}
		);
		return false;
	}
	
	function sendEmailtwo() {
		$('#sendbutton').val('sending...');
		$('#sendbutton').attr("disabled","true");
		$.post('contact-form2.php?r='+Math.random(),{
			v_name2: $('#name2').val(),
			v_email2: $('#email2').val(),
			v_telephone2: $('#telephone2').val(),
			v_message2: $('#message2').val()
		},
		function (data) {
			$('#contactFormbottom').html("");
			$('#sendStatusbottom').html("<br /><p>Your message has been sent, we will reply as soon as possible.<br /><br />Thank you,<br />Water Colours</p>");
			$('#sendbuttonbottom').val('Send Message');
			$('#sendbuttonbottom').attr("disabled",false);
		}
		);
		return false;
	}
	
	//	booking	
	function sendBookNow() {
		if(validateEmail($('#yourEmail').val()) == true && $('#yourName').val() != "") {
			$('#sendbutton').val('sending...');
			$('#sendbutton').attr("disabled","true");
			$.post('booknow-form.php?r='+Math.random(),{
				servicelist: $('#test').val(),
				sproduct: $('#product').val(),
				sproduct2: $('#itemname').val(),
				item_price: $('#selectprice').val(),
				your_name: $('#yourName').val(),
				your_email: $('#yourEmail').val(),
				address: $('#address').val(),
				mob: $('#mob').val(),
				tel: $('#tel').val(),
				pcode: $('#pcode').val(),
				coo: $('#coo').val(),
				hotel: $('#yourEmail').val(),
				your_comments: $('#comments').val()
			},
			function (data) {
				$('#contactFormbottom').html("");
				$('#sendStatusbooking').html("<br /><p>Your Booking has been sent, we will reply as soon as possible.<br /><br />Thank you,<br />Water Colours</p>");
				$('#sendbuttonbooking').val('Send Message');
				$('#sendbuttonbooking').attr("disabled",false);
			}
			);
			return false;
		}else{
			if(validateEmail($('#yourEmail').val()) == false){
				alert('Please corrent email field');
			}
			if($('#yourName').val() == ""){
				alert('Please corrent name field');
			}			
		}
	}
	
	function validateEmail($email) {
		var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
		if($email == ""){
			return false;
		}else{
			if( !emailReg.test( $email ) ) {
			return false;
			} else {
				return true;
			}
		}
		
	}
	
		
	function clickSub(thediv,div,image){
        $.each($('.'+div),function(){
            if(this.id==thediv){
                if(this.style.display=='none')
                {
                    $('#'+this.id).slideDown(700);
                    $('#'+image).show(700);
                    $('#'+'plus-'+this.id).hide(700)
                }
                else
                {
                    $('#'+this.id).slideUp(700);
                    $('#'+image).show(700);
                    $('#'+'minus-'+this.id).hide(700)
                }
            }else
            {
                $('#'+this.id).slideUp(700);
                $('#'+'minus-'+this.id).hide(700);
                $('#'+'plus-'+this.id).show(700);
            }

        });
	}
	
	function runvideo(videoid){
		$.fancybox({
			'padding'		: 0,
			'autoScale'		: false,
			'transitionIn'	: 'none',
			'transitionOut'	: 'none',
			'title'			: this.title,
			'width'		: 680,
			'height'		: 495,
			'href'			: 'http://www.youtube.com/v/'+videoid+'&autoplay=1',
			'type'			: 'swf',
			'swf'			: {
			   	 'wmode'		: 'transparent',
				'allowfullscreen'	: 'true'
			}
		});

		return false;
	}
	

