var http_request = false;
   function makeRequest(url) {
      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, true);
      http_request.send(null);
   }

   function alertContents() {
      if (http_request.readyState == 4) {
         if (http_request.status == 200) {
             result = http_request.responseText;
           if (result!=""){
            
			
			if(result=='welcome'){
			alert('Welcome to DocuChannel! You may log in now...');
			//document.data.submit();
			window.location='http://www.docuchannel.net';
			} 
			if(result=="queue"){
			alert('Note: The content provider you subscribed to placed a maximum capacity on their channel. Unfortunately, this capacity has been reached! DocuChannel has placed you in a queue which will automatically subscribe you when subscription slots become available. At that time you will receive an e-mail notification and can begin receiving content. In the mean time, your account is now active and you may log in!');
			//document.data.submit();
			window.location='http://www.docuchannel.net';
			} 
			if(result=="nochannel"){
			alert('Note: The provider code you entered is invalid! You can try adding your subscription again after running the DocuChannel receiver. In the mean time, your account is now active and you may log in!');
			//document.data.submit();
			window.location='http://www.docuchannel.net';
			} 			
			if(result!="queue" && result!="welcome" && result!="nochannel"){
			alert(result)	
			}	
			
		    }
		               
            
			} else {
            alert('There was a problem with the request.');
         }
      }
   }
   
  

 function form_check(){
 
 un=document.forms['signup'].elements['uname'].value;
 //document.forms['data'].elements['n'].value=un; // Set form data in form 'DATA' equal to input for submission

 
 // Blank username
 if (document.forms['signup'].elements['uname'].value==""){
 alert('Error: Username cannot be blank!');
 return false;
 }
 
 // Check for vaild e-mail
 var emailFilter=/^.+@.+\..{2,3}$/;
 if (!(emailFilter.test(document.forms['signup'].elements['uname'].value))) { 
 alert ('Error: Invalid e-mail address! Example: john@docuchannel.net');
 return false;
 }
 
 
 // Check for invalid domain names
 var email_check = document.forms['signup'].elements['uname'].value.split("@");
 if (email_check[1]=="docuchannel.net" || email_check[1]=="sensoryventures.com" || email_check[1]=="scriptreminder.com"){
 alert ('Error: Invalid e-mail address!');
 return false;
 } 

 
 
 // Password blank
 if (document.forms['signup'].elements['pword1'].value=="" || document.forms['signup'].elements['pword2'].value==""){
 alert('Error: Password is required!');
 return false;
 }
 
 // Password mismatch
 if (document.forms['signup'].elements['pword1'].value!=document.forms['signup'].elements['pword2'].value){
 alert('Error: Passwords don\'t match!');
 return false;
 }
 
 // Check password length
 if (document.forms['signup'].elements['pword1'].value.length<5){
 alert('Error: Password must be at least 5 characters!');
 return false;
 }
 
 
 makeRequest('sign_up_save.php?u='+escape(document.forms['signup'].elements['uname'].value)+'&pc='+escape(document.forms['signup'].elements['pc'].value)+'&p='+escape(document.forms['signup'].elements['pword2'].value)+'&verify='+escape(document.forms['signup'].elements['verify'].value)+'&cp='+escape(document.forms['signup'].elements['cp'].value));
 
 
 
 
 
 } // End function form_check
 
