$(document).ready(function() 
{
    /*
    $('#a_help').each(function() 
    {
        $(this).click(function() 
        {
            $(this).next('span').show();
        });
    });
    $('.tips_block').each(function() 
    {
        $(this).click(function() 
        {
            $(this).hide();
        });
    });
    */
    
    
    $(".select_type").change(function() 
    {
         var type = $(this).val();
         if (type == 'select')
            $(".hidden").animate( { opacity: "show" }, 500);
         else    
            $(".hidden").animate( { opacity: "hide" }, 500);
    });
    
    $(".datepicker").each(function() 
    {
        $(this).datepick();
    });
    
    $(".datetimepicker").each(function() 
    {
        $(this).dynDateTime(
        {
            showsTime: true,
            ifFormat: "%Y/%m/%d-%H:%M",
            daFormat: "%l;%M %p, %e %m,  %Y",
            align: "TL",
            electric: false,
            singleClick: false,
            displayArea: ".siblings('.dtcDisplayArea')",
            button: ".next()" //next sibling
        });
    });

    $(".datetimepicker").each(function() 
    {
        $(this).dynDateTime();
    });
    
});

function in_array(what, where) 
{
    for(var i=0; i<where.length; i++)
        if(what == where[i]) 
            return true;
    
    return false;
}


function ShowHideAttr(checked, id) 
{
    if (checked == true) 
    {
        $("tbody #" + id).each(function() 
        {
            $(this).animate( { opacity: "show" }, 500); 
        });
    }
    else 
    {
        $("tbody #" + id).each(function() 
        {
            $(this).animate( { opacity: "hide" }, 500);;
        }); 
    }
}


function select_tab(tab_id)
{
    $('.multi_attributes').each(function() 
    {
        $(this).hide();
        if ($(this).attr('alt') == tab_id) 
            $(this).show();
    });
    
    $('#tabnav li').each(function() 
    {
        $(this).removeClass('tab_selected');
    });
    $('#tab_' + tab_id).addClass('tab_selected');
}


function checkbox_all(main_class, sub_class)
{
    var val = $('.' + main_class).attr('checked');
    $('.' + sub_class).each(function()
    {
        $(this).attr('checked', val);
    });
}

function checkbox_sum(main_class, classname) 
{
    var val = $('.' + main_class).attr('checked');
    if (val) {
        var sum = 0;
        $('.' + classname).each(function() {
            sum += parseFloat($(this).val());
        });
        return sum.toFixed(2);
    }
    return false;
}

function showCheckboxSum(html) 
{
    $('body').append('<div id="checkbox_sum" style="background-color: #FFF8DA;border-color: #F1E3A8;border-style: solid;border-width: 1px;bottom: 10px;display: block;font-size: 10px;left: 15px;padding: 2px 3px;position: fixed;z-index: 1000;">' + html + ' ₪</div>');
}
function hideCheckboxSum() 
{
    $('#checkbox_sum').remove();
}

