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

// 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();
    
    // 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() });
});
