var DOMutils = {
	/* http://www.quirksmode.org/blog/archives/2005/10/_and_the_winner_1.html */
	addEvent:function(obj, type, fn) {
		if (obj.addEventListener)
			obj.addEventListener(type, fn, false);
		else if (obj.attachEvent) {
			obj["e"+type+fn] = fn;
			obj[type+fn] = function() {obj["e"+type+fn](window.event);}
			obj.attachEvent("on"+type, obj[type+fn]);
		}
	},
	/* http://www.robertnyman.com/2005/11/07/the-ultimate-getelementsbyclassname/ */
	getElementsByClassName:function(oElm, strTagName, strClassName) {
	    var arrElements = (strTagName == "*" && document.all)? document.all : oElm.getElementsByTagName(strTagName);
	    var arrReturnElements = new Array();
	    strClassName = strClassName.replace(/\-/g, "\\-");
	    var oRegExp = new RegExp("(^|\\s)" + strClassName + "(\\s|$)");
	    var oElement;
	    for(var i=0; i<arrElements.length; i++){
	        oElement = arrElements[i];      
	        if(oRegExp.test(oElement.className)){
	            arrReturnElements.push(oElement);
	        }   
	    }
	    return (arrReturnElements)
	}
}

/*	ELO - Encapsulated Load Object, by Robert Nyman, http://www.robertnyman.com
	Inspired and influenced by Dean Edwards, Matthias Miller, and John Resig: http://dean.edwards.name/weblog/2006/06/again/
*/
var ELO={loaded:false,timer:null,functionsToCallOnload:[],init:function(){if(ELO.loaded)return;ELO.loaded=true;ELO.load();},load:function(){if(this.timer){clearInterval(this.timer);}for(var i=0;i<this.functionsToCallOnload.length;i++){try{eval(this.functionsToCallOnload[i]);}catch(e){ /* Handle error here */ }}}}; /*@cc_on @*//*@if(@_win32)if(document.getElementById){document.write("<script id=\"ieScriptLoad\" defer src=\"//:\"><\/script>");document.getElementById("ieScriptLoad").onreadystatechange=function(){if(this.readyState=="complete"){ELO.init();}};}/*@end @*/if(document.addEventListener){document.addEventListener("DOMContentLoaded",ELO.init,false);}if(navigator.userAgent.search(/WebKit/i)!=-1){ELO.timer=setInterval(function(){if(document.readyState.search(/loaded|complete/i)!=-1){ELO.init();}},10);}window.onload=ELO.init;

var prepExternalLinks = {
	sLinkClass:"external",
	sExitMsg:"You will be leaving the FORADIL Web site.\nClick OK to continue, or CANCEL to return to Foradil.us.",
	oElementContainer: document.getElementById('main-content'),
	init:function() {
		if (!document.getElementById) {return;}
		var arrLinks = DOMutils.getElementsByClassName( document.getElementById('main-content'), 'a', prepExternalLinks.sLinkClass);
		iLinks = arrLinks.length;
		if (iLinks == 0) return; 
		for (var i=0; i<iLinks; i++) {
			oLink = arrLinks[i];
			oLink.onclick = function() {
				if (! confirm(prepExternalLinks.sExitMsg) ){ return false; };
			}
		}
	}
};
ELO.functionsToCallOnload.push("prepExternalLinks.init()");


// Legacy scripts
function runFlash(swfFile,width,height,id) { 
document.write('<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" WIDTH="' + width + '" HEIGHT="'+ height + '" id="' + id + '" ALIGN="">\n');
document.write('<PARAM NAME=movie VALUE="' + swfFile + '">\n');
document.write('<PARAM NAME=quality VALUE=high>\n');
document.write('<PARAM NAME=bgcolor VALUE=#FFFFFF>\n');
document.write('<EMBED src="' + swfFile + '" quality=high bgcolor=#FFFFFF  WIDTH="' + width +'" HEIGHT="'+ height + '" NAME="' + id + '" ALIGN="" TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></EMBED></OBJECT>');  
}

