var nowDate = new Date();  
nowDate.setMonth(nowDate.getMonth() + 6);  
dontExpire = nowDate.toGMTString();

/*function setCookie(cookieName, cookieValue, cookieExpires, cookiePath, cookieDomain)  
{ 
	cookieValue = escape(cookieValue);
	document.cookie = cookieName + "=" + cookieValue + "; expires=" + cookieExpires + "; path=" + cookiePath + "; domain=" + cookieDomain;
}*/

function getCookie(name)
{ 
	var cookieString = document.cookie;  
	var index = cookieString.indexOf(name + "=");  

	if (index == -1) 
		{ return null; } 

	index = cookieString.indexOf("=", index) + 1;  
	var endstr = cookieString.indexOf(";", index);  

	if (endstr == -1) 
		{ endstr = cookieString.length; } 

	return unescape(cookieString.substring(index, endstr)); 
}

//This function is for our normal pop-up survey.  Comment this out if a special survey needs to be used.  This cookie needs to stay the same.
function checkSurvey() 
{ 
	var pagesviewed = getCookie('ASQClickSurvey01'); 
	if (pagesviewed != 'taken') // if the user has seen the popup do not show it again.
	{ 
	
		parseInt(pagesviewed);
		if (pagesviewed >= 5) 
		{ 
			window.open("/includes/surveys/click-survey-intro.html","survey","menubar=no,width=500,height=300,toolbar=no");
			document.cookie = 'ASQClickSurvey01=taken;expires=' + dontExpire + ';path=/;domain=asq.org';
		}
		
		else
		{
			parseInt(pagesviewed); 
			pagesviewed++;
			document.cookie = 'ASQClickSurvey01=' + pagesviewed + ';path=/;domain=asq.org';
		}
	}		
}

//This is the funtion that can be used for speical surveys.  It's the same as the upper function but it can have the link and cookie changed.
/*function checkSurvey() 
{ 
	var pagesviewed = getCookie('ASQClickSpecial02'); //Update my +1 for new survey.
	if (pagesviewed != 'taken') // if the user has seen the popup do not show it again.
	{ 
	
		parseInt(pagesviewed);
		
		if (pagesviewed >= 3) 
		{ 
			window.open("/includes/surveys/click-survey-intro.html","survey","menubar=no,width=500,height=300,toolbar=no");
			document.cookie = 'ASQClickCertSurvey=taken;expires=' + dontExpire + ';path=/;domain=asq.org';
		}
		
		else
		{
			parseInt(pagesviewed); 
			pagesviewed++;
			document.cookie = 'ASQClickCertSurvey=' + pagesviewed + ';path=/;domain=asq.org';
		}
	}		
}*/

//This is the funtion that can be used for speical surveys.  It's the same as the upper function but it can have the link and cookie changed. But contains an extra directory logic equation.
/*function checkSurvey() 
{ 
	var pagesviewed = getCookie('ASQUS02'); //Increment by one for new survey
	if (pagesviewed != 'taken') // if the user has seen the popup do not show it again.
	{ 
	
		parseInt(pagesviewed);
		
		if (pagesviewed > 5
			|| location.href.indexOf("/audit/") > -1
			|| location.href.indexOf("/auto/") > -1
			) 
		{ 
			window.open("/includes/surveys/click-survey-intro.html","survey","menubar=no,width=500,height=300,toolbar=no");
			document.cookie = 'ASQUS02=taken;expires=' + dontExpire + ';path=/;domain=asq.org';
		}
		
		else
		{
			parseInt(pagesviewed); 
			pagesviewed++;
			document.cookie = 'ASQUS02=' + pagesviewed + ';path=/;domain=asq.org';
		}
	}		
}*/
