// JavaScript Document
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function didja(){
	theNum=Math.floor(Math.random()*6);
	theDiv=document.getElementById("didYouKnow");
	switch (theNum) {
		case 0 : theCode='<a href="fortunes.html">There’s no word in French for booger.<br /><br /><span style="font-size:12px">Sound bogus? Click here.</span></a>'; break;
		case 1 : theCode='<a href="fortunes.html">Butterflies have been known to kill.<br /><br /><span style="font-size:12px">Say what? Click here.</span></a>'; break;
		case 2 : theCode='<a href="fortunes.html">Earwax tastes like pennies.<br /><br /><span style="font-size:12px">You think? Click here.</span></a>'; break;
		case 3 : theCode='<a href="fortunes.html">Young people hear more radio ads for alcohol than legal-aged drinkers do.<br /><br /><span style="font-size:12px">Really? Click here.</span></a>'; break;
		case 4 : theCode='<a href="fortunes.html">The more alcohol ads young people see, the more they drink.<br /><br /><span style="font-size:12px">Sound bogus? Click here.</span></a>'; break;
		case 5 : theCode='<a href="fortunes.html">The alcohol industry spends over $2 billion a year on ads.<br /><br /><span style="font-size:12px">Sound bogus? Click here.</span></a>'; break;
	}
	theDiv.innerHTML=theCode;
}

