function detectMacXFF2() {
  var userAgent = navigator.userAgent.toLowerCase();
  if (/firefox[\/\s](\d+\.\d+)/.test(userAgent)) {
    var ffversion = new Number(RegExp.$1);
    if (ffversion < 3 && userAgent.indexOf('mac') != -1) {
      return true;
    }
  }
}

function launchSurvey() {
	$('SurveyScreen').height = document.viewport.getHeight();
	$('SurveyScreen').width = document.viewport.getWidth();

	var newX = Math.round((document.viewport.getWidth()-($('SurveyBody').getWidth()))/2);
	var newY = Math.round((document.viewport.getHeight()-($('SurveyBody').getHeight()))/2);

	if (detectMacXFF2()) {
		$('SurveyScreen').appear({ duration: 0 });
		$('SurveyBody').appear({ duration: 0 });
	} else {
		$('SurveyScreen').appear({ duration: 1.0, to: .75 });
		$('SurveyBody').appear({ duration: 2.0 });
	}

	new Effect.Move('SurveyBody', { x: newX, y: newY, mode: 'absolute', duration: 0 });

	if (!detectMacXFF2()) {
	  setTimeout('do_sIFR()',50);
	}
	setTimeout('centerRight()',50);

	pageTracker._trackPageview('/survey_open');
}

function closeSurvey() {
	$('SurveyScreen').fade({ duration: 2.0 });
	$('SurveyBody').fade({ duration: 1.0 });

	pageTracker._trackPageview('/survey_close');
}

var currentPage = 1;
var formValues = "";


function nextPage() {
	recordForm();
	currentPage++;



	if (currentPage == 10) {

		pageTracker._trackPageview('/survey_complete');

		currentPage = 9;
		doSubmit();
		//alert("email_submit.php?foo=foo&"+formValues)
		var n = new Ajax.Request("email_submit.php?foo=foo&"+formValues);
		$('SurveyLeft').innerHTML = $('Page10Left').innerHTML;
		$('SurveyRightContent').innerHTML = $('Page10Right').innerHTML;
				if (!detectMacXFF2()) {6
					do_sIFR();
				}

		$('SurveyNext').fade({duration:0});
		currentPage = 1;
		formValues = "";

	} else {

		pageTracker._trackPageview('/survey_'+currentPage);

		$('SurveyLeft').innerHTML = $('Page'+currentPage+'Left').innerHTML;
		$('SurveyRightContent').innerHTML = $('Page'+currentPage+'Right').innerHTML;
		if (!detectMacXFF2()) {
			do_sIFR();
		}

		if (currentPage == 3) {
		var so = new SWFObject('/lib/flash/mediaplayer.swf','jsplayer','240','200','7');
		so.addVariable("allowfullscreen","true");
		so.addVariable("enablejs","true");
		so.addVariable("javascriptid","jsplayer");
		so.addVariable("autostart","false");
		so.addVariable("displayheight",200);
		so.addVariable("displaywidth",240);
		so.addVariable("file","/lib/video/RockPaperScissorsSpot.flv");
		so.write('page3player');
		}


		if (currentPage == 9) {
			$('NextButton').src = "/lib/images/survey/submit.png";
		}
	}

	//centerRight();

}

function centerRight() {
	//var mgn = ($('SurveyRight').getHeight() - $('SurveyRightContent').getHeight())/2;
	//new Effect.Move('SurveyRightContent',{y:mgn,mode:'absolute',duration:0});
}

function recordForm() {
	formValues = formValues + '&' + $('FormPage'+currentPage).serialize();
}

function popShootTheRock() {
	var newW = window.open('/games/shoot_the_rock.htm', 'NewWindow', 'width=760,height=550,scrollbars=no,resizable=yes,menubar=no,toolbar=no,location=no');
}

function popRockBlox() {
	var newW = window.open('/games/rock_blox.htm', 'NewWindow', 'width=775,height=600,scrollbars=no,resizable=yes,menubar=no,toolbar=no,location=no');
}

function doSubmit() {
	//alert(formValues);
}

function popup(theURL,winName,features) { //v2.0
	window.open(theURL,"tour","width=340,height=350");
}

// these functions are caught by the JavascriptView object of the player.
function sendEvent(typ,prm) { thisMovie("jsplayer").sendEvent(typ,prm); };
// These functions are caught by the feeder object of the player.
function loadFile(obj) { thisMovie("jsplayer").loadFile(obj); sendEvent('playpause'); };
// This is a javascript handler for the player and is always needed.
function thisMovie(movieName) {
if(navigator.appName.indexOf("Microsoft") != -1) {
return window[movieName];
} else {
return document[movieName];
}
};