// Copyright (c) 2,011 AZGalleries.com. All Rights Reserved
// Unauthorized use of this code is strictly forbidden

function AjaxRequest (sMethod, sUrl, bAsync, fCallback)
{
  var xmlhttp ;

  if (window.XMLHttpRequest) xmlhttp = new XMLHttpRequest () ; // IE7+, Firefox, Chrome, Opera, Safari
  else xmlhttp = new ActiveXObject ('Microsoft.XMLHTTP') ;     // IE6, IE5

  if (fCallback) xmlhttp.onreadystatechange = function ()
  {
    if ((xmlhttp.readyState == 4) && (xmlhttp.status == 200)) fCallback (xmlhttp.responseText) ;
  }

  xmlhttp.open (sMethod, sUrl, bAsync) ;
  xmlhttp.send (null) ;
}

function DisableAnchor (obj, bDisable)
{
  if (bDisable && (obj.className != 'disabled'))
  {
    obj.setAttribute ('href_bak', obj.getAttribute ('href')) ;
    obj.setAttribute ('className_bak', obj.className) ;

    obj.removeAttribute ('href') ;
    obj.className = 'disabled' ;
  }

  if (!bDisable && (obj.className == 'disabled'))
  {
    obj.setAttribute ('href', obj.attributes ['href_bak'].nodeValue) ;
    obj.className = obj.attributes ['className_bak'].nodeValue ;
  }
}

function DisableTextSelection (obj)
{
  var func_false = function () { return false ; } ;
  var func_true  = function () { return true  ; } ;

  if      (typeof obj.onselectstart       != 'undefined') obj.onselectstart       = func_false ;  // IE
  else if (typeof obj.style.MozUserSelect != 'undefined') obj.style.MozUserSelect = 'none' ;      // Firefox
  else                                                  { obj.onmousedown         = func_false ;  // Other
                                                          obj.onclick             = func_true ; }

  obj.style.cursor = 'default' ;
}

function GetAbsoluteXPosition (obj, container)
{
  var i = 0 ;
  while (obj && (obj != container)) { i += obj.offsetLeft ; obj = obj.offsetParent ; }
  return i ;
}

function GetAbsoluteYPosition (obj, container)
{
  var i = 0 ;
  while (obj && (obj != container)) { i += obj.offsetTop ; obj = obj.offsetParent ; }
  return i ;
}

function PadNumber (iNumber, iLength)
{
  var str = '' + iNumber ;
  while (str.length < iLength) str = '0' + str ;
  return str ;
}

/*
var sLocation = location.toString () ;
if (sLocation.length && !sLocation.match (/http\:\/\/([-_0-9a-z]+\.)?azgalleries\.com(\/.*)?/))
 alert ('ATTENTION: This website is using copyrighted code stolen from http://www.azgalleries.com') ;
*/
