$(document).ready(function() {
$('.error').hide();
$('input.text-input').css({backgroundColor:"#FFFFFF"});
$('input.text-input').focus(function(){
$(this).css({backgroundColor:"#eee"});
});
$('input.text-input').blur(function(){
$(this).css({backgroundColor:"#FFFFFF"});
});

$(".agree").click(function() {
// validate and process form

// get the parent form of this anchor tag
var form = $(this).closest('form');

// add use it to select the child elements

/*
var firstname = $("input[name=firstname]").val();
if (firstname == "") {
$("label.firstname_error").show();
$("input.firstname").focus();
return false;
}
*/

var firstname = form.find("input[name=firstname]").val();
if (firstname == "") {
form.find("label.firstname_error").show();
form.find("input.firstname").focus();
return false;
}

var lastname = form.find("input[name=lastname]").val();
if (lastname == "") {
$("label.lastname_error").show();
$("input.lastname").focus();
return false;
}

var email = form.find("input[name=email]").val();
if (email == "") {
$("label.email_error").show();
$("input.email").focus();
return false;
}

var company = form.find("input[name=company]").val();
if (company == "") {
$("label.company_error").show();
$("input.company").focus();
return false;
}

var country = form.find("input[name=country]").val();
if (country == "") {
$("label.country_error").show();
$("input.country").focus();
return false;
}

var city = form.find("input[name=city]").val();
if (city == "") {
$("label.city_error").show();
$("input.city").focus();
return false;
}

var download = form.find("input[name=file]").val();

var dataString = 'firstname='+ firstname + '&lastname='+ lastname + '&email=' + email + '&company=' + company + '&country=' + country + '&city=' + city +'&download='+ download;

//alert (dataString);
//return false;

$.ajax({
type: "POST",
url: "/global/scripts/process.php",
data: dataString,
success: function() {
	$.unblockUI();
	window.location.href = download;
}
});
return false;
});
});

