$(document).ready(function() {
	
$('#sendrequest').submit(function () {		
		
		//Get the data from all the fields
	var gjuha = $('input[name=gj]');
	var gj=gjuha.val();
		
		var firstname=$('input[name=firstname]');
		var lastname=$('input[name=lastname]');
		var email=$('input[name=email]');
		var phone=$('input[name=phone]');
		var adresa=$('input[name=adresa]');
		var city=$('input[name=city]');
		var country=$('input[name=country]');
		var zipcode=$('input[name=zipcode]');
		
		var foo=$('input[name=foo[input]]');
		
		
		if (firstname.val()=='') {
			
			if(gj="gj1"){alert('Kujdes! Duhet te plotesoni te gjitha fushat.');}else{alert('Attention! All fields mus be field.');}
			return false;
		} 
		if (lastname.val()=='') {
			
			if(gj="gj1"){alert('Kujdes! Duhet te plotesoni te gjitha fushat.');}else{alert('Attention! All fields mus be field.');}
			return false;
		} 
		
		if (email.val()=='') {
			if(gj="gj1"){alert('Kujdes! Duhet te plotesoni te gjitha fushat.');}else{alert('Attention! All fields mus be field.');}
			return false;
		} 
		if(!isValidEmailAddress(email.val())){
			if(gj="gj1"){alert('Kujdes! Duhet adresa email nuk eshte nje adrese e vlefshme.');}else{alert('Attention! Email address is not valid.');}
			return false;
		} 
		
		if (phone.val()=='') {
			
			if(gj="gj1"){alert('Kujdes! Duhet te plotesoni te gjitha fushat.');}else{alert('Attention! All fields mus be field.');}
			return false;
		}
		if (adresa.val()=='') {
			
			if(gj="gj1"){alert('Kujdes! Duhet te plotesoni te gjitha fushat.');}else{alert('Attention! All fields mus be field.');}
			return false;
		} 
		if (city.val()=='') {
			
			if(gj="gj1"){alert('Kujdes! Duhet te plotesoni te gjitha fushat.');}else{alert('Attention! All fields mus be field.');}
			return false;
		}
		if (country.val()=='') {
			
			if(gj="gj1"){alert('Kujdes! Duhet te plotesoni te gjitha fushat.');}else{alert('Attention! All fields mus be field.');}
			return false;
		} 
		if (zipcode.val()=='') {
			
			if(gj="gj1"){alert('Kujdes! Duhet te plotesoni te gjitha fushat.');}else{alert('Attention! All fields mus be field.');}
			return false;
		} 
		
		if (foo.val()=='') {
			if(gj="gj1"){alert('Kodi i pasakte.');}else{alert('Attention! All fields mus be field.');}
			return false;}
		
		
	});
return false;
});

function isValidEmailAddress(emailAddress) {
	var pattern = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i);
	return pattern.test(emailAddress);
	}
