// wait for the DOM to be loaded 
   $(document).ready(function() { 
   
   
$('img').each(function(){

  var src = $(this).attr("src");
  $(this).attr("src", src.replace("https://www.eurolineperformance.com/wp-content/themes/euroline/timthumb/timthumb.php?", "http://www.eurolineperformance.com/wp-content/themes/euroline/timthumb/timthumb.php?"));
});

   	
   	
       // bind form using ajaxForm 
		$('.error').hide();
	    $('#requestingform').ajaxForm({ 
			beforeSubmit: validate,
	        // target identifies the element(s) to update with the server response 
	        target: '#eurolineform', 
	        // success identifies the function to invoke when the server response 
	        // has been received; here we apply a fade-in effect to the new content 
	        success: function() { 
	            $('#eurolineform').fadeIn('slow');
				Cufon.refresh();
	        } 
	    });
	
	
		var showSearch='<a class="thepopup2" href="#">Show Contact/Request information</a>';
		var hideSearch='<a class="thepopup2" href="#">Hide Contact/Request information</a>';
		
		var is_visible = true;
		$('#contactform').slideToggle(500);;
		$('.requestinfo').html( ''+showSearch+'');
		$('.requestinfo').show();
			
		$('.requestinfo').click(function() {
			is_visible = !is_visible;
			$(this).html( (!is_visible) ? hideSearch : showSearch);
			$('#contactform').slideToggle(500);
			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);
	}

	function validate(formData, jqForm, options) { 
	    var namevalue = $('input[name=name]').fieldValue(); 
	    var humanvalue = $('input[name=human]').fieldValue(); 
	    var telvalue = $('input[name=telephone]').fieldValue(); 
	    var emailvalue = $('input[name=email]').fieldValue();
	    var subjectvalue = $('SELECT[name=usedsubject]').fieldValue();

		if (namevalue == "") {
		      $("label#name_error").show();
		      $("input#name").focus();
		      return false;
		}
		if (humanvalue == "") {
		      $("label#human_error").show();
		      $("input#human").focus();
		      return false;
		}
		
		// phone Validation
		// if (telvalue == "") {
		//	      $("label#tel_error").show();
		//	      $("input#tel").focus();
		//	      return false;
		//}

		// email Validation
		
		if (emailvalue == "") {		
			  				$("label#email_error2").hide();
			$("label#email_error").show();
	    	$("input#email").focus();
	    	return false;
		}else{
			if (isValidEmailAddress(emailvalue)) {
 				$("label#email_error2").hide();
				$("label#email_error").hide();
			}else{
				$("label#email_error").hide();
		    	$("label#email_error2").show();
		    	$("input#email").focus();
		    	return false;
		 }}
		
		// subject Validation
		if (subjectvalue == "---------- Select ----------") {
			      $("label#subject_error").show();
			      $("input#usedsubject").focus();
			      return false;
		}
		
		
		
	}

