﻿//*** MGM 02122009 Begin: Add this script to validate result page 
function ValidateBusinessSearch2(source, args)
{
  var valid = true;
  try
  {
    //Gets the containing control id.
    var id = source.id.split("_")[0];
    if ((document.getElementById(id+"_txtBusinessName2").value=="") &&
    (document.getElementById(id+"_txtBusinessCategory2").value==""))
    {
        valid = false;
    }
  } 
  catch(e) 
  {
    valid = false;
  }
  args.IsValid = valid;
}

function BusinessReturn2(event, button)
{
    var key = event.keyCode;
    //Gets the containing control id.
    var id = button.split("_")[0];
    if(key == 13) 
    {
        if (((document.getElementById(id+"_txtBusinessName2").value!="") ||
        (document.getElementById(id+"_txtBusinessCategory2").value!="")) &&
        (document.getElementById(id+"_txtBusinessLocation2").value!=""))
        {
            var butSearch = document.getElementById(button);
            butSearch.focus();
        }
        
        
    }
    return false;
}

function ResidentialReturn2(event, button)
{
    var key = event.keyCode;
    //Gets the containing control id.
    var id = button.split("_")[0];
    if(key == 13) 
    {
        if ((document.getElementById(id+"_txtResidentialName2").value!="") &&
        (document.getElementById(id+"_txtResidentialLocation2").value!=""))
        {
            var butSearch = document.getElementById(button);
            butSearch.focus();
        }
        
        
    }
    return false;
}

//*** MGM 02122009 End


function ValidateBusinessSearch(source, args)
{
  var valid = true;
  try
  {
    //Gets the containing control id.
    var id = source.id.split("_")[0];
    if ((document.getElementById(id+"_txtBusinessName").value=="") &&
    (document.getElementById(id+"_txtBusinessCategory").value==""))
    {
        valid = false;
    }
  } 
  catch(e) 
  {
    valid = false;
  }
  args.IsValid = valid;
}


function ValidateAdvancedSearch(source, args)
{
  var valid = true;
  try
  {
    //Gets the containing control id.
    var id = source.id.split("_")[0];
    if (((document.getElementById(id+"_txtAdvancedBusinessName1").value=="") &&
        (document.getElementById(id+"_txtAdvancedBusinessName2").value=="")) &&
        (document.getElementById(id+"_txtAdvancedBusinessCategory").value==""))
    {
        valid = false;
    }
  } 
  catch(e) 
  {
    valid = false;
  }
  args.IsValid = valid;
}

function ValidateAdvancedResSearch(source, args)
{
  var valid = true;
  try
  {
    //Gets the containing control id.
    var id = source.id.split("_")[0];
    if (((document.getElementById(id+"_txtAdvResLocation").value=="") &&
        (document.getElementById(id+"_txtAdvResSurname").value=="")) )
    {
        valid = false;
    }
  } 
  catch(e) 
  {
    valid = false;
  }
  args.IsValid = valid;
}

function BusinessReturn(event, button)
{
    var key = event.keyCode;
    //Gets the containing control id.
    var id = button.split("_")[0];
    if(key == 13) 
    {
        if (((document.getElementById(id+"_txtBusinessName").value!="") ||
        (document.getElementById(id+"_txtBusinessCategory").value!="")) &&
        (document.getElementById(id+"_txtBusinessLocation").value!=""))
        {
            var butSearch = document.getElementById(button);
            butSearch.focus();
        }
        
        
    }
    return false;
}


function BusinessPopulated(source, eventArgs)
{
     //Gets the containing control id.
    var id = source.get_element().id.split("_")[0];
    if (((document.getElementById(id+"_txtBusinessName").value!="") ||
        (document.getElementById(id+"_txtBusinessCategory").value!="")) &&
        (document.getElementById(id+"_txtBusinessLocation").value!=""))
    {
        var butSearch = document.getElementById(id+"_butBusiness");
        butSearch.focus();
    }
}


function ResidentialReturn(event, button)
{
    var key = event.keyCode;
    //Gets the containing control id.
    var id = button.split("_")[0];
    if(key == 13) 
    {
        if ((document.getElementById(id+"_txtResidentialName").value!="") &&
        (document.getElementById(id+"_txtResidentialLocation").value!=""))
        {
            var butSearch = document.getElementById(button);
            butSearch.focus();
        }
        
        
    }
    return false;
}



function ResidentialPopulated(source, eventArgs)
{
     //Gets the containing control id.
    var id = source.get_element().id.split("_")[0];
    if ((document.getElementById(id+"_txtResidentialName").value!="") &&
        (document.getElementById(id+"_txtResidentialLocation").value!=""))
    {
        var butSearch = document.getElementById(id+"_butResidential");
        butSearch.focus();
    }
}



function AdvancedReturn(event, button)
{
    var key = event.keyCode;
    //Gets the containing control id.
    var id = button.split("_")[0];
    if(key == 13) 
    {
        if ((document.getElementById(id+"_txtAdvancedBusinessName1").value!="") || 
        (document.getElementById(id+"_txtAdvancedBusinessName2").value!="") ||
        (document.getElementById(id+"_txtAdvancedBusinessLocation").value!="") ||
        (document.getElementById(id+"_txtAdvancedBusinessStreet").value!="") ||
        (document.getElementById(id+"_txtAdvancedBusinessCategory").value!=""))
        {
            var butSearch = document.getElementById(button);
            butSearch.focus();
        }
        
        
    }
    return false;
}

function AdvancedResReturn(event, button)
{
    var key = event.keyCode;
    //Gets the containing control id.
    var id = button.split("_")[0];
    if(key == 13) 
    {
        if ((document.getElementById(id+"_txtAdvResFirstName").value!="") || 
        (document.getElementById(id+"_txtAdvResSurname").value!="") ||
        (document.getElementById(id+"_txtAdvResLocation").value!="") ||
        (document.getElementById(id+"_txtAdvResStreet").value!=""))
        {
            var butSearch = document.getElementById(button);
            butSearch.focus();
        }
        
        
    }
    return false;
}
















