$(function(){
    $("#calendar").datepicker({
        dayNamesShort: ['Dum', 'Lun', 'Mar', 'Mie', 'Joi', 'Vin', 'Sam'],
        monthNamesShort: ['Ian','Feb','Mar','Apr','Mai','Iun','Iul','Aug','Sep','Oct','Nov','Dec']
    });
});

function update_cart()
{
    plata = $('#plata').val();
    livrare = $('#livrare').val();
    $.ajax({
        type: "POST",
        url: "http://www.adviser.ro/mobile/update-cart",
        data: "plata="+plata+"&livrare="+livrare,
        success: function(msg){
            $('#show_opt').hide('blind');
            $('#taxes').html(msg);
            $('#next_step').show('blind');
        }
    });
}

function add_to_cart(id, qty, names, price, cid)
{
    colorz = $('#color').val();
    if (!colorz || colorz == '- alege culoare -') colorz = '';
    $.ajax({
        type: "POST",
        url: "http://www.adviser.ro/mobile/add-to-cart",
        data: "pid="+id+"&qty="+qty+"&name="+names+" "+colorz+"&price="+price+"&cid="+cid,
        success: function(msg){
            $('#scart').effect('highlight');
            $('#scart').html(msg);
        }
    });
}

function remove_from_cart(id)
{
    $.ajax({
        type: "POST",
        url: "http://www.adviser.ro/mobile/remove-from-cart",
        data: "pid="+id,
        success: function(msg){
            $('#scart').effect('highlight');
            $('#scart').html(msg);
        }
    });
}

function add_to_compare(id)
{
    $.ajax({
        type: "POST",
        url: "http://www.adviser.ro/mobile/add-to-compare",
        data: "id="+id,
        success: function(msg){
            document.location.href = 'http://www.adviser.ro/mobile/compara';
        }
    });
}

function build_prod()
{
    id = $('#aj_cats').val();
    $.ajax({
        type: "POST",
        url: "http://www.adviser.ro/mobile/aj_get_prod",
        data: "cid="+id,
        success: function(msg){
            $('#aj_prods').html(msg);
        }
    });
}
function build_mod()
{
    id = $('#aj_prods').val();
    $.ajax({
        type: "POST",
        url: "http://www.adviser.ro/mobile/aj_get_mods",
        data: "pid="+id,
        success: function(msg){
            $('#aj_mods').html(msg);
        }
    });
}

function go_model()
{
    id = $('#aj_mods').val();
    document.location.href = 'http://www.adviser.ro/mobile/produs/'+id+'_.html';
}