﻿//browser detection
var AgntUsr=navigator.userAgent.toLowerCase();
var AppVer=navigator.appVersion.toLowerCase();
var mozilla=AgntUsr.indexOf('gecko')!=-1?1:0;
var msie=navigator.appName.toLowerCase()=='microsoft internet explorer'?1:0;
var Opr=AgntUsr.substring(AgntUsr.indexOf('opera'), AgntUsr.length).split(" ");
var obj = null;
/***************************************************************************
**	Written By: Anthony Romero
**	Description: An object class that is intended to make AJAX apps easier to
**				 write. Has various data output methods, handles multiple 
**				 requests, and can transform xml using an xsl. (Note: xml xsl
**				 transformations only supported in IE 6.0+, Netscape 7.0+, 
**				 and Firefox, all other functionality is supported in IE 6.0, 
**				 Netscape 6.0, Opera 7.0, IE 7.0 and Firefox.)
**	Version Log: 
**		0.1.1: Modified code from a previous AJAX app I wrote to allow 
**				for more abstraction. 
**		0.1.2: Added a 'waiting splash screen' feature to alert users that
**				a request is in progress
**		0.1.3: Expanded the data output features - output methods: print to 
**				page, pass to function, parse xml
**		0.1.4: Basic IFRAME fallback method implemented, IE activex-less only
**		0.1.5: Request Management Bugs fixed, IFRAME fallback added for 
**				netscape 6.0
**		0.1.6: IFRAME fallback added for opera 7.0, made the iframe fallback 
**				method compliant with the output functionality for the 
**				getNewRequest function
**		0.1.7: Made minor improvements to the error handling and request management
**				(fixed the bug that appeared the first time the script was run in firefox)
**		0.1.8: Made improvements to the error handling - changed the way the error 
**				message is conveyed to the user, and what qualifies as an error.
**		0.1.9: Added simplified request methods, to make using the object easier. 
**		0.2.0: Changed the FUNCTION output option to first html encode the request 
** 				result before passing it onto the specified function. Also, now 
**				waiting until the output_data method to get the html element as 
**				opposed to at request create. This is to facilitate using the 
**				function output method.
**
**	TODO: Add native safari support aswell as iframe fallback for older versions,
**		  improve IFRAME fallback and test in more browsers, make the 'waiting 
**		  splash page' more customizable, split the xml function up so that 
**		  it is also possible to return an xml doc, make the xmlhttprequest
**		  within the xml_from_string function more robust, add more support for
**		  request types other than GET and POST, add back and forward capablities 
**		  requests, Remove the need for browser detection move to full object
**		  dectection, add IE 7.0 support, add request timer: submit time interval
**		  and have the object carry out your request at each interval automatically
***************************************************************************/
function createXMLRequestObj(){
	obj = new Object();
	obj.requests = new Array();
	obj.getRequest = getNewRequest;
	obj.getBasicGetRequest = getBasicGetReq;
	obj.getBasicGetRequestWait = getBasicGetReqWait;
	obj.getBasicPostRequest = getBasicPostReq;
	obj.getBasicPostRequestWait = getBasicPostReqWait;
	obj.getFunctionGetRequest = getFunctionGetReq;
	obj.getFunctionPostRequest = getFunctionPostReq;
	obj.parseXML = xml_from_string;
	obj.screenSize = get_screen_size;
	obj.name = "XMLHTTPRequestHandler";
	obj.version = "0.2.0";
	return obj;}
	
