	var SelectedTab;
	var Screen;
	var AccessType;
	var LoginFormHTML;
	var RegisterPageHTML;
	var PinRetrieveHTML;
	
	if( getCookie("Tab") != null && window.location.protocol == "https:")
	{
	    setTimeout("SpawnLogin('"+getCookie("Tab")+"')", 2000);
	    deleteCookie("Tab");
	}
	
	
	var LightBoxinnerHTML =  document.getElementById ("OnlineLogin").innerHTML;
	document.getElementById ("OnlineLogin").innerHTML = "";	
	
//---------------------------------------------------------------------------
	function SwapLoginForm ( thisDiv )
	{
	    var LoginForm = thisDiv.id.replace ("LoginItem", "");
        var thisDivid = thisDiv.id;
        
	    document.getElementById ( "LoginItem" + Screen ).className = "LoginItemTab";  
	    
	    document.getElementById ( Screen + "Form").style.display = "none";
	    document.getElementById ( LoginForm + "Form").style.display = "block";

        Screen = LoginForm;
        
	    document.getElementById (thisDivid).className = 'LoginItemTabSelected';

	    if ( SelectedTab != 'Member' )
	        {
	            SelectTab ( SelectedTab );
	        }  

	}        
//--------------------------------------------------------------------------
	function SelectTab ( Selection )
	{
	    document.getElementById ( SelectedTab + 'LoginTab' ).className = 'LoginUserTab';
	    document.getElementById ( Selection + 'LoginTab' ).className = 'LoginUserTabSelected';
		SelectedTab = Selection;
		if ( Selection == 'Member' )   
			{ 
			    AccessType = 1;
				if ( Screen == 'Login')
				    {
				        document.getElementById ('AccessUser').innerHTML = 'Member number:';   
				    }
				else if ( Screen == 'Register')
				    {
				        document.getElementById ( 'MemberRegister' ).style.display = 'block';
				        document.getElementById ( 'ServiceProviderRegister' ).style.display = 'none';
				        document.getElementById ( 'DMAUserRegister' ).style.display = 'none';
				    }
				else if ( Screen == 'PinRetrieval')
				    {
				        document.getElementById ( 'DMAUserPinRetrival' ).style.display = 'none';
				        document.getElementById ('PinRetrievalForm').style.display = 'block';
	                    document.getElementById ('lblType').innerHTML = 'Member number:' ;
	                    document.getElementById('idnumberid').style.display="block";
				    }
			} 
		else if ( Selection == 'ServiceProvider' )
		   	{ 
		   	    AccessType = 2;
		   	    if ( Screen == 'Login')
				    {
				        document.getElementById ('AccessUser').innerHTML = 'Practice number:';
				        

				    }
				else if ( Screen == 'Register')
				    {
				        document.getElementById ( 'MemberRegister' ).style.display = 'none';
				        document.getElementById ( 'ServiceProviderRegister' ).style.display = 'block';
				        document.getElementById ( 'DMAUserRegister' ).style.display = 'none';
				    }
				else if ( Screen == 'PinRetrieval')
				    {
				        document.getElementById ( 'DMAUserPinRetrival' ).style.display = 'none';
				        document.getElementById ('PinRetrievalForm').style.display = 'block';
	                    document.getElementById ('lblType').innerHTML = 'Practice number:' ;
	                    document.getElementById('idnumberid').style.display="none";
				    }
			}   
		else if ( Selection == 'DMAUser' ) 
			{ 
			    document.getElementById ( 'DMAUserPinRetrival' ).style.display = 'none';
			    document.getElementById ( 'DMAUserRegister' ).style.display = 'none';
			    AccessType = 3;
				if ( Screen == 'Login')
				    {
				        document.getElementById ('AccessUser').innerHTML = 'DMA user:';
				        
				    }
				else if ( Screen == 'Register')
				    {
				        document.getElementById ( 'MemberRegister' ).style.display = 'none';
				        document.getElementById ( 'ServiceProviderRegister' ).style.display = 'none';
				        document.getElementById ( 'DMAUserRegister' ).style.display = 'block';
				    }
				else if ( Screen == 'PinRetrieval')
				    {
				        document.getElementById ( 'DMAUserPinRetrival' ).style.display = 'block';
				        document.getElementById ('PinRetrievalForm').style.display = 'none';
				    }
		    }
		else if ( Selection == 'Broker' ) 
			{ 
			    document.getElementById ( 'DMAUserPinRetrival' ).style.display = 'none';
			    document.getElementById ( 'DMAUserRegister' ).style.display = 'none';
			    AccessType = 4;
				if ( Screen == 'Login')
				    {
				        document.getElementById ('AccessUser').innerHTML = 'Broker Code:';
				        
				    }
				else if ( Screen == 'Register')
				    {
				        document.getElementById ( 'MemberRegister' ).style.display = 'none';
				        document.getElementById ( 'ServiceProviderRegister' ).style.display = 'none';
				        document.getElementById ( 'DMAUserRegister' ).style.display = 'block';
				    }
				else if ( Screen == 'PinRetrieval')
				    {
				        document.getElementById ( 'DMAUserPinRetrival' ).style.display = 'block';
				        document.getElementById ('PinRetrievalForm').style.display = 'none';
				    }
				    
			}  
	}
