var $j = jQuery.noConflict();

var $ = function(string) {
	var wrapper = $j('#' + string);
	var element = wrapper[0];
	element.setStyle = function(options) {
		wrapper.css(options);
	}
	element.show = function(options) {
		wrapper.show(options);
	}
	element.hide = function(options) {
		wrapper.hide(options);
	}
	element.toggle = function(options) {
		wrapper.toggle(options);
	}
	return element;
}

function getElementsByClassName(searchClass, domNode, tagName) {
    if (domNode == null) domNode = document;
    if (tagName == null) tagName = '*';
    var el = new Array();
    var tags = domNode.getElementsByTagName(tagName);
    var tcl = " "+searchClass+" ";
    for(i=0,j=0; i<tags.length; i++) {
        var test = " " + tags[i].className + " ";
        if (test.indexOf(tcl) != -1)
        el[j++] = tags[i];
    }
    return el;
}

if (!Array.prototype.toJSON) {
	Array.prototype.toJSON = function() {
		for(var i=0, json=[];i<this.length;i++) {
			switch (typeof this[i]) {
				case 'array':
				case 'object':
					json[i] = this[i].toJSON();
				break;
				case 'boolean':
				case 'null':
					json[i] = String(this[i]);
				break;
				case 'number':
					json[i] = isFinite(this[i]) ? String(this[i]) : 'null';
				break;
				case 'string':
				default:
					json[i] = '"' + this[i] + '"';
				break;
			}
		}
		return "["+json.join(", ")+"]";
	}
}

if (!String.prototype.evalJSON) {
	String.prototype.evalJSON = function() {
		return eval ( "(" + this + ")");
	}
}

$j(function() {
	
	var newElement = $j('<img src="/images/www/zoom-loader.gif" id="ajaxLoader">')
					 .css('position','absolute').css('z-index','9999');
	$j('body').append(newElement);
	$j('#ajaxLoader').hide();
	$j('body').bind('mousemove scroll', function(e) {
		$j('#ajaxLoader').css('top',(e.pageY + 20) + 'px');
		$j('#ajaxLoader').css('left',(e.pageX + 20) + 'px');
	});
});


var Ajax = {};

Ajax.Loader = {};
Ajax.Loader.Element = false;
Ajax.Loader.Timeout = 0;

Ajax.Request = function(url, options) {
	clearTimeout(Ajax.Loader.Timeout);
	Ajax.Loader.Timeout = setTimeout('Ajax.Loader.Show();',2000);
	$j.ajax({
	  url: url,
	  type: options.method || 'post',
	  success: function(data) {
		var newData = {
			responseText: data 
		};
		options.onSuccess(newData);
		Ajax.Loader.Hide();
	  },
	  error: function(data) {
		options.onFailure(data);
		Ajax.Loader.Hide();
	  },
	  data: options.parameters
	});
}
Ajax.Loader.Show = function() {
	$j('#ajaxLoader').show();
}
Ajax.Loader.Hide = function() {
	clearTimeout(Ajax.Loader.Timeout);
	$j('#ajaxLoader').hide();
}
Ajax.Updater = function(element, url, options) {
	if (!options) {
		options = {};
	}
	options.onSuccess = function(data) {
		$j('#' + element).html(data.responseText);
	}
	Ajax.Request(url, options);
}

var Class = {
  create: function() {
    return function() {
      if (this.initialize) {
        this.initialize();
      }
    }
  }
}  














