	function setCookie (cookieName,cookieValue,cookiePath,cookieExpires)
			{
				cookieValue  = escape(cookieValue);
				if (cookieExpires == "")
				{
					var nowDate = new Date();
					nowDate.setMonth(nowDate.getMonth() + 3);
					cookieExpires = nowDate.toGMTString();
				}
				if(cookiePath != "")
				{
					cookiePath = ";Path=" + cookiePath;
				}
				document.cookie = cookieName + "=" + cookieValue + ";expires=" + cookieExpires + cookiePath;
			}
			function getCookieValue(cookieName)
			{
				var cookieValue = document.cookie;
				var cookieStartsAt = cookieValue.indexOf(" " + cookieName + "=");
				if(cookieStartsAt == -1)
				{
					cookieStartsAt = cookieValue.indexOf(cookieName + "=");
				}
				if(cookieStartsAt == -1)
				{
					cookieValue = null;
				}
				else
				{
					cookieStartsAt = cookieValue.indexOf("=",cookieStartsAt) + 1;
					var cookieEndsAt = cookieValue.indexOf(";",cookieStartsAt);
					if(cookieEndsAt == -1)
					{
						cookieEndsAt = cookieValue.length;
					}
					cookieValue = unescape(cookieValue.substring(cookieStartsAt,cookieEndsAt));
				}
				return cookieValue;
			}
			//setCookie("Surveyed","Yes","","");
			//alert(document.cookie);
			//var tester = getCookieValue("Surveyed");
			//alert("tester is " + tester);



$(document).ready(function() {	
	var randomnumber=Math.floor(Math.random()*6)
	//alert("randomnumber is "+randomnumber);
	if(randomnumber >=3) {
		//alert("randomnumber is "+randomnumber);
		//Put in the DIV id you want to display
		var cookieChecker = getCookieValue("surveyed");
		//alert("cookieChecker = " + cookieChecker);
		if(cookieChecker == null)
		{
			launchWindow('#dialog');
			setCookie("surveyed","Yes","","");
			
		}
	}
	//if close button is clicked
	$('.window .close').click(function () {
		$('#mask').hide();
		$('.window').hide();
		Openwin = window.open("survey.html","Survey","width=300,height=300,location=0,status=1,scrollbars=1");
		 
		Openwin.moveTo(screen.width-20,screen.height-20);
		this.window.focus(); 
	});		
		//if close button is clicked
	$('.window .close2').click(function () {
		$('#mask').hide();
		$('.window').hide();
	});		
	
	//if mask is clicked
	$('#mask').click(function () {
		$(this).hide();
		$('.window').hide();
	});			
	
});

function launchWindow(id) {
	
		//Get the screen height and width
		var maskHeight = $(window).height();
		var maskWidth = $(window).width();
	    var msk1 = "100%";
		var msk2 = "100%";
		//Set heigth and width to mask to fill up the whole screen
		$('#mask').css({'width':maskWidth,'height':maskHeight});
		
		//transition effect		
		$('#mask').fadeIn(500);	
		$('#mask').fadeTo("slow",0.8);	
	
		//Get the window height and width
		var winH = $(window).height();
		var winW = $(window).width();
              
		//Set the popup window to center
		$(id).css('top',  winH/2-$(id).height());
		$(id).css('left', winW/2-$(id).width()/2);
	
		//transition effect
		$(id).fadeIn(1000); 
	

}
/*$(window).unload(function() {			
	Openwin.change();
});*/


	

