/*====================================================================================================*/

(function ($) {
	$.fn.closeButton = function() {
		$(this).each(function () {
			$(this).prepend('<a title="Close" href="javascript:;" class="close-button">X</a>');
		});
		return this;
	}
})(jQuery);

/*====================================================================================================*/

$(document).ready(function () {


/*====================================================================================================*/

	var ajaxLoader = '<div class="ajax-loader ajax-loader-large"></div>';

/*====================================================================================================*/

	// $('.modal-view').modal_view();

/*====================================================================================================*/

	/*
		Checkboxes and radios
	 */
	// $("input:checked").parent().addClass('selected');
	$("input:checked").livequery(function () {
		$(this).parent().addClass('selected');
	});

	$(":radio").live('change', function () {
		$('input[name="' + $(this).attr('name') + '"]').parent().removeClass('selected');
		$(this).parent().addClass('selected');
	});
	
	$(":checkbox").live('change', function () {
		if ($(this).is(':checked')) {
			$(this).parent().addClass('selected');
		} else {
			$(this).parent().removeClass('selected');
		}
	});
	/*
		Multiselect options
	*/
	$('.multiselect .toggle :checkbox').live('change', function () {
		checked = $(this).attr('checked');
		inputs = $(this).parents('.multiselect').find(':checkbox:not(:disabled)');
		if (checked) {
			inputs.attr('checked', checked).parent().addClass('selected');
		} else {
			inputs.attr('checked', checked).parent().removeClass('selected');
		}
	});

/*====================================================================================================*/

	$('.message').closeButton().hide().fadeIn();
	// $('.close-me').closeButton();

	$('.close-button').live('click', function () {
		$(this).parent().fadeTo(400, 0, function () {
			$(this).slideUp('fast', function () {
				$(this).remove();
			});
		});
	});

/*====================================================================================================*/

	// Open all PDF files and external links in a new tab
	// $('a[href*=".pdf"], a[href^="http"], a[href^="/*:"]')
	// .not('[href^="'+BASE_URL+'"]').click(function (e) {
	$('a[href*=".pdf"]').click(function (e) {
		e.preventDefault();
		window.open(this.href);
	});

/*====================================================================================================*/

	/* Nav dropdowns for IE */
	$(".nav ul").css({display: "none"}); // Opera Fix
	$(".nav li").hover(function () {
		$(this).find('ul:first').css({visibility: "visible", display: "none"}).show(140);
	},
	function () {
		$(this).find('ul:first').css({visibility: "hidden"});
	});

/*====================================================================================================*/

	$('.admin-editable').addClass('disabled');
	$('#edit_mode').click(function () {
		$('.admin-editable').toggleClass('disabled');
	});

/*====================================================================================================*/


	// $('.PHOTOS-INDEX #content a').live('click', function (e) {
		// e.preventDefault();
		// var $href = $(this).attr('href');
		// $('#content').slideUp(function () {
			// $(this).load($href, function () {
				// $(this).slideDown();
			// });
		// });
	// });




/*====================================================================================================*/
});
/* end file */
