// Change text based on hover
$(document).ready(function() {
$('#default-text').show();
$('#employers-text, #carers-text, #parents-text').hide();

$('a#parents').mouseover(function() {
	$('#parents-text').show();
	$('#default-text, #employers-text, #carers-text').hide();
});

$('a#employers').mouseover(function() {
	$('#employers-text').show();
	$('#default-text, #parents-text, #carers-text').hide();
});

$('a#carers').mouseover(function() {
	$('#carers-text').show();
	$('#default-text, #employers-text, #parents-text').hide();
});

// Login form show/hide, close button and submit button
$('#login form').hide();
  $('#login a.client_login').toggle(function() {
    $(this)
      .addClass('active')
      .next('form')
      .fadeIn('slow')
	;
  }, function() {
    $(this)
      .removeClass('active')
      .next('form')
      .fadeOut();
  });
  $('a.login-close').click(function() {
	 $('#login form')
      .prev('a')
      .click();
	 });
  $('#login form :submit').submit(function() {
    $(this)
      .parent()
      .prev('a')
      .click();
  });


//New Validation
	$('#homepage_enquiry').validate(
	{
		rules: {
			name: {required: true},
			enquirytb: {required: true},
		    tel: {required:'#email:blank'},
			email: {email:'#tel:blank'}
	},
		success: function(label) 
		{label.addClass('valid')},
		failure: function(flabel)
		{label.addClass('error')}
	});


// Recapcha pop up
	  $('#homepage_enquiry :button').click(function() {
		$('#homepage_enquiry :button').fadeOut('slow');	
		$('.recap').fadeIn('slow');
	  													})
		$('#homepage_enquiry a.recap-close').click(function() {
		$('.recap').fadeOut('slow');
		$('#homepage_enquiry :button').fadeIn('slow');	
															  });
});

		
// Rounded Corners
$(document).ready(function(){
	$('.rounded').corner("8px");
	$('.web-link').corner("5px");
	$('.purple-box-heading').corner("5px");
	$('.top').corner("10px top");
	$('.bot').corner("10px bottom");
	$('.footer').corner("10px top");
});

// Login

$(function() {
	$(".button").click(function() {
		// validate and process form
		// first hide any error messages
			$("#logintext").html("Checking...")		
			var username = $("input#username").val();
			var password = $("input#password").val();
			var dataString = 'user='+ username + '&amp;pass=' + password;			     
			var myRequest = $.getJSON("logmein.php", { user: username, pass: password }, function(json)
				{
					if(json.done == "done")
						{
						window.location = globalSiteLink+"vsl_payments/index.php";		
						} 
					else if(json.done == "no")
						{	
							$("#logintext").html("<p id='login-fail'>Incorrect details! Please try again.</p>");
						}
				});
		return false;
		});
});
