﻿/// <reference path="../../../js/jquery-1.2.6-vsdoc.js"/>
$(function() {
    SetStylesForDisplayLocation();
    SetEditFunction1();
    Sys.WebForms.PageRequestManager.getInstance().add_endRequest(endRequestHandler);
});

function SetStylesForDisplayLocation() {
    var fontColor = $('.LocationFontColor').val();
    $('.Locationheader').css('color', $('.LocationFontColor').val());
    $('.Locationheader').css('font-size', $('.LocationMedFontSize').val());
    $('.Locationheader').css('font-weight', 'bold');
    $('.locationsTable').css('border-bottom', 'solid 1px ' + fontColor);
}
function endRequestHandler(sender, args) {
    SetStylesForDisplayLocation();
    SetEditFunction();
}
function SetEditFunction1() {
    if ($('.LocationIsLive').val() == 'False') {
        var locations = $('.locationDiv');
        locations.unbind('mouseover').unbind('mouseout');
        locations.unbind('mouseenter').unbind('mouseleave');
        $('.locationDiv').children('.LocatorLocation-delete').remove();
        $('.locationDiv').children('.LocatorLocation-edit').remove();
        $('.locationDiv').children('.LocatorLocation-view').remove();

        var ischeckedout = $('#imgCheckmark').is(':visible');
        if (ischeckedout == true) {
            locations.prepend('<div class="LocatorLocation-edit" title="Update this location"></div><div class="LocatorLocation-delete" title="Delete this location."></div>');
        }
        else {
            locations.prepend('<div class="LocatorLocation-view" title="View this location"></div>');
        }

        $('.locationDiv').children('.LocatorLocation-edit').bind('click', function () {
            openAddLocationWindow(currentLocationId);
            return false;
        });
        $('.locationDiv').children('.LocatorLocation-view').bind('click', function () {
            openAddLocationWindow(currentLocationId);
            return false;
        });
        $('.locationDiv').children('.LocatorLocation-delete').bind('click', function () {
            jQuery.facebox({ div: '#divDeleteLocationConfirm' });
        });


        locations.hover(function () {
            if (ischeckedout == true) {
                $(this).children('.LocatorLocation-edit').show();
                $(this).children('.LocatorLocation-delete').show();
                currentLocationId = $(this).children('.locationsTable').attr('locguid');
            } else {
                $(this).children('.LocatorLocation-view').show();
                currentLocationId = $(this).children('.locationsTable').attr('locguid');
            }
        }, function () {
            if (ischeckedout == true) {
                $(this).children('.LocatorLocation-edit').hide();
                $(this).children('.LocatorLocation-delete').hide();
            } else {
                $(this).children('.LocatorLocation-view').hide();
            }
        });
    }
}