/**************************************************************************
**	This method does the bulk of the work.  It creates the request and 
**	handles multiple requests at once.  All other functions are called from 
**	here
**
**  Argument List: 
**	Request URL: The url that is being requested
**	Output Element: The id of the element that will display the output or
**		the name of the function that will recieve the data
**	Request Id: Used to identify if a new request should override a 
**		request already in progress
**	Output Type: A string representing the possible output methods current methods:
**			PAGE_OUTPUT - Prints the data out to a html element
**			FUNCTION	- Passes the data on to a javascript function
**			PARSE_XML	- treats the data as well formed xml transforms it
**						  with a xslt and the prints it out a html element
**	Request Type: The type of request to be carried out i.e. GET, POST, 
**				  HEAD, etc. (note:not all browser currently support all 
**				  request types through xmlhttprequest)
**	Post Data: Used to pass the post data to the request object, pass null if
**			   unused.
**	Xsl: if the data is going to be pasrsed as xml, this represents the url 
**		 to the xsl, pass null if unused
**  Waiting Mode:The splash waiting screen has three different modes
**		DIV: This mode causes the splash screen to be displayed 
**			 within a floating div.
**		INNER: This mode causes the splash screen text to be 
**		 	   displayed within the innerHTML parameter of the 
**			   display object
**		NONE: This mode causes no splash screen to be displayed
**	Error output: This variable determines the mode in which the error data(If there 
**   			  is any!) will be displayed to the user.
**		ALERT: This will display the error data in an alert box.
**		HIDE:  This will not display any of the error data.
**		FUNCTION-<function name>: This will pass the error data along to a user defined function for 
**				  further processing.
**		<element id>: If an element id is passed then the error data will display 
**					  within this element on the page.
**
**	note:   - if the iframe fallback method is called in the event that activex
**			is disabled all post data will be lost, thus it is recommended
**			to use the get method when ever possible.
**************************************************************************/
function getNewRequest(){
	var index = -1;
	try{//Check if there is already a request with this id
		for(i=0;i<this.requests.length;i++){
			if(this.requests[i].id == arguments[2]){//There is a request with this id, abort the old request and continue
				index = i;
				if(this.requests[i].xml != null && this.requests[i].xml.readyState != 0 && this.requests[i].xml.readyState != 4){//Get rid of the old request
					this.requests[i].xml.abort();
					this.requests[i] = null;}
				break;}}}
	catch(err){request.errMsg=err.message;error_handler(request.id);}
	if(index==-1) index=this.requests.length;//if this id is not found set the index to the length of the array
	this.requests[index] = new Object();
	this.requests[index].xml = "";
	var request=this.requests[index];
	try{//assign the variables to the object		
		request.output 		 = arguments[1];
		request.otype 		 = arguments[3];
		request.id	   		 = arguments[2];
		request.method 		 = arguments[4];
		request.xsl	    	 = arguments[6];
		request.waiting      = true;
		request.wait_mode    = arguments[7];
		request.wait_screen  = waiting_func;
		request.waiting_time = 125;
		request.errCode 	 = -1;
		request.errMsg 		 = "";
		request.errOut		 = arguments[8];}
	catch(err){this.errMsg = "Error Code - One or more of the variables being passed the request are incorrect or missing: "+err.message;this.errCode = 0;}
	if(window.XMLHttpRequest) request.xml = new XMLHttpRequest();//mozilla/gecko, opera, safari?
	else if(window.ActiveXObject)//activeX enabled IE
		try{request.xml = new ActiveXObject("Microsoft.XMLHTTP");}
		catch(err){fallback(arguments);request.xml=null;return true;}
	else{fallback(arguments);request.xml=null;return true;}//anything else
	try{//assign request variables
		request.request		= arguments[0].length<=0?null:arguments[0].indexOf("?")!=-1?arguments[0]+"&":arguments[0]+"?";
		request.post		= arguments[5];
		request.xml.onreadystatechange = function(){//handle request state change
			if (request.xml.readyState == 4){//if the request is finished
				try{
					if (request.xml.status == 200 || request.xml.status == 304){//if the request was successful
						if(request.wait_mode != "NONE") request.waiting = false;
						request.errMsg = output_data(request.xml, request.otype, request.output, request.xsl)
						request.errCode =(request.errMsg = ""?-1:1);
						error_handler(request.id);}
					else if (request.xml.status != 0){
						request.errMsg = "The data could not be retrieved."+request.xml.status;
						request.errCode = 2;request.waiting = false;error_handler(request.id);return true}}
				catch (err){
					request.errMsg = "There was an error retrieving the data: "+err.message;request.errCode = 3;
					error_handler(request.id);request.waiting = false;return true;}}
			return true;};}
	catch(err){
		request.errCode=4;request.errMsg = "One or more of the variables being passed the request are incorrect: "+err.message;
		error_handler(request.id);request.waiting = false;return true;}
	try{//carry out the request
		if(request.request != null && request.request.indexOf("http") != 0 && request.request.indexOf("ftp") != 0){
			if(request.wait_mode != "NONE") request.wait_screen(request)
			request.xml.open(request.method	, request.request + "date=" + Date.parse(new Date()), true);//date parameter added to prevent caching
			request.xml.send(request.post);}
		else{request.errCode=5;request.errMsg="The url you have entered is either an empty string or is an absolute url.";error_handler(request.id);}}
	catch(err){}
	return true;}

