////////////////////////////////////////////////////////////////////////////////
// File name: flash.js
// Description: The Javascripts for the flash plugin check.
////////////////////////////////////////////////////////////////////////////////
  
// Check if flash plugin is installed to browser 
// and show flash or image
function checkFlashPlugin() {

  var flashinstalled = 0; 
  // Check if browser is Firefox or IE
  if (navigator.plugins && navigator.plugins.length) { // Browser is FIREFOX 
      
      // Check if flash plugin is installed
      x = navigator.plugins["Shockwave Flash"];
      
      if (x) { // flash plugin found 
          flashinstalled = 1;
          
          // Check plugin version
          if (x.description) {
              y = x.description;
              flashversion = y.charAt(y.indexOf('.')-1); 
          }
      } else { // flash plugin NOT found                                                                
          flashinstalled = 0; 
      }            
  } else { // Browser is not FIREFOX
      x = navigator.mimeTypes['application/x-shockwave-flash'];
      
      if (x && x.enabledPlugin) { // Another browser                 
          flashinstalled = 1;
      } else { // Browser is IE                 
          for(var i=10; i>0; i--){
              flashVersion = 0;
              try{ 
                  var flash = new ActiveXObject("ShockwaveFlash.ShockwaveFlash." + i);
                  flashVersion = i;    
                  if (flash) {                                
                      flashinstalled = 1;
                  } else {                                                                                    
                      flashinstalled = 0;
                  }
              }
              catch(e){  
              }
          }
      }                            
  }
  
  return flashinstalled;

}

// This function returns true/false depending whether the client browsers 
// operating system is Macintosh
function isMac() {
    return (navigator.appVersion.indexOf('Mac') != -1);
}

// This function returns true/false depending whether the client browser
// is Safari.
function isSafari() {
    return (navigator.userAgent.indexOf('Safari') != -1);
}

// Hides the field of the given id
function hide(fieldId) {
  // Get the field
  var field = getField(fieldId);
  field.style.visibility = 'hidden';
  field.style.position = 'absolute';    
  field.style.margin = 0;
}    

// Shows the field of the given id
function show(fieldId) {
  // Get the field
  var field = getField(fieldId);
  field.style.visibility = 'visible';
  field.style.position = 'relative';
  field.style.margin = 0;
}
