var preloadFlag = false;
function preloadImages() {
	if (document.images) {
		tnav_home_over = newImage("/images/tnav_home-over.gif");
		tnav_cheerios_family_over = newImage("/images/tnav_cheerios_family-over.gif");
		tnav_history_over = newImage("/images/tnav_history-over.gif");
		tnav_promotions_over = newImage("/images/tnav_promotions-over.gif");
		tnav_button_go_over = newImage("/images/tnav_button_go-over.gif");
		tnav_for_kids_over = newImage("/images/tnav_for_kids-over.gif");
		tnav_for_new_parents_over = newImage("/images/tnav_for_new_parents-over.gif");
		tnav_for_families_over = newImage("/images/tnav_for_families-over.gif");
		tnav_for_adults_over = newImage("/images/tnav_for_adults-over.gif");
		unav_print_page_over = newImage("/images/unav_print_page-over.gif");
		unav_tell_a_friend_over = newImage("/images/unav_tell_a_friend-over.gif");
		unav_type_size1_over = newImage("/images/unav_type_size1-over.gif");
		unav_type_size2_over = newImage("/images/unav_type_size2-over.gif");
		unav_type_size3_over = newImage("/images/unav_type_size3-over.gif");
		ff_lnav_cholesterol_over = newImage("/images/cr_lnav_team43-over.gif");
		ff_lnav_heart_healthy_eating_over = newImage("/images/cr_lnav_team98-over.gif");
		ff_lnav_getting_active_over = newImage("/images/cr_lnav_getcoolstuff-over.gif");
		lnav_your_stories_over = newImage("/images/lnav_your_stories-over.gif");
		lnav_your_tips_over = newImage("/images/lnav_your_tips-over.gif");
		lnav_message_board_over = newImage("/images/lnav_message_board-over.gif");
		ff_lnav_being_active_over = newImage("/images/ff_lnav_being_active-over.gif");
		ff_lnav_eating_well_over = newImage("/images/ff_lnav_eating_well-over.gif");
		ff_lnav_ready_for_life_over = newImage("/images/ff_lnav_ready_for_life-over.gif");
		ff_lnav_cheerios_playroom_over = newImage("/images/ff_lnav_cheerios_playroom-o.gif");
		ff_lnav_radio_shows_over = newImage("/images/ff_lnav_radio_shows-over.gif");
		cr_landing_titl1 = newImage("/images/cr_landing_titl1-over.gif");
		cr_landing_titl2 = newImage("/images/cr_landing_titl2-over.gif");
		cr_landing_titl3 = newImage("/images/cr_landing_titl3-over.gif");
		cr_landing_submit = newImage("/images/cr_landing_submit-over.gif");
		cr_t98_tit1 = newImage("/images/cr_t98_tit1-over.gif");
		cr_t98_tit2 = newImage("/images/cr_t98_tit2-over.gif");
		cr_t98_tit3 = newImage("/images/cr_t98_tit3-over.gif");
		cr_t43_tit1 = newImage("/images/cr_t43_tit1-over.gif");
		cr_t43_tit2 = newImage("/images/cr_t43_tit2-over.gif");
		cr_t43_tit3 = newImage("/images/cr_t43_tit3-over.gif");
		cr_re_p1big = newImage("/images/cr_re_p1big.jpg"); 
		cr_re_p2big = newImage("/images/cr_re_p2big.jpg"); 
		cr_rp_p1big = newImage("/images/cr_rp_p1big.jpg"); 
		cr_rp_p2big = newImage("/images/cr_rp_p2big.jpg"); 
		cr_bl_p1big = newImage("/images/cr_bl_p1big.jpg"); 
		cr_bl_p2big = newImage("/images/cr_bl_p2big.jpg"); 
		cr_bl_p3big = newImage("/images/cr_bl_p3big.jpg"); 
		cr_bl_p4big = newImage("/images/cr_bl_p4big.jpg"); 
		cr_ec_p1big = newImage("/images/cr_ec_p1big.jpg"); 
		cr_ec_p2big = newImage("/images/cr_ec_p2big.jpg"); 
		preloadFlag = true;
	}
}
if(navigator.userAgent.indexOf("Firefox") != -1) var ffx = 7
else var ffx=0

function showanswer(ansid){
	document.getElementById(ansid).style.position='relative';
	document.getElementById(ansid).style.visibility='visible';
	document.getElementById('s'+ansid).style.visibility='hidden';
}
function hideanswer(ansid){
	document.getElementById(ansid).style.position='absolute';
	document.getElementById(ansid).style.visibility='hidden';
	document.getElementById('s'+ansid).style.visibility='visible';
}