function setOptinValues(theForm, bbdo_opt_in, optin_direct, optin_email) {
   if (theForm.bbdo_opt_in[1].checked) { disableChoices(true, theForm.bbdo_opt_in_preference) };
   if (bbdo_opt_in)
   {
    return;
   }
   if (optin_direct.indexOf("true")>=0 && optin_email.indexOf("true")>=0)
   {
     theForm.bbdo_opt_in_preference[0].checked=true;     
     theForm.bbdo_opt_in[0].checked=true;     
     return;
   }
   if (optin_direct.indexOf("false")>=0 && optin_email.indexOf("false")>=0)
   {     
     theForm.bbdo_opt_in[1].checked=true;     
     return;
   }   
   if (optin_direct.indexOf("true")>=0 )
   {
   	
     theForm.bbdo_opt_in_preference[2].checked=true;     
     theForm.bbdo_opt_in[0].checked=true;     
     return;
   }
   if (optin_email.indexOf("true")>=0 )
   {
     theForm.bbdo_opt_in_preference[1].checked=true;     
     theForm.bbdo_opt_in[0].checked=true;     
     return;
   }   
   if (optin_email.indexOf("false")>=0 )
   {     
     theForm.bbdo_opt_in[1].checked=true;     
   }   
   if (optin_direct.indexOf("false")>=0 )
   {     
     theForm.bbdo_opt_in[1].checked=true;     
   }   
}

function disableChoices(action, radioBtns) {
  for (var i=0; i<radioBtns.length; i++) {
      radioBtns[i].disabled = action;
      if (radioBtns[i].disabled) { radioBtns[i].checked = false; }
  }
}


function popUp(URL, attributes){
  var popUp = window.open(URL, 'newWindow', attributes)
  popUp.focus();
} 


function changeFormAction(theForm, newAction){
  document.forms[theForm].action = newAction;
  document.forms[theForm].submit();
}


function featureTopics(theForm){
  topics = new Array();            //All the topics form elements
  topicsIndex = 0;                 //Topics elements array index
  topicsChkd = new Array();        //Checked topics
  topicsChkdIndex = 0;             //Check topics index
  
  var hivesChkd = false;               
  var qaChkd= false;
  
  formElements = document.forms[theForm].elements.length;
  
  // Gather all form elements named 'topics'
  for (i=0; i<formElements; i++){
    if(document.forms[theForm].elements[i].name == "topics") {
      topics[topicsIndex] = document.forms[theForm].elements[i];
      topicsIndex++;
    }
    
  }
  
  //Gather how many topics elements checked  
  for (i=0; i<topics.length; i++){
    if (topics[i].checked){
      topicsChkd[topicsChkdIndex] = topics[i];
      topicsChkdIndex++;
    }       
  }

  //One topic selected, if it's hives or q&a, select clarinex info
  if (topicsChkd.length == 1) {  
      for (i=0; i<topicsChkd.length; i++){
        if (topicsChkd[i].value == "hives") hivesChkd = true;
        if (topicsChkd[i].value == "q_and_a") qaChkd = true;      
      }
      
      if( hivesChkd || qaChkd){
        for (i=0; i<topics.length; i++){
          if (topics[i].value == "clarinex_inf") topics[i].checked = true;
        }
      }  
  }
}



function pollenAlertCheck(theForm, mainChk){
  theForm = document.forms[theForm];  // Syntax shortcut
  sectionElements = new Array ();      // Section form elements
  var elementChkd;                    // Section form element checked flag

  
  //Gather section elements
  numSectionElements = pollenAlertCheck.arguments.length - 2;
  for (i=0; i<numSectionElements; i++){
    sectionElements[i] = pollenAlertCheck.arguments[i+2]; // Add 2 to bypass first 2 parameters of function
  }
  
  //Check element type and if checked
  for (i=0; i<sectionElements.length; i++){
    if ( sectionElements[i].type == "checkbox" && sectionElements[i].checked) {
      elementChkd = true;
    }
    else if (sectionElements[i].type == "text" && sectionElements[i].value != ""){
      elementChkd = true;
    }
    else if ( sectionElements[i].type == "radio" && sectionElements[i].checked ){
      elementChkd = true;
    }
  }
  
  if (elementChkd) theForm.elements[mainChk].checked = true;
}


