﻿function handleLayerDropdown() {
    $jq("#toc-head a").click(function() {
       // fixLayer();
        showHideLayers();
    });
    $jq("#property-toc-top a").click(function() {
        //fixLayer();
        showHideLayers();
    });
}
function showHideLayers() {
    if ($jq("#property-toc-holder:hidden").length != 0) {
        $jq("#property-toc-holder").show('slide', { direction: 'right' }, 'slow');
        $jq("#toc-head").hide();
    } else {
        $jq("#toc-head").show(); // weird IE6 bug if shown after slide
        $jq("#property-toc-holder").hide('slide', { direction: 'right' }, 'slow');
    }
}

function doPrint() {
    var loc = location.search;
    if (loc.indexOf("print=1") != -1) {
        //window.print();
        $jq("#print-warning").show();
    } else {
        $jq("#print-warning").hide();
    }
}
function fixWidths() {
    // fix icon widths - ridiculous that it comes to this
    var icons = $jq(".toolbar-controls td");
    icons.eq(0).width(39);
    icons.eq(1).width(41);
    icons.eq(2).width(32);
    icons.eq(3).width(51);
    icons.eq(4).width(60);
    icons.eq(5).width(39);
    icons.eq(6).width(55);
    icons.eq(7).width(51);
    icons.eq(8).width(43);
    icons.eq(9).width(62);

}

function fixLayer() {
    $jq("div#property-toc-inner").ifixpng();
}

function toggleExportProcessing(complete) {
    if (complete) {
        $jq(".pdf-export").show();
        $jq("#export-loading").hide();
    } else {
        $jq(".pdf-export").hide();
        $jq("#export-loading").show();
    }
}

function showDestination() {
    $jq('#dialog').jqmHide();
}

function acceptDisclaimer() {
    $.cookie('TermsOfUse', true, { expires: 1 }); // set cookie
    showDestination();
}

function changeScale(scale) {
    $jq("#ddlZoomLevel").val(scale);
}

function clearJSONGrid() {
    $jq("#divJSONGrid").html('');
    $jq("#property-results-grid").html('');
}

function toggleBufferProcessing(complete) {
    $jq("#btnBuffer").toggle();
    $jq("#buffer-loading").toggle();
    if (complete)
        $jq("#buffer-complete").show();
}
function showBusinesses(businessType) {
    $jq("#" + businessType).toggle();
}

$jq(document).ready(handleLayerDropdown);
$jq(document).ready(fixLayer);
$jq(document).ready(fixWidths);
$jq(document).ready(function() {
    $jq(".toolbar-controls td").mousedown(fixWidths);
});
$jq(document).ready(doPrint);
//$jq(document).ready(function() { $jq("#toc-head").hide();  });