
  var myAjaxRequest = 0;
  var myAjaxDivId = new Array();
  var myAjaxState = new Array();
  var myAjaxCount = new Array();
  var myAjaxRef = new Array();
  var myAjaxRefx = new Array();
  var myImgCount = '1';
  var myTextCount = '1';
  var myInstalComplete = 'No';

  function ajaxSendRequest(divId, myRequestX, url, params, HttpMethod)
  {
  	var myAjaxReq = null;
  	var myAjaxData = null;
    var READY_STATE_UNINITIALIZED = 0;
    var READY_STATE_LOADING = 1;
    var READY_STATE_LOADED = 2;
    var READY_STATE_INTERACTIVE = 3;
    var READY_STATE_COMPLETE = 4;
  	
    myAjaxDivId[myRequestX] = divId;
    myAjaxState[myRequestX] = 0;
    myAjaxCount[myRequestX] = 0;
    myAjaxRef[myRequestX] = "";
    myAjaxRefx[myRequestX] = "";

  	if (!HttpMethod) {
  		HttpMethod = "GET";
  	}
  	
  	myAjaxReq = ajaxInitXMLHTTPRequest();
  	
  	if (myAjaxReq) {
  		myAjaxReq.onreadystatechange = function () {
  			if (myAjaxReq.readyState == READY_STATE_COMPLETE) {
  		    myAjaxData = myAjaxReq.responseText;
  	    }
  	    ajaxToConsole(myAjaxReq.readyState, myAjaxData, myRequestX);
      }
  		myAjaxReq.open(HttpMethod, url, true); 
  		myAjaxReq.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
  		
  		myAjaxReq.send(params);
  	}
  }
  
  function ajaxInitXMLHTTPRequest()
  {
  	var xRequest = false;
  	
  	try{
		  xRequest = new XMLHttpRequest();
	  } catch (e) {
		    try{
			    xRequest = new ActiveXObject("Msxml2.XMLHTTP");
		    } catch (e) {
			      try{
				      xRequest = new ActiveXObject("Microsoft.XMLHTTP");
			      } catch (e) {
      	        alert('Your browser does not support AJAX Technology!\nGiving up :( Cannot create an XMLHTTP instance.');
				        return false;
			      }
		    }
	  }
  	return xRequest;
  }
  
  function ajaxGetData(xdivId, xurl, xmethod, xparams)
  {
  	++myAjaxRequest;
  	divId = document.getElementById(xdivId);
  	ajaxSendRequest(divId, myAjaxRequest, xurl, xparams, xmethod);
  }

  function ajaxToConsole(ready, data, myRequestX)
  {
  	if (ready <= '1' && myAjaxRef[myRequestX] == "") {
  		myAjaxRef[myRequestX] = setInterval("ajaxToConsoleSet()", 3000);
  		if (myInstalComplete == 'Yes') {
  			myAjaxDivId[myRequestX].innerHTML = "";
  			myAjaxRefx[myRequestX] = setInterval("ajaxToConsoleSetText()", 2000);
  		} else {
  		    myAjaxDivId[myRequestX].innerHTML = '<table align="center" border="0" cellpadding="2" cellspacing="1" width="210"><tr><td align="center"><img src="running.gif"></td></tr><tr><td align="center">Please wait...</td></tr></table>';
  		}
  	}
  	else if (ready == '2' || ready == '3') {
  		myAjaxDivId[myRequestX].innerHTML = '<table align="center" border="0" cellpadding="2" cellspacing="1" width="210"><tr><td align="center">Request Completed.</td></tr></table>';
  	}
  	else if (ready > '3') {
  		clearInterval(myAjaxRef[myRequestX]);
  		document.getElementById('InstallImgTag').innerHTML = '';
  		if (myInstalComplete == 'Yes') {
  			myTextCount = '1';
  			myInstalComplete = 'No';
  			clearInterval(myAjaxRefx[myRequestX]);
  			document.getElementById('InstallTextTag').innerHTML = '';
  		}
  		myAjaxDivId[myRequestX].innerHTML = data;
  	}
  }
  
  function ajaxToConsoleSet()
  { 
  	var xContentCell = '';
  	if (myImgCount == '1') { xContentCell = '<table align="center" border="0" cellpadding="0" cellspacing="1" width="100%" class="t_content_bg"><tr><td align="center"><img src="http://www.nicplex.com/images/install/x7/1.jpg" border="0"></td></tr></table>'; }
  	else if (myImgCount == '2') { xContentCell = '<table align="center" border="0" cellpadding="0" cellspacing="1" width="100%" class="t_content_bg"><tr><td align="center"><img src="http://www.nicplex.com/images/install/x7/2.jpg" border="0"></td></tr></table>'; }
  	else if (myImgCount == '3') { xContentCell = '<table align="center" border="0" cellpadding="0" cellspacing="1" width="100%" class="t_content_bg"><tr><td align="center"><img src="http://www.nicplex.com/images/install/x7/3.jpg" border="0"></td></tr></table>'; }
  	else if (myImgCount == '4') { xContentCell = '<table align="center" border="0" cellpadding="0" cellspacing="1" width="100%" class="t_content_bg"><tr><td align="center"><img src="http://www.nicplex.com/images/install/x7/4.jpg" border="0"></td></tr></table>'; }
  	else if (myImgCount == '5') { xContentCell = '<table align="center" border="0" cellpadding="0" cellspacing="1" width="100%" class="t_content_bg"><tr><td align="center"><img src="http://www.nicplex.com/images/install/x7/5.jpg" border="0"></td></tr></table>'; }
  	else if (myImgCount == '6') { xContentCell = '<table align="center" border="0" cellpadding="0" cellspacing="1" width="100%" class="t_content_bg"><tr><td align="center"><img src="http://www.nicplex.com/images/install/x7/6.jpg" border="0"></td></tr></table>'; }
  	else if (myImgCount == '7') { xContentCell = '<table align="center" border="0" cellpadding="0" cellspacing="1" width="100%" class="t_content_bg"><tr><td align="center"><img src="http://www.nicplex.com/images/install/x7/7.jpg" border="0"></td></tr></table>'; }
  	else if (myImgCount == '8') { xContentCell = '<table align="center" border="0" cellpadding="0" cellspacing="1" width="100%" class="t_content_bg"><tr><td align="center"><img src="http://www.nicplex.com/images/install/x7/8.jpg" border="0"></td></tr></table>'; }
  	else if (myImgCount == '9') { xContentCell = '<table align="center" border="0" cellpadding="0" cellspacing="1" width="100%" class="t_content_bg"><tr><td align="center"><img src="http://www.nicplex.com/images/install/x7/9.jpg" border="0"></td></tr></table>'; }
  	else if (myImgCount == '10') { xContentCell = '<table align="center" border="0" cellpadding="0" cellspacing="1" width="100%" class="t_content_bg"><tr><td align="center"><img src="http://www.nicplex.com/images/install/x7/10.jpg" border="0"></td></tr></table>'; }
  	else if (myImgCount == '11') { xContentCell = '<table align="center" border="0" cellpadding="0" cellspacing="1" width="100%" class="t_content_bg"><tr><td align="center"><img src="http://www.nicplex.com/images/install/x7/11.jpg" border="0"></td></tr></table>'; }
  	
  	++myImgCount;
  	if (myImgCount == '12') { myImgCount = '1'; }
  	
  	document.getElementById('InstallImgTag').innerHTML = xContentCell;
  }
  
  function ajaxToConsoleSetText(myRequestX)
  { 
  	var xContentCell = '';
  	if (myTextCount == '1') { xContentCell = 'Gathering server Information...'; }
  	else if (myTextCount == '2') { xContentCell = 'Creating database tables...'; }
  	else if (myTextCount == '3') { xContentCell = 'Loading database with default data...'; }
  	else if (myTextCount == '4') { xContentCell = 'Creating configuration files...'; }
  	else if (myTextCount == '5') { xContentCell = 'Removing temporary installation files...'; }
  	else if (myTextCount == '6') { xContentCell = 'Finalizing installation...'; }

  	if (myTextCount < '6') { ++myTextCount; }
  	
  	document.getElementById('InstallTextTag').innerHTML = '&nbsp;<table align="center" border="0" cellpadding="0" cellspacing="1" width="100%" class="t_content_bg"><tr><td align="center" class="t_content_cell"><b>Installation Status</b></td></tr><tr><td align="center" class="t_content_cell2">' + xContentCell + '</td></tr></table>';
  }
  
  function ajaxGetFormElement(xFormName)
  {
    var formParams = new Array();
    if (document.forms.length > '0') {
      for (i=0; i < document.forms.length; ++i) {
        if (document.forms[i].name == xFormName) {
          for (j=0; j < document.forms[i].elements.length; ++j) {
            if (document.forms[i].elements[j].name) {
              if (document.forms[i].elements[j].type == 'hidden'
                  || document.forms[i].elements[j].type == 'text'
                      || document.forms[i].elements[j].type == 'password'
                          || document.forms[i].elements[j].type == 'select-one'
                              || document.forms[i].elements[j].type == 'textarea'
                                  || document.forms[i].elements[j].type == 'button'
                                      || document.forms[i].elements[j].type == 'submit') {
                                      formParams[j] = document.forms[i].elements[j].name + '=' + document.forms[i].elements[j].value;
              }
              else if (document.forms[i].elements[j].type == 'checkbox'
                  || document.forms[i].elements[j].type == 'radio') {
                  var varCheckRadio = '';
                  if (document.forms[i].elements[j].checked == true) {
                    varCheckRadio = document.forms[i].elements[j].value;
                    formParams[j] = document.forms[i].elements[j].name + '=' + varCheckRadio;
                  }
              }
              else if (document.forms[i].elements[j].type == 'file') {
                formParams[j] = document.forms[i].elements[j].name + '=' + document.forms[i].elements[j].value;
              }
            }
          }
          break;
        }
      }
    }
    return formParams.join('&');
  }

  