function updateListItem() {

}

$(document).ready(function(){
	// Create list
	$('#departdate, #listname').keypress(function(event){
		if (event.which == 13) {return false;}
	});

	//
    $('.infoPopup').colorbox({width:"700px", height:"600px", iframe:true});
    $('.list_adverts').cycle({
        timeout: 8000
    });
    $.ajaxSetup({
        url: '/list-change.php',
        chache: false,
        type: 'POST',
        dataType: 'json',
        complete: function(jqXHR, textStatus) {
         //   alert(textStatus);
        }
    });

    $('.check_done').change(function(){
        itemId = $(this).attr('id').replace('check_done_','');
        itemType = $('#item_type_' + itemId).val();
        if ($(this).attr('checked')) {
           state = 0;
        } else {
           state = 1;
        }
        $.post(
            '/list-change.php',
            {
                'itemId': itemId,
                'itemType': itemType,
                'itemState': state,
                'itemChange': 'state',
                'action': 'update'
            },
            function(data, textStatus, jqXHR) {
              //  alert(data.state);
                if (textStatus == 'success' && data.state == '1') {
                   $('#list_item_row_' + itemId).removeClass('list_item_row_checked');
                   $('#list_item_row_' + itemId).addClass('list_item_row_unchecked');
                }
                if (textStatus == 'success' && data.state == '0') {
                   $('#list_item_row_' + itemId).removeClass('list_item_row_unchecked');
                   $('#list_item_row_' + itemId).addClass('list_item_row_checked');
                }
            }
        );
    });

    $('.item_ready').change(function(){
        itemId = $(this).attr('id').replace('item_ready_','');
        itemType = $('#item_type_' + itemId).val();
        if ($(this).attr('checked')) {
           state = 1;
        } else {
           state = 0;
        }
        $.post(
            '/list-change.php',
            {
                'itemId': itemId,
                'itemType': itemType,
                'itemState': state,
                'itemChange': 'ready',
                'action': 'update'
            },
            function(){}
        );
    });
});

