jQuery.extend({
	postJSON: function(url, data, callback) {
		return $.post(url, data, callback, 'json');
	}	
}); 

function Search() {
	
}

Search._term = '';
Search._id = '.search input[name="searchparam"]';

Search.setTerm = function(term) {
	Search._term = term;
}

function editSlideshow() {
	$('.anythingControls').hide();

	$('.anythingSlider').mouseenter(function() {
		$('.anythingControls').show();
		$('span.arrow').show();
	});
	
	$('.anythingSlider').mouseleave(function() {
		$('.anythingControls').hide();
		$('span.arrow').hide();
	});
}

function showLogin(view) {
	$('#mask').addClass('on');
	$('#login').show();
	
	if(view != null) {
		$('#login form input[name="cl"]').val(view);
	}
	
	$('#login input[name="lgn_usr"]').focus(); 
}

$(document).ready(function() {
	$(Search._id).focus(function() {
		if($(this).val() == Search._term) {
			$(this).val('');
		}
	});
	
	$(Search._id).blur(function() {
		if($(this).val() == '') {
			$(this).val(Search._term);
		}
	});
	
	$('#mainNav li').mouseenter(function() {
		if($(this).children('div.sub').size() > 0) {
			$(this).children('div.sub').show();
		}
	});
	
	$('#mainNav li').mouseleave(function() {
		if($(this).children('div.sub').size() > 0) {
			$(this).children('div.sub').hide();
		}
	});
	
	$('#head .login .showLogin').click(function(i) {
		showLogin(null);
	});
	
	$('#mask.on').click(function() {
		$('#mask').removeClass('on');
	});
	
	$('#login .head .close').click(function() {
		$('#mask').removeClass('on');
		$('#login').hide();
	});
	
	$('#head .content > .toNoticeList').click(function() {
		$('#head .content .noticeList').fadeIn();
	});
	
	$('#head .content .noticeList > .toNoticeList').click(function() {
		$('#head .content .noticeList').fadeOut();
	});
	
	$('#foot .gogreen').hover( 
		function() {
			offset = $(this).offset();
			$('#gogreen').css({left: offset.left, top: offset.top - $('#gogreen').height() - 32}).fadeIn();
		},
		function() {
			$('#gogreen').fadeOut();
		}
	);	
});
