// This code was written by Birchtree Web Development (www.birchtreeweb.com) for Johnston,
// Zabor, McManus & Associates (www.jzm.com) and may not be used or copied without the
// express written permission of Johnston, Zabor, McManus & Associates. The functions
// GetCookieVal, FixCookieDate, GetCookie, DeleteCookie and SetCookie were written by
// Bill Dortch (bdortch@netw.com) and have been released into the public
// domain.
//
// This code is referenced on any desired page by adding the following lines
// (after adjusting the domain and path in the source URL) to the HTML file
// defining the page:
//
//
// The above lines can be inserted in the HTML file at the beginning or the
// end, but not in the middle. The location of the lines (beginning or end) is
// irrelevant except in one case. If the user's browser has been configured to
// reject cookies, this code will add the recruiting image and message to the
// web page. The location of the image and message is determined by the
// location of the above lines in the HTML file. If the lines were inserted at
// the beginning, the image and message will display on the page before the
// rest of the content of the web page. If the lines were inserted at the end,
// the image and message will display on the page after the rest of the
// content.

// ***************************************************************************
// * Beginning of code that must be modified for each client web site.       *
// ***************************************************************************

var intSiteHitCountTrigger = 2;
var strExpirationDate = "September 21, 2006";
var strSurveyStartDate = "March 21, 2006";
var strEpochDate = "Thu, 01-Jan-70 00:00:01 GMT"
var intCookieAgeLimit = 8;
var strRecruitImage = "http://www.jzmsurvey.com/8930/jzmRateIMG108.gif";
var strInviteImage = "http://www.jzmsurvey.com/8930/jzmInviteIMG108.gif";
var strRecruitMessage = "";
var strRecruitURL = "http://www.jzmsurvey.com/8930/8930logn.htm";
var strRecruitWindowHeight = "250";
var strRecruitWindowWidth = "400";
var strWebSiteName = "Janssen, L.P. MentalWellness.com Web Satisfaction Study WINTER 2006";
var oneMinute = 60 * 1000
var qtrHour = oneMinute * 15
var oneHour = oneMinute * 60
var oneDay = oneHour * 24
var oneWeek = oneDay * 7
var intTimeIntervalNo = (3 * qtrHour)
var intTimeIntervalLater = (15 * oneMinute)
var blnShowInvitationFirst = true
var strMessagePosition = "BottomRight"
var strTriggerType = "TIME"
var intTimeTrigger = qtrHour

// ***************************************************************************
// * End of code that must be modified for each client web site.             *
// ***************************************************************************

var blnStartSurvey;
var blnBrowserAcceptsCookies;
var blnPagePreviouslyVisited;
var blnPopUpPreviouslyDisplayed;
var blnCookieFresh;
var blnSiteTriggerExceeded;
var dteExpiration;
var dteSurveyStart;
var dteNow;
var dteEpoch;
var intCookieAge;
var intSiteHitCount;
var strCountString = "JZMRecruit." + escape(strWebSiteName) + ".HitCount";
var strPageCookie;
var strPopupCookie;
var strPopupDisplayed;
var strPopupString = "JZMRecruit." + escape(strWebSiteName) + ".Popup";
var strSiteCookie;
var strVisitString = "JZMRecruit." + escape(location) + ".Visited";
var dteCookieCreated;
var strCookieCreatedDate;

//  Rate and Invite Variables
var topOffset = parseInt(screen.availHeight - 50);
var strAppName = navigator.appName;
var strAppVersion = navigator.appVersion;
var strVersion = strAppVersion.substring(0,4);
var intWidthRate = 75;
var intWidthInvite = 285;
var intHeightRate = 43
var intHeightInvite = 222
var isCSS, isW3C, isIE4, isNN4, isIE6CSS;
var isIE, isIEMac, isOpera, isNS, isW3CDOM;
var jzmRate
var jzmInvite
var blnHideRecruitMSG
var strInviteResponse
var dteNoInvitation
var dteLaterInvitation