/********************************************************************************
**	Request method overrides:getBasicGetReq()
**	Request method overrides:getBasicGetReqWait()
**	
**	Very basic get request only accepts two variables one for the page being  
**	reqested and one for the element that will be used to display the content. With 
**	this method waiting splash screen and error messages are disabled, XSL rendering
**	can also not be handled by the ajaxRequest object. Request id defaults to 0.
**
**	The difference between the getBasicGetReq and the getBasicGetReqWait methods is that
**	the getBasicGetReqWait method shows the waiting screen.
**
**	Argument List:
**	Page:The page being requested.
**	Output:The element id of the element that will display the content.
********************************************************************************/
function getBasicGetReq(){this.getRequest(arguments[0],arguments[1],0,"PAGE_OUTPUT","GET",null,null,"NONE","HIDE");}
function getBasicGetReqWait(){this.getRequest(arguments[0],arguments[1],0,"PAGE_OUTPUT","GET",null,null,"DIV","HIDE");}

/********************************************************************************
**	Request method overrides:getBasicPostReq()
**	Request method overrides:getBasicPostReqWait()
**	
**	Very basic post request only accepts three variables one for the page being  
**	reqested, one for the element that will be used to display the content, and one 
**	for any postdata that might be pasted. With this method waiting splash screen 
**	and error messages are disabled, XSL rendering can also not be handled by 
**	the ajaxRequest object. Request id defaults to 0.
**
**	The difference between the getBasicPostReq and the getBasicPostReqWait methods is that
**	the getBasicPostReqWait method shows the waiting screen.
**
**	Argument List:
**	Page:The page being requested.
**	Output:The element id of the element that will display the content.
**	Postdata:parameters to be pasted along to the page through the post request
********************************************************************************/
function getBasicPostReq(){this.getRequest(arguments[0],arguments[1],0,"PAGE_OUTPUT","POST",arguments[2],null,"NONE","HIDE");}
function getBasicPostReqWait(){this.getRequest(arguments[0],arguments[1],0,"PAGE_OUTPUT","POST",arguments[2],null,"DIV","HIDE");}

/********************************************************************************
**	Request method overrides:getFunctionGetReq()
**	Request method overrides:getFunctionPostReq()
**	
**	These functions work very similar to the two other sets of request method override 
**	above. However these methods will pass the response text to a javascript function 
**	that is defined by the user.
**
**	Argument List:
**	Page:The page being requested.
**	Output:The name of the function that will process the data.
**	Postdata:parameters to be pasted along to the page through the post request
********************************************************************************/
function getFunctionGetReq(){this.getRequest(arguments[0],arguments[1],0,"FUNCTION","GET",null,null,"NONE","HIDE");}
function getFunctionPostReq(){this.getRequest(arguments[0],arguments[1],0,"FUNCTION","POST",arguments[2],null,"NONE","HIDE");}
	
/********************************************************************************
**	Handles the errors raised by the getNewRequest method
********************************************************************************/
function error_handler(){
	var request = obj.requests[arguments[0]];
	if(request.errMsg != "")
	{
		if(request.errOut == "ALERT") alert(request.errMsg);
		else if(request.errOut != "HIDE" && request.errOut != null && request.errOut.indexOf("FUNCTION") == -1)
			//document.getElementById(request.errOut).innerHTML = "<span style='color:#ff0000;font-weight:bold;'>"+request.errMsg+"</span>"
			document.getElementById(request.errOut).innerHTML = ""
		else if(request.errOut.indexOf("FUNCTION") > -1)
			eval(request.errOut.replace("FUNCTION-", "")+"("+escape(request.errCode)+","+escape(request.errMsg)+")");}
	}

