function clearField(fieldName,defaultText){
    if(document.getElementById(fieldName).value==defaultText){
        document.getElementById(fieldName).value=''
    }
    document.getElementById(fieldName).style.background='#fff';
    document.getElementById(fieldName).style.color='#60829f'
    }
function defaultFill(fieldName,defaultText){
    if(document.getElementById(fieldName).value==''){
        document.getElementById(fieldName).value=defaultText;
        document.getElementById(fieldName).style.color='red'
    }else{
        document.getElementById(fieldName).style.color='#60829f'
    }
    document.getElementById(fieldName).style.background='#fff url(formField.gif) repeat-x'
}
function fnValidate(){
    var bValid=true;
    var sFirstName=document.HomeSubmit.CRM_Leads_Name.value;
    var sLastName=document.HomeSubmit.CRM_Leads_Surname.value;    
    var sEmail=document.HomeSubmit.CRM_Leads_EMail.value;
    var sPhone=document.HomeSubmit.CRM_Leads_Phone.value;
    var sAgency=document.HomeSubmit.CRM_Leads_CompanyName.value;
    if(sFirstName==""||sFirstName=='First Name'){
        document.getElementById("CRM_Leads_Name").style.color="red";
        bValid=false
    }
    if(sLastName==""||sLastName=='Last Name'){
        document.getElementById("CRM_Leads_Surname").style.color="red";
        bValid=false
    }
    var reEmailPat=/([\w-\.]+)@((?:[\w]+\.)+)([a-zA-Z]{2,4})/;
    if(reEmailPat.test(sEmail)==false){
        document.getElementById("CRM_Leads_EMail").style.color="red";
        bValid=false
    }
    var bValidPhone=fnPhoneValid(sPhone);
    if(bValidPhone==false){
        document.getElementById("CRM_Leads_Phone").style.color="red";
        bValid=false
    }
    if(sAgency==""||sAgency=='Agency Name'){
        document.getElementById("CRM_Leads_CompanyName").style.color="red";
        bValid=false
    }
    return bValid
}
function fnPhoneValid(str){
    var sTempPhone='';
    for(var i=0;i<str.length;i++){
        var sChar=str.charAt(i);
        if(parseFloat(sChar)>-1&&parseFloat(sChar)<10){
            sTempPhone+=sChar
        }
    }
    if(sTempPhone.length!=10){
        return false
    }else{
        return true
    }
}