//--------------------------------------------------------------------
	function SpawnLogin ()
	{
	
	     SelectedTab = "Member";
	     Screen = "Login";
	     AccessType = 1;
	     SpawnLightBox ( LightBoxinnerHTML ); 
	}
	
	function SpawnLogin (tab)
	{
	    if ( window.location.protocol == "http:" )
	     {	 	              
            setCookie("Tab", tab, 1);
	        window.location = window.location.href.replace ("http", "https");
	     }
	     else
	     {
	        if(tab=='undefined'|| tab=='' || tab == null)
	        {
	            //alert(tab);
	            SelectedTab = "Member";
	             Screen = "Login";
	             AccessType = 1;
	             SpawnLightBox ( LightBoxinnerHTML ); 
	        }
	        else
            {
                //alert(tab);
                SelectedTab = tab;
                Screen = "Login";
                //AccessType = 1;
                SpawnLightBox ( LightBoxinnerHTML ); 
                SelectTab(tab);
             }
	     }
	}
	
	function SpawnFOGLogin (tab)
	{
	if(tab==null)
	{
	    //alert(tab);
	    SelectedTab = "Member";
	     Screen = "Login";
	     AccessType = 1;
	     SpawnLightBox ( LightBoxinnerHTML ); 
	}
	else
	    {
	        //alert(tab);
	        SelectedTab = tab;
	        Screen = "Login";
	        //AccessType = 1;
	        SpawnLightBox ( LightBoxinnerHTML ); 
	        SelectTab(tab);
	     }
	     document.getElementById("LoginItemRegister").innerHTML = "<span>Register for a PIN</span>";
	}
//-----------------------------------------------------------------------
var AjaxResponseString = "";
//----------------------------------------------------------------------	
	function ShowRegisterPage ( AJAXResponse )
	{
	    RegisterPageHTML = AJAXResponse; 
	}
//-------------------------------------------------------------------

	function ShowPinRetrieve ( AJAXResponse )
	{
	    PinRetrieveHTML = AJAXResponse;
	}
//----------------------------------------------------------------------- 
function DoLogin ()
{   
    var url = "CMSAjax.aspx?Action=ProcessLogin" + MakeQuerystringFromForm ( "UserLoginForm" );
    document.getElementById ("lightbox").style.zIndex = "30";
    document.getElementById ("ProcesingClaimsPage").style.display = "block";
    document.getElementById ("ProcesingClaimsPage").style.zIndex = "100000000";
    RunAjax ( url, "ReturnLogin", "LoginAjaxErrorHandler" );
}

function DoBankmedLogin()
{
    var url = "CMSAjax.aspx?Action=ProcessLogin" + MakeQuerystringFromForm ( "UserLoginForm" );
    document.getElementById ("lightbox").style.zIndex = "30";
    document.getElementById ("ProcesingClaimsPage").style.display = "block";
    document.getElementById ("ProcesingClaimsPage").style.zIndex = "100000000";   
    RunAjax ( url, "ReturnBankmedLogin", "LoginAjaxErrorHandler" );
}

