// START JQUERY
		    $(document).ready(function(){
		  	   //set to 0 to not use cookies, 1 to use them
		  	   var useCookie = '1';
		  	   if ($.cookie('neversplash2')){
		  	   	return false;
		  	   }
		  	   var count = $.cookie('splashcount');
		  	   count++;
		  	   $.cookie("splashcount", count, { expires: 7 });
		  	   
		  	   if ((count % 3) != 0){
		  	   		if(count != 1){
		  	   			return false;
		  	   		}
		  	   }
		  	   
		  	   
		 
			   if ((!$.cookie('splash')) || (useCookie == 0)){
			   	  $('body').append('<div id="modal"><div id="remote"></div></div>');
			   	  setTimeout(function(){
			   	  	   popModal();
					}, 30000);
				}
				$('#popoverlay').click(function(){
					popModal();
					return false;
				});
			   function popModal(){
					  var api = $('#modal').overlay({
					   		top: 144,
					   		expose: {
					   			color:'#fff',
					   			loadSpeed: 200,
						   		opacity: 0.5
						   	},
						   	api: true,
						   	onBeforeLoad: function() {
						   		$.get('form_wfg2.html',
						   			function(data){
						   				$('#remote').html(data);
						   				$('#submitit').click(function(){
	  										var email = $("#icpsignup :input[name=fields_email]").val();
	  										var re = /^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/;
	  										if (!email.match(re)){
	  											alert("Please check that your email is in the correct format");
	  											return false;
	  										}							
	  										$('.signupframe').hide();
	  										$('#required').hide();
	  										$('#SignUp').append('<p style="color:#fff;margin-left:50px;margin-top:80px;">Thank you. Your request has been submitted.</p>');
	  										
	  										$('#modal').fadeOut(5000);
	  										setTimeout(function(){ $('#icpsignup').submit(); }, 5000);
						   					return false;
						   				});
						   				return false;
						   			});
						   	},
						   	closeOnClick: true,
						   	api: true
						}).load();
						if (useCookie == 1){
						   	$.cookie("splash", "1", { expires: 1 });
						}
			   }
		  });