// intSiteHitCountTrigger	The number of pages in the web site that must be
//							opened in a single session before the recruiting page
//							is displayed.
//
// strExpirationDate		The expiration date for the recruiting effort. Once
//							this date has passed, the JavaScript will exit
//							without doing anything.
//
// strSurveyStartDate		This is the date the code will start to execute.
//
// strEpochDate				Date used when deleting cookies
//
// intCookieAgeLimit		Specifies the number of hours the 
//							cookie is effective for.  
//
// strPopupURL				The URL of the page to be displayed when the
//							appropriate number of page hits have occurred in a
//							single session. This page will most likely contain
//							an image and some text. Selecting on either item
//							should take the user to a survey to be filled out.
//							This page will usually be a private page located on
//							the JZA web site. Since it is private, it can be
//							modified without any client interaction. This
//							parameter is used only if the client's browser
//							accepts cookies.
//
// strRecruitImage			The image to be displayed at the top or bottom of the
//							client's web page. Selecting this item will take the
//							user to a surver to be filled out. This parameter is
//							used only if the client's browser does not accept
//							cookies.
//
// strRecruitMessage		The message to be displayed at the top or bottom of
//							the client's web page. Selecting this item will take
//							the user to a survey to be filled out. This parameter
//							is used only if the client's browser does not accept
//							cookies.
//
// strRecruitURL			The URL of the survey to which the user will be taken
//							if the recruit image or message is selected on the
//							client web page. This parameter is used only if the
//							client's browser does not accept cookies.
//
// strRecruitWindowHeight	The desired height of the window to be displayed when
//							the appropriate number of page hits have occurred in
//							a single session.
//
// strRecruitWindowWidth	The desired width of the window to be displayed when
//							the appropriate number of page hits have occurred in
//							a single session.
//
// strWebSiteName			The name of the client web site. This would normally
//							be something like "XYZ Corp. Web Site".
//

// **************                                ****************
// **************   BEGIN FUNCTION DECLARATION   ****************
// **************                                ****************

// Parses a cookie string. This method was obtained from the public domain.
function GetCookieVal (offset) {
	var endstr = document.cookie.indexOf (";", offset);
	if (endstr == -1)
		endstr = document.cookie.length;
		return unescape(document.cookie.substring(offset, endstr));
}

// Fixes a bug with Macintosh cookies. This method was obtained from the
// public domain.
function FixCookieDate (date) {
	var base = new Date(0);
	var skew = base.getTime(); // dawn of (Unix) time - should be 0
	if (skew > 0)  // Except on the Mac - ahead of its time
	  date.setTime (date.getTime() - skew);
}

// Gets a cookie. This method was obtained from the public domain.
function GetCookie (name) {
	var arg = name + "=";
	var alen = arg.length;
	var clen = document.cookie.length;
	var i = 0;
	while (i < clen) {
		var j = i + alen;
		if (document.cookie.substring(i, j) == arg)
			return GetCookieVal (j);
			i = document.cookie.indexOf(" ", i) + 1;
		if (i == 0) break; 
	}
	return null;
}

// Sets a cookie. This method was obtained from the public domain.
function SetCookie (name,value,expires,path,domain,secure) {
  document.cookie = name + "=" + escape (value) +
    ((expires) ? "; expires=" + expires.toGMTString() : "") +
    ((path) ? "; path=" + path : "") +
    ((domain) ? "; domain=" + domain : "") +
    ((secure) ? "; secure" : "");
}

//This function parses a cookie and returns the result as an array.
function parseCookie() {
	// Separate each cookie.
	var cookieList = document.cookie.split("; ");
	// Array for each cookie in cookieList
	var cookieArray = new Array();
	for (var i = 0; i < cookieList.length; i++) {
		// Separate name-value pairs.
		var name = cookieList[i].split("=");
		// Decode and add to cookie array.
		cookieArray[unescape(name[0])] = unescape(name[1]);
   }
   return cookieArray;
}  

//  Function to delete a cookie. (Sets expiration date to start of epoch)
//    name -   String object containing the cookie name
//    path -   String object containing the path of the cookie to delete.  This MUST
//             be the same as the path used to create the cookie, or null/omitted if
//             no path was specified when creating the cookie.
//    domain - String object containing the domain of the cookie to delete.  This MUST
//             be the same as the domain used to create the cookie, or null/omitted if
//             no domain was specified when creating the cookie.
//
function DeleteCookie (name,path,domain) {
  if (GetCookie(name)) {
    document.cookie = name + "=" +
      ((path) ? "; path=" + path : "") +
      ((domain) ? "; domain=" + domain : "") +
      "; expires=Thu, 01-Jan-70 00:00:01 GMT";
  }
}

//This function is used when the browser doesn't accept cookies

