$(function () { $(".tips").tooltip({placement: 'auto left'}); });
$('#keywords').tagsInput({'defaultText':'', height: '75px', width: '100%'});
$('#num_display').TouchSpin({
	min: 0,
	max: 50
});
$('#notes').summernote({
	height: "200px",
	toolbar: [
		//['style', ['style']], // no style button
		['style', ['bold', 'italic', 'underline', 'clear']],
		['fontsize', ['fontsize']],
		['color', ['color']],
		['para', ['ul', 'ol', 'paragraph']],
		//['height', ['height']],
		['table', ['table']],
		['insert', ['link']],
		['fullscreen', ['fullscreen']]

		//['help', ['help']] //no help button
	]
});

/*----------- BEGIN chosen CODE -------------------------*/
$("#ads").multiSelect({
	keepOrder: true,
	selectableHeader: "<div class='multiselect-header'>" + lang_available_ads + "</div>",
	selectionHeader: "<div class='multiselect-header'>" + lang_selected_ads + "</div>"
});

/*----------- END chosen CODE -------------------------*/

$(function (){
	$("form").validate({
		rules: {
			title:{
				minlength: 1,
				maxlength: 256,
				required: true
			},
			num_display:{
				integer: true,
				required: true,
				min: 0
			}
		},
		highlight: function (element) {
			$(element).closest('.form-group').removeClass('has-success').addClass('has-error');
		},
		unhighlight: function (element) {
			$(element).closest('.form-group').removeClass('has-error').addClass('has-success');
		}
	});
});

$(function (){
	setTimeout(function(){
		$("input:text:visible:first").focus();
	}, 0);
});