//window.addEvent("domready", initPopUpSurvey);

function initPopUpSurvey() {
    //Cookie.dispose('surveyPopped');
    var surveyPopped = Cookie.read('surveyPopped');
    var surveyPopUpRate = 0.01; // only do the pop up 1% of the time.. (1 in every 100 visitor)
    var rand = Math.random();
    if (rand <= surveyPopUpRate && surveyPopped == null) {
        popUpSurvey();
    }
}

var surveySlide;

function popUpSurvey() {
    var surveyPopped = Cookie.read('surveyPopped');
    if (surveyPopped == null)
	{
		$('survey-banner').setStyle('display', 'block');
		surveySlide = new Fx.Slide('survey-banner', {duration: 'long'});

		//safari/chrome
		if (!Browser.Engine.trident)
		{
			$('survey-banner').setStyles({
				'left': '50%',
				'margin-left': -485
			});
		}


		if (Browser.Engine.trident && Browser.Engine.version < 5)
			$('survey-banner').setStyle('position','absolute');

		//alert( Browser.Engine.trident + ' ' + Browser.Engine.version );

		surveySlide.hide().toggle();

        //var popup = window.open(site_root + 'Survey', 'm10survey', 'width=500,height=657,resizable=no,scrollbars=no,tolbar=no,location=no,directories=no,menubar=no,copyhistory=no');
        /*if (!popup) {
            // the visitor has pop-up blocker active - so put on onclick on the mainwrapper so when the user clicks on anything on the page, it'll pop up
            $('mainwrapper').addEvent('click', popUpSurvey);
        } else {
            // survey has been popped up - prevent it from popping up again for this user
            surveyPopped = Cookie.write('surveyPopped', true);
        }*/

		surveyPopped = Cookie.write('surveyPopped', true);
    }
}

function openSurveyPopup()
{
	var popup = window.open(site_root + 'Survey', 'm10survey', 'width=500,height=657,resizable=no,scrollbars=no,tolbar=no,location=no,directories=no,menubar=no,copyhistory=no').blur();
	window.focus();
}

function whyAreWeDoingThis()
{
	var popup = window.open(site_root + 'Survey#why', 'm10survey', 'width=500,height=657,resizable=no,scrollbars=no,tolbar=no,location=no,directories=no,menubar=no,copyhistory=no');
}
