// JavaScript Document

var httpRequest;
   function CallChecker (actionType, thevalue, checktag, divtag , theurl)
   
   { //alert (actionType);
	   var contentViewerC = document.getElementById(divtag);
	   contentViewerC.innerHTML =  'checking....';
	    var url = theurl + '/jax/registrationChecks.asp?action=' + actionType + '&value='+ thevalue ;
		
		//alert (url);
        if (window.ActiveXObject)
        {
          httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
        }
        else
        {
          httpRequest = new XMLHttpRequest();
        }
        httpRequest.open("GET", url, true);
        httpRequest.onreadystatechange= function () {processRequest(actionType, thevalue, checktag, divtag,theurl); } ;
        httpRequest.send(null);
		// contentViewerC.innerHTML = '';
		
      }
  
	
	   
   function processRequest( actionType, thevalue, checktag, divtag,theurl)
   {
      if (httpRequest.readyState == 4)
      {
        if(httpRequest.status == 200)
        {
          var contentViewer = document.getElementById(divtag);
          //contentViewer.innerHTML =
		  var theresponse =  httpRequest.responseText;
		  var  contentBuild;
		  //alert (theresponse);
		  switch (actionType)
		  	{
			// U S E R  N A M E
			case 'username':
					
					if (theresponse == 'true')
						{
							contentViewer.innerHTML ='<img src=\''+ theurl +'/images/icons/cross.gif\' class= \'absMiddle\'alt=\'Username taken\'  />Sorry but that username is taken';
						}
					else if (theresponse == 'invalid')
						{
							contentViewer.innerHTML ='<img src=\''+ theurl +'/images/icons/cross.gif\' class= \'absMiddle\'alt=\'Username invalid\'  />Sorry but that username is invalid';
						}
					else
						{
							contentViewer.innerHTML ='<img src=\''+ theurl +'/images/icons/tick.gif\' class= \'absMiddle\'alt=\'Username ok\'  />' ;
							}
							if (thevalue == '')
								{
							contentViewer.innerHTML ='<img src=\''+ theurl +'/images/icons/cross.gif\' class= \'absMiddle\'alt=\'Username needs entering\'  />Enter your username' ;
							}
							
					break
			//P A S S W O R D 
			case 'password'	:
				//alert (theresponse);
					if (theresponse == 'True')
						{
							contentViewer.innerHTML ='<img src=\''+ theurl +'/images/icons/tick.gif\' class= \'absMiddle\'alt=\'password correct length\'  />';
						}
					else
						{
							contentViewer.innerHTML ='<img src=\''+ theurl +'/images/icons/cross.gif\' class= \'absMiddle\'alt=\'password incorrect length\'  />Password needs to be over six characters long';
						}
					break
				// F O R N A M E
				case 'forname'	:
				//alert (theresponse);
					if (theresponse == 'True')
						{
							contentViewer.innerHTML ='<img src=\''+ theurl +'/images/icons/tick.gif\' class= \'absMiddle\'alt=\'forname ok\'  />';
						}
					else
						{
							contentViewer.innerHTML ='<img src=\''+ theurl +'/images/icons/cross.gif\' class= \'absMiddle\'alt=\'forname not entered\'  />Enter your forname';
						}
					break
				// S U R  N A M E
				case 'surname'	:
				//alert (theresponse);
					if (theresponse == 'True')
						{
							contentViewer.innerHTML ='<img src=\''+ theurl +'/images/icons/tick.gif\' class= \'absMiddle\'alt=\'surname ok\'  />';
						}
					else
						{
							contentViewer.innerHTML ='<img src=\''+ theurl +'/images/icons/cross.gif\' class= \'absMiddle\'alt=\'surname not entered\'  />Enter your surname';
						}
					break
				// M O B I L E
				case 'mobile'	:
				//alert (theresponse);
					if (theresponse == 'True')
						{
							contentViewer.innerHTML ='<img src=\''+ theurl +'/images/icons/tick.gif\' class= \'absMiddle\'alt=\'mobile ok\'  />';
						}
					else if (theresponse == 'doh')
						{
							contentViewer.innerHTML ='<img src=\''+ theurl +'/images/icons/cross.gif\' class= \'absMiddle\'alt=\'dont use the example number, just leave it blank\'  />Thats the example phone number!';
							}
					else
						{
							contentViewer.innerHTML ='<img src=\''+ theurl +'/images/icons/cross.gif\' class= \'absMiddle\'alt=\'surname not entered\'  />You can leave this field blank, if not we require you enter a UK mobile number such as: <span class=\'smallText\' >07713 345678</span>';
						}
						if (thevalue =='')
						{
							contentViewer.innerHTML ='';
						}
					break	
				// E M A I L 
				case 'email'	:
				//alert (theresponse);
					if (theresponse == 'True')
						{
							contentViewer.innerHTML ='<img src=\''+ theurl +'/images/icons/tick.gif\' class= \'absMiddle\'alt=\'email ok\'  />';
						}
					else if (theresponse =='taken')
						{contentViewer.innerHTML ='<img src=\''+ theurl +'/images/icons/cross.gif\' class= \'absMiddle\'alt=\'please enter a valid email addresss\'  />That address has already been entered before<br /><a href=\''+ theurl + '/login.asp?action=forgot\'><strong>Click here to access the account reminder</a>';}
					else
						{
							contentViewer.innerHTML ='<img src=\''+ theurl +'/images/icons/cross.gif\' class= \'absMiddle\'alt=\'please enter a valid email addresss\'  />please enter a valid email address';
						}
					break	
				case  'emailbt'	:
				//alert (theresponse);
					if (theresponse == 'True')
						{
							contentViewer.innerHTML ='<img src=\''+ theurl +'/images/icons/tick.gif\' class= \'absMiddle\'alt=\'email ok\'  />';
						}
					else if (theresponse =='taken')
						{contentViewer.innerHTML ='<img src=\''+ theurl +'/images/icons/cross.gif\' class= \'absMiddle\'alt=\'please enter a valid email addresss\'  />That address has already been entered before<br /><a href=\''+ theurl + '/login.asp?action=forgot\'><strong>Click here to access the account reminder</a>';}
					else
						{
							contentViewer.innerHTML ='<img src=\''+ theurl +'/images/icons/cross.gif\' class= \'absMiddle\'alt=\'please enter a valid email addresss\'  />please enter a valid email address';
						}
					break		
				//C O U N T Y 
				case 'county':
					if (theresponse == 'True')
						{
							contentViewer.innerHTML ='<img src=\''+ theurl +'/images/icons/tick.gif\' class= \'absMiddle\'alt=\'you have selected a county\'  />';
						}
					else
						{
							contentViewer.innerHTML ='<img src=\''+ theurl +'/images/icons/cross.gif\' class= \'absMiddle\'alt=\'you have selected a country\'  />Please choose a county from the drop down list. Countries are not valid selections';
						}
				break
				//A D D R E S S 1
				case 'address1':
					if (theresponse == 'True')
						{
							contentViewer.innerHTML ='<img src=\''+ theurl +'/images/icons/tick.gif\' class= \'absMiddle\'alt=\'Address entered\'  />';
						}
					else
						{
							contentViewer.innerHTML ='<img src=\''+ theurl +'/images/icons/cross.gif\' class= \'absMiddle\'alt=\'enter your house number and street name\'  />Please enter your house/flat number and street name';
						}
				break
				
				//A D D R E S S 2
				case 'address2':
					if (theresponse == 'True')
						{
							contentViewer.innerHTML ='<img src=\''+ theurl +'/images/icons/tick.gif\' class= \'absMiddle\'alt=\'Town entered\'  />';
						}
					else
						{
							contentViewer.innerHTML ='<img src=\''+ theurl +'/images/icons/cross.gif\' class= \'absMiddle\'alt=\'enter the town you live in\'  />Please enter the town or city you live in';
						}
				break
				//P O S T C O D E
				case 'postcode':
					if (theresponse == 'True')
						{
							contentViewer.innerHTML ='<img src=\''+ theurl +'/images/icons/tick.gif\' class= \'absMiddle\'alt=\'Town entered\'  />';
						}
					else
						{
							contentViewer.innerHTML ='<img src=\''+ theurl +'/images/icons/cross.gif\' class= \'absMiddle\'alt=\'enter the town you live in\'  />Please enter your postcode';
						}
				break
				}
		  
        }
        else
        {
           // alert("Error loading page\n"+ httpRequest.status +":"+ httpRequest.statusText);
        }
      }
     }
	 
	 function chooseACounty ( selectObject, divtag , theurl)
	 {
		 var choice = selectObject.options[selectObject.selectedIndex].value;
		 
		 CallChecker ('county', choice, '', divtag , theurl)
		 
		
	 }