// clear function
function clear() {
    this.value = "";
}

function enter_child_age(row_id)
{
    var kids=($('#kids_'+row_id).val())    
    
    if (kids>0)
    {
        $('#child_age_row_'+row_id).css('display','table-row');
        
        for (i=0;i<=19;i=i+1)
        {
            $('#child_age_'+row_id+'_'+i).css('display','none');
        }
        for (i=0;i<kids;i=i+1)
        {
            $('#child_age_'+row_id+'_'+i).css('display','block');
        }
    }

    if ((kids==0)||(kids==""))
    {
        $('#child_age_row_'+row_id).css('display','none');
    }

}

// submit check function
function submit_check(form) {
    var return_value = true;
    $(form).find(".required").each(function() {
        var value = "";
        if ($(this).get(0).tagName == 'SELECT') value = $(this).find('option:selected').val();
        else value = $(this).val();

        if (value == "") {
            return_value = false;
            $(this).parent().parent().css({'background-color' : '#ffa640'});
        }
        else {
            $(this).parent().parent().css({'background-color' : 'transparent'});
        }
    });

    if (return_value == false) alert("Nevyplnili ste všetky povinné položky!");

    return return_value;
}

function check_business_conditions(form) {
    if(form.business_conditions.checked==true) {
        return true;
    }
    else {
        alert('Musíte akceptovať obchodné podmienky!');
        return false;
    }
}

$(function() {
    
    
    // equal heights
    $('div.product_title').equalHeights();
    
    $('.calendar').datepicker( { dateFormat: "dd.mm.yy" } );     
    
    // jQuery lightbox
    $('a.gallery').lightBox();

    // idTabs
    $('#tabs').idTabs();

    // hiding form items (in registration form)
    $('input#comp').load(function() {
        if ($('input#comp:checked').val() != null) $('tr.company').show();
        else $('tr.company').hide();
    });

    $('input#add2').load(function() {
        if ($('input#add2:checked').val() != null) $('tr.add2').show();
        else $('tr.add2').hide();
    });

    $('input#comp').change(function() {
        if ($('input#comp:checked').val() != null) $('tr.company').show();
        else $('tr.company').hide();
    });

    $('input#add2').change(function() {
        if ($('input#add2:checked').val() != null) $('tr.add2').show();
        else $('tr.add2').hide();
    });

    // hiding order details (in order list)
    $('tr.order_detail').hide();
    //$('tr.order_info').hover(function() { $(this).next().show() }, function() { $(this).next().hide() });
    $('tr.order_info').css('cursor', 'pointer');
    $('tr.order_info').toggle(function() { $(this).next().show() }, function() { $(this).next().hide() });
    $('tr.order_detail').click(function() { $(this).hide() });
});
