/**
//\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
//\\\       \\\\\\\\|
//\\\ @@    @@\\\\\\| Hierophant Framework
//\\ @@@@  @@@@\\\\\|
//\\\@@@@| @@@@\\\\\|
//\\\ @@ |\\@@\\\\\\| http://www.deadmarshes.com/hierophant
//\\\\  ||   \\\\\\\| (c) Copyright 2009 Richard York, All rights Reserved
//\\\\  \\_   \\\\\\|
//\\\\\        \\\\\| Use and redistribution are subject to the terms of the license.
//\\\\\  ----  \@@@@| http://www.deadmarshes.com/hierophant/license
//@@@@@\       \@@@@|
//@@@@@@\     \@@@@@|
//\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
*/

var $vars = window.location.search.substring(1).split('&');

if (typeof($_GET) == 'undefined') {
  var $_GET = new Array();
};

if ($vars.length) {
  for (var $i = 0; $i < $vars.length; $i++) {
    var $pair = $vars[$i].split('=');
    $_GET[$pair[0]] = decodeURIComponent($pair[1]);
  };
};

$.fn.extend({
  SplitID : function()
  {
    var $id = this.attr('id');
    
    if (!$id) {
      return '';
    }

    if ($id.indexOf('-') < 0) {
      return '';
    }
  
    if (arguments[1]) {
      var $bits = $id.split('-');
      $bits = $bits.reverse();
  
      for ($i = 0; $i < $bits.length; $i++) {
        if ($i == arguments[1]) {
          return $bits[$i];  
        }
      }
    }

    return $id.split('-').pop();
  },

  SplitNumericID : function()
  {
    var $id = this.attr('id');
    return $id.indexOf('--') != -1 ? -(parseInt($id.split('-').pop())) : parseInt($id.split('-').pop());
  },

  SelectSet : [],

  Select : function($set)
  {
    if ($$.SelectSet[$set]) {
      $$.Unselect.call($$.SelectSet[$set], $set);
    }

    $$.SelectSet[$set] = this;

    this.addClass($set + 'Selected');

    // Allow a callback function
    if (arguments[1]) {
      arguments[1].call(arguments[2]? arguments[2] : this);
    }

    return this;
  },

  Unselect : function($set)
  {
    if ($$.SelectSet[$set]) {
      $$.SelectSet[$set].removeClass($set + 'Selected');
      $$.SelectSet[$set] = null;
    }

    return this;
  },

  GetSelected : function($set)
  {
    return $$.SelectSet[$set]? $$.SelectSet[$set] : [];
  },

  Delete : function()
  {
    this.each(
      function() {
        this.parentNode.removeChild(this);
      }
    );
    
    return this;
  },
  
  Include : function($path) {
    var $script = document.createElement('script');
    $script.type = 'text/javascript';
    $script.src  = $$.Path($path);
    $('head').append($script);
  },
  
  Debug: function($html)
  {
    if (!$('div.hFrameworkDebug').length) {
      $debug = document.createElement('div');
      $debug.className = 'hFrameworkDebug';

      $('body').append($debug);
    }

    $('div.hFrameworkDebug')
      .dblclick(
        function() {
          $(this).remove();
        }
      )
      .css({
        position: 'fixed',
        top: '10px',
        left: '10px',
        overflow: 'auto',
        background: '#fff',
        border: '1px solid rgb(128, 128, 128)',
        width: '500px',
        height: '500px',
        padding: '10px',
        zIndex: '30000',
        whiteSpace: 'pre'
      })
      .append($html);
  },

  ScrollTo : function($element)
  {
    $(this).get(0).scrollLeft = $element.offsetLeft;
    $(this).get(0).scrollTop  = $element.offsetTop;
  },
  
  Path : function(path)
  {
    if (hPath != '/') {
      path = hPath + path;
    }

    if (typeof(arguments[1]) != 'undefined') {
      var $i = 0;

      for (var key in arguments[1]) {
        path += (($i == 0)? '?' : '&') + key + '=' + encodeURIComponent(arguments[1][key]);
        $i++;
      }
    }

    return path;
  }
});

var $$ = $.fn;

$.ajaxSetup({
  cache: false
});


var PNG = function($img)
{
  if ($img && $img.src && /MSIE (\d+\.\d+);/.test(navigator.userAgent)) { //test for MSIE x.x;
    var ieversion = new Number(RegExp.$1); // capture x.x portion and store as a number

    if (ieversion >= 6 || ieversion >= 5) {
      $img.outerHTML = '<span src="' + $img.src + '"' + (($img.id)? " id='" + $img.id + "' " : '') + (($img.className)? " class='" + $img.className + "' " : '') + (($img.title)? " title='" + $img.title + "' " : '') + ' style="display: inline-block; width: ' + $img.width + 'px; height: ' + $img.height + "px; filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + $img.src + "', sizingMethod='scale'); " + $img.style.cssText + '"></span>';
    }
  }
};

var hFramework = {};

//hFramework.IE  = (hUserAgent == 'ie');
//hFramework.IE6 = (hUserAgent == 'ie' && hUserAgentVersion < 7);