function DoIPALogin ()
{   
    var url = "CMSAjax.aspx?Action=ProcessIPALogin" + MakeQuerystringFromForm ( "UserLoginForm" );
    //alert(url);
    document.getElementById ("lightbox").style.zIndex = "30";
    document.getElementById ("ProcesingClaimsPage").style.display = "block";
    document.getElementById ("ProcesingClaimsPage").style.zIndex = "100000000"; 
    RunAjax ( url, "ReturnIPALogin", "LoginAjaxErrorHandler" );
}

function DoQualsaLogin ()
{   
    var url = "CMSAjax.aspx?Action=ProcessFOGLogin"+ MakeQuerystringFromForm ( "UserLoginForm" );
    //alert(url);
    document.getElementById ("lightbox").style.zIndex = "30";
    document.getElementById ("ProcesingClaimsPage").style.display = "block";
    document.getElementById ("ProcesingClaimsPage").style.zIndex = "100000000"; 
    RunAjax ( url, "ReturnQualsaLogin" );
}
function DoFOGLogin ()
{   
    var url = "CMSAjax.aspx?Action=ProcessFOGLogin" + MakeQuerystringFromForm ( "UserLoginForm" );
    //alert(url);
    document.getElementById ("lightbox").style.zIndex = "30";
    document.getElementById ("ProcesingClaimsPage").style.display = "block";
    document.getElementById ("ProcesingClaimsPage").style.zIndex = "100000000"; 
    RunAjax ( url, "ReturnFOGLogin", "LoginAjaxErrorHandler" );
}

function DoGenericLogin (CmsAjaxCall)
{   
    var url = "CMSAjax.aspx?Action="+CmsAjaxCall +""+ MakeQuerystringFromForm ( "UserLoginForm" );
    RunAjax ( url, "ReturnGENERICLogin", "LoginAjaxErrorHandler" );
}

function DoProviderProfilingLogin ()
{   
    var url = "CMSAjax.aspx?Action=ProcessProfilerLogin" + MakeQuerystringFromForm ( "UserLoginForm" );
    //alert(url);
    document.getElementById ("lightbox").style.zIndex = "30";
    document.getElementById ("ProcesingClaimsPage").style.display = "block";
    document.getElementById ("ProcesingClaimsPage").style.zIndex = "100000000"; 
    RunAjax ( url, "ReturnProviderProfilingLogin" );
}


//------------------------------------------------------------------------

function ReturnIPALogin (AJAXResponse)
{

if (AJAXResponse == "false")
        {
            //alert(AJAXResponse);
            //document.getElementById ("ProcesingClaimsPage").style.display = "none";
            document.getElementById ("lightbox").style.zIndex = "10000000";
            document.getElementById ("ValidationMessage").innerHTML = "Login Error";
            //LooseLightBox ();
        }
        else if (AJAXResponse == "true")
        {
            
            LooseLightBox ();
            window.location = "https://" + window.location.hostname + "/default.aspx?Scheme=" + RedirectionURL + "&Version=" + AddVersion;  
            
        }
        else
        {
            //alert(AJAXResponse);
            //document.getElementById ("ProcesingClaimsPage").style.display = "none";
            document.getElementById ("lightbox").style.zIndex = "10000000";
            document.getElementById ("ValidationMessage").innerHTML = "Login Error";
            //LooseLightBox ();
        }
}

function ReturnFOGLogin (AJAXResponse)
{

if (AJAXResponse == "false")
        {
            //alert(AJAXResponse);
            //document.getElementById ("ProcesingClaimsPage").style.display = "none";
            document.getElementById ("lightbox").style.zIndex = "10000000";
            document.getElementById ("ValidationMessage").innerHTML = "Login Error";
            //LooseLightBox ();
        }
        else if (AJAXResponse == "true")
        {
            
            LooseLightBox ();
            window.location ="https://" + window.location.hostname + "/ContentName.aspx?Name=Provider Registration&Scheme=56&Version=" + AddVersion;  
        }
        else
        {
            //alert(AJAXResponse);
            //document.getElementById ("ProcesingClaimsPage").style.display = "none";
            document.getElementById ("lightbox").style.zIndex = "10000000";
            document.getElementById ("ValidationMessage").innerHTML = "Login Error";
            //LooseLightBox ();
        }
}

