﻿// JScript File
function showpresent(gpb)
  {
     if (gpb.value == "Brochure from GP")   
         document.getElementById("mypresent").style.display = "block";
     else
         {
         document.getElementById("mypresent").style.display = "none";
         //document.getElementById("em_wfs_formfield_1557090").value = "";
         //document.getElementById("em_wfs_formfield_1557093").value = "";
         //document.getElementById("em_wfs_formfield_1557096").value = "";
         //document.getElementById("em_wfs_formfield_1557097").value = "";
         //document.getElementById("em_wfs_formfield_1557142").value = "";
         //document.getElementById("em_wfs_formfield_1557143").value = "";
         //document.getElementById("em_wfs_formfield_1557144").value = "";
         }
  }
function validate_myform(frm)
{
    errormsg = "";
    myfocus = 0;
    if (document.getElementById("em_wfs_formfield_1547142").value == "")
       { 
          errormsg = "* Please select Age\n";
          myfocus = 1;
       } 
    if (document.getElementById("em_wfs_formfield_1557187").value == "")
       { 
          errormsg = errormsg + "* Please select Are you a carer?\n";
          if (myfocus == 0)
              myfocus = 2;
       } 
    if (document.getElementById("em_wfs_formfield_1547159").value == "")
       { 
          errormsg = errormsg + "* Please select How did you hear about this website?\n";
          if (myfocus == 0)
              myfocus = 3;
       } 
    if (document.getElementById("em_wfs_formfield_1547159").value == "Brochure from GP")
       { 
          if (document.getElementById("em_wfs_formfield_1557090").value == "")
          {
             errormsg = errormsg + "* Please enter Name\n";
             if (myfocus == 0)
                 myfocus = 4;
          }
          // Validate Email Address   
          if (document.getElementById("em_wfs_formfield_1557093").value != "")        
          {
             if (checkvalidemail(document.getElementById("em_wfs_formfield_1557093").value) == false)
             {
                errormsg = errormsg + "* Invalid Email address\n";
                if (myfocus == 0)
                    myfocus = 5;
             }
          }
          if (document.getElementById("em_wfs_formfield_1557096").value == "")
          {
             errormsg = errormsg + "* Please enter Address\n";
             if (myfocus == 0)
                 myfocus = 6;
          }       
          if (document.getElementById("em_wfs_formfield_1557142").value == "")
          {
             errormsg = errormsg + "* Please enter City/Suburb\n";
             if (myfocus == 0)
                 myfocus = 7;
          }       
          if (document.getElementById("em_wfs_formfield_1557143").value == "")
          {
             errormsg = errormsg + "* Please select State\n";
             if (myfocus == 0)
                 myfocus = 8;
          }       
          if (document.getElementById("em_wfs_formfield_1557144").value == "")
          {
             errormsg = errormsg + "* Please enter Postcode\n";
             if (myfocus == 0)
                 myfocus = 9;
          }       
       } 
    if (errormsg == "")
       return true;
    else
       {
          alert(errormsg); 
          switch (myfocus) 
             {
             case 1: document.getElementById("em_wfs_formfield_1547142").focus();break;
             case 2: document.getElementById("em_wfs_formfield_1557187").focus();break;
             case 3: document.getElementById("em_wfs_formfield_1547159").focus();break;
             case 4: document.getElementById("em_wfs_formfield_1557090").focus();break;
             case 5: document.getElementById("em_wfs_formfield_1557093").focus();break;
             case 6: document.getElementById("em_wfs_formfield_1557096").focus();break;
             case 7: document.getElementById("em_wfs_formfield_1557142").focus();break;
             case 8: document.getElementById("em_wfs_formfield_1557143").focus();break;
             case 9: document.getElementById("em_wfs_formfield_1557144").focus();break;
             }
          return false;
       }
}
function validate_myform2(frm)
{
    errormsg = "";
    myfocus = 0;
    if (document.getElementById("em_wfs_formfield_1547127").value == "")
       { 
          errormsg = "Please enter Your email address";
       } 
    else
       { 
        if (checkvalidemail(document.getElementById("em_wfs_formfield_1547127").value) == false)
           {
                 errormsg = "Invalid Email address";
           }
       }
    if (errormsg == "")
       return true;
    else
       {
          alert(errormsg); 
          document.getElementById("em_wfs_formfield_1547127").focus();
          return false;
       }
}
function checkvalidemail(pemail) 
{
var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
if (!filter.test(pemail))
   return false;
else
   return true;   
}
function validate_questionare(frm)
{
    errormsg = "";
    myfocus = 0;
    if (document.getElementById("ctl00_ContentPlaceHolder1_DDLAgeGroup").value == "")
       { 
          errormsg = "- Please select Age\n";
          myfocus = 1;
       } 
    if (document.getElementById("ctl00_ContentPlaceHolder1_DDLAreYouCarer").value == "")
       { 
          errormsg = errormsg + "- Please select Are you a carer?\n";
          if (myfocus == 0)
              myfocus = 2;
       } 
    if (document.getElementById("ctl00_ContentPlaceHolder1_DDLYouHear").value == "")
       { 
          errormsg = errormsg + "- Please select How did you hear about this website?\n";
          if (myfocus == 0)
              myfocus = 3;
       } 
    if (document.getElementById("ctl00_ContentPlaceHolder1_DDLYouHear").value == "Brochure from GP")
       { 
          if (document.getElementById("ctl00_ContentPlaceHolder1_TBName").value == "")
          {
             errormsg = errormsg + "- Please enter Name\n";
             if (myfocus == 0)
                 myfocus = 4;
          }
          // Validate Email Address   
          if (document.getElementById("ctl00_ContentPlaceHolder1_TBEmailAddress").value != "")        
          {
             if (checkvalidemail(document.getElementById("ctl00_ContentPlaceHolder1_TBEmailAddress").value) == false)
             {
                errormsg = errormsg + "- Invalid Email address\n";
                if (myfocus == 0)
                    myfocus = 5;
             }
          }
          if (document.getElementById("ctl00_ContentPlaceHolder1_TBAddress1").value == "")
          {
             errormsg = errormsg + "- Please enter Address\n";
             if (myfocus == 0)
                 myfocus = 6;
          }       
          if (document.getElementById("ctl00_ContentPlaceHolder1_TBCity").value == "")
          {
             errormsg = errormsg + "- Please enter City/Suburb\n";
             if (myfocus == 0)
                 myfocus = 7;
          }       
          if (document.getElementById("ctl00_ContentPlaceHolder1_DDLState").value == "")
          {
             errormsg = errormsg + "- Please select State\n";
             if (myfocus == 0)
                 myfocus = 8;
          }       
          if (document.getElementById("ctl00_ContentPlaceHolder1_TBPostCode").value == "")
          {
             errormsg = errormsg + "- Please enter Postcode\n";
             if (myfocus == 0)
                 myfocus = 9;
          }       
       } 
    if (errormsg == "")
       return true;
    else
       {
          alert(errormsg); 
          switch (myfocus) 
             {
             case 1: document.getElementById("ctl00_ContentPlaceHolder1_DDLAgeGroup").focus();break;
             case 2: document.getElementById("ctl00_ContentPlaceHolder1_DDLAreYouCarer").focus();break;
             case 3: document.getElementById("ctl00_ContentPlaceHolder1_DDLYouHear").focus();break;
             case 4: document.getElementById("ctl00_ContentPlaceHolder1_TBName").focus();break;
             }
          return false;
       }
}