/*********************************************************************************
**	This method serves as a fallback method for those browsers with activex 
**	disabled or that do not have any native form of the xmlhttprequest object.
**	It takes the request and carries it out through a hidden iframe.
**
**	Browsers Currently Supported By This Method:
**		IE 6.0+, when ActiveX is disabled
**		Netscape 6.0
**		Opera 7.0
**
**	Needed Browser Tests:
**		IE 5.5
**		Opera 6.0
**		Safari
**
**	For many older browsers scripting the onload event of an iframe does not work.
**	The only work around is to set a time to collect the data after a reasonible 
**	time interval. This is sufficient for small requests but, for very large requests
**	this may cause a problem.  There are two solutions to this either raise the time 
**	variable in the function below or break up your request into smaller pieces.
**
**	The argument list is the same as getNewRequest(), except for they are not 
**	directly acessible through the all of the indexes methods arguments property.
**	However they are contained within an array at index 0 of the methods arguments
**  property.
*********************************************************************************/
function fallback(){//TODO: Improve this, test in more browsers
	var src      = arguments[0][0];
	var output   = arguments[0][1];
	var iframeID = arguments[0][2];
	var time = 250;//1000 = one second
	
	if(!document.getElementById(iframeID)){//create the iframe
		if (document.body && document.body.insertAdjacentHTML){//activex-less IE, old versions of opera
			document.body.insertAdjacentHTML('beforeEnd', '<iframe width="0px" height="0px" id="' + iframeID + '" src="'+src+
				'" onload="getContent(\''+iframeID+'\',\''+output+'\',\''+arguments[0][3]+'\')"></iframe>');
			//The onload event doesn't fire for opera 7.0 use a timer instead
			if(Opr[0]=='opera') setTimeout("getContent('"+arguments[0][2]+"', '"+output+"', '"+arguments[0][3]+"')", time);}
		else if (document.createElement && document.documentElement && msie == 0){//onload event doesn't fire correctly in older netscape versions, use timer instead
			var iframe = document.createElement('iframe');
			iframe.setAttribute('id', iframeID);
			iframe.setAttribute("style", "display:block;");
			iframe.setAttribute("frameborder", 0);
			iframe.src    = src;
			iframe.width  = 0;
			iframe.height = 0;
			iframe.border = 0;
			document.getElementsByTagName('body')[0].appendChild(iframe);
			setTimeout("getContent('"+iframeID+"', '"+output+"', '"+arguments[0][3]+"')", time);}}
	else{//the iframe already exists
		if (document.body && document.body.insertAdjacentHTML){//activex-less IE, opera 7.0
			iframe = document.getElementById(iframeID)
			iframe.src = src;
			//The onload event doesn't fire for opera 7.0 use a timer instead
			if(Opr[0]=='opera') setTimeout("getContent('"+arguments[0][2]+"', '"+output+"', '"+arguments[0][3]+"')", time);}
		else if (document.createElement && document.documentElement && msie == 0){
			iframe = document.getElementById(iframeID)
			iframe.src = src;
			setTimeout("getContent('"+iframeID+"', '"+output+"', '"+arguments[0][3]+"')", time);}}}

/******************************************************************************
**	Called by fallback() after a given time interval, is used to fetch the data 
**	from the iframe.
**
**	Argument List:
**	IFrameID: The id of the iframe that you will get the data from
**	Output Id: The id of the element or function that will recieve the data
**	Method: The method that will that will be used to handle the request:
**			PAGE_OUTPUT - Prints the data out to a html element
**			FUNCTION	- Passes the data on to a javascript function
******************************************************************************/
function getContent(){	
	if(msie==1 && Opr[0]!='opera'){
		try{
			iframeContent = document.getElementById(arguments[0]).contentWindow.document.getElementsByTagName('body')[0].innerHTML;
			output_data(iframeContent, arguments[2], arguments[1], null, true);}
		catch(err){return err}}
	else if(mozilla==1){
		try{
			iframeContent = window.frames[arguments[0]].document.childNodes[0].innerHTML;
			output_data(iframeContent, arguments[2], arguments[1], null, true);}
		catch(err){return err}}
	else if(Opr[0]=='opera'){
		try{
			iframeContent = document.getElementById(arguments[0][0]).contentDocument.getElementsByTagName('body')[0].innerHTML;
			output_data(iframeContent, arguments[2], arguments[1], null, true);}
		catch(err){return err}}}

