var ie = (document.all) ? true : false;

var ns = (document.layers) ? true : false;

var dom = (!document.all && document.getElementById) ? true : false;




//nav

preload('nHome_on','/test/images/nav/home_on.gif');
preload('nHome_off','/test/images/nav/home_off.gif');

preload('nCheckup_on','/test/images/nav/checkup_on.gif');
preload('nCheckup_off','/test/images/nav/checkup_off.gif');

preload('nTheShow_on','/test/images/nav/theshow_on.gif');
preload('nTheShow_off','/test/images/nav/theshow_off.gif');

preload('nTunein_on','/test/images/nav/tunein_on.gif');
preload('nTunein_off','/test/images/nav/tunein_off.gif');

preload('nAbout_on','/test/images/nav/about_on.gif');
preload('nAbout_off','/test/images/nav/about_off.gif');

preload('nPlaysafe_on','/test/images/nav/playsafe_on.gif');
preload('nPlaysafe_off','/test/images/nav/playsafe_off.gif');

preload('nSpeakup_on','/test/images/nav/speakup_on.gif');
preload('nSpeakup_off','/test/images/nav/speakup_off.gif');


//about subnav
preload('nMission_on','/test/images/about/nav/mission_on.gif');

preload('nMission_off','/test/images/about/nav/mission_off.gif');
preload('nAboutcbmp_on','/test/images/about/nav/aboutcbmp_on.gif');

preload('nAboutcbmp_off','/test/images/about/nav/aboutcbmp_off.gif');
preload('nActivities_on','/test/images/about/nav/activities_on.gif');

preload('nActivities_off','/test/images/about/nav/activities_off.gif');
preload('nPress_on','/test/images/about/nav/press_on.gif');

preload('nPress_off','/test/images/about/nav/press_off.gif');

//checkup subnav
preload('nGetTheFacts_on','/test/images/checkup/nav/get_the_facts_on.gif');

preload('nGetTheFacts_off','/test/images/checkup/nav/get_the_facts_off.gif');
preload('nGetTested_on','/test/images/checkup/nav/get_tested_on.gif');

preload('nGetTested_off','/test/images/checkup/nav/get_tested_off.gif');
preload('nProtectYourself_on','/test/images/checkup/nav/protect_yourself_on.gif');

preload('nProtectYourself_off','/test/images/checkup/nav/protect_yourself_off.gif');
preload('nTalkAboutIt_on','/test/images/checkup/nav/talk_about_it_on.gif');

preload('nTalkAboutIt_off','/test/images/checkup/nav/talk_about_it_off.gif');
preload('nResources_on','/test/images/checkup/nav/resources_on.gif');

preload('nResources_off','/test/images/checkup/nav/resources_off.gif');

//tunein subnav
preload('nWatch_on','/test/images/tunein/nav/watch_on.gif');

preload('nWatch_off','/test/images/tunein/nav/watch_off.gif');
preload('nListen_on','/test/images/tunein/nav/listen_on.gif');

preload('nListen_off','/test/images/tunein/nav/listen_off.gif');
preload('nScrapbook_on','/test/images/tunein/nav/scrapbook_on.gif');

preload('nScrapbook_off','/test/images/tunein/nav/scrapbook_off.gif');

//speakup subnav
preload('nTalkAbout_on','/test/images/speakup/nav/talk_about_it_on.gif');

preload('nTalkAbout_off','/test/images/speakup/nav/talk_about_it_off.gif');
preload('nExpress_on','/test/images/speakup/nav/express_on.gif');

preload('nExpress_off','/test/images/speakup/nav/express_off.gif');
preload('nRealPeople_on','/test/images/speakup/nav/real_people_on.gif');

preload('nRealPeople_off','/test/images/speakup/nav/real_people_off.gif');


//poll
preload('bPoll_on','/test/images/btn_pollSubmit_on.gif');

preload('bPoll_off','/test/images/btn_pollSubmit_off.gif');
preload('bHomePoll_on','/test/images/home/btn_submit_on.gif');

preload('bHomePoll_off','/test/images/home/btn_submit_off.gif');

//the show
preload('nWatchShow_on','/test/images/theshow/watch_on.gif');
preload('nWatchShow_off','/test/images/theshow/watch_off.gif');
preload('nReact_on','/test/images/theshow/react_on.gif');
preload('nReact_off','/test/images/theshow/react_off.gif');
preload('nAskUs_on','/test/images/theshow/askus_on.gif');
preload('nAskUs_off','/test/images/theshow/askus_off.gif');
preload('nHosts_on','/test/images/theshow/thehosts_on.gif');
preload('nHosts_off','/test/images/theshow/thehosts_off.gif');
preload('nAboutShow_on','/test/images/theshow/about_on.gif');
preload('nAboutShow_off','/test/images/theshow/about_off.gif');