function validate_enquiry(frm)
{
    errormsg = "";
    myfocus = 0;
    if (document.getElementById("ctl00_ContentPlaceHolder1_TBName").value == "")
       { 
          errormsg = "- Please enter First Name\n";
          myfocus = 1;
       } 
    if (document.getElementById("ctl00_ContentPlaceHolder1_TBEmail").value == "")
       { 
          errormsg += "- Please enter Email\n";
          if (myfocus == 0)
          myfocus = 2;
       } 
    if (document.getElementById("ctl00_ContentPlaceHolder1_TBEmail").value != "")        
       {
          if (checkvalidemail(document.getElementById("ctl00_ContentPlaceHolder1_TBEmail").value) == false)
          {
                errormsg = errormsg + "- Invalid Email address\n";
                if (myfocus == 0)
                    myfocus = 2;
          }
      }
      if (document.getElementById("ctl00_ContentPlaceHolder1_TBPhone").value == "") {
          errormsg += "- Please enter phone\n";
          if (myfocus == 0)
              myfocus = 4;
      } 
    if (document.getElementById("ctl00_ContentPlaceHolder1_TBQuestion").value == "")
       { 
          errormsg += "- Please enter your enquiry\n";
          if (myfocus == 0)
          myfocus = 3;
       } 
    if (errormsg == "")
       return true;
    else
       {
          alert(errormsg); 
          switch (myfocus) 
             {
             case 1: document.getElementById("ctl00_ContentPlaceHolder1_TBName").focus();break;
             case 2: document.getElementById("ctl00_ContentPlaceHolder1_TBEmail").focus();break;
             case 3: document.getElementById("ctl00_ContentPlaceHolder1_TBQuestion").focus(); break;
             case 4: document.getElementById("ctl00_ContentPlaceHolder1_TBPhone").focus(); break;
             }
          return false;
       }
}
