// JavaScript Document

document.include = function (url) {
 if ('undefined' == typeof(url)) return false;
 var p,rnd;
 try
	{	p = new XMLHttpRequest();
	}catch (e)
	{	try
		{	p = new ActiveXObject("Msxml2.XMLHTTP");
		}catch (e)
		{	try
			{	p = new ActiveXObject("Microsoft.XMLHTTP");
			}catch (e)
		{	alert("Your browser does not support AJAX!");
		return false;
		}
		}
	}

 // Prevent browsers from caching the included page
 // by appending a random  number
 rnd = Math.random().toString().substring(2);
 url = url.indexOf('?')>-1 ? url+'&rnd='+rnd : url+'?rnd='+rnd;
 // Open the url and write out the response
 p.open("GET",url,false);
 p.send(null);
 document.write( p.responseText );
}
	   
	  
function GetXmlHttpObject(url, id) {
this.xmlHttp=null;
try
  {
  // Firefox, Opera 8.0+, Safari
this.xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
this.xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    try{
this.xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
     }catch(e){this.xmlHttp=null;}
    }
  }
  if(this.xmlHttp!=null){
var c=this;
this.el=document.getElementById(id);
this.xmlHttp.open("GET",url,true);
this.xmlHttp.onreadystatechange=function(){c.stateChanged();};
this.xmlHttp.send(null);
}
else alert('Your browser does not support AJAX!');
}


GetXmlHttpObject.prototype.stateChanged=function () {
if (this.xmlHttp.readyState==4)
	{
	var tid=this.xmlHttp.responseText;
	this.el.innerHTML = tid;
	}
}
////////////////////////////////////////

// ====================================================================
//       URLEncode and URLDecode functions
//
// Copyright Albion Research Ltd. 2002
// http://www.albionresearch.com/
//
// You may copy these functions providing that 
// (a) you leave this copyright notice intact, and 
// (b) if you use these functions on a publicly accessible
//     web site you include a credit somewhere on the web site 
//     with a link back to http://www.albionresearch.com/
//
// If you find or fix any bugs, please let us know at albionresearch.com
//
// SpecialThanks to Neelesh Thakur for being the first to
// report a bug in URLDecode() - now fixed 2003-02-19.
// And thanks to everyone else who has provided comments and suggestions.
// ====================================================================
function URLEncode(ptext)
{
	// The Javascript escape and unescape functions do not correspond
	// with what browsers actually do...
	var SAFECHARS = "0123456789" +					// Numeric
					"ABCDEFGHIJKLMNOPQRSTUVWXYZ" +	// Alphabetic
					"abcdefghijklmnopqrstuvwxyz" +
					"-_.!~*'()";					// RFC2396 Mark characters
	var HEX = "0123456789ABCDEF";

	var plaintext = ptext;
	var encoded = "";
	for (var i = 0; i < plaintext.length; i++ ) {
		var ch = plaintext.charAt(i);
	    if (ch == " ") {
		    encoded += "+";				// x-www-urlencoded, rather than %20
		} else if (SAFECHARS.indexOf(ch) != -1) {
		    encoded += ch;
		} else {
		    var charCode = ch.charCodeAt(0);
			if (charCode > 255) {
			    alert( "Unicode Character '" 
                        + ch 
                        + "' cannot be encoded using standard URL encoding.\n" +
				          "(URL encoding only supports 8-bit characters.)\n" +
						  "A space (+) will be substituted." );
				encoded += "+";
			} else {
				encoded += "%";
				encoded += HEX.charAt((charCode >> 4) & 0xF);
				encoded += HEX.charAt(charCode & 0xF);
			}
		}
	} // for

	return encoded;
    //document.URLForm.F2.select();
	//return false;
};

function URLDecode(etext)
{
   // Replace + with ' '
   // Replace %xx with equivalent character
   // Put [ERROR] in output if %xx is invalid.
   var HEXCHARS = "0123456789ABCDEFabcdef"; 
   //var encoded = document.URLForm.F2.value;
   var encoded = etext
   var plaintext = "";
   var i = 0;
   while (i < encoded.length) {
       var ch = encoded.charAt(i);
	   if (ch == "+") {
	       plaintext += " ";
		   i++;
	   } else if (ch == "%") {
			if (i < (encoded.length-2) 
					&& HEXCHARS.indexOf(encoded.charAt(i+1)) != -1 
					&& HEXCHARS.indexOf(encoded.charAt(i+2)) != -1 ) {
				plaintext += unescape( encoded.substr(i,3) );
				i += 3;
			} else {
				alert( 'Bad escape combination near ...' + encoded.substr(i) );
				plaintext += "%[ERROR]";
				i++;
			}
		} else {
		   plaintext += ch;
		   i++;
		}
	} // while
	return plaintext;
//   document.URLForm.F1.value = plaintext;
//   document.URLForm.F1.select();
//   return false;
};

////////////////////////////////////////////////////



//////////////////////////////////////////////////////////
