﻿function locChange(e)
{
    var el = e.target;
    var hideEl, showEl;
    var newHeight = 23;
    if (Element.hasClassName(el, "selected") == false)
    {
        if (el.id == "location_town")
        {
            postTown = true;
            Element.addClassName("location_town", "selected");
            Element.removeClassName("location_postcode", "selected");
            showEl = document.getElementById("postcodeTownDiv");
            hideEl = document.getElementById("postcodeDiv");
            newHeight = 21;
            document.getElementById("location_tabs").style.backgroundImage = "url(/images/construction/jobs/search_panel_loc_tabs_town.gif)"; 
        }
        else
        {
            postTown = false;
            Element.addClassName("location_postcode", "selected");
            Element.removeClassName("location_town", "selected");
            showEl = document.getElementById("postcodeDiv");
            hideEl = document.getElementById("postcodeTownDiv");
            newHeight = 23;
            document.getElementById("location_tabs").style.backgroundImage = "url(/images/construction/jobs/search_panel_loc_tabs_postcode.gif)";
        }
        
        showEl.style.display = "block";
        showEl.style.height = "0px";
        hideEl.style.display = "block";
        hideEl.style.height = newHeight + "px";
         
        document.getElementById('p_c').value="Postcode";
        document.getElementById('radius').selectedIndex=9;
        document.getElementById('l_c').value="City/Town";
        hideEl.style.display = "none";
       /* var t = new Tween(hideEl.style, 'height', Tween.strongEaseInOut, 0, 0, .1, 'px');
        t.addListener({
                onMotionFinished : function() {
                    hideEl.style.display = "none";
                }
        });
        t.fixTime;
        t.start();*/
        
        t = new Tween(showEl.style, 'height', Tween.strongEaseInOut, parseInt(showEl.style.height), newHeight, .4, 'px');
        t.fixTime;
        t.start();
    }
    e.preventDefault();
    //return false;
}
