// This script gathers client information
// Read some data from the page and browser, which we send back
// to the server for registration of the users hardware, to 
// improve the service to the client. (Optimized-Web-Expierance )
//
// SankorSystems, Prilep, Macedonia
// ++389 48 428286
// Questions: sankor@cashette.com
// Programmer: Richard Sanders
// Date 26-03-2006
//

function rip()
{
  var cookstat = "";
  var javastat = "";
  var plugin = "";
  var maxi = navigator.plugins.length;
  var version = deconcept.SWFObjectUtil.getPlayerVersion();
  fvers = version['major'] +"."+ version['minor'] +"."+ version['rev'];
  if( navigator.cookieEnabled == true ){
    cookstat = "1";
  }else{
    cookstat = "0";
  }
  
  if( navigator.javaEnabled() == true ){
    javastat = "1";
  }else{
    javastat = "0";
  }
  
  // Detect if flash plugin is installed
  function detectFlash()
  {
    if( navigator.mimeTypes.length > 0 ){
      if( navigator.mimeTypes[ "application/x-shockwave-flash" ].enabledPlugin != null ) {
        return "ns";
      }
    }else if( window.ActiveXObject ){
      try {
        new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
        return "ie";
      } catch (oError) {
        return "nf";
      }
    }else{
    // Not detectable
      return "nf";
    }
  }
  
  function detectFlashVersion()
  {
    var version = 0;
    var agent = detectFlash();
    if( agent == "ns" ){
      // Always the latest flash plugin is installed
      var maxlist = navigator.plugins.length;
      for (var i = 0; i < maxlist; i++) {
        if( navigator.plugins[i].name = "Shockwave Flash" ){
          var label = navigator.plugins[i].description;
          i = maxlist;
        }
      }
      // Now we extract the version from this string, we are interested in
      // Shockwave Flash 7.0 r25
      var words = label.split(" ");
      var dig = words[2].split(".");
      version = parseInt( dig[0] );
    }
    if( agent == "ie"){
      // We must test, trial and error is appropriate
      // We will test from 4 to 9, we check on the version.specific names
      var minlist = 0;
      var i = 9;
      while( i > minlist ){
        try {
          new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+i);
          version = i;
          i = minlist;
        } catch (oError) {
          i--;
        }
      }
    }
    return version;
  }


  // Discover the installed plugins
  // we use # as delimiter so we can
  // split the result if neccessary
  // We search serverside for Flashversion.
  for (i = 0; i < maxi; ++i){
    plugin = plugin + navigator.plugins[i].name;
    if( i < (maxi-1) ){
      plugin = plugin + '#';
    }
  }
  
  // Read some data from the page.which we need to bring back
  // to the server for registration of the users hardware, to 
  // improve the service to the client. (Optimized-Web-Expierance)
  function getPageID()
  {
    return document.getElementsByName( "pageID" )[0].value;
  }

  function getUserID()
  {
    return document.getElementsByName( "userID" )[0].value;
  }

  function getSiteLocation()
  {
    return document.getElementsByName( "site" )[0].value;
  }

  function getUserType()
  {
    return document.getElementsByName( "type" )[0].value;
  }
  
  function getBrowserLanguage()
  {
    var slang = navigator.language || navigator.browserLanguage;
    return slang;
  }
  
  // Send back the information
  var address = getSiteLocation() + "/ripinfo.php";
  //var address = "http://localhost/facade/test.php";
  url = address + "?uid=" + getUserID() + "&pid=" + getPageID() + "&tp=" + getUserType();
  url += "&ref=" + navigator.referrer;
  url += "&os=" + navigator.platform;
  url += "&bn=" + navigator.appName;
  url += "&bv=" + navigator.appVersion;
  url += "&bg=" + navigator.appCodeName;
  url += "&la=" + getBrowserLanguage();
  url += "&ce=" + cookstat;
  url += "&je=" + javastat;
  url += "&cs=" + "2";
  url += "&cd=" + screen.colorDepth;
  url += "&sw=" + screen.width;
  url += "&sh=" + screen.height;
  url += "&pl=" + fvers;
  url = encodeURI( url );
  tag = "<img src='"; 
  opt = "' border='0'>";
  //alert(tag + url + opt);
  document.write( tag + url + opt );
}