/**********************************************************************************
**	Argument List:
**	Data: The results of the request
**	Method: A string representing the possible output methods current methods:
**			PAGE_OUTPUT - Prints the data out to a html element
**			FUNCTION	- Passes the data on to a javascript function
**			PARSE_XML	- treats the data as well formed xml transforms it
**						  with a xslt and the prints it out a html element
**	Output_obj: if the data is to be printed to the page(i.e. PAGE_OUTPUT or PARSE_XML)
**				this is be treated as a valid html element on the page and the
**				data with be output to this element. if the method is FUNCTION
**				the data will be passed to a user designed function for further
**				processing there.
**	Xsl: (optional)the path to the xsl being used to transform the xml
**	Fallback: A boolean value indicating wheather or not the request is coming from 
**			  the fallback method or not.
**********************************************************************************/
function output_data(){
	if(arguments[1]=='PAGE_OUTPUT' ||arguments[1]=='PARSE_XML' && arguments[4])//print to the page
		try{
			if(!arguments[4])document.getElementById(arguments[2]).innerHTML = arguments[0].responseText;
			else document.getElementById(arguments[2]).innerHTML = arguments[0];}
		catch(err){return "There was a problem printing the data to the provided element: "+err;}
	else if(arguments[1]=='FUNCTION')//pass to a function
		try{
			if(!arguments[4]) eval(arguments[2]+"(\""+escape(arguments[0].responseText)+"\");")
			else eval(arguments[2]+"(\""+escape(arguments[0])+"\");")}
		catch(err){return "There was a problem passing the data to the provided function: "+err;}
	else if(arguments[1]=='PARSE_XML')//parse as xml
		try{xml_from_string(arguments[0].responseText, arguments[3], arguments[2]);}
		catch(err){return "There was a problem printing the data to the provided element: "+err;}}

/*************************************************************************
**	Used to take the xml output of a requested page or a string and 
**	transform it using an xsl.  If the client browser does not support 
**	client side transformations the raw data will be printed out to the page
**
**	Argument List:
**	XML Text: A string representing well formed xml data
**	XSL URI: The URI leading to the xsl
**	Output Element: The html element that the data will but printed on
*************************************************************************/
function xml_from_string(){
	var divResults = arguments[2]
	
	if (window.ActiveXObject){//Internet Explorer
		try{// Load XML 		
		var xml = new ActiveXObject("Microsoft.XMLDOM");
		xml.loadXML(arguments[0]);
		// Load XSL and Transform and print the results to the page  
		var xsl = new ActiveXObject("Microsoft.XMLDOM");
		xsl.onreadystatechange = function(){if(xsl.readyState==4){divResults.innerHTML = xml.transformNode(xsl);}}
		xsl.load(arguments[1]);}
		catch(err){divResults.innerHTML=arguments[0];}}
	else if(document.implementation && document.implementation.createDocument && mozilla==1){//Netscape, Mozilla, FireFox
		try{var xslStylesheet;
		var xsltProcessor = new XSLTProcessor();
		
		// load the xslt file
		var myXMLHTTPRequest = new XMLHttpRequest();
		myXMLHTTPRequest.open("GET", arguments[1], false);
		myXMLHTTPRequest.send(null);
		
		// get the xslt document and import it into the xsltProcessor
		xslStylesheet = myXMLHTTPRequest.responseXML;      
		xsltProcessor.importStylesheet(xslStylesheet);
		
		//parse the xml from the string
		var xmlDoc= new DOMParser()
		var resultDocument = xsltProcessor.transformToDocument(xmlDoc.parseFromString(arguments[0], "text/xml"));
		
		//print the results to the page
		divArray = resultDocument.documentElement.getElementsByTagName("div");
		divResults.innerHTML=resultDocument.firstChild.innerHTML}
		catch(err){divResults.innerHTML=arguments[0];}}
	else divResults.innerHTML=arguments[0];}

function get_screen_size(){
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  } else if(screen.width){
	myWidth = screen.width;
	myHeight = screen.height;}
	
  return [myWidth, myHeight];}	
	