function getNewWind(strURL)
{
	var newWind = window.open(strURL, "WebPopUp", "WIDTH=400,HEIGHT=250");
}

//This function is used to determine whether the current date is within the Survey Date range
function startSurvey(){

	if((dteNow.getTime() >= dteSurveyStart.getTime()) && (dteNow.getTime() <= dteExpiration.getTime())){
		return true
	}else{
		return false
	}
}

//This function is used to determine whether the page has previously been visited
function pagePreviouslyVisited(){
	strPageCookie = GetCookie(strVisitString);
	return (strPageCookie != null);
}

//Sets the .Visited cookie for the current page visit
function setCurrentPageVisit(){
	SetCookie(strVisitString, "true", dteExpiration, "/");
	strPageCookie = GetCookie(strVisitString);

}

//Determines whether the browser accepts cookies by retrieving 
//the .Visited cookie for the current page
function browserAcceptsCookies(){
	return (strPageCookie != null)
}

//Determines whether the popup has previously been displayed
function popupPreviouslyDisplayed(){
	strPopupDisplayed = GetCookie(strPopupString);
	return (strPopupDisplayed != null)
}

//Sets the CookieCreated cookie if it hasn't previously been set
function setCookieCreatedDate(){
	strCookieCreatedDate = GetCookie("CookieCreated")
	if (null == strCookieCreatedDate)
	{
		//Set the cookie creation date
		SetCookie("CookieCreated", dteNow, dteExpiration, "/");
		strCookieCreatedDate = GetCookie("CookieCreated")
	}
	dteCookieCreated = new Date(strCookieCreatedDate);
	FixCookieDate(dteCookieCreated);
}

//Determines whether the cookie is fresh
function getCookieFreshness(){
	var dateCookieCreated = dteCookieCreated.getTime();
	var dateCurrent = dteNow.getTime();
	var dateAdjustment = oneHour * intCookieAgeLimit;
						
	//Add intCookieAgeLimit to the cookie creation date, 
	//then compare to current date
	dateCookieCreated = (dateCookieCreated + dateAdjustment);
	var dateDiff = (dateCurrent - dateCookieCreated);

	if (dateCurrent <= dateCookieCreated){
		//Cookie is fresh, return true
		return true
	}else{
		//Cookie is stale, return false
		return false
	}
}

//Resets cookie values if cookie is stale
function resetCookie(){

	//Reset the site hit counter cookie to 0
	intSiteHitCount = 0;
	SetCookie(strCountString, intSiteHitCount, dteExpiration, "/");

	//Cycle through the cookies, for each .Visited, 
	//either set it's value to False or delete the cookie 
	//by modifying the expiration date
							
	//Call parseCookie to retrieve the name=value pairs
	var cookie;
	var cookies = parseCookie();
					
	//Delete the .Visited cookies
	for (cookie in cookies)
	{
		if (cookie.indexOf(".Visited") != -1){
		DeleteCookie(escape(cookie), "/");
		}
	}
							
	//Reset the CookieCreated Date
	SetCookie("CookieCreated", dteNow, dteExpiration, "/");
	strCookieCreatedDate = GetCookie("CookieCreated");
					
	//Set the current page hit cookie
	SetCookie(strVisitString, "true", dteExpiration, "/");
					
	//Reset PagePreviouslyVisited variable
	blnPagePreviouslyVisited = pagePreviouslyVisited();

	// Increment the session page hit count and store the value in a cookie.
	intSiteHitCount = intSiteHitCount + 1;
	SetCookie(strCountString, intSiteHitCount, dteExpiration, "/");
}

//Determines if the Site Hit Count Trigger has been exceeded
function siteTriggerExceeded(){
	strSiteCookie = GetCookie(strCountString);
	if (strSiteCookie != null){
	  intSiteHitCount = parseInt(strSiteCookie);
	}else{
	  intSiteHitCount = 0;
	}
	// Increment the session page hit count and store the value in a cookie.
	intSiteHitCount = intSiteHitCount + 1;
	SetCookie(strCountString, intSiteHitCount, dteExpiration, "/");

	if (intSiteHitCount >= intSiteHitCountTrigger){
		return true
	}else{
		return false
	}
}

//Retrieves the value of the InviteResponse cookie
function getInviteResponse(){
	var strResponse = GetCookie("InviteResponse");
	return strResponse
}

