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 ds = document.HomeSubmit, bValid = true, sFirstName = ds.CRM_Leads_Name.value, sLastName = ds.CRM_Leads_Surname.value, sEmail = ds.CRM_Leads_EMail.value;
    var sPhone = ds.CRM_Leads_Phone.value, sAgency = ds.CRM_Leads_CompanyName.value,  sJPos = ds.CRM_Leads_BusinessRole.value, sState = ds.CRM_Leads_Province.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;
    }
    if(sJPos==""||sJPos=='Job Title'){
        document.getElementById("CRM_Leads_BusinessRole").style.color="red";
        bValid=false;
    }
    if(sState==""||sState=='State'){
        document.getElementById("CRM_Leads_Province").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
    }
}