/************************************************************ 
**  The two functions below carry out the splashing waiting screen. It
**  is called directed before the request is attempted, and ends
**  after the content is sent to the output method.  This method 
**  is passed no parameters but, instead the 8th(index 7) variable
**  that the request obj is passed through its caller function
**  is the mode for which this method is to operate under.
**
**  Modes:
**		DIV: This mode causes the splash screen to be displayed 
**			 within a floating div.
**		INNER: This mode causes the splash screen text to be 
**		 	   displayed within the innerHTML parameter of the 
**			   display object
**		NONE: This mode causes no splash screen to be displayed
************************************************************/
function waiting_func(){//TODO: make this more customizable
	this.divID = "waiting_div_"+this.id;
	if(this.wait_mode == "DIV" || this.wait_mode == null){
		var xy    = get_screen_size();
		var width = 125;
		var style = "width:"+width+"px;border:1px solid #777777;position:absolute;top:"+Math.ceil((xy[1]/2)-70)+"px;left:"+Math.ceil((xy[0]/2)-(width/2))+"px;padding:10px;background-color:#ffffff;";
		if(document.getElementById(this.divID)==null){
			if (document.createElement && document.documentElement && msie == 0){
				var div = document.createElement('div');
				div.setAttribute('id', this.divID);
				div.setAttribute('name', this.divID);
				div.style.position = 'absolute';
				div.setAttribute('style', style);
				div.innerHTML = "";
				document.getElementsByTagName('body')[0].appendChild(div);}
			else if (document.body && document.body.insertAdjacentHTML){
				document.body.insertAdjacentHTML('beforeEnd', '<div id="' + this.divID + '" style="'+style+'"></div>');}}
		else 
			document.getElementById(this.divID).style.display = "block";}
	var rf = 20, gf = 5, bf = 10, length = 10, base = 40, base2 = 5, stepSize = .9;
	var strColorArray = new Array();
	for(i=base2;i<length+base2;i++){
		//alert(RGB2Color(Math.ceil(rf * i), Math.ceil(gf * i), Math.ceil(bf * i)))
		strColorArray[i-base2] = RGB2Color(Math.ceil(rf * Math.floor(i/stepSize))+base, Math.ceil(gf * Math.floor(i/stepSize))+base, Math.ceil(bf * Math.floor(i/stepSize))+base)
	}
	for(i=0;i<length;i++){
		strColorArray[length+i] = strColorArray[length-i-1];
	}
	//alert(strColorArray);
	/*var royAugment = 0, gAugment = 0, bivAugment = 500, length = 20, frequency = .325, light = 1;
	var strColorArray = new Array();
	for (i = light; i < (length+light); i++){
	    strColorArray[i-light] = RGB2Color((Math.sin(frequency*i) * royAugment),(Math.sin(frequency*i) * gAugment),(Math.sin(frequency*i) * bivAugment));
		//alert(strColorArray[i]);
	}
	alert(strColorArray)*/
	waiting_loop(this.id, this.divID, 0, strColorArray);
	}
	
function RGB2Color(r,g,b){
	temp = byte2Hex(r) + byte2Hex(g) + byte2Hex(b);
	//alert(temp+" red:"+byte2Hex(r)+", "+r+" green:"+ byte2Hex(g)+", "+g+" blue:" + byte2Hex(b)+", "+b)
	return temp;}

function byte2Hex(n){var nybHexString = "0123456789ABCDEF";return String(nybHexString.substr((n >> 4) & 0x0F,1)) + nybHexString.substr(n & 0x0F,1);}

function waiting_loop(){
	var wait_txt  = "<span style='font-family:arail, helvetica, sans serif;cursor:default;'>Please Wait...</span>";
	var request   = obj.requests[arguments[0]];
	var innerHTML = "";
	var pre_dot   = "<span style='color:#";
	var after_dot = "'>&middot;</span>";
	var dot_style = ";letter-spacing:-2px;cursor:default;";
	for(i=arguments[2];i<arguments[3].length;i++)
		innerHTML = pre_dot+arguments[3][i]+dot_style+after_dot+pre_dot+arguments[3][i]+dot_style+after_dot+pre_dot+arguments[3][i]+dot_style+after_dot+innerHTML;
	for(i=0;i<arguments[2];i++)
		innerHTML = pre_dot+arguments[3][i]+dot_style+after_dot+pre_dot+arguments[3][i]+dot_style+after_dot+pre_dot+arguments[3][i]+dot_style+after_dot+innerHTML;
	var output = "<p align='center' style='margin-top:0px;margin-bottom:0px;margin-left:1px;'>"+wait_txt+"<br />"+innerHTML+"</p>";
	if(request.wait_mode == "DIV" || request.wait_mode == null) document.getElementById(arguments[1]).innerHTML = output;
	else if(request.wait_mode == "INNER" && request.xml.readyState != 4) 
		request.output.innerHTML="<div style='text-align:center;vertical-align:middle;'>"+output+"</div>";
	arguments[2]=arguments[2]<arguments[3].length?arguments[2]+1:0;
	if(request.waiting) {
		strColorArray = "new Array(";
		for(i=0;i<arguments[3].length;i++){
			if(i>0)
				strColorArray += ","
			strColorArray += "\""+arguments[3][i]+" \"";
		}
		strColorArray += ")";
		setTimeout("waiting_loop("+arguments[0]+",'"+arguments[1]+"',"+arguments[2]+","+strColorArray+")", request.waiting_time)}
	else if(request.wait_mode == "DIV" || request.wait_mode == null) document.getElementById(arguments[1]).style.display = "none";}
