$().ready(
    function()
    {
        $('.blank').attr('target', '_blank');
        $('.selectorBtn').mouseover(
            function()
            {
                $(this).css('background','red').css('fontWeight', 'bold').css('color', 'white');
            }
        );
        $('.selectorBtn').mouseout(
            function()
            {
                $(this).css('background','transparent').css('fontWeight', 'normal').css('color', 'black');
            }
        );
    }
);

function countChildren(el)
{
    var ret = 0;
    var ch = el.firstChild;
    while(ch)
    {
        if(ch.innerHTML.length > 4)
        {
            ch.style.display = '';
            ret++;
        }
        else
            ch.style.display = 'none';
        ch=ch.nextSibling;
    }
    return ret;
}

function SuburbListShowing(sender, e)
{
    var n = countChildren(sender._completionListElement);
}

function SuburbListShown(sender, e)
{
    var ul = sender._completionListElement;
    var n = countChildren(ul);
    if(n == 0)
    {
        ul.style.visibility = 'hidden';
    }
    else
    {
        ul.style.visibility = '';
        var ch = ul.firstChild.scrollHeight;
        if (n > 6) 
        {
            ul.style.height = (ch * 6 + 22) + 'px';
        }
        else
        {
            ul.style.height = ((ch + 1) * n + 2) + 'px';
        }
    }
 
}

function SuburbListPopulating(sender, e)
{
}

function SuburbListPopulated(sender, e)
{
}

function showTandc()
{
    $('#tandc_container').show();
    document.body.style.overflow = 'hidden';
    return false;
}
function hideTandc()
{
    $('#tandc_container').hide();
    document.body.style.overflow = '';
    return false;
}

function showMainDescription()
{
    $('#main_description_container').show();
    document.body.style.overflow = 'hidden';
    return false;
}
function hideMainDescription()
{
    $('#main_description_container').hide();
    document.body.style.overflow = '';
    return false;
}
function getAspElementCrossbrowser(id) {
    var el = document.getElementById(id);
    if(el == null) {
        var idx = id.indexOf('_');
        if(idx > -1) {
            el = document.getElementById(id.substr(idx+1));
        }
    }
    return el;
}
function changeAdType() {
    var el = getAspElementCrossbrowser(adTypeID);
    var tgt = document.getElementById("PaidSection");
    if (el != null && tgt != null) {
        var disp = (el.selectedIndex != 0);
        var inlineStyle = disp ? "block" : "none";
        tgt.style.display = inlineStyle;
    }
}
function setAspDdCb(aspid, fn) {
    var tgt = getAspElementCrossbrowser(aspid);
    if(tgt)
    {
        if (typeof (fn) == "function") {
            if (tgt.addEventListener) {
                tgt.addEventListener("change", fn, false);
            }
            else if (tgt.attachEvent) {
                tgt.attachEvent("onchange", fn);
            }
        }
        else {
            tgt.onChange = fn;
        }
    }
    
}