function ReturnBankmedLogin(AJAXResponse)
{
    if(AJAXResponse == "true")
    {
        if( AccessType == 1 )
            window.location = "https://" + window.location.hostname + "/default.aspx?Scheme=" + RedirectionURL + "&Version=" + AddVersion;
        else if( AccessType == 2 || AccessType == 3 )
        {          
            document.getElementById("LoginSpawner").innerHTML = "<form action='https://www.newmed.co.za/logon/login.asp?env="+ AccountBox +"' method='post' target='_self' id='SpForm'><input name='UserName' value='"+ document.getElementById("UserName").value + "'><input name='Password' value='" + document.getElementById("Password").value + "'><input name='AccessType' value='"+ AccessType + "'></form>";            
            document.getElementById("SpForm").submit();                                  
        }
    }
    else if( AJAXResponse.search("Incorrect") >= 0 )
    {
            document.getElementById ("ProcesingClaimsPage").style.display = "none";
            document.getElementById ("lightbox").style.zIndex = "10000000";
            document.getElementById ("ValidationMessage").innerHTML = AJAXResponse;
    }
    else if (AJAXResponse == "ServerError") {
        document.getElementById("ProcessingClaimsPage").style.display = "none";
        document.getElementById("lightbox").style.zIndex = "10000000";
        document.getElementById("ValidationMessage").innerHTML = "We are experiencing a server error, please try again later.";
    }

    else
    {
             document.getElementById ("ProcesingClaimsPage").style.display = "none";
             document.getElementById ("lightbox").style.zIndex = "10000000";
             document.getElementById ("ValidationMessage").innerHTML = AJAXResponse;        
    }
}

function ReturnQualsaLogin (AJAXResponse)
{

if (AJAXResponse == "false")
        {
            document.getElementById ("lightbox").style.zIndex = "10000000";
            document.getElementById ("ValidationMessage").innerHTML = "Login Error";
        }
        else if (AJAXResponse == "true")
        {
            LooseLightBox ();
            window.location ="https://" + window.location.hostname + "/ContentName.aspx?Name=Provider Registration&Scheme=2&Version=" + AddVersion;  
        }
        else
        {
            document.getElementById ("lightbox").style.zIndex = "10000000";
            document.getElementById ("ValidationMessage").innerHTML = "Login Error";
        }
}

function ReturnProviderProfilingLogin (AJAXResponse)
{
    if (AJAXResponse == "false")
        {
            document.getElementById ("lightbox").style.zIndex = "10000000";
            document.getElementById ("ValidationMessage").innerHTML = "Login Error";
        }
        else if (AJAXResponse == "true")
        {
            LooseLightBox ();
            window.location = "https://" + window.location.hostname + "/default.aspx?Scheme=" + 107 + "&Version=" + AddVersion;  
            
        }
        else
        {
            document.getElementById ("lightbox").style.zIndex = "10000000";
            document.getElementById ("ValidationMessage").innerHTML = "Login Error";
        }
}


function EncodeString ( AJAXResponse )
{
    var usrPwd = AJAXResponse.split("|||");
    encodedUsrPwd = "<input name='EncUserName' value='"+usrPwd[0]+"'><input name='EncPassword' value='"+usrPwd[1]+"'>";
    //encodedUsrPwd = "<input name='EncUserName' value='"+usrPwd[0]+"'><input name='EncPassword' value=''>";
    
    document.getElementById ("LoginForm").innerHTML = "<form action='http://w3.newmed.co.za/logon/login.asp?env=" + AccountBox + "' method='post' id='SpForm' target='_blank'><input name='UserName' value='" + document.getElementById ("UserName").value + "'><input name='Password' value='" + document.getElementById ("Password").value + "'>"+encodedUsrPwd+"<input name='AccessType' value='" + AccessType + "'></form>"

    document.getElementById ('SpForm').submit();
    document.getElementById ("LoginForm").innerHTML = LoginFormHTML;
    LooseLightBox ();
}

function ReturnGENERICLogin(AJAXResponse)
{
    if(AJAXResponse=="true")
        window.location = "https://" + window.location.hostname + "/default.aspx?Scheme=" + RedirectionURL + "&Version=" + AddVersion;  
    else
        document.getElementById("ValidationMessage").innerHTML="The username or password is incorrect. Please try again";
}

