// JavaScript Document


jQuery(document).ready(function() {
	jQuery('#mycarousel').jcarousel({
		auto: 3,
		wrap: 'circular'
	});
	
	$('#openme').hide();
});
jQuery.fn.openMenu = function(id) {
    var box = document.getElementById('a'+id);
	if(box.style.display == "none") {
		$('#a'+id).slideDown(400);
		$(this[0]).removeClass('p_expand');
		$(this[0]).addClass('p_close');
	} else if(box.style.display == "block") {
		$('#a'+id).slideUp(400);
		$(this[0]).removeClass('p_close');
		$(this[0]).addClass('p_expand');
	} else {
		$('#a'+id).slideUp(400);
		$(this[0]).removeClass('p_close');
		$(this[0]).addClass('p_expand');
	}
};
jQuery.fn.openeventMenu = function(id) {
    var box = document.getElementById('a'+id);
	if(box.style.display == "none") {
		$('#a'+id).slideDown(400);
		$(this[0]).removeClass('expand');
		$(this[0]).addClass('close');
	} else if(box.style.display == "block") {
		$('#a'+id).slideUp(400);
		$(this[0]).removeClass('close');
		$(this[0]).addClass('expand');
	} else {
		$('#a'+id).slideUp(400);
		$(this[0]).removeClass('close');
		$(this[0]).addClass('expand');
	}
};
$(document).ready(function() {	
	$('.error').hide();
	//Enquiry Form 1
	$("form#enquiryform").submit(function() { 
	$('.error').hide();
     var name = $('#name').attr('value');
	 if (name == "") {
      $("span#form_error").show();
      $("input#name").focus();
      return false;
    }
	 var email  = $('#email').attr('value');  
	 $('.error').hide();
	 if (email == "") {
      $("span#form_error").show();
      $("input#email").focus();
      return false;
    }
	var telephone  = $('#telephone').attr('value');
	 $('.error').hide();
	 if (telephone == "")  {
      $("span#form_error").show();
      $("input#telephone").focus();
      return false;
    }
	var enquire  = $('#enquire').attr('value');
	 $('.error').hide();
	 if (enquire == "")  {
      $("span#form_error").show();
      $("input#enquire").focus();
      return false;
    }
    var robotest   = $('#robotest').attr('value');
     $.ajax({  
     type: "POST",  
     url: "includes/sendenquiryajax.php",  
     data: "name="+ name+ "& email="+ email+ "& telephone="+ telephone+ "& enquire="+ enquire+ "& robotest="+ robotest,  
     success: function(){  
	 			var url = "enquiry-submitted"; 
				$(location).attr('href',url);
             }  
         });  
     return false;  
     }); 
	 $('.error').hide(); 
 	
	$('.signupsuccess').hide();
	$('.signuperror').hide();
	//Call Back Form
	$("form#callbackform").submit(function() { 
	$('.signupsuccess').hide();
	$('.signuperror').hide();
     var name     = $('#signname').attr('value');
	 if (name == "") {
      $(".signuperror").show();
      $("input#signname").focus();
      return false;
    }
	var telephone  = $('#signtelephone').attr('value');
	 $('.signuperror').hide();
	 if (telephone == "") {
      $(".signuperror").show();
      $("input#signtelephone").focus();
      return false;
    }
	var type = $('#type').attr('value');
	var robotest = $('#robotest').attr('value');
     $.ajax({  
     type: "POST",  
     url: "includes/sendenquiryajax.php",  
     data: "name="+ name+ "& telephone="+ telephone+ "& type="+ type+ "& robotest="+ robotest,  
     success: function(){  
	 			var url = "call-back-request-submitted"; 
				$(location).attr('href',url); 
				_gaq.push(['_trackPageview', '/call-back-request-submitted']);
             }  
         });  
     return false;  
     }); 
	 
	$('.signupsuccess').hide();
	$('.signuperror').hide();
	//EVENT BOOKING
	$("form#bookevent").submit(function() { 
	$('.signupsuccess').hide();
	$('.signuperror').hide();
     var name     = $('#eventname').attr('value');
	 if (name == "") {
      $(".signuperror").show();
      $("input#eventname").focus();
      return false;
    }
	var telephone  = $('#eventtelephone').attr('value');
	 $('.signuperror').hide();
	 if (telephone == "") {
      $(".signuperror").show();
      $("input#eventtelephone").focus();
      return false;
    }
	var email  = $('#eventemail').attr('value');
	 $('.signuperror').hide();
	 if (email== "") {
      $(".signuperror").show();
      $("input#eventemail").focus();
      return false;
    }
	var type = $('#etype').attr('value');
	var eventtype = $('#eventtype').attr('value');
	var robotest = $('#robotest').attr('value');
     $.ajax({  
     type: "POST",  
     url: "includes/sendenquiryajax.php",  
     data: "name="+ name+ "&telephone="+ telephone+ "&email="+ email+ "&type="+ type+ "&robotest="+ robotest+ "&eventtype="+ eventtype,  
     success: function(){  
	 			var url = "enquiry-submitted"; 
				$(location).attr('href',url); 
             }  
         });  
     return false;  
     }); 
	
	//Call Back Form

	$(".joberror").hide();
	$("form#jobform").submit(function() {
	 
	$('.joberror').hide();
     var name     = $('#jobname').attr('value');
	 if (name == "") {
      $(".joberror").show();
      $("input#jobname").focus();
      return false;
    }
	var telephone  = $('#jobtelephone').attr('value');
	 $('.joberror').hide();
	 if (telephone == "") {
      $(".joberror").show();
      $("input#jobtelephone").focus();
      return false;
    }
	var email  = $('#jobemail').attr('value');
	 $('.joberror').hide();
	 if (email == "") {
      $(".joberror").show();
      $("input#jobemail").focus();
      return false;
    }
	var type = $('#type2').attr('value');
	var job = $('#jobtitle').attr('value');
	var robotest = $('#robotest').attr('value');
     $.ajax({  
     type: "POST",  
     url: "includes/sendenquiryajax.php",  
     data: "name="+ name+ "& telephone="+ telephone+ "& email="+ email+ "& job="+ job+ "& type="+ type+ "& robotest="+ robotest,  
     success: function(){  
	 			var url = "job-application-submitted"; 
				$(location).attr('href',url); 
             }  
         });  
     return false;  
     }); 
	 $('.joberror').hide();
	
});


