﻿function clientValidateCountry(source, arguments)
{
    var pnlTxtCountryRef = document.getElementById(prefixTagNameMain + 'pnlTxtCountry');
    var txtCountryRef = document.getElementById(prefixTagNameMain + 'txtCountry');
    var drpCountriesRef = document.getElementById(prefixTagNameMain + 'drpCountries');

    try
    {
        if (pnlTxtCountryRef)
        {
            if (trim(txtCountryRef.value).length == 0)
                arguments.IsValid = false;
            else
                arguments.IsValid = true;
        }
        else if (drpCountriesRef.selectedIndex == 0)
            arguments.IsValid = false;
        else
            arguments.IsValid = true;
    }
    catch (err)
    {
        arguments.IsValid = false;
    }
}

function clientValidateCity(source, arguments)
{
    var pnlTxtCityRef = document.getElementById(prefixTagNameMain + 'pnlTxtCity');
    var txtCityRef = document.getElementById(prefixTagNameMain + 'txtCity');
    var drpCitiesRef = document.getElementById(prefixTagNameMain + 'drpCities');

    try
    {
        if (pnlTxtCityRef)
        {
            if (trim(txtCityRef.value).length == 0)
                arguments.IsValid = false;
            else
                arguments.IsValid = true;
        }
        else if (drpCitiesRef.selectedIndex == 0)
            arguments.IsValid = false;
        else
            arguments.IsValid = true;
    }
    catch (err)
    {
        arguments.IsValid = false;
    }
}

function clientValidateDistrict(source, arguments)
{
    var pnlTxtDistrictRef = document.getElementById(prefixTagNameMain + 'pnlTxtDistrict');
    var txtDistrictRef = document.getElementById(prefixTagNameMain + 'txtDistrict');
    var drpDistrictsRef = document.getElementById(prefixTagNameMain + 'drpDistricts');

    try
    {
        if (pnlTxtDistrictRef)
        {
            if (trim(txtDistrictRef.value).length == 0)
                arguments.IsValid = false;
            else
                arguments.IsValid = true;
        }
        else if (drpDistrictsRef.selectedIndex == 0)
            arguments.IsValid = false;
        else
            arguments.IsValid = true;
    }
    catch (err)
    {
        arguments.IsValid = false;
    }
}

function setDivCA(isInput)
{
    var divCAListRef = $('divCAList');
    var divCAInputRef = $('divCAInput');
    if (isInput)
    {
        divCAListRef.style.display = 'none';
        divCAInputRef.style.display = 'block';
    }
    else
    {
        divCAListRef.style.display = 'block';
        divCAInputRef.style.display = 'none';
    }
}

function setDivCAByEffect(isInput)
{
    if (isInput)
    {
        new Effect.Fade('divCAList', { duration: 0.5, afterFinish: function() { new Effect.Appear('divCAInput'); } });
    }
    else
    {
        new Effect.Fade('divCAInput', { duration: 0.5, afterFinish: function() { new Effect.Appear('divCAList'); } });
    }
}

function setDivBtnBackCA(isVisible)
{
    var divBtnBackCARef = $('divBtnBackCA');
    if (isVisible)
        divBtnBackCARef.style.display = 'block';
    else
        divBtnBackCARef.style.display = 'none';
}

function deleteRecordCASuccessful(divID)
{
    new Effect.DropOut($(divID), { afterFinish: function() { runJSOfHref($(prefixTagNameMain + 'lbtnRptCAFill')); } });
}