//Sets the value of the InviteResponse cookie
function setInviteResponse(strResponse){
	SetCookie("InviteResponse", strResponse, dteExpiration, "/");
}

function setNoInvitationDate(){

	// Set the NoInvitation date to the current date/time
	dteNoInvitation = dteNow
	
	// Write NoInvitation date to cookie
	SetCookie("NoInvitationDate", dteNoInvitation, dteExpiration, "/");
}

function setLaterInvitationDate(){

	// Set the LaterInvitation date to the current date/time
	dteLaterInvitation = dteNow
	
	// Write LaterInvitation date to cookie
	SetCookie("LaterInvitationDate", dteLaterInvitation, dteExpiration, "/");
}

function evalInvitationDates(strCase){

	switch(strCase){
		case "NO": //User responded NO to invitation
			var strNoInvitationDate = GetCookie("NoInvitationDate")
			dteNoInvitation = new Date(strNoInvitationDate);
			FixCookieDate(dteNoInvitation);
			var mstNoInvitation = dteNoInvitation.getTime();
			var mstNow = dteNow.getTime();
			//alert("dteNoInvitation = " + dteNoInvitation + ", intTimeIntervalNo = " + intTimeIntervalNo)
			if(mstNow >= (mstNoInvitation + intTimeIntervalNo)){
				//alert("NO time interval exceeded, show recruit <IMG>s!")
				setupInvitation(); 
				showElement(objRate)
			}
			break
		
		case "LATER":  //User responded LATER to invitation
			var strLaterInvitationDate = GetCookie("LaterInvitationDate")
			dteLaterInvitation = new Date(strLaterInvitationDate);
			FixCookieDate(dteLaterInvitation);
			var mstLaterInvitation = dteLaterInvitation.getTime();
			var mstNow = dteNow.getTime();
			//alert("dteLaterInvitation = " + dteLaterInvitation + ", intTimeIntervalLater = " + intTimeIntervalLater)
			if(mstNow >= (mstLaterInvitation + intTimeIntervalLater)){
				//alert("LATER time interval exceeded, show recruit <IMG>s!")
				setupInvitation(); 
				showElement(objRate)
			}
			break
	}		

}

// ********   Rate and Invite Functions   **************


function initDHTML(){
	if(document.images){
		isCSS = (document.body && document.body.style) ? true : false;
		isW3C = (isCSS && document.getElementById) ? true : false;
		isIE4 = (isCSS && document.all) ? true : false;
		isNN4 = (document.layers) ? true : false;
		isIE6CSS = (document.compatMode && document.compatMode.indexOf("CSS1") >= 0) ? true : false;
	}
}

function getClientWidth(){
	if(window.innerWidth){
		return window.innerWidth
	}else if(isIE6CSS){
		return document.body.parentElement.clientWidth;
	}else if(document.body && document.body.clientWidth){
		return document.body.clientWidth;
	}
	return 0;
}

function getClientHeight(){
	if(window.innerHeight){
		return window.innerHeight;
	}else if(isIE6CSS){
		return document.body.parentElement.clientHeight;
	}else if(document.body && document.body.clientHeight){
		return document.body.clientHeight;
	}
}

