$(document).ready(function(){
	/**
	 * Show & Hide Form inputs based on selected
	 */
	$('.show_hide').change(function(){
		// hide all options
		$.each($(this).children(),function(k,v){
			var val = v.value;
			if(val != '') {
				$('#show_hide_'+val).hide();
			}
		});

		// fade in the selected option input
		var selected = $(this).val();
		$('#show_hide_'+selected).fadeIn();
	});


	// add a confirm box to all delete links
	$('.confirm_delete').click(function(){
		var answer = confirm('Delete this Item?');
		return answer;
	});
	
	// datepicker
	if( $('.datepicker').length ) {
		$(".datepicker").datepicker({
			dateFormat:'dd/mm/yy',
			showOn:'button',
			buttonImage:'/css/ui-lightness/images/calendar.gif',
			buttonImageOnly:true,
			firstDay:1,
			changeMonth:true,
			changeYear:true
		});
	}
	
	// chosen plugin
	if( $(".chzn-select").length ) {
		$(".chzn-select").chosen();
	}
	
	// same height
	if( $('.same_height').length ) {
		var _max = 0;
		$('.same_height').each(function(k,v){
			var _height = $(this).height();
			if(_height > _max) {
				_max = _height;
			}
		});
		
		if(_max > 0) {
			$('.same_height').animate({height:_max},'slow');
		}
	}
});