function homeDidja(){
	theNum=Math.floor(Math.random()*6);
	theDiv=document.getElementById("randomFact");
	switch (theNum) {
		case 0 : theCode='<a href="fortunes.html"><em><strong>Did you know: </strong></em><span id="ranFact">There’s no word in French for booger. Sound questionable? Click here.</span>'; break;
		case 1 : theCode='<a href="fortunes.html"><em><strong>Did you know: </strong></em><span id="ranFact">Butterflies have been known to kill. Sound questionable? Click here.</span>'; break;
		case 2 : theCode='<a href="fortunes.html"><em><strong>Did you know: </strong></em><span id="ranFact">Young people hear more alcohol radio ads than legal-aged drinkers do. What? Click here.</span>'; break;
		case 3 : theCode='<a href="fortunes.html"><em><strong>Did you know: </strong></em><span id="ranFact">Ear wax tastes like pennies. Sound questionable? Click here.</span>'; break;
		case 4 : theCode='<a href="fortunes.html"><em><strong>Did you know: </strong></em><span id="ranFact">The more alcohol ads young people see, the more they drink. Really? Click here.</span>'; break;
		case 5 : theCode='<a href="fortunes.html"><em><strong>Did you know: </strong></em><span id="ranFact">The alcohol industry spends over $2 billion a year on ads. Sound bogus? Click here.</span>'; break;
	}
	theDiv.innerHTML=theCode;
}
function cookieDidja(){
	theNum=Math.floor(Math.random()*6);
	theDiv=document.getElementById("cookie");
	switch (theNum) {
		case 0 : theCode="Knock knock jokes were invented in 1842."; break;
		case 1 : theCode='The movie "Snakes On A Plane" was a true story.'; break;
		case 2 : theCode="Until 1976, the NBA didn't allow deodorant. Eww."; break;
		case 3 : theCode="The first football helmet was made out of cheese."; break;
		case 4 : theCode="Help! I'm trapped in a fortune cookie factory!"; break;
		case 5 : theCode='Over 1,000 people a year die from exploding whoopie cushions.'; break;
	}
	theDiv.innerHTML=theCode;
}
function bogusDidja(){
	theNum=Math.floor(Math.random()*3)+1;
	theDiv=document.getElementById("bogus");
	switch (theNum) {
		case 1 : theSource=document.getElementById("set1"); break;
		case 2 : theSource=document.getElementById("set2"); break;
		case 3 : theSource=document.getElementById("set3"); break;
	}
	theDiv.innerHTML=theSource.innerHTML;
	theSource.innerHTML="";
}
function popUp(URL) {
	day = new Date();
	id = day.getTime();
	width=300;
	height=420;
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,status=0,menubar=0,width="+width+",height="+height+",left=150,top=80');");
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function downloadCall(whichClick){
	var pageTracker = _gat._getTracker("UA-4448692-1");
	pageTracker._initData();
	whichClick="/downloads/"+whichClick+".html";
	pageTracker._trackPageview(whichClick);
}
function addWord(theWord){
	var lastWord=theWord;
	var messageDiv=document.getElementById("message");
	var theCount=document.getElementById("wordCount");
	var theMessage=messageDiv.innerHTML;
	var yourMessage=document.getElementById("yourMessage");
	theMessage=theMessage+" "+theWord;
	if(theMessage.length<60){
		if(messageDiv.innerHTML.length>0){
		messageDiv.innerHTML=messageDiv.innerHTML+" "+theWord;
		} else {
			messageDiv.innerHTML=theWord;
		}
		theCount.innerHTML="Characters Remaining: "+String(59-theMessage.length);
		yourMessage.value=theMessage;
		
	} else {
		alert("Sorry, your message has to be less than 60 characters, including spaces.");
	}
}
function clearMessage(){
	var messageDiv=document.getElementById("message");
	messageDiv.innerHTML="";
	var theCount=document.getElementById("wordCount");
	theCount.innerHTML="Characters Remaining: 60";
}
function deleteWord(){
	var theCount=document.getElementById("wordCount");
	var messageDiv=document.getElementById("message");
	goBack=messageDiv.innerHTML.length;
	lastSpace=messageDiv.innerHTML.lastIndexOf(" ");
	newMessage=messageDiv.innerHTML.substring(0,lastSpace);
	messageDiv.innerHTML=newMessage;
	theCount.innerHTML="Characters Remaining: "+String(59-newMessage.length);
}
/* BROWSER DETECTION */
//initialization, browser, os detection
function browCheck(){
	var d, dom, nu='', brow='', ie, ie4, ie5, ie5x, ie6, ie7;
	var ns4, moz, moz_rv_sub, release_date='', moz_brow, moz_brow_nu='', moz_brow_nu_sub='', rv_full=''; 
	var mac, win, old, lin, ie5mac, ie5xwin, konq, saf, op, op4, op5, op6, op7;
	
	d=document;
	n=navigator;
	nav=n.appVersion;
	nan=n.appName;
	nua=n.userAgent;
	old=(nav.substring(0,1)<4);
	mac=(nav.indexOf('Mac')!=-1);
	win=( ( (nav.indexOf('Win')!=-1) || (nav.indexOf('NT')!=-1) ) && !mac)?true:false;
	lin=(nua.indexOf('Linux')!=-1);
	// begin primary dom/ns4 test
	// this is the most important test on the page
	if ( !document.layers )
	{
		dom = ( d.getElementById ) ? d.getElementById : false;
	}
	else { 
		dom = false; 
		ns4 = true;// only netscape 4 supports document layers
	}
	// end main dom/ns4 test
	
	op=(nua.indexOf('Opera')!=-1);
	saf=(nua.indexOf('Safari')!=-1);
	konq=(!saf && (nua.indexOf('Konqueror')!=-1) ) ? true : false;
	moz=( (!saf && !konq ) && ( nua.indexOf('Gecko')!=-1 ) ) ? true : false;
	ie=((nua.indexOf('MSIE')!=-1)&&!op);
	if (op)
	{
		brow = 'Opera';
	}
	else if (saf)
	{
		brow = 'Safari';
	}
	else if (konq)
	{
		brow = 'Konqueror';
	}
	// this part is complicated a bit, don't mess with it unless you understand regular expressions
	// note, for most comparisons that are practical, compare the 3 digit rv nubmer, that is the output
	// placed into 'nu'.
	else if (moz)
	{
		brow="mozilla";
	}
	else if (ie)
	{
		str_pos=nua.indexOf('MSIE');
		nu=nua.substr((str_pos+5),3);
		brow = 'Microsoft Internet Explorer';
	}
	// default to navigator app name
	else 
	{
		brow = nan;
	}
	op5=(op&&(nu.substring(0,1)==5));
	op6=(op&&(nu.substring(0,1)==6));
	op7=(op&&(nu.substring(0,1)==7));
	op8=(op&&(nu.substring(0,1)==8));
	op9=(op&&(nu.substring(0,1)==9));
	ie4=(ie&&!dom);
	ie5=(ie&&(nu.substring(0,1)==5));
	ie6=(ie&&(nu.substring(0,1)==6));
	ie7=(ie&&(nu.substring(0,1)==7));
	// default to get number from navigator app version.
	if(!nu) 
	{
		nu = nav.substring(0,1);
	}
	/*ie5x tests only for functionavlity. dom or ie5x would be default settings. 
	Opera will register true in this test if set to identify as IE 5*/
	ie5x=(d.all&&dom);
	ie5mac=(mac&&ie5);
	ie5xwin=(win&&ie5x);
	if ( ie5 || ie6 ) {
		d.write('<link rel = "stylesheet" type = "text\/css" href = "http://www.questionthemessage.com/styles/ie_styles.css" />');
	}
	else {
		d.write('<link rel = "stylesheet" type = "text\/css" href = "http://www.questionthemessage.com/styles/styles.css" />');
	}
}