function writeRecruitMSG(){

	var strContent = "<div ID='jzmRate' STYLE='position:absolute; top:0; left:0; width:50; height:43; visibility:hidden; z-index:1000; bgColor:null' border=0>"
	strContent += "<a href='javascript:void' onMouseOver='hideElement(objRate); showElement(objInvite);'>"
	strContent += "<img NAME='jzmRateIMG' SRC='" + strRecruitImage + "' useMap='#jzmRateIMG' BORDER=0 WIDTH='50' HEIGHT='43'></a>"
	strContent += "<map NAME='jzmRateIMG'>"
	strContent += "<area SHAPE='RECT' COORDS='0,0,50,43' onMouseOver='hideElement(objRate); showElement(objInvite);' ALT='Please Rate Our Site'>"
	strContent += "</map></div>"
	
	strContent += "<div ID='jzmInvite' STYLE='position: absolute; top:0; left:0; width:260; height:222; visibility:hidden; z-index:1001; bgColor:null' border=0>"
	strContent += "<a href='javascript:void' onMouseOver='showElement(objInvite);' onMouseOut='hideElement(objInvite); showElement(objRate);'>"
	strContent += "<img NAME='jzmInviteIMG' SRC='" + strInviteImage + "' useMap='#jzmInviteIMG' BORDER=0 WIDTH='260' HEIGHT='222'></a>"
	strContent += "<map NAME='jzmInviteIMG'>"
	//strContent += "<form name='frmYesRecruit' method=post action='TestJS_post.asp' target='_blank'>" + "\n"
	//strContent += "<input type=hidden name='btnClicked' value='YesRecruit'>" + "\n"
	//strContent += "<input type=hidden name='siteName' value='" + strWebSiteName + "'>" + "\n"
	//strContent += "<input type=hidden name='currentDateTime' value='" + dteNow + "'>" + "\n"
	//strContent += "<input type=hidden name='currentHitCount' value='" + intSiteHitCount + "'>" + "\n"
	//strContent += "<input type=hidden name='recruitURL' value='" + strRecruitURL + "'>" + "\n"
	strContent += "<area SHAPE='RECT' COORDS='35,143,86,189' HREF='javascript:yesRecruit(document.frmYesRecruit);'  onMouseOver='showElement(objInvite); hideElement(objRate);' ALT='Yes'>"
	//strContent += "</form>" + "\n"
	
	//strContent += "<form name='frmNoRecruit' method=post action='TestJS_post.asp' target='_blank'>" + "\n"
	//strContent += "<input type=hidden name='btnClicked' value='NoRecruit'>" + "\n"
	//strContent += "<input type=hidden name='siteName' value='" + strWebSiteName + "'>" + "\n"
	//strContent += "<input type=hidden name='currentDateTime' value='" + dteNow + "'>" + "\n"
	//strContent += "<input type=hidden name='currentHitCount' value='" + intSiteHitCount + "'>" + "\n"
	strContent += "<area SHAPE='RECT' COORDS='105,143,158,190' HREF='javascript:noRecruit(document.frmNoRecruit);'  onMouseOver='showElement(objInvite); hideElement(objRate);' ALT='No Thanks'>"
	//strContent += "</form>" + "\n"
	
	//strContent += "<form name='frmAskLaterRecruit' method=post action='TestJS_post.asp' target='_blank'>" + "\n"
	//strContent += "<input type=hidden name='btnClicked' value='AskLaterRecruit'>" + "\n"
	//strContent += "<input type=hidden name='siteName' value='" + strWebSiteName + "'>" + "\n"
	//strContent += "<input type=hidden name='currentDateTime' value='" + dteNow + "'>" + "\n"
	//strContent += "<input type=hidden name='currentHitCount' value='" + intSiteHitCount + "'>" + "\n"
	strContent += "<area SHAPE='RECT' COORDS='176,142,226,190' HREF='javascript:askLaterRecruit(document.frmAskLaterRecruit);'  onMouseOver='showElement(objInvite); hideElement(objRate);' ALT='Ask Me Later'>"
	//strContent += "</form>" + "\n"
	
	strContent += "</map></div>"
	
	document.write(strContent)
	//document.close()

}

function writeNNRecruit(){

	var strContent = "<div ID='jzmRate' align='center' border=0>"
	strContent += "<a href='" + strRecruitURL + "'>"
	strContent += "<img NAME='jzmRateIMG' SRC='" + strRecruitImage + "' BORDER=0 WIDTH='50' HEIGHT='43'></a>"
	strContent += "</div>"
	
	document.write(strContent)

}


