
//Get/set the page visit count from the session cookie.
var pageCnt = 0; 
var ipAddr = '<!--#echo var="REMOTE_ADDR"-->';

function get_cookie ( cookie_name )
{
	var results = document.cookie.match ( '(^|;) ?' + cookie_name + '=([^;]*)(;|$)' );
	
	if ( results )
		return ( unescape ( results[2] ) );
	else
		return null;
}



function doSurvey()
{
	if (! get_cookie("pageVisitCnt")) 
	{
		pageCnt = 1;
		document.cookie = "pageVisitCnt=" + pageCnt + ";domain=childrenshospital.org";
	}
	else
	{
		pageCnt = get_cookie("pageVisitCnt");
		pageCnt++;
		document.cookie = "pageVisitCnt=" + pageCnt + ";domain=childrenshospital.org";
	}
	
	if (pageCnt == 5) popup('/survey/survey.cfm', 'survey');
	//else alert("current page count = " + pageCnt);
}

function popup(mylink, windowname)
{
	if (! window.focus)return true;
	var href;
	if (typeof(mylink) == 'string')
	   href=mylink;
	else
	   href=mylink.href;
	window.open(href, windowname, 'width=400,height=775,scrollbars=no,menubar=0,resizable=0');
	return false;
}