function clearPollenAlert(chkbox){
  if (!chkbox.checked){
    
    numSectionElements = clearPollenAlert.arguments.length - 1; //Gather section elements
    sectionElements = new Array (); // Section form elements
 
    for (i=0; i<numSectionElements; i++){
      sectionElements[i] = clearPollenAlert.arguments[i+1]; // to bypass first 1
    }
  
    for (i=0; i<sectionElements.length; i++){
      if (sectionElements[i].type == "text"){
        sectionElements[i].value = "";
      }
      else if (sectionElements[i].type == "radio" || sectionElements[i].type == "checkbox"){
        sectionElements[i].checked = false;
      }
    } //end type check
    
  }  //end if not checked 

} // end function

function preloadImgs() {
  imgs = preloadImgs.arguments.length;
  
  for (i=0; i<imgs; i++){
    loadedImage = new Image();
    loadedImage.src = preloadImgs.arguments[i];
  }

}			

function checkHiddenField(theForm, chkbox, hiddenField){
  if (chkbox.checked) {
      hiddenField.value = true;
  } else {
    hiddenField.value = tempValue;
  }
  theForm.submit();
}


function usImgSwap(imgPath){
  document.images.USMAP.src = imgPath;
} 

function usThumbnailImgSwap(imgPath){
  document.images.THUMBNAIL.src = imgPath;
}

function openNationalWeatherMap(mapImg){
  var mapWindow = open("", "mapWindow", 'width=660,height=525,resizable');
  mapWindow.focus();
  mapWindow.document.open();
  mapWindow.document.writeln("<html><body><center><img src=" + mapImg + "><br><a href='javascript:window.close()'>Close Window</a></center></body></html>");
  mapWindow.document.close();
}
 
 
function linkOffSite(URL){
  if ( confirm("You will be leaving the FORADIL Web site.\nClick OK to continue, or CANCEL to return to Foradil.us") ){
    popUp(URL,'width=640,height=480,location,scrollbars,menubar,toolbar,resizable,directories,status')
  } 
} 


function validateMonths(theForm, monthGroupNames, yearValue){
  months = new Array();            //All the month form elements
  monthsIndex = 0;                 //Topics elements array index
  monthsChkd = new Array();        //Checked topics
  monthsChkdIndex = 0;             //Check topics index
  
  formElements = theForm.elements.length;
  
  // Gather all form elements named monthGroupNames
  for (i=0; i<formElements; i++){
    if(theForm.elements[i].name == monthGroupNames) {
      months[monthsIndex] = theForm.elements[i];
      monthsIndex++;
    }
  }

  // If yearround is checked, uncheck all individual months
  for (i=0; i<months.length; i++){
    if (months[i].value == yearValue && months[i].checked){
      for (j=0; j<months.length; j++) {
        if (months[j].value != yearValue && months[j].checked) {
         months[j].checked = false;
        }
      }
    break;
    }
  }
  
  //Submit form
  theForm.submit();
}



function bCanPrint(){
  if (window.print){
    window.print();
  } else {
    alert('Please select Print under the File menu to print this page.');
  }
}

/* Date and Time Functions */
var date = new Date();
var day  = date.getDate();
var month = date.getMonth() + 1;
var yy = date.getYear();
var year = (yy < 1000) ? yy + 1900 : yy;	

var tmp = date.getHours();
var hour = (tmp <= 12) ? tmp : (tmp-12);
hour = ( hour < 10 ) ? "0" + hour : hour;
var sym = (tmp < 12) ? "am" : "pm";
if (hour == "00"){hr=12;}

var minutes = (( date.getMinutes() < 10) ? "0" : "" ) + date.getMinutes();