function scrollSmooth() 
{
	// Initialize Properties
	var clientHeight = clientWidth = docTop = 0
	var intRateOffsetHeight = intInviteOffsetHeight = 0
	var rateTop = inviteTop = rateLeft = inviteLeft = 0
	
	// Get the inner width of the browser window
	clientWidth = getClientWidth();
	 
	// Get the inner height of the browser window
	clientHeight = getClientHeight(); 
	
	// Initialize browser differences
	if(isNS || isOpera) {
		// Fudge for the scrollbars
		//clientHeight = window.innerHeight - 20
		//clientWidth = window.innerWidth - 20
		docTop = window.pageYOffset
		intRateOffsetHeight = intHeightRate
		intInviteOffsetHeight = intHeightInvite

	}else{
		//clientHeight = document.body.clientHeight
		//clientWidth = document.body.clientWidth
		docTop = document.body.scrollTop
		intRateOffsetHeight = objRate.obj.offsetHeight
		intInviteOffsetHeight = objInvite.obj.offsetHeight
	}

	// Do the real work	
	switch(strMessagePosition){
		case "TopLeft":
			rateTop = docTop;
			rateLeft = 0;
			inviteTop = docTop;
			inviteLeft = 0;
			break
		case "TopRight":
			rateTop = docTop;
			rateLeft = (clientWidth - intWidthRate);
			inviteTop = docTop;
			inviteLeft = (clientWidth - intWidthInvite);
			break
		case "BottomLeft":
			rateTop = (docTop + clientHeight)-intRateOffsetHeight;
			rateLeft = 0;
			inviteTop = (docTop + clientHeight)-intInviteOffsetHeight;
			inviteLeft = 0;
			break
		case "BottomRight":
			rateTop = (docTop + clientHeight)-intRateOffsetHeight;
			rateLeft = (clientWidth - intWidthRate);
			inviteTop = (docTop + clientHeight)-intInviteOffsetHeight;
			inviteLeft = (clientWidth - intWidthInvite);
			break
		case "Center":
			//alert("docTop: " + docTop + ", clientHeight: " + clientHeight + ", clientWidth: " + clientWidth + ", intRateOffsetHeight: " + intRateOffsetHeight + ", intInviteOffsetHeight: " + intInviteOffsetHeight);
			rateTop = Math.round(((docTop + (docTop + clientHeight))/2) - (intHeightRate / 2));
			rateLeft = Math.round((clientWidth / 2) - (intWidthRate / 2));
			inviteTop = Math.round(((docTop + (docTop + clientHeight))/2) - (intHeightInvite / 2));
			inviteLeft = Math.round((clientWidth / 2) - (intWidthInvite / 2));
			break
		default:
			rateTop = (docTop + clientHeight)-intRateOffsetHeight;
			rateLeft = (clientWidth - intWidthRate);
			inviteTop = (docTop + clientHeight)-intInviteOffsetHeight;
			inviteLeft = (clientWidth - intWidthInvite);
	}
			
	objRate.top = objRate.style.top = objRate.style.pixelTop = rateTop;
	objInvite.top = objInvite.style.top = objInvite.style.pixelTop = inviteTop;

	objRate.left = objRate.style.left = objRate.style.pixelLeft = rateLeft;
	objInvite.left = objInvite.style.left = objInvite.style.pixelLeft = inviteLeft;
		
}	        


function getRate(){
	if(document.getElementById){
		this.obj = document.getElementById("jzmRate");
		this.style = document.getElementById("jzmRate").style;
	}else if(document.all){
		this.obj = document.all.jzmRate;
		this.style = document.all.jzmRate.style;
	}else if(document.layers){
		this.obj = document.layers.jzmRate;
		this.style = document.layers.jzmRate;
	}
}

function getInvite(){
	if(document.getElementById){
		this.obj = document.getElementById("jzmInvite");
		this.style = document.getElementById("jzmInvite").style;
	}else if(document.all){
		this.obj = document.all.jzmInvite;
		this.style = document.all.jzmInvite.style;
	}else if(document.layers){
		this.obj = document.layers.jzmInvite;
		this.style = document.layers.jzmInvite;
	}
}

function setBrowserType(strAppName){
	switch(strAppName){
		case "Microsoft Internet Explorer":
			if(navigator.platform.indexOf("Mac")>=0){
				isIEMac = true
			}else{
				isIEMac = false
			}
			isIE = true
			isNS = false
			isOpera = false
			break
			
		case "Netscape":
			isNS = true
			isIE = false
			isIEMac = false
			isOpera = false
			break
			
		case "Opera":
			isOpera = true
			isIE = false
			isIEMac = false
			isNS = false
			break
		
		default:
			//treat the browser like IE
			if(navigator.platform.indexOf("Mac")>=0){
				isIEMac = true
			}else{
				isIEMac = false
			}
			isIE = true
			isNS = false
			isOpera = false 
	}
}


function hideElement(obj){
	// Hide an element
	if(isNS && !isW3CDOM){
		// NS4
		obj.style.visibility = "hide"
	}else{
		obj.style.visibility = "hidden"
	}
}

function showElement(obj){
	// Show an element
	if(!blnHideRecruitMSG){
		if(isNS && !isW3CDOM){
			// NS4
			obj.visibility = "show"
		}else{		
			obj.style.visibility = "visible"
		}
	}
}

