﻿
function defPanel_valign(id, row) {

    var max = 0;
    $('#' + id).parent().find('div[defPanel_row=' + row + ']>table').each(function() {
        if ($(this).height() > max) { max = $(this).height() }; 
    });

    $('#' + id + ">table").height(max);
}

function defPanel_valign2(id, row) {

    var max = 0;
    $('#' + id).parent().find('div[defPanel_row=' + row + ']').each(function () {
        if ($(this).outerHeight() > max) { max = $(this).outerHeight(); };
    });

    max = max - (
                 parseInt($('#' + id).css("margin-bottom"), 10) +
                 parseInt($('#' + id).css("padding-top"), 10) +
                 parseInt($('#' + id).css("padding-bottom"), 10) +
                 parseInt($('#' + id).css("border-top-width"), 10) + 
                 parseInt($('#' + id).css("border-bottom-width"), 10));
    
    $('#' + id).css("height", max + "px"); //.height(max);
}


function gv_Init() {
    //$('.bigButton').button();
    $('.bigButton').each(function() { bigButton(this) });
    $('.gv_row_click').bind('click', function() { gv_row_click(this); return false; });
    $('.gv_row_click').bind('mouseover', function() { gv_row_mouseover(this); });
    $('.gv_row_click').bind('mouseout', function() { gv_row_mouseout(this); });
}

function gv_row_mouseover(obj) {
    $(obj).parent().children('.gv_row_click, .gv_row_button').addClass('gv_row_select');
}

function gv_row_mouseout(obj) {
    $(obj).parent().children('.gv_row_click, .gv_row_button').removeClass('gv_row_select');
}

function gv_row_click(obj) {
    $(obj).parent().children('.gv_row_button').children('[id$=btnRowClick]').click();
}

function bigButton(obj) {
//    $(obj).css('border', '0 none');
//    
//    $(obj).after("<div class='btn_div'><table class='bigButtonTable'><tr><td class='btn-menu-l'></td><td class='btn-menu-c'></td><td class='btn-menu-r'></td><tr></table></div>");
//    $(obj).next().css('float', $(obj).css('float'));
//    $(obj).next().css('padding', $(obj).css('padding'));
//    $(obj).next().find('table').css('width', $(obj).css('width'));
//    if ($(obj).css('display') == 'none')
//        $(obj).next().find('table').css('display', 'none');
//    $(obj).next().find('td.btn-menu-c').append($(obj));

//    $(obj).removeClass('bigButton');

//    $('.btn_div table').bind('mouseover', function() { btn_table_mouseover(this); });
//    $('.btn_div table').bind('mouseout', function() { btn_table_mouseout(this); });
}


function btn_table_mouseover(obj) {
    $(obj).addClass('btn_div_select');
}

function btn_table_mouseout(obj) {
    $(obj).removeClass('btn_div_select');
}
    
function tooltip_init() {

    if ($.browser.msie || $.browser.safari) 
    {
        $(".tooltip_icon").tooltip({
            layout: '<div><table class="tooltip_ie_tb"><tbody><tr><td class="tooltip_ie_tl"></td><td class="tooltip_ie_tc"></td><td class="tooltip_ie_tr"></td></tr><tr><td class="tooltip_ie_ml"></td><td class="tooltip_ie_mc" style="padding: 3px;"><span class="tooltip-inner"></span></td><td class="tooltip_ie_mr"></td></tr><tr><td class="tooltip_ie_bl"></td><td class="tooltip_ie_bc"></td><td class="tooltip_ie_br"></td></tr></tbody></table></div>',
            tipInner: 'tooltip-inner',
            offset: [15, 117],
            opacity: 0.9,
            predelay: 200
        });
    }
    else 
    {
        $(".tooltip_icon").tooltip({
            layout: '<div><table class="tooltip_table"><tbody><tr><td width="11px" style="width: 11px; min-width:11px; max-width:11px;">&nbsp;</td><td width="39px" style="width: 39px; min-width:39px; max-width:39px;">&nbsp;</td><td>&nbsp;</td><td width="39px" style="width: 39px; min-width:39px; max-width:39px;">&nbsp;</td><td width="11px" style="width: 11px; min-width:11px; max-width:11px;">&nbsp;</td></tr><tr><td class="tooltip_tl" colspan="2"></td><td class="tooltip_tc"></td><td class="tooltip_tr" colspan="2"></td></tr><tr><td class="tooltip_ml"></td><td class="tooltip_mc" style="padding:5px;" colspan="3"><span class="tooltip-inner"></span></td><td class="tooltip_mr"></td></tr><tr><td class="tooltip_bl" colspan="2"></td><td class="tooltip_bc"></td><td class="tooltip_br" colspan="2"></td></tr></tbody></table></div>',
            tipInner: 'tooltip-inner',
            offset: [15, 117],
            opacity: 0.9,
            predelay: 200
        });
        //.dynamic({ bottom: { direction: 'down', bounce: true } });
    }

    $(".tooltip_icon").focus(function() {
        this.blur();
    });

}

function ReklamaLog(token, id, akcja, impgf) {
    
    $.ajax({
        type: "POST",
        async: false,
        url: "/Default.aspx/ReklamaLogSet",
        data: "{'token' : '" + token + "', 'id' : '" + id + "', 'akcja' : '" + akcja + "', 'impgf' : '" + impgf + "'}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function(msg) {
            //alert("OK");
        },
        error: function(xhr, status, error) {
            alert(xhr.responseText);
        }
    });
}

function confirm_delete() {
    if (confirm("Usunąć plik?") == true)
        return true;
    else
        return false;
}