function EncodeString ( AJAXResponse )
{
    var usrPwd = AJAXResponse.split("|||");
    //encodedUsrPwd = "<input name='EncUserName' value='"+usrPwd[0]+"'><input name='EncPassword' value='"+usrPwd[1]+"'>";
    encodedUsrPwd = "<input name='EncUserName' value='"+usrPwd[0]+"'><input name='EncPassword' value=''>";
    //encodedUsrPwd = "<input name='EncUserName' value=''><input name='EncPassword' value=''>";
    
    document.getElementById ("LoginForm").innerHTML = "<form action='https://www.newmed.co.za/logon/login.asp?env=" + AccountBox + "' method='post' id='SpForm' target='_blank'><input name='UserName' value='" + document.getElementById ("UserName").value + "'><input name='Password' value='" + document.getElementById ("Password").value + "'>"+encodedUsrPwd+"<input name='AccessType' value='" + AccessType + "'></form>"

    document.getElementById ('SpForm').submit();
    document.getElementById ("LoginForm").innerHTML = LoginFormHTML;
    LooseLightBox ();
}

function ReturnLogin ( AJAXResponse )
{
    if (AJAXResponse == "true")
        {
            if ( AccessType == 1 )
                {
                    window.location = "https://" + window.location.hostname + "/default.aspx?Scheme=" + RedirectionURL + "&Version=" + AddVersion;  
                }
            else if ( AccessType == 2 || AccessType == 3  || AccessType == 4)    
                {
                    var eurl = "CMSAjax.aspx?Action=EncodeUsernamePassword&usr="+document.getElementById ("UserName").value+"&pwd="+document.getElementById ("Password").value;
                    RunAjax(eurl, "EncodeString", "LoginAjaxErrorHandler");
                }
        }
    else if (AJAXResponse == "false")
        {
            document.getElementById ("ProcesingClaimsPage").style.display = "none";
            document.getElementById ("lightbox").style.zIndex = "10000000";
            document.getElementById ("ValidationMessage").innerHTML = "Login Error";
        }
   else if (AJAXResponse == "ServerError")
        {
             document.getElementById ("ProcesingClaimsPage").style.display = "none";
             document.getElementById ("lightbox").style.zIndex = "10000000";
             document.getElementById ("ValidationMessage").innerHTML = "We are experiencing a server error, please try again later.";
        }
   else 
        {
             document.getElementById ("ProcesingClaimsPage").style.display = "none";
             document.getElementById ("lightbox").style.zIndex = "10000000";
             document.getElementById ("ValidationMessage").innerHTML = AJAXResponse;
        }
        

}
//------------------------------------------------------------------------
function MakeQuerystringFromForm ( FormName )
{
   var Output = "";
   for ( var i = 0; i < document.getElementById ( FormName ).elements.length; i++ )
        {
            Output = Output + "&" + document.getElementById ( FormName ).elements[i].name + "=" + document.getElementById ( FormName ).elements[i].value;
        }
   Output = Output + "&AccessType=" + AccessType;
   return Output
}
//------------------------------------------------------------------------
var StorageFormArray = new Array(2);
for (i=0; i <2; i++)
    {
        StorageFormArray[i] = new Array(100);
    }
//---------------------------------------------------------------------
    function ShowBox ( UserType )
        {
            if ( UserType == 'Member' )
                {
                    document.getElementById ( 'Member' ).style.display = 'block';
					document.getElementById ( 'MemberTab' ).className = 'selectedtab';
					document.getElementById ( 'ServiceProviderTab' ).className = 'tab';
                    document.getElementById ( 'ServiceProvider' ).style.display = 'none';
                }
            else if ( UserType == 'ServiceProvider' )
                {
                    document.getElementById ( 'Member' ).style.display = 'none';
                    document.getElementById ( 'ServiceProvider' ).style.display = 'block';
					document.getElementById ( 'ServiceProviderTab' ).className = 'selectedtab';
					document.getElementById ( 'MemberTab' ).className = 'tab';
                }
        }