function shiftTo(jzmObj, x, y){
	jzmObj.left = jzmObj.style.pixelLeft = parseInt(x);
	jzmObj.top = jzmObj.style.top = jzmObj.style.pixelTop = parseInt(y);
}

function hideRecruitMSG(){
	blnHideRecruitMSG = true
	hideElement(objRate)
	hideElement(objInvite)
}

function yesRecruit(frm){
	// Set the InviteResponse cookie
	setInviteResponse("YES")
		
	// Submit the form
	//frm.submit(); 

	// Hide the Recruit Elements
	hideRecruitMSG(); 

	//MW 12-01-05 BEGIN ADD
	//Add disclaimer
	if (confirm('You are now leaving MentalWellness.com.  This link will take you to a site maintained by a third party who is conducting a survey on behalf of Janssen, L.P.  Although the third party is working on our behalf, Janssen, L.P. is not responsible for the privacy policy on that site.  We encourage you to review the privacy policy of every Web site you visit.') == 1)
	//MW 12-01-05 END ADD 	


	// Redirect user to first page of survey in the current window
	// location.href = strRecruitURL
	location.href = "javascript:getSurvey('http://www.jzmsurvey.com/8930/8930logn.htm')" 
}

function getSurvey(strURL)
{

	var avWidth = screen.availWidth - 20;
	var avHeight = screen.availHeight - 175;
	var heightspeed = 40;  // vertical scrolling speed (higher = slower)
	var widthspeed = 40;  // horizontal scrolling speed (higher = slower)
	var winwidth = window.screen.availWidth;
	var winheight = window.screen.availHeight;


	if(navigator.appName == "Netscape") {
		var windowprops = "toolbar=no,resizable,location=no,scrollbars,menubar=no,status=no"
		var newWind = window.open(strURL, "Survey", windowprops);
	}else{
		var windowprops = "toolbar=no,resizable,location=no,scrollbars,menubar=no,status=no,top=0,left=0,height=" + 1 + ",width=" + 1
		var newWind = window.open("", "Survey", windowprops);
		for (sizeheight = 1; sizeheight < winheight; sizeheight += heightspeed) {
			newWind.resizeTo("1", sizeheight);
		}
		for (sizewidth = 1; sizewidth < winwidth; sizewidth += widthspeed) {
			newWind.resizeTo(sizewidth, sizeheight);
		}
		newWind.location = strURL
	}
	
}


function noRecruit(frm){

	// Set the InviteResponse cookie
	setInviteResponse("NO")
	
	// Set the NoInvitation date/time
	setNoInvitationDate()
	
	// Hide the Recruit Elements
	hideRecruitMSG(); 
	
	// Submit the form
	//frm.submit(); 
}

function askLaterRecruit(frm){

	// Set the InviteResponse cookie
	setInviteResponse("LATER")
	
	// Set the LaterInvitation date/time
	setLaterInvitationDate()
	
	// Hide the Recruit Elements
	hideRecruitMSG(); 
	
	// Submit the form
	//frm.submit(); 
}

function setupInvitation(){
	//alert("setupInvitation!");
	
	//Write the Recruit Elements out to the page
	writeRecruitMSG()
	
	// Set the Hide Recruit Elements variable
	blnHideRecruitMSG = false
	
	// Determine if the browser is compatible with W3C DOM
	isW3CDOM = document.getElementById
	
	//call function to set browser version variables
	setBrowserType(strAppName)
	//alert("IE: " + isIE + ", NS: " + isNS + ", Opera: " + isOpera + ". Version: " + strVersion)
	
	// Initialize DHTML variables
	initDHTML()
		
	// Set the dynamic global "Rate" and "Invite" objects
	objRate = new getRate()
	objInvite = new getInvite()

	// Determine when scrollSmooth should be called, 
	// based on browser type and DOM support
	if(isW3CDOM && (isIE || isIEMac)){
		// The browser is IE and W3CDOM-compliant
		// Call scrollSmooth in the onScroll event
		window.onresize = window.onscroll = scrollSmooth;
		if(isIEMac){
			setInterval("scrollSmooth()",50)
		}
		scrollSmooth()
	}
	
	if((isW3CDOM && isOpera) || (isW3CDOM && isNS)){
		// The browser is Opera or NS and W3CDOM-compliant
		// Use setInterval to call scrollSmooth()
			//alert("setInterval() for W3CDOM and NS/Opera!")
			window.onresize = scrollSmooth;
			setInterval("scrollSmooth()",50)
			scrollSmooth()
	}
	
	if(!isW3CDOM && isNS){
		// The browser is NS and is not W3CDOM-compliant
		// Use setInterval to call scrollSmooth()
		setInterval("scrollSmooth()",50)
	}
	
	// Show the Rate element
	//showElement(objRate)

}


