// JavaScript Document

var cookie_name = "BMSurvey";

function setCookie(whereDo) 
{
	// Check if cookie exists and load
	if(document.cookie != document.cookie)
	{index = document.cookie.indexOf(cookie_name);}
	else
	{ index = -1;}

	// Cookie Exists
	if (index == -1)
	{
		// Check if user has clicked the no thanks button
		if(whereDo=='NoThanks')
		{
			document.cookie=cookie_name+"="+whereDo+"; expires=Monday, 04-Apr-2009 05:00:00 GMT; path=/;";
		}
		// User is at the YES NO Screen
		else
		{
			document.cookie=cookie_name+"="+whereDo+"; expires=Monday, 04-Apr-2009 05:00:00 GMT; path=/;";
		}
	}
}

function showSurveyPopup()
{
	setCookie('YESNO');
	//alert("Cookie Monster says 'Look heres the Survey'");
	WindowE();
}

function timedSurvery()
{
	var cookieMonster;
	
	cookieMonster = cookieMonsterSays();
	
	// Check for a previous 'NoThanks'
	if(cookieMonster != 'NoThanks' && cookieMonster != 'YESNO')
	{
		showSurveyPopup();
	}
	else { /*Do Nothing*/ }
}

function cookieMonsterSays()
{
	var cookieValue;

	if(document.cookie)
	{
		index = document.cookie.indexOf(cookie_name);
		if (index != -1)
		{
			namestart = (document.cookie.indexOf("=", index) + 1);
			nameend = document.cookie.indexOf(";", index);
			if (nameend == -1) {nameend = document.cookie.length;}
			cookieValue = document.cookie.substring(namestart, nameend);
		}
	}
	return cookieValue;
}

function WindowE()
{
GB_showCenter('Brett Martin Online Research Survey', '/popup_survey.aspx', 700, 750);
}