//-------------------------------------------------------
    function RegisterValidateMember ()
        {
            //MEMBER NUMBER VALIDATION
             if(!RequiredFieldValidator('ValidationMessage','UserName1','Please enter your member number'))
             {
                // SpawnLightBox (document.getElementById ("OnlineLogin").innerHTML ); 
                
                return false;
             }

             if(!IsNumeric('ValidationMessage','UserName1','Please enter a numeric member number'))
             {
                // SpawnLightBox (document.getElementById ("OnlineLogin").innerHTML ); 
                
                return false;
             }
            //1st PIN NUMBER VALIDATION
            if(!RequiredFieldValidator('ValidationMessage','Pass','Please enter your pin'))
             {
                // SpawnLightBox (document.getElementById ("OnlineLogin").innerHTML ); 
                
                return false;
             }

             if(!IsNumeric('ValidationMessage','Pass','Please enter a numeric pin number'))
             {
                // SpawnLightBox (document.getElementById ("OnlineLogin").innerHTML ); 
                
                return false;
             }

             if(!ValidateFieldLenght('ValidationMessage','Pass','4','Please enter a four-digit numeric PIN'))
             {
                // SpawnLightBox (document.getElementById ("OnlineLogin").innerHTML ); 
                
                return false;
             }
             //2nd PIN NUMBER VALIDATION
             if(!CompareFieldData('ValidationMessage','Pass','ConfirmPassword','Your PINs do not match'))
             {
                // SpawnLightBox (document.getElementById ("OnlineLogin").innerHTML ); 
                
                return false;
             }
             //ID NUMBER VALIDATION
             if(!RequiredFieldValidator('ValidationMessage','IDNumber','Please enter your id number'))
             {
                // SpawnLightBox (document.getElementById ("OnlineLogin").innerHTML ); 
                
                return false;
             }

             if(!IsNumeric('ValidationMessage','IDNumber','Please enter a numeric id number'))
             {
                // SpawnLightBox (document.getElementById ("OnlineLogin").innerHTML ); 
                
                return false;
             }

             if(!ValidateFieldLenght('ValidationMessage','IDNumber','13','Please enter a 13 digit id number'))
             {
                // SpawnLightBox (document.getElementById ("OnlineLogin").innerHTML ); 
                
                return false;
             }
            
            var url = "CMSAjax.aspx?Action=ProcessMemberRegister" + MakeQuerystringFromForm ( "MemberRegisterForm" ); 
            document.getElementById ("lightbox").style.zIndex = "30";
            document.getElementById ("ProcesingClaimsPage").style.display = "block";
            document.getElementById ("ProcesingClaimsPage").style.zIndex = "100000000";
            RunAjax ( url, "MemberRegister", "LoginAjaxErrorHandler" );

        }
