//Created / Generates the captcha function    
function DrawCaptcha()
{
   var a = Math.ceil(Math.random() * 9)+ '';
   var b = Math.ceil(Math.random() * 9)+ '';       
   var c = Math.ceil(Math.random() * 9)+ '';  
   var d = Math.ceil(Math.random() * 9)+ '';  
   var e = Math.ceil(Math.random() * 9)+ '';  
   var f = Math.ceil(Math.random() * 9)+ '';  
   var g = Math.ceil(Math.random() * 9)+ '';  
   var code = a + ' ' + b + ' ' + ' ' + c + ' ' + d + ' ' + e + ' '+ f + ' ' + g;
   if(document.getElementById("txtCaptcha")){ document.getElementById("txtCaptcha").value = code; }
}

// Remove the spaces from the entered and generated code
function removeSpaces(string)
{
   return string.split(' ').join('');
}

// Validate the Entered input aganist the generated security code function   
function ValidCaptcha(){
	if( document.getElementById('txtCaptcha') ){
	   var str1 = removeSpaces(document.getElementById('txtCaptcha').value);
	   var str2 = removeSpaces(document.getElementById('txtInput').value);
	   if (str1 == str2) return true;        
	   return false;
 	}
}
