//these functions can either be used to place a single flash animation with replacement gif, if user doesn't have flash plugin

//or they can be used to place a series of 3 flash animations with 3 replacement gifs, all picked at random



//1.  to place a single flash animation with replacement gif call this function, using this format, feel free to copy and paste:

//<script type="text/javascript" language="javascript">checkforFlash('graphics/flash/someFLASH.swf', #WIDTH, #HEIGHT, 'graphics/someIMAGE.gif')</script>



//2.  to place a series of 3 flash animations with replacement gifs call this function, using this format, feel free to copy and paste:

//*IMPORTANT:  if you only include one flash file in this function and leave the other two blank this

//function will not replace that single flash file with 3 random pics it will only do the first pic as a replacement

//<script type="text/javascript" language="javascript">checkFlash('graphics/flash/someFLASH1.swf', 'graphics/flash/someFLASH2.swf', 'graphics/flash/someFLASH3.swf', 'graphics/someIMAGE1.gif', 'graphics/someIMAGE2.gif', 'graphics/someIMAGE3.gif', #WIDTH, #HEIGHT);</script>



//--------------------------------------------------------------------------



var actualVersion = 0;          // version the user has

var requiredVersion = 4;        // version we planned for, feel free to change 

var maxVersion = 6;             // highest version currently detectable, i'm sure that'll change soon

	

var flash2Installed = false;    // true if flash 2 installed

var flash3Installed = false;    // true if flash 3 installed

var flash4Installed = false;    // true if flash 4 installed

var flash5Installed = false;    // true if flash 5 installed

var flash6Installed = false;    // true if flash 6 installed



var hasRightVersion = false;    // true if embeding is to proceed



//--------------------------------------------------------------------------



  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.charAt(flashDescription.indexOf(".") - 1));

        

        flash2Installed = flashVersion == 2;    

        flash3Installed = flashVersion == 3;

        flash4Installed = flashVersion == 4;

        flash5Installed = flashVersion == 5;

        flash6Installed = flashVersion >= 6;



      }

    }



    for (var i = 2; i <= maxVersion; i++) {  

      if (eval("flash" + i + "Installed") == true) actualVersion = i;

    }



    if(navigator.userAgent.indexOf("WebTV") != -1) actualVersion = 3;  



    if (actualVersion >= requiredVersion){

	  return true;

	}  

    else{

	  return false;

	}

}



//--------------------------------------------------------------------------

/*places either 1 out of 3 "random" flash animations or if the user doesn't have the plugin it places 1 out of 3 "random" pics

or places 1 flash animations or if the user doesn't have the plugin 1 replacement image*/



  function rotateFlash(doit, picA, picB, picC, picWidth, picHeight){

    

	picRotate= new Array(picA, picB, picC); 

	

	if (picB==""){

	  var rotate=0;

	}

	else{     

	  var rotate=Math.floor(Math.random()*picRotate.length);

	}

	

	if (doit==1){	 

	 var flashpic = '<OBJECT CLASSID="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'

        + 'WIDTH="'+picWidth+'" HEIGHT="'+picHeight+'"'

        + 'CODEBASE="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab">'

        + '<PARAM NAME="MOVIE" VALUE="'+picRotate[rotate]+'">'

        + '<PARAM NAME="PLAY" VALUE="true">'

        + '<PARAM NAME="LOOP" VALUE="false">'

        + '<PARAM NAME="QUALITY" VALUE="high">'

        + '<PARAM NAME="MENU" VALUE="false">'

        + '<EMBED SRC="'+picRotate[rotate]+'"'

        + 'WIDTH="'+picWidth+'" HEIGHT="'+picHeight+'"' 

        + 'PLAY="true"'

        + 'LOOP="false"'

        + 'QUALITY="high"'

        + 'MENU="false"'

        + 'TYPE="application/x-shockwave-flash"'

        + 'PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></EMBED></OBJECT>';

	}

	else if(doit==2){

	  if (picA == ""){

	    var flashpic = 'You need Flash to view the interactive tools on this site.';

	  }

	  else {

	    var flashpic = '<IMG SRC="'+picRotate[rotate]+'" HEIGHT="'+picHeight+'" WIDTH="'+picWidth+'" ALT="random image">';

	  }

	} 

	

    document.write(flashpic);	 

		 

  }

 

//-------------------------------------------------------------------------- 

//when referenced from an html document this function, "checkFlash" allows you to place either 3 flash files or 3

//replacement images if flash is not installed on the users browser

  

  function checkFlash(picFlashA, picFlashB, picFlashC, picPhotoA, picPhotoB, picPhotoC, picWidth, picHeight){



	var isIE = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false; 

	var isWin = (navigator.appVersion.indexOf("Windows") != -1) ? true :

 false; 

	

	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('</SCR' + 'IPT\> \n');

	}



   var hasRightVersion = detectFlash();

   

//if picFlashB equals "blank" then this "if then" checks to see if you want to use a single image either flash 

//or gif placed in the html document or 3 images picked at random

   

   if(picFlashB==""){  

     if(hasRightVersion) {

	   var doit=1;

	   rotateFlash(doit, picFlashA,'','', picWidth, picHeight);

     } 

	 else {

       var doit=2;

	   rotateFlash(doit, picPhotoA,'','', picWidth, picHeight);

     }

   }    

    else{

      if(hasRightVersion) {

	    var doit=1;

	    rotateFlash(doit, picFlashA, picFlashB, picFlashC, picWidth, picHeight);

      }

      else{

	    var doit=2;

        rotateFlash(doit, picPhotoA, picPhotoB, picPhotoC, picWidth, picHeight);

      }

    }

	

  }



//--------------------------------------------------------------------------

//when referenced from an html document this function, "checkforFlash" allows you to place either a single flash file or a single

//replacement image if flash is not installed on the users browser

  

  function checkforFlash(flashImage,picWidth, picHeight, photoImage){

    checkFlash(flashImage, '', '', photoImage, '', '', picWidth, picHeight);

	

  }

//--------------------------------------------------------------------------


