function c(m){
	console.log(m)
}
$(document).ready(function(){
	$('a.logo').ifixpng();
	
	$(".dp").datepicker({
		dateFormat: 'dd.mm.yy'
	});

	$("table.clicky tr.clicky").hover(
		function(){
			$(this).children('td').css('background','#ffffff');
		},
		function(){
			$(this).children('td').css('background','url(/public/images/gfx/table_cell_bg.gif)');
		}
	);

	$("table.clicky tr.clicky td").click(
		function(){
			location.href = $(this).parent("tr").find('a.clickylink').attr('href');
		}
	);
	$(".confirm_dialog").click(function(){
        var th = $(this);
        var title = 'Confirm dialog';
        var text = 'Are you sure you want to delete?';
        var ob = $("<div/>").addClass("dialog").attr("style", "display: block;").attr("title", title).append($("<p/>").text(text));
        ob.dialog({
            bgiframe: true,
            resizable: false,
            height: 140,
            modal: true,
            overlay: {
                backgroundColor: '#000',
                opacity: 0.5
            },
            buttons: {
                'Delete': function(){
                    $(this).dialog('close');
                    location.href = th.attr('href');
                },
                'Cancel': function(){
                    $(this).dialog('close');
                }
            }
        });
        return false;
    })
	
	$(".delete_multi_gallery").livequery(function(){
		$(this).click(function(){
			var th = $(this);
			$.post('/others/index/deleteimage',{'id' : th.attr('imgv')},function(){
				th.parent().fadeOut('normal', function(){th.parent().remove();});
				
			})
		})
	})
	
	$.each($(".content img"),function(i,item){
		if ($(item).attr('border') > 0){
			$(item).css('border', $(item).attr('border')+ 'px solid black')
			$(item).attr('border',0)
		}
		if ($(item).attr('vspace') > 0){
			$(item).css('margin-top', $(item).attr('vspace') + 'px')
			$(item).css('margin-bottom', $(item).attr('vspace') + 'px')
			$(item).attr('vspace',0)
		}
		if ($(item).attr('hspace') > 0){
			$(item).css('margin-right', $(item).attr('hspace') + 'px')
			$(item).css('margin-left', $(item).attr('hspace') + 'px')
			$(item).attr('hspace',0)
		}
		
	})	
});

function multi_files_writeImage(obj){
	obj = eval('(' + obj + ')');

    var item = '<a target="_blank" href="/page/index/show/type/3/id/' + obj.id + '"  >' + obj.tmp_name + '</a>';
    var div = '<div id="' + obj.id + '" class="item dnd" style="display: none;">' + item + '&nbsp;<img class="delete_multi_gallery ro_button"  src="/public/images/admin/delete_button.gif" imgv="' + obj.id + '" /></div>';
    
    
    $("#thumbnails_files").prepend(div);

	$("#thumbnails_files div").fadeIn('slow');
	
    $("#thumbnails_files").sortable('refresh');
}