function getimagewidth(imagename){
	myImage = new Image();
	myImage.src = imagename 
	return myImage.width;
}
var origpholder;
function resetpholder(imagename,pdiv){
	if(origpholder == ""){
		document.getElementById("pholder").style.left = origpholder;
	}else{
		origpholder = document.getElementById("pholder").style.left;
	}
	document.getElementById("pholder").style.left = parseInt(document.getElementById("pholder").offsetLeft) - getimagewidth(imagename);
	document.getElementById("pholder").style.top = parseInt(document.getElementById(pdiv).offsetTop)
	document.getElementById("pholder").innerHTML = document.getElementById(pdiv).innerHTML;
}
function hidepholder(){
	document.getElementById("pholder").innerHTML = "";
}

function popdown(pathname,wide,high){
	window.open(pathname,"somthingracing","height="+wide+",width="+high+",status=yes,toolbar=no,menubar=no,location=no,scrollbars=yes");
}

function checkwhatpollstatetoshow(){
	if (readCookie("voted") == "y") {
		votedata(readCookie("pollidgenerated"));
	}else{
		
		var xmlhttp=false; //Clear our fetching variable
	    try {
			xmlhttp = new ActiveXObject('Msxml2.XMLHTTP'); //Try the first kind of active x object.
	    } catch (e) {
			try {
				xmlhttp = new
				ActiveXObject('Microsoft.XMLHTTP'); //Try the second kind of active x object
			} catch (E) {
				xmlhttp = false;
			}
	    }
	    if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
			xmlhttp = new XMLHttpRequest(); //If we were able to get a working active x object, start an XMLHttpRequest
	    }
	    var file = 'votegenerate.aspx'; //This is the path to the file we just finished making
		xmlhttp.open('POST', file, true); //Open the file through GET, and add the id we want to retrieve as a GET variable
		xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		xmlhttp.send("pollid="+readCookie("pollidgenerated"));//<<#-------------------- if the cookie is blank it will generate one
		xmlhttp.onreadystatechange=function() {
			if (xmlhttp.readyState==4) { //Check if it is ready to recieve data
				var content = xmlhttp.responseText; //The content data which has been retrieved
				if( content != "failure"){ //If the response was not "n" (meaning it worked)
					var contentsplit = content.split("||")
					setCookie("pollidgenerated",contentsplit[0]);
					document.getElementById("votingdiv").innerHTML = contentsplit[1];
				}
			}
	    }
		return;
	}
}
function setvote(id,vt){
	if(vt == ""){
document.getElementById("votingdiv").innerHTML = document.getElementById("votingdiv").innerHTML.replace("<!--errors-->",'<span style="color:#FF0000">Please select an answer and resubmit.</span><br />');
		return;
	}
	var xmlhttp=false; //Clear our fetching variable
    try {
		xmlhttp = new ActiveXObject('Msxml2.XMLHTTP'); //Try the first kind of active x object.
    } catch (e) {
		try {
			xmlhttp = new
			ActiveXObject('Microsoft.XMLHTTP'); //Try the second kind of active x object
		} catch (E) {
			xmlhttp = false;
		}
    }
    if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
		xmlhttp = new XMLHttpRequest(); //If we were able to get a working active x object, start an XMLHttpRequest
    }
    var file = 'vote.aspx'; //This is the path to the file we just finished making
	xmlhttp.open('POST', file, true); //Open the file through GET, and add the id we want to retrieve as a GET variable
	xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlhttp.send("id="+id+"&vt="+vt);
	xmlhttp.onreadystatechange=function() {
		if (xmlhttp.readyState==4) { //Check if it is ready to recieve data
			var content = xmlhttp.responseText; //The content data which has been retrieved
			if( content != 'failure' ){ //If the response was not "n" (meaning it worked)
				votedata(id);
			}
		}
    }
	setCookie("voted", "y")
	return;
}
function votedata(id){
	var xmlhttp=false;
    try {
		xmlhttp = new ActiveXObject('Msxml2.XMLHTTP');
    } catch (e) {
		try {
			xmlhttp = new
			ActiveXObject('Microsoft.XMLHTTP');
		} catch (E) {
			xmlhttp = false;
		}
    }
    if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
		xmlhttp = new XMLHttpRequest();
    }
    var file = "votedata.aspx?id="+id;
	xmlhttp.open('get', file, true);
	xmlhttp.onreadystatechange=function() {
		if (xmlhttp.readyState==4) {
			var content = xmlhttp.responseText;
			if( content != '' ){
				document.getElementById("votingdiv").innerHTML = content;
			}
		}
    }
	xmlhttp.send(null);
	return;
}
//##########COOKIE FUNCTIONS
function setCookie(name,value,days){
	if (days){
		var date = new Date();
		date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
		var expires = "; expires=" + date.toGMTString();
	} else {
		var expires = "";
	}
	document.cookie = name + "=" + value + expires + "; path=/";
}

function readCookie(name){
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++)	{
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}