function preload(imgObj,imgSrc) {

	if (document.images) {

		eval(imgObj+' = new Image()')

		eval(imgObj+'.src = "'+imgSrc+'"')

	}

}

function chgImg(imgField,newImg) {

	if (ns) {eval('document.images[imgField].src = '+newImg+'.src')}

	if (ie) {document[imgField].src = eval(newImg+'.src')}

	if (dom) {document.images[imgField].src = eval(newImg+'.src');}

}

function popEmailToAFriend(pageTitle,pageUrl){
	winurl = "../email_this_page.php?pageTitle=" + pageTitle + "&pageUrl=" + pageUrl;

	window.open(winurl,"EmailPage","height=387,width=381,menubar=0,resizeable=0,location=0,scrollbars=0,status=0,titlebar=0,toolbar=0");
}
function popJoinTheCommunity(){
	winurl = "../join_the_community.php";

	window.open(winurl,"JoinPage","height=387,width=381,menubar=0,resizeable=0,location=0,scrollbars=0,status=0,titlebar=0,toolbar=0");
}
function popNominateYourHero(){
	winurl = "/nominate_your_hero.php";

	window.open(winurl,"NominatePage","height=649,width=614,menubar=0,resizeable=0,location=0,scrollbars=0,status=0,titlebar=0,toolbar=0");
}
function popThisIsMe(){
	winurl = "/thisismeform.php";

	window.open(winurl,"ThisIsMe","height=649,width=614,menubar=0,resizeable=0,location=0,scrollbars=1,status=0,titlebar=0,toolbar=0");
}
function popTellUsYourStory(){
	winurl = "../tell_us_your_story.php";

	window.open(winurl,"StoryPage","height=700,width=612,menubar=0,resizeable=0,location=0,scrollbars=1,status=0,titlebar=0,toolbar=0");
}
function popWatchEpisode(){
	winurl = "watchEpisode.php";

	window.open(winurl,"Episode","height=590,width=900,menubar=0,resizeable=0,location=0,scrollbars=0,status=0,titlebar=0,toolbar=0");
}
function popWatchApril(){
	winurl = "watchApril.php";

	window.open(winurl,"Episode","height=590,width=900,menubar=0,resizeable=0,location=0,scrollbars=0,status=0,titlebar=0,toolbar=0");
}
function popWatchSeptember(){
	winurl = "watchSeptember.php";

	window.open(winurl,"Episode","height=590,width=900,menubar=0,resizeable=0,location=0,scrollbars=0,status=0,titlebar=0,toolbar=0");
}
function popWatchNovember(){
	winurl = "watchNovember08.php";

	window.open(winurl,"Episode","height=590,width=900,menubar=0,resizeable=0,location=0,scrollbars=0,status=0,titlebar=0,toolbar=0");
}
function popWatchDecember(){
	winurl = "watchDecember08.php";

	window.open(winurl,"Episode","height=590,width=900,menubar=0,resizeable=0,location=0,scrollbars=0,status=0,titlebar=0,toolbar=0");
}
function popText(){
	winurl = "/playsafe/text.php";

	window.open(winurl,"Text","height=314,width=376,menubar=0,resizeable=0,location=0,scrollbars=0,status=0,titlebar=0,toolbar=0");
}
function popWhereishiv(){
	winurl = "/whereishiv.php";

	window.open(winurl,"Text","height=409,width=690,menubar=0,resizeable=0,location=0,scrollbars=0,status=0,titlebar=0,toolbar=0");
}
// @method : scrollToTop();
// @purpose : scrolls browser window to top
function scrollToTop(){
	scrollTo(0,0);	
}

		function getSelectedRadio(buttonGroup) {
		   // returns the array number of the selected radio button or -1 if no button is selected
		   if (buttonGroup[0]) { // if the button group is an array (one button is not an array)
			  for (var i=0; i<buttonGroup.length; i++) {
				 if (buttonGroup[i].checked) {
					return i
				 }
			  }
		   } else {
			  if (buttonGroup.checked) { return 0; } // if the one button is checked, return zero
		   }
		   // if we get to this point, no radio button is selected
		   return -1;
		} // Ends the "getSelectedRadio" function

function getSelectedRadioValue(buttonGroup) {
// returns the value of the selected radio button or "" if no button is selected
	var i = getSelectedRadio(buttonGroup);
	if (i == -1) {
		return "";
	} else {
		if (buttonGroup[i]) { // Make sure the button group is an array (not just one button)
			return buttonGroup[i].value;
		} else { // The button group is just the one button, and it is checked
	 		return buttonGroup.value;
		}
	}
} // Ends the "getSelectedRadioValue" function
		
		
function poll_submit(frm){
	var frm = document.forms['pollForm'];
	pageTracker._trackEvent("Polls",
							"Poll_Submit", 
							"Have you ever talked to a partner about their/your HIV status?",
							getSelectedRadioValue(frm.radios) );									
	frm.submit();
}