/* Refill Reminder date validation */
var dtCh= "/";
var minYear=1900;
var maxYear=2100;

function isInteger(s){
	var i;
    for (i = 0; i < s.length; i++){   
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    return true;
}

function stripCharsInBag(s, bag){
	var i;
    var returnString = "";
    for (i = 0; i < s.length; i++){   
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function daysInFebruary (year){
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
function DaysArray(n) {
	for (var i = 1; i <= n; i++) {
		this[i] = 31;
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
		if (i==2) {this[i] = 29}
   } 
   return this;
}

function isDate(dtStr){
	var daysInMonth = DaysArray(12);
	var pos1=dtStr.indexOf(dtCh);
	var pos2=dtStr.indexOf(dtCh,pos1+1);
	var strMonth=dtStr.substring(0,pos1);
	var strDay=dtStr.substring(pos1+1,pos2);
	var strYear=dtStr.substring(pos2+1);
	strYr=strYear;
	if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1);
	if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1);
	for (var i = 1; i <= 3; i++) {
		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1);
	}
	month=parseInt(strMonth);
	day=parseInt(strDay);
	year=parseInt(strYr);
	if (pos1==-1 || pos2==-1){
		alert("The date format should be : mm/dd/yyyy");
		return false;
	}
	if (strMonth.length<1 || month<1 || month>12){
		alert("Please enter a valid month");
		return false;
	}
	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
		alert("Please enter a valid day");
		return false;
	}
	if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
		alert("Please enter a valid 4 digit year between "+minYear+" and "+maxYear);
		return false;
	}
	if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
		alert("Please enter a valid date");
		return false;
	}
return true;
}

function isEmpty(str) {
  return (str == null || str == "" || str.length == 0); 
}


function pfdDelete(formName) {
  var form = document.forms[formName];
  var itemChecked = 0;
  
  for (var i=0; i<form.elements.length; i++){
      if (form.elements[i].type == "checkbox" && form.elements[i].name == "delete" && form.elements[i].checked) {
      itemChecked++;
    }
  }
  
  if (itemChecked) form.submit();
  else alert("Please select an entry to delete.");
  
}

function closeAndGoto(url) {
  window.close();
  opener.location = url;
  opener.focus();
}

function whatsThis() {
  alert("Checking this box saves your login information onto the computer you are currently using so you do not have to type it in whenever you visit this site. If you 'sign out' you will have to type in your user name and password the next time you visit the site.\n\nWe offer this option purely for your convenience and do not track whether you select this option or not.");
}

function getRandomFactImage(imgPath) {
  factImages = ["fact_callout_1.gif", "fact_callout_2.gif", "fact_callout_3.gif", "fact_callout_4.gif", "fact_callout_5.gif"];
  var num = Math.floor(Math.random() * factImages.length);
  document.write("<img src='" + imgPath + factImages[num] + "' alt='Foradil treatment for Asthma and COPD' border='0'>");  
}

function pfdInfoPop(obj, entryDate, entryTime, reading, score) {
  if (reading > 0){
    obj.firstChild.className="highlight";
    document.onmousemove = function (event) {
		var e = event || window.event;
		pos = getRelativeCoordinates(event, document.getElementById('wrap'));
		document.getElementById("barDetailDiv").style.left = pos.x - 155 + 'px';
		document.getElementById("barDetailDiv").style.top = pos.y + 'px';
	}

    var content = '<div class="detailTitle">' + entryDate + '&nbsp;&nbsp;' + entryTime + '</div><div class="detailBody">Peak Flow Reading: ' + reading + '<br />Symptom Score: ' + score + '</div></div>';
    document.getElementById("barDetailDiv").innerHTML = content;
    setTimeout("document.getElementById('barDetailDiv').style.visibility = 'visible'", 50);
  }
}