matchColumns=function(){
	if(document.getElementById('leftcol')) {
		 if($('#leftcol').height() > $('#rightcol').height()) {
			 $('#rightcol').css({
     			 minHeight: $('#leftcol').height()
   			 });

		 }
	}
} 
$(document).ready(function() {
	  //Fancybox Options
	  $("#main_image").fancybox({
		  'titlePosition'		: 'inside',
		  'transitionIn'		: 'fade',
		  'transitionOut'		: 'fade',
		  'overlayColor'		: '#000',
		  'overlayOpacity'		: '0.3',
		  'width'				: '500',
		  'height'				: '200',
		  'margin'				: '50',
		  'padding'				: '2'  
	  }); 
	  /*$("#enlarge").fancybox({
		  'titlePosition'		: 'inside',
		  'transitionIn'		: 'fade',
		  'href'				: $('#hgallery1').attr('href'),
		  'transitionOut'		: 'fade',
		  'overlayColor'		: '#000',
		  'overlayOpacity'		: '0.3',
		  'width'				: '500',
		  'height'				: '200',
		  'margin'				: '50',
		  'padding'				: '2' 
	  });*/
	  	  $("#enlarge_gallery").fancybox({
		  'titlePosition'		: 'inside',
		  'transitionIn'		: 'fade',
		  'href'				: $('#main_event_image').attr('href'),
		  'transitionOut'		: 'fade',
		  'overlayColor'		: '#000',
		  'overlayOpacity'		: '0.3',
		  'width'				: '500',
		  'height'				: '200',
		  'margin'				: '50',
		  'padding'				: '2' 
	  });
	  $("#main_event_image").fancybox({
		  'titlePosition'		: 'inside',
		  'transitionIn'		: 'fade',
		  'transitionOut'		: 'fade',
		  'overlayColor'		: '#000',
		  'overlayOpacity'		: '0.3',
		  'width'				: '500',
		  'height'				: '200',
		  'margin'				: '50',
		  'padding'				: '2' 
	  });
	  $("#request_callback").fancybox({
			'titleShow'		:false,
			'autoScale' :false,
			'scrolling' :false,
			'transitionIn'		: 'none',
			'transitionOut'		: 'none',
			'margin'			: '0',
			'padding'			: '0',
			'overlayColor'		: '#000',
			'overlayOpacity'	: '0.4'
	});	
	  $(".apply_now").fancybox({
			'titleShow'		:false,
			'autoScale' :false,
			'scrolling' :false,
			'transitionIn'		: 'none',
			'transitionOut'		: 'none',
			'margin'			: '0',
			'padding'			: '0',
			'overlayColor'		: '#000',
			'overlayOpacity'	: '0.4'
	});	
	$("#book_event").fancybox({
			'titleShow'		:false,
			'autoScale' :false,
			'scrolling' :false,
			'transitionIn'		: 'none',
			'transitionOut'		: 'none',
			'margin'			: '0',
			'padding'			: '0',
			'overlayColor'		: '#000',
			'overlayOpacity'	: '0.4'
	});	
});
