﻿$(function() {
    setDefaultButton();
    gaPageTracker("UA-12300268-1");
});

setDefaultButton = function() {
    $('div[returncmd]').each(function() {
        var defbut = $(this).attr('returncmd');
        var parentdiv = $(this);
        
        $('input', this).unbind('keypress').bind('keypress', function(event) {
            if (event.keyCode == 13) {
                $('input[id$=' + defbut + ']', parentdiv).click();
                event.preventDefault();
                return false;
            }
        });
    });
}

var pageTracker;

gaPageTracker = function(account_id) {
    var scope = this;
    //check whether to use an unsecured or a ssl connection:
    var host = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
    var src = host + 'google-analytics.com/ga.js';

    //load the Google Analytics javascript file:
    $.ajax(
      {
          type: 'GET',
          url: src,
          success: function() {
              //the ga.js file was loaded successfully, set the account id:
              pageTracker = _gat._getTracker(account_id);

              //track the pageview:
              pageTracker._trackPageview();
              try { scope.gaSaveTransaction(); } catch (err) { }
          },
          error: function() {
              //the ga.js file wasn't loaded successfully:
              //throw "Unable to load ga.js; _gat has not been defined.";
          },
          dataType: 'script',
          cache: true
      }
    );
}
