var detect = navigator.userAgent.toLowerCase();
var OS,browser,version,thestring;

if (checkIt('konqueror'))
{
        browser = "Konqueror";
        OS = "Linux";
}
else if (checkIt('safari')) browser = "Safari"
else if (checkIt('omniweb')) browser = "OmniWeb"
else if (checkIt('opera')) browser = "Opera"
else if (checkIt('webtv')) browser = "WebTV";
else if (checkIt('icab')) browser = "iCab"
else if (checkIt('msie')) browser = "Internet Explorer"
else if (!checkIt('compatible')){
        browser = "Netscape Navigator"
        version = detect.charAt(8);
}else browser = "An unknown browser";

if (!version) version = detect.charAt(place + thestring.length);

if (!OS){
        if (checkIt('linux')) OS = "Linux";
        else if (checkIt('x11')) OS = "Unix";
        else if (checkIt('mac')) OS = "Mac"
        else if (checkIt('win')) OS = "Windows"
        else OS = "an unknown operating system";
}

function checkIt(string){
        place = detect.indexOf(string) + 1;
        thestring = string;
        return place;
}

/*****************************************************************
* Flash Fix script
* Fixes embedded object activation issues in Internet Explorer
*****************************************************************/
function writeSWFCode(movie,var_string , movie_name, width, height, bgcolor,flash_align,flash_menu,flash_scale,flash_wmode,flash_version,flash_hspace,flash_vspace){
   if(bgcolor == '' || bgcolor == undefined){
    bgcolor = '#FFFFFF';
   }
   if(flash_version == '' || flash_version == undefined){
    flash_version = '6,0,0,0';
   }
   if(flash_align == '' || flash_align == undefined){
    flash_align = 'middle';
   }
   if(flash_menu == '' || flash_menu == undefined){
    flash_menu = 'false';
   }
   if(flash_hspace == '' || flash_hspace == undefined){
    flash_hspace = '0';
   }
   if(flash_vspace == '' || flash_vspace == undefined){
    flash_vspace = '0';
   }

   if(flash_wmode == '' || flash_wmode == undefined){
    flash_wmode_object='';
    flash_wmode_embed='';
   }else{
    flash_wmode_object='<PARAM NAME="wmode" VALUE="'+flash_wmode+'">';
    flash_wmode_embed=' wmode="'+flash_wmode+'" ';
   }
   if(flash_scale == '' || flash_scale == undefined){
    flash_scale='exactfit';
   }
  if(OS=='Mac' && browser=='Safari'){
  //Safari does not accept Flash Vars.
  //It also bugs when the embed tag is there. After 10 reloads...
  //The javascript is activated but the flash does not display
    //If show only object tag, it seems to work 100%
  flash_code = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version='+flash_version+'" name="'+movie_name+'" width="'+width+'" height="'+height+'" hspace="'+flash_hspace+'" vspace="'+flash_vspace+'" id="'+movie_name+'" align="'+flash_align+'"><param name="movie" value="'+movie+'?'+ var_string +'"><param name="quality" value="high"><param name="SCALE" value="'+flash_scale+'"><param name="BGCOLOR" value="'+bgcolor+'"><PARAM NAME="menu" VALUE="'+flash_menu+'">'+flash_wmode_object+'</object>';
  }else	if(OS=='Mac' && browser=='Internet Explorer'){
  	flash_code = "<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' "
		+ "codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/"
		+ "swflash.cab#version="+flash_version+"' width='"+width+"' height='"+height+"'>"
		+ "<param name='movie' value='"+movie+"?"+var_string+"'>"
		+ "<param name='quality' value='high'>"
		+ "<embed src='"+movie+"?"+var_string+"' quality=high "
		+ "width='"+width+"' height='"+height+"' type='application/x-shockwave-flash' "
		+ "pluginspace='http://www.macromedia.com/go/getflashplayer'></embed>"
		+ "</object>";
  }else{
		flash_code = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version='+flash_version+'" name="'+movie_name+'" width="'+width+'" height="'+height+'" hspace="'+flash_hspace+'" vspace="'+flash_vspace+'" id="'+movie_name+'" align="'+flash_align+'"><param name="movie" value="'+movie+'"><PARAM NAME=FlashVars VALUE="'+ var_string +'"><param name="quality" value="high"><param name="SCALE" value="'+flash_scale+'"><param name="BGCOLOR" value="'+bgcolor+'"><PARAM NAME="menu" VALUE="'+flash_menu+'">'+flash_wmode_object+'<embed src="'+movie+'"  FlashVars="'+ var_string +'" width="'+width+'" height="'+height+'" hspace="'+flash_hspace+'" vspace="'+flash_vspace+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" scale="'+flash_scale+'" menu='+flash_menu+' name="'+movie_name+'" bgcolor="'+bgcolor+'" '+flash_wmode_embed+' align="'+flash_align+'"></embed></object>';
   }
   document.write(flash_code);
}
