function demoLogin()
{	
	if (document.login.CustType.checked == false) 
	  {
	  	var tbl2=document.getElementById("userbox");
	  	tbl2.innerHTML='<input type="text" size="10" maxlength="32" name="account_id" class="Text">';
	  }
	else 
	  {
	  	var tbl2=document.getElementById("userbox");
	  	tbl2.innerHTML='<input type="text" size="10" maxlength="32" name="account_id" class="Text" value="DEMO-">';
	  }
	
}

function trim(s) {
  			while (s.substring(0,1) == ' ') {
    			s = s.substring(1,s.length);
  			}
  			while (s.substring(s.length-1,s.length) == ' ') {
    			s = s.substring(0,s.length-1);
  			}
  			return s;
			}

function left(str, n){
	if (n <= 0)
	    return "";
	else if (n > String(str).length)
	    return str;
	else
	    return String(str).substring(0,n);
}
	
		
function checklogin(){                	
//verify the form fields 

  document.login.account_id.value = document.login.account_id.value.toUpperCase();
  document.login.password.value = document.login.password.value.toUpperCase();
    
                    
  if (left(document.login.account_id.value, 4) != 'DEMO')
	  {
	  	document.login.action = 'https://www.marketdatasystems.com/login/dealing/pd/cfd/security?action=authenticate'
      //make sure that the user id field is not blank.
        if (document.login.account_id.value.length < 4 ) {
        	//it isn't so show the user an alert and go to that field
          alert ("Please enter your user ID");
          document.login.account_id.focus();
          //and return false so the form doesn't get submitted
          return false;
        }
    }
	else 
	  {
	  	document.login.action = 'https://demo.marketdatasystems.com/login/dealing/pd/cfd/security?action=authenticate'
	  	//make sure that the user id field is not blank.
        if (document.login.account_id.value.length < 6 ) {
        	//it isn't so show the user an alert and go to that field
          alert ("Please enter your user ID");
          document.login.account_id.focus();
          //and return false so the form doesn't get submitted
          return false;
        }
      }
      
      
//make sure that the password field is not blank.
  if (document.login.password.value.length == 0) {
  	//it isn't so show the user an alert and go to that field
    alert ("Please enter your password");
    document.login.password.focus();
    //and return false so the form doesn't get submitted
    return false;
  }
                        
//everything checks out, final checkout, then submit the form
return true;
}