function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function SendMSNMessage(name){
  MsgrObj.InstantMessage(name); 
}

function AddMSNContact(name){
  MsgrObj.AddContact(0, name);
}



  function $(elementId){     return document.getElementById(elementId);  }


var $A = function(iterable) {
  if (!iterable) return [];
  if (iterable.toArray) {    return iterable.toArray();  } else {
    var results = [];  for (var i = 0, length = iterable.length; i < length; i++)  results.push(iterable[i]);
    return results;  }
}

Function.prototype.bind = function() {   var __method = this, args = $A(arguments), object = args.shift();  return function() {    return __method.apply(object, args.concat($A(arguments)));  }
}


function getHttpRequestObject() {
	
	var http_request = false ; 

	if (window.XMLHttpRequest) { 
		http_request = new XMLHttpRequest();
		  if (http_request.overrideMimeType) {    http_request.overrideMimeType('text/xml');   }
   } else if (window.ActiveXObject) {
     try {    http_request = new ActiveXObject("Msxml2.XMLHTTP");
     } catch (e) {    try {  http_request = new ActiveXObject("Microsoft.XMLHTTP");  } catch (e) {}  }
   }
	 if (!http_request) {    alert('unsupported HttpProtocol');    return false;    }
	return http_request; 
}


Ajax = {   getTransport: getHttpRequestObject,   activeRequestCount: 0,   RequestEvents :   ['Uninitialized', 'Loading', 'Loaded', 'Interactive', 'Complete']  }

Ajax.Request = function(url,options){
  
    this.transport = Ajax.getTransport();
    
	this.options = {
      method:       'post',
      asynchronous: true,
      contentType:  'application/x-www-form-urlencoded',
      encoding:     'UTF-8',
      parameters:   '',
	  onSuccess:	function(){},
	  onFailure:	function(){},
	  onException:	function(){}
	};
	for(var p in options){ this.options[p]=options[p];	}
  this.options.method = this.options.method.toLowerCase();
	this.onSuccess = this.options.onSuccess;
	this.onFailure = this.options.onFailure;

 this.request(url);
}

Ajax.Request.prototype.request = function(url){
	this.url = url;
	this.method = this.options.method;
	var param;
	if (typeof this.options.parameters != 'string'){		param = Form.Methods.toQueryString(this.options.parameters);
	}else{ 		param = this.options.parameters;	}
	
	if (this.method == 'get' && param != null && param != ''){		this.url += ((this.url.indexOf('?') > -1 ) ? '&' : '?') + param;	}
    try {
      this.transport.open(this.method.toUpperCase(), this.url,
        this.options.asynchronous);
      if (this.options.asynchronous)    setTimeout(function() { this.respondToReadyState(1) }.bind(this), 10);
      this.transport.onreadystatechange = this.onStateChange.bind(this);
      this.setRequestHeaders();
      this.body = this.method == 'post' ? (this.options.postBody || param) : null;
      this.transport.send(this.body);
      if (!this.options.asynchronous && this.transport.overrideMimeType)    this.onStateChange();  }
    catch (e) {      this.dispatchException(e);    }
}

Ajax.Request.prototype.onStateChange = function() {    var readyState = this.transport.readyState;
    if (readyState > 1 && !((readyState == 4) && this._complete))       this.respondToReadyState(this.transport.readyState); }


Ajax.Request.prototype.respondToReadyState = function(readyState) {
    var state = Ajax.RequestEvents[readyState];
    var transport = this.transport;
    if (state == 'Complete') {
      try {         this._complete = true;		this.options['on' + (this.success() ? 'Success' : 'Failure')](transport);
      } catch (e) {        this.dispatchException(e);  } }
    if (state == 'Complete') {      this.transport.onreadystatechange = function(){}; }
}

Ajax.Request.prototype.success = function(){
    return !this.transport.status  || (this.transport.status >= 200 && this.transport.status < 300);
}

Ajax.Request.prototype.setRequestHeaders = function(){
    var headers = {
      'X-Requested-With': 'XMLHttpRequest',
      'Accept': 'text/javascript, text/html, application/xml, text/xml, */*'
    };

    if (this.method == 'post') {
      headers['Content-type'] = this.options.contentType +
        (this.options.encoding ? '; charset=' + this.options.encoding : '');

      if (this.transport.overrideMimeType &&
          (navigator.userAgent.match(/Gecko\/(\d{4})/) || [0,2005])[1] < 2005)
            headers['Connection'] = 'close';
    }
    for (var name in headers)   this.transport.setRequestHeader(name, headers[name]);
}

Ajax.Request.prototype.dispatchException = function(exception) {    (this.options.onException || function(){})(this, exception);}

