function generatecode() 
{
    if (parseInt(navigator.appVersion) <= 3) { 
        alert("Sorry this only works in 4.0 browsers"); 
        return true; 
    }

    var length=6;
    var sPassword = "";

    
    var noPunction = true;
    var randomLength = false;
    
    if (randomLength) { 
        length = Math.random(); 
        
        length = parseInt(length * 100);
        length = (length % 7) + 6
    }
    
    
    for (i=0; i < length; i++) {
    
        numI = getRandomNum();
        if (noPunction) { while (checkPunc(numI)) { numI = getRandomNum(); } }
        
        sPassword = sPassword + String.fromCharCode(numI);
    }

    document.getElementById("code").innerHTML = sPassword
    
    return true;
}

function getRandomNum() {
        
    // between 0 - 1
    var rndNum = Math.random()

    // rndNum from 0 - 1000    
    rndNum = parseInt(rndNum * 1000);

    // rndNum from 33 - 127        
    rndNum = (rndNum % 94) + 33;
            
    return rndNum;
}

function checkPunc(num) {
    
    if ((num >=33) && (num <=47)) { return true; }
    if ((num >=58) && (num <=64)) { return true; }    
    if ((num >=91) && (num <=96)) { return true; }
    if ((num >=123) && (num <=126)) { return true; }
    
    return false;
}

function valform()
{
	if(document.frmpost.txttitle.value=="")
	{
	alert("Please Enter - title");
	document.frmpost.txttitle.focus();
	return false;
	}
	
	if(document.frmpost.txtname.value=="")
	{
	alert("Please Enter - Name");
	document.frmpost.txtname.focus();
	return false;
	}
	
	
	var divtxt = document.getElementById("code").innerText;
    if(divtxt=="" || divtxt==undefined)
	 {
	 	divtxt = document.getElementById("code").textContent;
	 }

    var code=  document.getElementById("security_code").value;
	
	
	if(code!=divtxt)
	{
	  var alertEmail = 'Enter secutity verification code correctly!\n';
	  alert(alertEmail);
	  //document.contactfrm.code.focus();
	  return false;
	}
	
	return true;
}	

