var options = { path: '/', expires: 50 }; // cookie options = path and expires in 50 days


jQuery(document).keydown( function( e ) {
	if( e.which == 27) {  // escape, close box
		jQuery('.dark').hide();
		jQuery('.floater').hide();
		jQuery.cookie('floater', 'shown', options);
	}
}); 

var t;

jQuery(document).ready(function() {
								
	//	alert ("sss");						
	if(jQuery.cookie('floater')=='shown'){
	}else{
		t = setTimeout(function(){
			jQuery('.dark').show();
			jQuery('.floater').show();
		},1000);
		jQuery('.floater_close').click(function() {
			jQuery('.dark').hide();
			jQuery('.floater').hide();
			jQuery.cookie('floater', 'shown', options);
		});
		

		/*
		jQuery('#floaterbutton').click(function() {
			//alert ("sss");			
			jQuery('.dark').hide();
			jQuery('.floater').hide();
			jQuery.cookie('floater', 'shown', options);
			var dataString = 'email=' + email ;
  			alert (dataString);
			//return false;
		});
		*/
		
	};
	$('#nlform').submit(function() {
		   var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;

			var email = $("input#nlemail").val(); 
			  if(reg.test(email) == false) {
   				  alert(unescape("Bitte geben Sie eine g%FCltige E-Mail-Adresse ein."));
			      return false;
			   }
			
			
			var affiliate = $("input#affiliate").val(); 
			var bmOptinSource = $("input#bmOptinSource").val();
			var optin = $("input#optin").val();
			var dataString = 'email=' + email + '&affiliate=' + affiliate + '&bmOptinSource=' + bmOptinSource+ '&optin=' + optin   ;
  			//alert (dataString);
			jQuery('.dark').hide();
			jQuery('.floater').hide();
			jQuery.cookie('floater', 'shown', options);
			$.ajax({
				type: "POST",
				url: "inc/process.php",
				data: dataString,
				success: function() {
						/*$('#nlform').html("<div id='message'></div>");
						$('#message').html("<h2>Contact Form Submitted!</h2>")
						.append("<p>We will be in touch soon.</p>")
						.hide()
						.fadeIn(1500, function() {
						$('#message').append("<img id='checkmark' src='images/check.png' />");
					
					});
							*/
				}
			});
		  return false;
	});
	
	/////////////////////
	//jQuery('.floater').show();
//	jQuery('.dark').hide();
//	jQuery('.floater').hide()
	/////////////////////
								

});


