/* Functions for Clubb Jeans and Fashion by Eldesign */
$(document).ready(function() {

//
// Winkels Section
//

// big photo slider
// $('#content').each(function() {
// 	var wrapper = this.id;
// 	$('#coverflow', this).localScroll( {
// 		target: $('#pcontent', this), 
// 		duration: 1500,
// 		hash: false,
// 		axis: 'yx',
// 		queue: true,
// 		onBefore: function(e, anchor, $target, $wrapper){ 
// 			$('.' + wrapper + 'scrolling').removeClass(wrapper + 'scrolling');
// 			$(this).addClass(wrapper + 'scrolling');
// 			this.blur();
// 		}
// 	} );
// 	$('li.sub p, li.sub li', this).localScroll( {
// 		target: $('#pcontent', this), 
// 		axis: 'xy',
// 		queue: true,
// 		hash: false,
// 		duration: 1500
// 	} );					
// } );

// thumb photo slider
// jQuery(function( $ ){
// 	$.easing.backout = function(x, t, b, c, d){
// 		var s=1.70158;
// 		return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b;
// 	};
// 				
// 	$('#coverflow').scrollShow({
// 		view:'#view',
// 		content:'#images',
// 		easing:'backout',
// 		wrappers:'simple',
// 		navigators:'.link[id]',
// 		navigationMode:'s',
// 		circular:true,
// 		start:0
// 	});
// });

//
// Maillist Section
//
	function validateEmail(){
		//testing regular expression
		var a = $("#email").val();
		var filter = /^[a-zA-Z0-9]+[a-zA-Z0-9_.-]+[a-zA-Z0-9_-]+@[a-zA-Z0-9]+[a-zA-Z0-9.-]+[a-zA-Z0-9]+.[a-z]{2,4}$/;
		//if it's valid email
		if(filter.test(a)){
			return true;
		}
		//if it's NOT valid
		else{
			return false;
		}
	}
	
	$('#mlist').submit(function(){
		var naam = $('#name').attr('value');
		var adres = $('#address').attr('value');
		var postcode = $('#postc').attr('value');
		var plaats = $('#wplaats').attr('value');
		var tel = $('#telnr').attr('value');
		var mail = $('#email').attr('value');
		var bmail = $('#bmail').attr('value');
		
		if(naam=='' || adres=='' || postcode=='' || plaats=='' || mail==''){
			$('#msg').text("Je hebt niet alles ingevuld").show('blind');
			return false;
		}
		if(naam<=4 || adres<=4 || postcode<7 || plaats<3){
			$('#msg').text("Je hebt niet alles goed ingevuld").show('blind');
			return false;
		}
		else if(validateEmail() == false){
			$('#msg').text("Je email klopt niet helemaal..").show('blind');
			return false;
		}
		else {
			$('#msg').hide("blind");
			$.ajax({
				url: 'contact.php',
				type: "POST",
				data: "naam="+naam+"&adres="+adres+"&postcode="+postcode+"&plaats="+plaats+"&tel="+tel+"&mail="+mail+"&bmail="+bmail+"&js=true",
				success: function(feedback){
					$('#msg').text(feedback).show('blind');
					$('#name, #address, #postc, #wplaats, #telnr, #email').val('');
					setTimeout('$("#msg").hide("blind")',10000);
				}
			});
			return false;
		}
	});
	


});
