$(document).ready(function() {
	
var pairs = $('.pair').size();
var currentpair = 1;

$("#nextservices div.active").live('click', function(){
	currentpair = currentpair+1;
	$("#preservices div").removeClass('active'); // clear them first
	$("#nextservices div").removeClass('active'); // clear them first
	$("#preservices div").addClass('active');
	if(currentpair != pairs){$("#nextservices div").addClass('active');}
	$("#servicesinner").animate({left: '-=474'}, 500);
});

$("#preservices div.active").live('click', function(){
	currentpair = currentpair-1;
	$("#preservices div").removeClass('active'); // clear them first
	$("#nextservices div").removeClass('active'); // clear them first
	$("#nextservices div").addClass('active');
	if(currentpair != 1){$("#preservices div").addClass('active');}
	$("#servicesinner").animate({left: '+=474' }, 500);
});


$(".homebox").click(function(){
	window.location = $(this).find("a").attr("href");
	return false;
});

$(".columnbox").click(function(){
	window.location = $(this).find("a").attr("href");
	return false;
});


$(".popup").click(function(){
	newwindow=window.open($(this).attr('href'),'Social','height=340,width=600');
	if (window.focus) {
		newwindow.focus();
	}
	return false;
});

$("#newsemail").click(function(){
		$("#newssubmit").animate({marginLeft:'290px'}, 500);
		$(this).animate({width:'180px'}, 500, function(){
			$(this).attr('value','');
		});
	});
	
	
$("#newsform").submit(function() {  
	  $.ajax({  
			type: "POST",  
			url: "/en/submit-newsletter.htm",  
			data: $("#newsform").serialize(),
			success: function(msg){
				$("#newsform").slideUp(400, function(){
					$("#newsform").html(msg).delay(400).slideDown(400);
			});
			}
		});	
	return false;
	});



$("#feedbacklink").click(function(){
		$("#feedbackholder").slideToggle(function(){
			$('html,body').animate({scrollTop: $("#feedbackholder").offset().top},300);
		});
		return false;
	});
	
	$(".lowerhomebox").click(function(){
		window.location = "/" + $(this).find("a").attr("href");
		return false;
	});
	
	$("#contactform").submit(function() {  
	   var  incomplete = false;
	   $(".required").each(function(index) {
	      if(!$(this).val()){
	         incomplete = true;
	      }
	   });
	  if(incomplete == false){
	  $.ajax({  
			type: "POST",  
			url: "/en/submit-form.htm",  
			data: $("#contactform").serialize(),
			success: function(msg){
				$("#contactform").slideUp(400, function(){
					$("#contactform").html(msg).delay(400).slideDown(400);
			});
			}
		});
	 }
	else{
		$("#formmessage").html("Please complete all the required form fields");
	}
	return false;
	});
	
	$("#feedbackform").submit(function() {  
	  $.ajax({  
			type: "POST",  
			url: "/en/submit-feedback.htm",  
			data: $("#feedbackform").serialize(),
			success: function(msg){
				$("#feedbackform").slideUp(400, function(){
					$("#feedbackform").html(msg).delay(400).slideDown(400);
			});
			}
		});	
	return false;
	});
	
	$("#downloadform").submit(function() {  
	  $.ajax({  
			type: "POST",  
			url: "/en/submit-download.htm",  
			data: $("#downloadform").serialize(),
			success: function(msg){
				$("#downloadformholder").slideUp(400, function(){
					$("#downloadformholder").html(msg).delay(400).slideDown(400);
			});
			}
		});	
	return false;
	});

});
