﻿
// Sometimes resolves problem with default button and Atlas on Firefox
if (navigator.userAgent.indexOf("Firefox")!=-1)
{
 __defaultFired = true;
}
else
{
 __defaultFired = false;
}


// Click method add
try {
  document.createElement('span');
  HTMLElement.prototype.click = function () {
    if (typeof this.onclick == 'function')
      this.onclick({type: 'click'});
  };
}
catch (e) {
  //alert('click method for HTMLElement couldn\'t be added')
}
try {
  document.createElement('a');
  HTMLElement.prototype.click = function () {
    if (typeof this.onclick == 'function') {
      if (this.onclick({type: 'click'}) && this.href) 
        window.open(this.href, this.target ? this.target : '_self');
    }
    else if (this.href)
      window.open(this.href, this.target ? this.target : '_self');
  };
}
catch (e) {
  //alert('click method for HTMLAnchorElement couldn\'t be added')
}

// Atlas managing
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(endRequest);
Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(beginRequest);
function beginRequest(sender, e) 
{
    document.body.style.cursor = 'wait';
}

function endRequest(sender, e) 
{
    document.body.style.cursor = 'default';
    // Never show errors to user
    if (e.get_error())
    {
          e.set_errorHandled(true);
    }
}