
     
$(document).ready(function() { 
	
	//var baseurl="http://joris.local/test/test.aspx?";
	var baseurl= "http://www.tomtommailer.com/ext.dll?";
	baseurl = baseurl + "ID=8q9EO8u_W6MH888Q&";
	
	// formulier homepage    
	$('form.registration.home').validate({
          onfocusout: false,
	  onkeyup: false,
	  onclick: false,	  
	  errorPlacement: function(error, element) {
	    $('form.registration.home').addClass('error');
	    element.parent().children('em').show();	       
	  },	  
	
          rules: {	    
	    mail: {
	      required: true,
	      email: true
	    },
	    agreed:{
	      required: true
	    }
	  }  	  

	});
	
	$('button.registration.home').click(function(e){     
			$('form.registration.home em').hide();
			$('form.registration.home').removeClass('error');
			
	        	//Check of het formulier valid is
	        	if($('form.registration.home').valid()){
	        		var url = baseurl;
	        		url = url + $('form.registration.home').formSerialize();
	        		//alert(url);	  	
			  	$.jsonp({  
			  		url: url,  
			  		callbackParameter: "jsoncallback",
			  		success: function (json, text){
							if (json.result=='OK'){
								$('.registration.home').hide();							
								$('.thankyou.registration.home').show();
								$('.thankyouerror.registration.home').hide();
							} else{	
								$('.registration.home').hide();							
								$('.thankyouerror.registration.home').show();
							}
						},
			  		error: function (json, text){
							$('.registration.home').hide();						
							$('.thankyouerror.registration.home').show();	
						}
					})
					
			}
     	});
	
	
	// formulier phonecheck 
	$('form.registration.phonecheck').validate({
	  onfocusout: false,
	  onkeyup: false,
	  onclick: false,	  
	  errorPlacement: function(error, element) {
	    $('form.registration.phonecheck').addClass('error');
	    element.parent().children('em').show();	       
	  },	  

	  rules: {	    
	    phonemodel:{
		required: true
	    },
	    phonebrand:{
		required: true
	    },
	    mail: {
	      required: true,
	      email: true
	    },
	    agreed:{
	      required: true
	    }
	  }  	  

	});

	$('button.registration.phonecheck').click(function(e){     
			$('form.registration.phonecheck em').hide();
			$('form.registration.phonecheck').removeClass('error');

			//Check of het formulier valid is
			if($('form.registration.phonecheck').valid()){
				
				
				var url = baseurl;
				url = url + $('form.registration.phonecheck').formSerialize();
				//alert(url);	  	
				$.jsonp({  
					url: url,  
					callbackParameter: "jsoncallback",
					success: function (json, text){
							if (json.result=='OK'){
								$('.registration.phonecheck').hide();							
								$('.thankyou.registration.phonecheck').show();
								$('.thankyouerror.registration.phonecheck').hide();
							} else{	
								$('.registration.phonecheck').hide();							
								$('.thankyouerror.registration.phonecheck').show();
							}
						},
					error: function (json, text){
							$('.registration.phonecheck').hide();						
							$('.thankyouerror.registration.phonecheck').show();	
						}
					})

			}
	});
     	
     	//formulier navigator check 
	$('form.registration.navcheck').validate({
	  onfocusout: false,
	  onkeyup: false,
	  onclick: false,	  
	  errorPlacement: function(error, element) {
	    $('form.registration.navcheck').addClass('error');
	    element.parent().children('em').show();	       
	  },	  

	  rules: {	    
	    
	    mail: {
	      required: true,
	      email: true
	    },
	    agreed:{
	      required: true
	    }
	  }  	  

	});

	$('button.registration.navcheck').click(function(e){   
			
			$('form.registration.navcheck em').hide();
			$('form.registration.navcheck').removeClass('error');

			//Check of het formulier valid is

			if($('form.registration.navcheck').valid()){
				
				$('form.registration.navcheck input[NAME="PHONEBRAND"]').val($("#device option:selected").html());
				$('form.registration.navcheck input[NAME="PHONEMODEL"]').val($("#device option:selected").html());
				$('form.registration.navcheck input[NAME="NAVIGATORVERSION"]').val($("#navigator option:selected").html());
				
				var url = baseurl;
				url = url + $('form.registration.navcheck').formSerialize();
				//alert(url);	  	
			  	
			  	$.jsonp({  
			  		url: url,  
			  		callbackParameter: "jsoncallback",
			  		success: function (json, text){
							if (json.result=='OK'){
								$('.registration.navcheck').hide();							
								$('.thankyou.registration.navcheck').show();
								$('.thankyou.error.registration.navcheck').hide();
							} else{	
								$('.registration.navcheck').hide();							
								$('.thankyou.error.registration.navcheck').show();
							}
						},
			  		error: function (json, text){
							$('.registration.navcheck').hide();						
							$('.thankyou.error.registration.navcheck').show();	
						}
					})
					
				
			}
	});

	
	
	
	
	
    
    
}); 


