   var http_request = false;
   
   function makeRequest(url, parameters, dothis) {
      http_request = false;
      if (window.XMLHttpRequest) { // Mozilla, Safari,...
         http_request = new XMLHttpRequest();
         if (http_request.overrideMimeType) {
         	// set type accordingly to anticipated content type
            //http_request.overrideMimeType('text/xml');
            http_request.overrideMimeType('text/html');
         }
      } else if (window.ActiveXObject) { // IE
         try {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
         } catch (e) {
            try {
               http_request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
         }
      }
      if (!http_request) {
         alert('Cannot create XMLHTTP instance');
         return false;
      }
      http_request.onreadystatechange = alertContents;
      http_request.open('GET', url + parameters, true);
      http_request.send(null);


   function alertContents() {
      if (http_request.readyState == 4) {
         if (http_request.status == 200) {
            // alert(http_request.responseText);
            result = http_request.responseText;
			
			if ( result > 0 )
			{
   				if (dothis == "register")
				{
					window.location = "/free_screen_saver"
				}
				else
				{	
					window.location = "/"
				}
			}
			else
			{
           		document.getElementById('error-report').innerHTML = result;
			}
			          
         } else {
            alert('There was a problem with the request.');
         }
      }
   }
   }   
   
   function get(obj) {
      var getstr = "?";
      for (i=0; i<obj.childNodes.length; i++) {
         if (obj.childNodes[i].tagName == "INPUT") { alert(obj.childNodes[i].type);
            if (obj.childNodes[i].type == "text") {
               getstr += obj.childNodes[i].name + "=" + obj.childNodes[i].value + "&";
            }
            if (obj.childNodes[i].type == "checkbox") {
               if (obj.childNodes[i].checked) {
                  getstr += obj.childNodes[i].name + "=" + obj.childNodes[i].value + "&";
               } else { alert('e');
                  getstr += obj.childNodes[i].name + "=&";
               }
            }
            if (obj.childNodes[i].type == "radio") {
               if (obj.childNodes[i].checked) {
                  getstr += obj.childNodes[i].name + "=" + obj.childNodes[i].value + "&";
               }
            }
         }   
         if (obj.childNodes[i].tagName == "SELECT") {
            var sel = obj.childNodes[i];
            getstr += sel.name + "=" + sel.options[sel.selectedIndex].value + "&";
         }
         
      }
      makeRequest('get.php', getstr);
   }
   
   
   
   function register()
   {
   	var getstr = "";
	var errRpt = "";
	var errMsg = "";
	
	if ( document.reg.username.value == "" )
	{
		document.reg.username.style.background = '#ffff99';
		errRpt = 1;
	}	
	
	if ( document.reg.email.value == "" )
	{
		document.reg.email.style.background = '#ffff99'; 
		errRpt = 1;
	}
	
	if ( document.reg.password.value == "" )
	{
		document.reg.password.style.background = '#ffff99'; 
		errRpt = 1;
	}
	
	if ( document.reg.password2.value == "" )
	{
		document.reg.password2.style.background = '#ffff99';
		errRpt = 1;
	}
	
	if ( ! document.reg.coppa.checked )
	{
		document.getElementById('coppa-report').innerHTML = "<span style='font-size:20px;color:#ffff99;font-weight:bold'>!</span>";
		errRpt = 1;
	}
			
	document.getElementById('error-report').innerHTML = errMsg;
		
	getstr += '&username=' + document.reg.username.value;
	getstr += '&email=' + document.reg.email.value;
	getstr += '&password=' + document.reg.password.value;
	getstr += '&password2=' + document.reg.password.value;
	getstr += '&coppa=' + document.reg.coppa.value;
	getstr += '&email_yn=' + document.reg.email_yn.value;

	if ( ! errRpt )
	{
		makeRequest('/Software/index.php?RBA_MOD=softwaremgr&RBA_CMD=reg_save', getstr, "register");
   	}
	return false;
  }
  
    function ulogin()
   {
   	var getstr = "";
	var errRpt = "";
	var errMsg = "";
	
	if ( document.login.username.value == "" )
	{
		document.login.username.style.background = '#ffff99';
		errRpt = 1;
	}	
	
	if ( document.login.password.value == "" )
	{
		document.login.password.style.background = '#ffff99'; 
		errRpt = 1;
	}
			
	document.getElementById('error-report').innerHTML = errMsg;
		
	getstr += '&username=' + document.login.username.value;
	getstr += '&password=' + document.login.password.value;

	if ( ! errRpt )
	{
		makeRequest('/Software/index.php?RBA_MOD=softwaremgr&RBA_CMD=user_login', getstr, "login");
   	}
	return false;	
  }