var allcookies = document.cookie;
var myCookiePos = allcookies.indexOf("askedAboutFedExSurvey");

var secs;
var timerID = null;
var timerRunning = false;
var delay = 1000;

InitializeTimer();

function launchSurvey() {
	if (myCookiePos == -1) {
		var newWin = window.open('http://fedex.quarry.com/surveyquery.html','surveyWin','height=350,width=500');

		var nextyear = new Date(); nextyear.setFullYear(nextyear.getFullYear() + 1);
		document.cookie = "askedAboutFedExSurvey=true; path=/; expires="+nextyear.toGMTString();
	}
}

function InitializeTimer() {
    secs = 30;
    StopTheClock();
    StartTheTimer();
}

function StopTheClock() {
    if(timerRunning) {
        clearTimeout(timerID);
    }
    timerRunning = false;
}

function StartTheTimer() {
    if (secs==0) {
        StopTheClock();
        launchSurvey();
    } else {
        secs = secs - 1;
        timerRunning = true;
        timerID = self.setTimeout("StartTheTimer()", delay);
    }
}