// **************                                ****************
// **************   END FUNCTION DECLARATION     ****************
// **************                                ****************


// Get the expiration date for this code, survey start date,
// and the current date.
dteExpiration = new Date(strExpirationDate);
FixCookieDate(dteExpiration);

dteSurveyStart = new Date(strSurveyStartDate);
FixCookieDate(dteSurveyStart);

dteNow = new Date();
FixCookieDate(dteNow);

//Get the epoch date used to delete cookies
dteEpoch = new Date(strEpochDate);
FixCookieDate(dteEpoch);

// The remaining code should only be executed if the expiration date has not
// already passed, and current date is greater than survey start date.

	blnStartSurvey = startSurvey()
	// Determine if the browser is compatible with W3C DOM
	isW3CDOM = document.getElementById
	
	//call function to set browser version variables
	setBrowserType(strAppName)
	
	// Initialize DHTML variables
	initDHTML()

if(blnStartSurvey) 
{
	// Determine if this page has already been visited this session.
	blnPagePreviouslyVisited = pagePreviouslyVisited();
	//alert("PagePreviously Visited: " + blnPagePreviouslyVisited);

	// Set a cookie indicating that this page is being visited. By immediately
	// reading the new cookie it can be determined if the browser has been
	// configured to accept or reject cookies.
	setCurrentPageVisit();
	blnBrowserAcceptsCookies = browserAcceptsCookies();
		
	if(!isW3CDOM && isNS){
		// The browser is NS and is not W3CDOM-compliant
		// Display the rate graphic
		writeNNRecruit()
	}else{
		//If browser accepts cookies check for
		//CookieCreated Date, and whether the cookie is stale or fresh
		if(blnBrowserAcceptsCookies)
		{			
			//If the "CookieCreated" param hasn't been set, set it
			setCookieCreatedDate();
			//alert("Cookie Created Date: " + dteCookieCreated);

			//Determine if the cookie is still "fresh"
			blnCookieFresh = getCookieFreshness();
			//alert("Cookie Fresh: " + blnCookieFresh);
						
			if (!blnCookieFresh)
			{
				//Cookie is stale				
				resetCookie();
				//alert("Cookie Refreshed!");
			}

			// If the browser accepts cookies, this page has not yet been
			// visited this session, get a cookie which contains the number of
			// pages from this web site that have been hit this session. If no such
			// cookie exists, then the number is zero.

			blnSiteTriggerExceeded = siteTriggerExceeded();
			//alert("Site Trigger Exceeded: " + blnSiteTriggerExceeded);
						
			// If the session page hit count has reached the trigger value, look for
			// a cookie indicating that the recruiting message has already been
			// displayed in some previous session.
			if(blnSiteTriggerExceeded) 
			{
				strInviteResponse = getInviteResponse();
				//alert("Invite Response: " + strInviteResponse);
				if(strInviteResponse == null || strInviteResponse == ""){
					strInviteResponse = "BLANK"
				}
					
				switch(strInviteResponse){
					case "YES":
						//alert("User has already seen rate/invite <IMG> so don't make them visible!");						
						break
							
					case "NO":
						//alert("Evaluate NoInvitationDate + intTimeIntervalNo against current date/time");
						evalInvitationDates("NO");
						break
						
					case "LATER":
						//alert("Evaluate LaterInvitationDate + intTimeIntervalLater against current date/time");
						evalInvitationDates("LATER");
						break
							
					case "BLANK":
						//alert("User hasn't responded to invitation, continue to show recruit <IMG>s!");
						//Assumes that the user needs to see Recruit message
						//Show the Rate and Invitation elements
						setupInvitation(); 
						if(blnShowInvitationFirst){
							showElement(objInvite)
						}else{
							showElement(objRate)
						}
						break
							
					default:
						//alert("Unable to evaluate InviteResponse cookie!");
						
				}
			}
		}else{
			// The browser does not accept cookies, so display the recruit image and
			// message on this web page so the user can select it manually if desired.
			setupInvitation(); 
			showElement(objRate);

		}
	}	
}

	

