(function($){
	$(function(){
		$('#lightbox').slideBox({width: '100%', height: '100px', position: 'bottom'});
		if ($('.styled').length<1) {
			$('#pdf').attr({disabled:true});
		}
		$('#delete').click(function(event){
			var checked = $('.styled:checked').parent();
			var tns = [];
			checked.each(function(i){
				var img = $(this).css('background-image').replace(/^url\('?(.*)'?\)$/, '$1').replace(/"/g,'');
				tns.push(img);
				$(this).animate({
					width:0,
					marginLeft: 0,
					marginRight: 0
				}, 1000, function(){
					$(this).remove();
					if ($('.styled').length<1) {
						$('#pdf').attr({disabled:true});
					}
				});
			});
			$.post("ajax.html", {action:'del','tns[]':tns});
			return false;
		});
		$('input[type=checkbox].styled').change(function(event){
			var input = event.currentTarget;
			var img = $(input).parent().css('background-image').replace(/^url\('?(.*)'?\)$/, '$1').replace(/"/g,'').replace(/tn_/,'');
			var checked = $(input).attr('checked');
			$.post("ajax.html", {action:(checked?'set':'unset'),image:img});
		});
		$('.styled').customFormElements();
        if ((navigator.userAgent.indexOf('iPhone') > -1) || (navigator.userAgent.indexOf('iPad') > -1) || (navigator.userAgent.indexOf('Android') > -1)) {
        	$('.slide-panel,.slide-button').hide();
        }
	});
})(jQuery);
