var error_uname_required;
var error_password_required;
var error_password_length;
var error_reqfieldmissing;
var error_reqfieldincorrect;
var error_uname_invalid;
 
 //function to initialize error messages
 function initializeLogin(uname_required, 
							password_required, 
							password_length, 
							reqfieldmissing, 
							reqfieldincorrect, 
							uname_invalid) {
							
		error_uname_required = uname_required;
		error_password_required = password_required;
		error_password_length = password_length;
		error_reqfieldmissing = reqfieldmissing;
		error_reqfieldincorrect = reqfieldincorrect;
		error_uname_invalid = uname_invalid;
 }
 
 //function to validate login
 function validateLogin() {
 		var returnVal = false
        var errorMessage = validateLoginForm();       
        if (errorMessage == '') {
          returnVal = true;
        } else {
          getElement('show_errors_login').innerHTML = errorMessage+'<br/>';          
        }
		return returnVal;
 }

 //function to validate form 
 function validateLoginForm() {
         var result = true;
         var errorMsg = '';
         var reqdErrorMsg = '';
         var invalidErrorMsg = '';

		 getElement('login').userName.value = trim(getElement('login').userName.value);
         var uName = getElement('login').userName;
         if ( !validRequired(uName)) {
             reqdErrorMsg = reqdErrorMsg + error_uname_required;
             result = false;
         }
         
         getElement('login').password.value = trim(getElement('login').password.value);
         var pass = getElement('login').password;
         if (!validRequired( pass)) {
             reqdErrorMsg = reqdErrorMsg + error_password_required;
             result = false;
         }
         
         if (reqdErrorMsg != '') {
             errorMsg = error_reqfieldmissing + reqdErrorMsg + '<br>';
         }
         if (invalidErrorMsg != '') {
             errorMsg = errorMsg + error_reqfieldincorrect + invalidErrorMsg;
         }
         return errorMsg;
 }

 //function to get devide id
 function getDeviceId(){
	try{
	  var objTCIM = document.getElementById("DVC_PM");
	  try{
		  retErrVal = objTCIM.CheckForUpgrades();
		  retErrVal = objTCIM.GetLastErrorCode();
		//objTCIM.DownloadSongs('3123', 'XX');
		//objTCIM.SetLoggedInUserContext(ccmdomain,ccmapplication,loginuser,auserID,nickname);
	  }catch(e){}

	  var deviceId = objTCIM.GetIdNum();		  
	  if (deviceId!=null && deviceId!=""){			  
		  document.getElementById("deviceId").value = deviceId;
	  } 
	}catch(e){
		document.getElementById("deviceId").value = 0;
	}
 }	