//Add an on click even for displaying the additional info under the what's this link
window.addEvent('domready', function(){
    $('what_is_this').style.display = "none";
    $('what_is_this_link').addEvent('click', function(event){
        if($('what_is_this').style.display == "none"){
            $('what_is_this').style.display = "block";
        }else{
            $('what_is_this').style.display = "none";
        }
        var ev = new Event(event);
        ev.stop();
    });
});

function check_options(event){
    $('id_ventilation_type_1').disabled = false;
    $('id_ventilation_type_1').getParent().setStyle('color', '#0594DA');
    $('id_plan_type_0').disabled = false;
    $('id_plan_type_0').getParent().setStyle('color', '#0594DA');
    switch($('id_building_type').value){
        case 'flat':
            $('id_ventilation_type_1').getParent().setStyle('color', '#bcbcbc');
            $('id_ventilation_type_1').disabled = true;
            $('id_ventilation_type_1').checked = false;
            break;
        case 'warehouse':
            $('id_ventilation_type_1').disabled = true;
            $('id_ventilation_type_1').checked = false;
            $('id_ventilation_type_1').getParent().setStyle('color', '#bcbcbc');
            $('id_plan_type_0').disabled = true;
            $('id_plan_type_0').checked = false;
            $('id_plan_type_0').getParent().setStyle('color', '#bcbcbc');
            break;
    }
}

//Certain combinations of options aren't allowed.  Warehouses can't be air condioned or narrow plan.
//Flats can't be airconed
//Disable inputs to enforce this a bit
window.addEvent('domready', function(){
    $('id_building_type').addEvent('change', function(event){check_options(event);});
});