function getCursor(e) {
	var posx = 0;
	var posy = 0;
	if (!e) var e = window.event;
	if (e.pageX || e.pageY) 	{
		alert(e.pageX);
		posx = e.pageX;
		posy = e.pageY;
	}
	else if (e.clientX || e.clientY) 	{
		posx = e.clientX + document.body.scrollLeft
			+ document.documentElement.scrollLeft;
		posy = e.clientY + document.body.scrollTop
			+ document.documentElement.scrollTop;
	}
  document.getElementById("barDetailDiv").style.left = posx + - 273 + "px";
  document.getElementById("barDetailDiv").style.top = posy + "px";
}

function getAbsolutePosition(element) {
  var r = { x: element.offsetLeft, y: element.offsetTop };
  if (element.offsetParent) {
    var tmp = getAbsolutePosition(element.offsetParent);
    r.x += tmp.x;
    r.y += tmp.y;
  }
  return r;
};

function getRelativeCoordinates(event, reference) {
  var x, y;
  event = event || window.event;
  var el = event.target || event.srcElement;
  if (!window.opera && typeof event.offsetX != 'undefined') {
    var pos = { x: event.offsetX, y: event.offsetY };
    var e = el;
    while (e) {
      e.mouseX = pos.x;
      e.mouseY = pos.y;
      pos.x += e.offsetLeft;
      pos.y += e.offsetTop;
      e = e.offsetParent;
    }
    var e = reference;
    var offset = { x: 0, y: 0 }
    while (e) {
      if (typeof e.mouseX != 'undefined') {
        x = e.mouseX - offset.x;
        y = e.mouseY - offset.y;
        break;
      }
      offset.x += e.offsetLeft;
      offset.y += e.offsetTop;
      e = e.offsetParent;
    }
    e = el;
    while (e) {
      e.mouseX = undefined;
      e.mouseY = undefined;
      e = e.offsetParent;
    }
  }
  else {
    var pos = getAbsolutePosition(reference);
    x = event.pageX  - pos.x;
    y = event.pageY - pos.y;
  }
  return { x: x, y: y };
}

function kill(obj){
  document.getElementById("barDetailDiv").style.top = document.getElementById("barDetailDiv").style.left = -1000;
  document.getElementById("barDetailDiv").style.visibility = 'hidden';
  document.onmousemove = '';
  obj.firstChild.className="chartBar";
}

function checkPeakflow() {
  theForm = document.forms['pf.measure.submit'];
  if ( isNaN(theForm.PF_PREDICTED.value) || theForm.PF_PREDICTED.value > 999 ) {
    alert("Please enter a valid predicted peak flow number. (1-999)");
    theForm.PF_PREDICTED.focus();
    theForm.PF_PREDICTED.select();
  }
  else if ( isNaN(theForm.PF_BEST.value) || theForm.PF_BEST.value > 999 ) {
    alert("Please enter a valid personal best peak flow number. (1-999)");
    theForm.PF_BEST.focus();
    theForm.PF_BEST.select();    
  }
  else theForm.submit();
}

function disableChoices(action, radioBtns) {
  for (var i=0; i<radioBtns.length; i++) {
      radioBtns[i].disabled = action;
      if (radioBtns[i].disabled) { radioBtns[i].checked = false; }
  }
}

// Checkbox names are passed as extra arguments from function call
function disableCheckboxes(controlCheckbox) {
  if (controlCheckbox.checked) {
    for (var i=1; i<disableCheckboxes.arguments.length; i++) {
      disableCheckboxes.arguments[i].checked = false;
      disableCheckboxes.arguments[i].disabled = true;
    }
  }
  
  else {
    for (var i=1; i<disableCheckboxes.arguments.length; i++) {
      disableCheckboxes.arguments[i].disabled = false;
    }
  }
}

