<!--
//This version passes a variable from the "TakeSurvey" function. This variable is used as the password to track which event was triggered. It is appended to the popUpURL

/*
current pages this file is on:
/index.html

/residential/index.html
/residential/newservice/index.html
/residential/manage/index.html
/residential/specialoffers/index.html
/residential/products/qch/plus/index.html
/residential/products/qcdsl/msn_deluxe.html

/stores/index.html

/wireless/promotions/promo1.html

----------

pages in question:
http://pcat.qwest.com/pcat/customerService.do?salesChannel=Residential
http://pcat.qwest.com/pcat/orderOnline.do?salesChannel=Residential
http://pcat.qwest.com/pcat/productsAndServices.do?salesChannel=Residential
*/

//Modify Survey cookie to match project number
var surveyID = "C1799-QWST04039";

//Sets the total percentage figure. Currently set to work on a 100 scale
var popUpScale = 100;
//Modify popup odds. 1 means 1% of the hits, 10=10%, etc...
var popUpOdds = 0;


//Variable to hold what event was triggered. IS NOT modified
var AtEvent = "";

//Modify the URL to match Either: the URL created in SurveyWriter.com for this project.
//OR to match the URL of the Popup Intermediate window
// var popUpURL = "http://www.qwest.com/global/popups/satisfaction_survey.html";
var popUpURL = "https://www.surveywriter.net/in/survey/survey162/Invite.htm";

//Sets popup window configuration options. Height, width, toolbars...
var popUpWindow = "height=300,width=300,fullscreen=0,location=0,menubar=0,resizable=1,scrollbars=auto,status=0,toolbar=0,screenY=300,left=300,top=100";


function setCookie(name, value, expires, path, domain, secure) {
	var curCookie = name + "=" + escape(value) +
		((expires) ? "; expires=" + expires.toGMTString() : "") +
		((path) ? "; path=" + path : "") +
		((domain) ? "; domain=" + domain : "") +
		((secure) ? "; secure" : "");
	document.cookie = curCookie;
}


function getCookie(name) {
	var dc = document.cookie;
	var prefix = name + "=";
	var begin = dc.indexOf("; " + prefix);
	if (begin == -1) {
		begin = dc.indexOf(prefix);
		if (begin != 0) return null;
	} else
		begin += 2;
	var end = document.cookie.indexOf(";", begin);
	if (end == -1)
		end = dc.length;
	return unescape(dc.substring(begin + prefix.length, end));
}


function fixDate(date) {
	var base = new Date(0);
	var skew = base.getTime();
	if (skew > 0)
		date.setTime(date.getTime() - skew);
}


function randomRange () {
	return Math.round(Math.random() * (popUpScale-1)) + 1
}


function TakeSurvey (goToURL, AtEvent) {
//popUpURL = popUpURL + AtEvent
	if (randomRange() <= popUpOdds) {
		var surveyAsked = getCookie(surveyID);
		if (!surveyAsked) {
			var now = new Date();
			fixDate(now);
			now.setTime(now.getTime() + 365 * 24 * 60 * 60 * 1000);
			setCookie(surveyID, "True", now);
			open(popUpURL, "SurveyPrompt", popUpWindow);
		}
	}
	if (typeof goToURL != 'undefined') {
		window.location = goToURL;
	}
}
//-->