function popUpWin()
{
    var tools = "resizable,toolbar=no,location=no,scrollbars=yes,menubar=no,width=800,height=800,top=0,left=0";
	newWindow = window.open('http://www.patentsoffice.ie/questionnaire.aspx', 'newWin', tools);
}

function setCookie(name,value,days) 
{
	var expires = "";
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		expires = "; expires="+date.toGMTString();
	}
	
	document.cookie = name+"="+value+expires+"; path=/";
}

function getCookie(name) 
{
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ')
		{
			c = c.substring(1,c.length);
		}
		if (c.indexOf(nameEQ) == 0)
		{
			return c.substring(nameEQ.length,c.length);
		}
	}
	return null;
}

function loadpopup()
{	
		
	questionnaire=getCookie('questionnaire');
	if (questionnaire!=null && questionnaire!="")
	{
		//alert('Cookie already exists...');
		// Cookie already exists so there is no need to display pop up
	}
	else 
	{		
		//alert('Cookie not found. Setting it now...');
		//Cookie does not exist so we display the popup
		popUpWin();
		
		//once the popup have been displayed,	set a cookie so it wont be displayed again
		setCookie('questionnaire','questionnaire',365)	;		
	}
	
			
}
