/*
// ---------------------------------------------------------------------------------------------
// This module is part of ongoing modifications to the Spicerhaart source code.
//
// Author: Context Software Limited.
//
// Copyright (c) 2007. All Rights reserved by Context Software Limited. The license does not
// allow for the creation, amendment or distribution of copies of  this source code,
// without the express written permission of Context Software Limited.
// ---------------------------------------------------------------------------------------------
*/

﻿//-----------------------------------------------------------------------------

function CheckAddressDetails(oForm, Suffix, Prefix)
{
    if (eval("oForm.hdn" + Suffix + "QuickAddr.value") == 'Y')
    {
        if (isBlank(eval("oForm." + Prefix + "txtPostcode.value")))
        {
            alert("Please enter a postcode.");
            eval("oForm." + Prefix + "txtPostcode.focus();");
            return false;
        }

        if (eval("oForm."+ Prefix + "lstAddr.options[oForm."+ Prefix + "lstAddr.selectedIndex].value") == '')
        {
            alert("Please select an address.");
            eval("oForm." + Prefix + "lstAddr.focus();");
            return false;
        }
    }
    else
    {
        if (isBlank(eval("oForm.txt" + Suffix + "HouseNo.value")))
        {
            alert("Please enter a house number or name");
            eval("oForm.txt" + Suffix + "HouseNo.focus();");
            return false;
        }

        if (isBlank(eval("oForm."+ Prefix + "txtStreet.value")))
        {
            alert("Please enter a street.");
            eval("oForm."+ Prefix + "txtStreet.focus();");
            return false;
        }

        if (isBlank(eval("oForm."+ Prefix + "txtTown.value")))
        {
            alert("Please enter a town.");
            eval("oForm."+ Prefix + "txtTown.focus();");
            return false;
        }
    }
}

function SwitchAddress()
{
    var hdnAddress = document.getElementById('hdnValQuickAddr');
    var spanText = document.getElementById('idDont');
    if (hdnAddress.value == 'Y')
    {
        hdnAddress.value = 'N';
        spanText.style.display= 'none';
        
        var postcode = document.getElementById('postcode');
	    postcode.style.display = 'none';
	    var address = document.getElementById('address');
	    address.style.display = 'none';
	    var manualAddress = document.getElementById('manualAddress');
	    manualAddress.style.display = 'block';
    }
    else
    {
        hdnAddress.value = 'Y';
        spanText.style.display= 'inline';

        var postcode = document.getElementById('postcode');
	    postcode.style.display = 'block';
	    var address = document.getElementById('address');
	    address.style.display = 'block';
	    var manualAddress = document.getElementById('manualAddress');
	    manualAddress.style.display = 'none';
    }
}

function SetAddressFocus(oForm, Prefix, NextCtrl)
{
    if (eval("oForm.lst" + Prefix + "Addr.options.length") > 1)
        eval("oForm.lst" + Prefix + "Addr.focus();");
    else
    {
       if (eval("oForm.lst" + Prefix + "Addr.options[oForm.lst" + Prefix + "Addr.selectedIndex].value") == '')
            eval("oForm.txt" + Prefix + "Postcode.focus();");
       else
       {
          if (NextCtrl != null)
              NextCtrl.focus();
       }       
    }
}


