$(document).ready(function() {
	
	// multiple selects
	$(".multiple-select").chosen();
	
	// set up qTip
	$(".tip").qtip({
					position: {
						my: 'bottom center',
						at: 'top center'
					},
					style: {
						classes: 'ui-tooltip-tipsy'
					}
				});
				
	$(".tip-left").qtip({
				position: {
					my: 'right center',
					at: 'left center'
				},
				style: {
					classes: 'ui-tooltip-tipsy'
				}
			});
			
	$(".tip-bottom").qtip({
					position: {
						my: 'top center',
						at: 'bottom center'
					},
					style: {
						classes: 'ui-tooltip-tipsy'
					}
				});
				
	$(".tip-bottom-adjust").qtip({
					position: {
						my: 'top center',
						at: 'bottom center',
						adjust: {
							y: 5
						}
					},
					style: {
						classes: 'ui-tooltip-tipsy'
					}
				});				
	
	// only allow numeric values
	$('.numeric').keyup(function () { 
	    this.value = this.value.replace(/[^0-9\.]/g,'');
	});
	
	// nicEditor for right classes
	$(".editor").each(function(){
		new nicEditor({	buttonList: ['bold','italic','underline','ol','ul','hr','fontFormat'], iconsPath : '/_design/images/nicEditorIcons.gif'}).panelInstance($(this).attr("id"));
	});
	
	// multiple checkboxes in dropdown
	//$("#categories_selector").dropdownchecklist({ width: 200, emptyText: "Choose a Category", firstItemChecksAll: true, explicitClose: 'Close' });
});

// Good functions

	function in_array(needle, heystack)
	{
		for(var i=0; i < heystack.length; i++)
		{
			if(needle == heystack[i])
			{
				return true;
			}
		}
		
		return false;
	}

