$(document).ready(function(){

	//-------------------------------------------------------------------------------------------------
	//--- ORDERS --

	//order delivery
	if ($('#form-order-delivery').length > 0){ // check if element is on page
		$("#form-order-delivery").livequery(function(){
			$(this).validate({
				rules: {
					f_fullname: "required",
					f_phone: "required",
					//f_mobile: "required",
					f_email: {
						required: true,
						email: true
					},
					f_confirm_email: {
						required: true,
						email: true
					},
					f_bill_address1: "required",
					f_bill_town: "required",
					f_bill_county: "required",
					f_bill_postcode: "required",
					f_bill_country: "required"
				},
				messages: {
					f_fullname: "Please enter fullname.",
					f_phone: "Please enter phone.",
					//f_mobile: "Please enter mobile.",
					f_email: "Please enter a valid email address.",
					f_confirm_email: "Please enter a valid email address.",
					f_bill_address1: "Please enter billing address 1",
					f_bill_town: "Please enter billing town",
					f_bill_county: "Please enter billing county",
					f_bill_postcode: "Please enter billing postcode",
					f_bill_country: "Please enter billing country"					
				}
			});	
		});
	}// check if element is on page
	
	//--- ORDERS ---
	//-------------------------------------------------------------------------------------------------




	//if the livequery plugin is detected
	if(jQuery.fn.ajaxify){
		if($('#content-loading').length > 0 ){ // check if element is on page
			//alert("grove");
			$('#main #main-center-panel div.col-1').css({'position':'relative'});
			$('#main #main-center-panel #load-content').css({'position':'relative'});
			$('#content-loading').css({
			  'clear':'both',
			  'float':'left',
			  'width':'100%',
			  'text-align':'left',
			  //'position':'absolute',
			  'top':'0',
			  'left':'0',
			  'font-size':'1.3em'
			  });
			
			$('a.ajax').livequery(function(){
		  
				$(this).ajaxify({
					onStart:function(options){
						$('#content-loading').fadeIn('slow');
					},
					onError:function(options,data){			
						$('#content-loading').html("<p class='error'>Error: Couldn't open &quot;"+options.link+"&quot;.</p>");	
					},
					onSuccess:function(options,data){
						$('#content-loading').css('display','none');
					},
					onComplete:function(options){
						$('#content-loading').css('display','none');
					},
					target: '#load-content',
					loadHash:'attr:href',
					loading_txt:'Page loading...',
					loading_img:'/img/site/jquery/ajax-loader-2.gif',
					loading_target:'#content-loading'			
				});
			
			});	
		}
	}
	
	/* EMBED MEDIA */
	if(jQuery.fn.media){
		//set default player location
		$.fn.media.defaults.flvPlayer = '/css/skins/default/flash/mediaplayer.swf';
		//run media plugin on all a links with media class
		$('a.media').media();
	}
	
	
	if(jQuery.fn.showhide){
		//apply show hide plugin for use in gallery
		if($('a.showhide').length > 0 ){
			$('a.showhide').showhide({
				animate:true,
				event:'click',
				target:'#large_img',
				closer_img:'/img/site/buttons/btn-closer.gif',
				show_closer:true
			});
		}
	}
	
	
	//contact form
	if ($('#form-contact').length > 0){ // check if element is on page
		$("#form-contact").livequery(function(){
			$(this).validate({
				rules: {
					txt_firstname: "required",
					txt_surname: "required",
					txa_address: "required",
					txt_tel: "required",
					txt_email: {
						required: true,
						email: true
					},
					txa_message: "required"
				},
				messages: {
					txt_firstname: "Please enter your firstname.",
					txt_surname: "Please enter your surname.",
					txa_address: "Please enter your address.",
					txt_tel: "Please enter your telephone number.",
					txt_email: "Please enter a valid email address.",
					txa_message: "Please enter your message."
				}
			});
		});	
	}// check if element is on page
	



}); //jquery load