//--------------------------------------------------------------------
    function RegisterValidateServiceProvider ()
        {
			
			//PRACTICE NUMBER VALIDATION
			
             if(!RequiredFieldValidator('ValidationMessage','S-DOC','Please enter your practice number'))
             {
                // SpawnLightBox (document.getElementById ("OnlineLogin").innerHTML ); 
                
                return false;
             }

             if(!IsNumeric('ValidationMessage','S-DOC','Please enter a numeric practice number'))
             {
                // SpawnLightBox (document.getElementById ("OnlineLogin").innerHTML ); 
                
                return false;
             }
           //1st PIN NUMBER VALIDATION
            if(!RequiredFieldValidator('ValidationMessage','S-PIN','Please enter your pin'))
             {
                // SpawnLightBox (document.getElementById ("OnlineLogin").innerHTML ); 
                
                return false;
             }

             if(!IsNumeric('ValidationMessage','S-PIN','Please enter a numeric pin number'))
             {
                // SpawnLightBox (document.getElementById ("OnlineLogin").innerHTML ); 
                
                return false;
             }

             if(!ValidateFieldLenght('ValidationMessage','S-PIN','4','Please enter a four-digit numeric PIN'))
             {
                // SpawnLightBox (document.getElementById ("OnlineLogin").innerHTML ); 
                
                return false;
             }
             //2nd PIN NUMBER VALIDATION
             if(!CompareFieldData('ValidationMessage','S-PIN','S-PIN-REP','Your PINs do not match'))
             {
                // SpawnLightBox (document.getElementById ("OnlineLogin").innerHTML ); 
                
                return false;
             }

             //Branch
             if(!RequiredFieldValidator('ValidationMessage','S-BRANCH','Please enter a branch'))
             {
                // SpawnLightBox (document.getElementById ("OnlineLogin").innerHTML ); 
                
                return false;
             }
             //ACCOUNT
             if(!RequiredFieldValidator('ValidationMessage','S-ACC','Please enter your account number'))
             {
                // SpawnLightBox (document.getElementById ("OnlineLogin").innerHTML ); 
                
                return false;
             }

             if(!IsNumeric('ValidationMessage','S-ACC','Please enter a numeric account number'))
             {
                // SpawnLightBox (document.getElementById ("OnlineLogin").innerHTML ); 
                
                return false;
             }
             //APPLICATION NAME
             if(!RequiredFieldValidator('ValidationMessage','S-APPL-NAME','Please enter Applicant Name'))
             {
                // SpawnLightBox (document.getElementById ("OnlineLogin").innerHTML ); 
                
                return false;
             }
             //APPLICANT ID
             if(!RequiredFieldValidator('ValidationMessage','S-APPL-ID','Please enter Applicant ID Number'))
             {
                // SpawnLightBox (document.getElementById ("OnlineLogin").innerHTML ); 
                
                return false;
             }

             if(!IsNumeric('ValidationMessage','S-APPL-ID','Please enter a numeric ID number'))
             {
                // SpawnLightBox (document.getElementById ("OnlineLogin").innerHTML ); 
                
                return false;
             }
             if(!ValidateFieldLenght('ValidationMessage','S-APPL-ID','13','Please enter a 13 digit id number'))
             {
                // SpawnLightBox (document.getElementById ("OnlineLogin").innerHTML ); 
                
                return false;
             }
            var url = "CMSAjax.aspx?Action=ProcessServiceProviderRegister" + MakeQuerystringFromForm ( "RegisterServiceProviderForm" ); 
            RunAjax ( url, "ServiceProviderRegister", "LoginAjaxErrorHandler" );
            
        }
 //---------------------------------------------------------------------------------
    function ServiceProviderRegister ( AJAXResponse )
        {
            if ( AJAXResponse == "true" )
                {
                    document.getElementById ("ValidationMessage").innerHTML = "Thank you for registering as a service provider. You can now login with your new pin.";
                }
            else
                {
                    document.getElementById ("ValidationMessage").innerHTML = AJAXResponse;
                    
                }
            // SpawnLightBox (document.getElementById ("OnlineLogin").innerHTML ); 
        }
 //---------------------------------------------------------------------------------
    function MemberRegister ( AJAXResponse )
        {
              if ( AJAXResponse == "true" )
                {
                    document.getElementById ("ValidationMessage").innerHTML =  "Congratulations, you have successfully registered as an Online user";
                    var NewUrl = "default.aspx?Scheme=" + RedirectionURL + "&Version=" + AddVersion;  
                    setTimeout ("window.location = '" + NewUrl + "'", 100);
                }
            else
                {
                    document.getElementById ("ProcesingClaimsPage").style.display = "none";
                    document.getElementById ("lightbox").style.zIndex = "10000000";
                    document.getElementById ("ValidationMessage").innerHTML = AJAXResponse;
                }  
           // SpawnLightBox (document.getElementById ("OnlineLogin").innerHTML );         
        }
 //----------------------------------------------------------------------------------
     function RetrievePinValidate ()
    {
        
       if(!RequiredFieldValidator('ValidationMessage','Firstname','Please enter a your first name'))
       {
            // SpawnLightBox (document.getElementById ("OnlineLogin").innerHTML ); 
            
          return false;
       }
       if(!RequiredFieldValidator('ValidationMessage','Surname','Please enter a your surname'))
       {
            // SpawnLightBox (document.getElementById ("OnlineLogin").innerHTML ); 
                   
          return false;
       }
       if(!IsNumeric('ValidationMessage','Contact','Please enter a your contact number'))
       {
            // SpawnLightBox (document.getElementById ("OnlineLogin").innerHTML ); 
              
            return false;
       }
       if(!ValidateFieldLenght('ValidationMessage','Contact','10','Please enter a valid contact number'))
       {
            // SpawnLightBox (document.getElementById ("OnlineLogin").innerHTML ); 
              
            return false;
       }

       if(!RequiredFieldValidator('ValidationMessage','Email','Please enter a your e-mail address'))
       {
            // SpawnLightBox (document.getElementById ("OnlineLogin").innerHTML ); 
              
            return false;
       }

       if(!IsValidEmail('ValidationMessage','Email','Please enter a valid e-mail address'))
       {
            // SpawnLightBox (document.getElementById ("OnlineLogin").innerHTML ); 
              
            return false;
       }
      if(!RequiredFieldValidator('ValidationMessage','RetrieveUserName','Please enter your member number'))
       {
          // SpawnLightBox (document.getElementById ("OnlineLogin").innerHTML ); 
                   
          return false;
       }
       if(!IsNumeric('ValidationMessage','RetrieveUserName','Please enter a numeric member number'))
       {
           // SpawnLightBox (document.getElementById ("OnlineLogin").innerHTML ); 
             
          return false;
       }
       if (AccessType == 1)
       {
            if(!RequiredFieldValidator('ValidationMessage','RetrieveIDNumber','Please enter a your id number'))
            {
                // SpawnLightBox (document.getElementById ("OnlineLogin").innerHTML ); 
                  
                return false;
            }
            if(!IsNumeric('ValidationMessage','RetrieveIDNumber','Please enter a numeric id number'))
            {
                // SpawnLightBox (document.getElementById ("OnlineLogin").innerHTML ); 
                              
                return false;
            }
            if(!ValidateFieldLenght('ValidationMessage','RetrieveIDNumber','13','Please enter a valid id number'))
            {
                // SpawnLightBox (document.getElementById ("OnlineLogin").innerHTML ); 
                              
                return false;
            }
       }
    var url = "CMSAjax.aspx?Action=ProcessPinRetrival" + MakeQuerystringFromForm ( "RetrivePinForm" ); 
    //alert(url);
    RunAjax ( url, "ProcessPinRetrival", "LoginAjaxErrorHandler" ); 
    }
 //--------------------------------------------------------------------------------  
 function ProcessPinRetrival ( AJAXResponse )
    {
          if ( AJAXResponse == "true" )
            {
                document.getElementById ("PinRetrievalForm").innerHTML = "<h4>Thank you</h4><br/><br/>" +
                                      "<div class=\"successfulpin\">Your query has been submitted successfully, and will be attended to in due course.<br/><br/>" +
                                      "Should you have any further queries, please do not hesitate to contact us again.</div>"                  
            }
        else
            {
                document.getElementById ("ValidationMessage").innerHTML = AJAXResponse;
            }  
       // SpawnLightBox (document.getElementById ("OnlineLogin").innerHTML );         
    }
 //-----------------------------------------------------------------------------
 function ShowPostorFax ( divid )
 {
	 document.getElementById ( 'ServiceProviderResisterForm' ).style.display = 'none';
	 document.getElementById ( 'post' ).style.display = 'none';
	 document.getElementById ( 'fax' ).style.display = 'none';
	 document.getElementById ( divid ).style.display = 'block';
	 
 }
 
//------------------------------------------------------------------------------\
function getCookie(Name) { 
var re=new RegExp(Name+"=[^;]+", "i"); //construct RE to search for target name/value pair
if (document.cookie.match(re)) //if cookie found
return document.cookie.match(re)[0].split("=")[1] //return its value
return null
}

function setCookie(name, value, days) {
var expireDate = new Date()
//set "expstring" to either future or past date, to set or delete cookie, respectively
var expstring=(typeof days!="undefined")? expireDate.setDate(expireDate.getDate()+parseInt(days)) : expireDate.setDate(expireDate.getDate()-5)
document.cookie = name+"="+value+"; expires="+expireDate.toGMTString()+"; path=/";
}

function deleteCookie(name){
setCookie(name, "moot")
}

//-------------------------------------------------------------------------------
function LoginAjaxErrorHandler( htmlResponse ){
     document.getElementById ("ProcesingClaimsPage").style.display = "none";
     document.getElementById ("lightbox").style.zIndex = "10000000";
     document.getElementById ("ValidationMessage").innerHTML = "We are experiencing a server error, please try again later.";   
}