﻿var CB_CallBackId;
var CB_CallBackArgs;

function CB_ValidateStep1(prefix)
{
  __FormErrorCount=0;
  if (__ValidateNotEmpty(prefix + "EmailAddressTextBox")) {
      __ValidateEmailAddress(prefix + "EmailAddressTextBox");
  }
  document.getElementById("ErrorLevel1").style.display=(__FormErrorCount==0?"none":"block");
  return(__FormErrorCount==0);
}

function CB_ValidateStep1A(prefix) {
    __FormErrorCount = 0;
    if (__ValidateNotEmpty(prefix + "EmailAddressTextBox2")) {
        if (!__ValidateEmailAddress(prefix + "EmailAddressTextBox2")) {
            __SetLabel(document.getElementById(prefix + "EmailAddressTextBox2"), true, "");
        }
    }
    document.getElementById("GraphicError").style.visibility = (__FormErrorCount == 0 ? "hidden" : "visible");
    return (__FormErrorCount == 0);
}

function CB_ValidateStep2(prefix) {
  __FormErrorCount=0;
  if (__ValidateNotEmpty(prefix + "FirstNameTextBox")) {
    var isError=__GetValue(prefix+"FirstNameTextBox")=="(First Name)";
    __FormErrorCount=__FormErrorCount+(isError?1:0);
    var ctl=document.getElementById(prefix+"FirstNameTextBox");
    __SetLabel(ctl,isError);
  }
  if(__ValidateNotEmpty(prefix+"LastNameTextBox"))
  {
    var isError=__GetValue(prefix+"LastNameTextBox")=="(Last Name)";
    __FormErrorCount=__FormErrorCount+(isError?1:0);
    var ctl=document.getElementById(prefix+"LastNameTextBox");
    __SetLabel(ctl,isError);
  }
  __ValidateNotEmpty(prefix+"TelephoneTextBox");
  __ValidateNotEmpty(prefix+"PostCodeTextBox");
  var aoiSelected=false;
  var checks=document.getElementById("AreasOfInterest").getElementsByTagName("input");
  if(checks)
  {
    for(var i=0;i<checks.length;i++)
    {
      if(checks[i].checked)
      {
        aoiSelected=true;
        i=checks.length;
      }
    }
  }
  __FormErrorCount=__FormErrorCount+(aoiSelected==false?1:0);
  document.getElementById(prefix+"AreasOfInterestLabel").className=(aoiSelected==true?"":"NormalRed");
  document.getElementById("ErrorLevel2").style.display=(__FormErrorCount==0?"none":"block");  
  return(__FormErrorCount==0);
} 

function CB_ConfirmAllocation(id,name,args)
{
  CB_CallBackId=id;
  CB_CallBackArgs=args;
  __ShowMessage("Request Call Back","Please confirm that you want "+name+" to contact you about your enquiry.",1,null,"Continue","Cancel",null,CB_PerformAllocation,null,__RequestPath+"/DesktopModules/Leads/XSLT/Customer/ContactAdvisorMessageDialog.xsl"); 
}
function CB_PerformAllocation()
{
  document.getElementById(CB_ID+"Step3").style.display="none";
  document.getElementById("PleaseWait").style.display="block";
  __doPostBack(CB_CallBackId,CB_CallBackArgs);
}

function CB_NameFocus(obj)
{
  if(obj.value=="(First Name)"||obj.value=="(Last Name)")
  {
    obj.value="";
  }
}