function setOptinValues(theForm, bbdo_opt_in, optin_direct, optin_email) {
   if (theForm.bbdo_opt_in[1].checked) { disableChoices(true, theForm.bbdo_opt_in_preference) };
   if (bbdo_opt_in)
   {
    return;
   }
   if (optin_direct.indexOf("true")>=0 && optin_email.indexOf("true")>=0)
   {
     theForm.bbdo_opt_in_preference[0].checked=true;     
     theForm.bbdo_opt_in[0].checked=true;     
     return;
   }
   if (optin_direct.indexOf("false")>=0 && optin_email.indexOf("false")>=0)
   {     
     theForm.bbdo_opt_in[1].checked=true;     
     return;
   }   
   if (optin_direct.indexOf("true")>=0 )
   {
   	
     theForm.bbdo_opt_in_preference[2].checked=true;     
     theForm.bbdo_opt_in[0].checked=true;     
     return;
   }
   if (optin_email.indexOf("true")>=0 )
   {
     theForm.bbdo_opt_in_preference[1].checked=true;     
     theForm.bbdo_opt_in[0].checked=true;     
     return;
   }   
   if (optin_email.indexOf("false")>=0 )
   {     
     theForm.bbdo_opt_in[1].checked=true;     
   }   
   if (optin_direct.indexOf("false")>=0 )
   {     
     theForm.bbdo_opt_in[1].checked=true;     
   }   
}

function ttProgress(q_answered, q_max) {
  document.getElementById("progressBarFill").style.width = document.getElementById("progressBarTextTop").style.width = (q_answered/q_max) * parseInt(document.getElementById("progressBarContainer").style.width) + 'px';
}

function clearFields(chkbox) {
  if (!chkbox.checked) {
    iElementsToClear = clearFields.arguments.length - 1; 
    aElementsToClear = new Array (); 

    for (i=0; i<iElementsToClear; i++){ 
      aElementsToClear[i] = clearFields.arguments[i+1]; // skip first parameter
    }
    
    for (i=0; i<aElementsToClear.length; i++){
      if (aElementsToClear[i].type == "text") aElementsToClear[i].value = "";
      else if (aElementsToClear[i].type == "radio" || aElementsToClear[i].type == "checkbox") {
        aElementsToClear[i].checked = false;
      }
    } 
  }
}

/* PLUG-IN CHECK */
var requiredVersion = 5;   

var flash2Installed = false;    
var flash3Installed = false;    
var flash4Installed = false;    
var flash5Installed = false;    
var flash6Installed = false;    
var flash7Installed = false;    
var flash8Installed = false;    
var flash9Installed = false;    
var maxVersion = 9;             
var actualVersion = 0;          
var hasRightVersion = false;    
var jsVersion = 1.0;            



var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;

jsVersion = 1.1;

if(isIE && isWin){
  document.write('<SCR' + 'IPT LANGUAGE=VBScript\> \n');
  document.write('on error resume next \n');
  document.write('flash2Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.2"))) \n');
  document.write('flash3Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.3"))) \n');
  document.write('flash4Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.4"))) \n');
  document.write('flash5Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.5"))) \n');  
  document.write('flash6Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.6"))) \n');  
  document.write('flash7Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.7"))) \n');
  document.write('flash8Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.8"))) \n');
  document.write('flash9Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.9"))) \n');
  document.write('<\/SCR' + 'IPT\> \n'); 
}


function detectFlash() {  
  if (navigator.plugins) {
    if (navigator.plugins["Shockwave Flash 2.0"]
        || navigator.plugins["Shockwave Flash"]) {

      var isVersion2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
      var flashDescription = navigator.plugins["Shockwave Flash" + isVersion2].description;
     
      var flashVersion = parseInt(flashDescription.substring(16));

      flash2Installed = flashVersion == 2;    
      flash3Installed = flashVersion == 3;
      flash4Installed = flashVersion == 4;
      flash5Installed = flashVersion == 5;
      flash6Installed = flashVersion == 6;
      flash7Installed = flashVersion == 7;
      flash8Installed = flashVersion == 8;
      flash9Installed = flashVersion >= 9;
    }
  }
  
  for (var i = 2; i <= maxVersion; i++) {  
    if (eval("flash" + i + "Installed") == true) actualVersion = i;
  }
  
  if(navigator.userAgent.indexOf("WebTV") != -1) actualVersion = 4;  

  if (actualVersion >= requiredVersion) {
    hasRightVersion = true;                
  }
}

detectFlash();