function scrollDiv(trig,value,target) {
	trig.click(function(e) { 
    	// Prevent a page reload when a link is pressed
   		e.preventDefault(); 
    	target.animate({
        scrollTop: value
		},'slow');           
	});
}

$(function(){
	var keyword;
	var jumpType;
	var locationID = 397; // defaults to Wausau
	var location;
	
	$('.clearOnFocus').clearOnFocus();
	$('.pin').tooltip({
		effect:"slide",
		bounce:false,
		slideOffset:22,
		slideInSpeed:200,
		slideOutSpeed:400,
		offset:[33, 33],
		position:"top center",
		relative:true
	});
	$('a.close').click(function() {
		$('.tooltip').hide();
		return false;
	});
	$("ul.tabs").tabs("div.panes > div", {
		effect:"default"	
	});
	//scrollDiv($("#wausau-t"),$("#wausau-scroll").position().top-70,$('.news-feed .scroll'));
	//scrollDiv($("#appleton-t"),$("#appleton-scroll").position().top-70,$('.news-feed .scroll'));
	//scrollDiv($("#madison-t"),$("#madison-scroll").position().top-70,$('.news-feed .scroll'));
	//scrollDiv($("#milwaukee-t"),$("#milwaukee-scroll").position().top-70,$('.news-feed .scroll'));
	//$("#wausau-scroll h3").append('<a href="http://www.newhorizons.com/wausau">Visit Website</a>');
	//$("#appleton-scroll h3").append('<a href="http://www.newhorizons.com/greenbay">Visit Website</a>');
	//$("#madison-scroll h3").append('<a href="http://www.newhorizons.com/madison">Visit Website</a>');
	//$("#milwaukee-scroll h3").append('<a href="http://www.newhorizons.com/milwaukee">Visit Website</a>');
	$('a img[rel="#selloc"],a#contact span').overlay({
		effect: 'apple',
		mask: {
			color: '#fff',
			loadSpeed: 200,
			opacity: 0.7
		},
		closeOnClick: false
	});
	$('a.feature img').click(function(e) {
		e.preventDefault();
		keyword = $(this).attr('alt');
		jumpType = 'search';
	});
	$('a#contact').click(function(e) {
		e.preventDefault();
		jumpType = 'contact';
	});
	$('#banner-container a img').click(function(e) {
		e.preventDefault();
		jumpType = 'banner';
	});
	$('#selloc a.jump').click(function(e) {
		e.preventDefault(); 
		locationID = $(this).attr('rel');
		location = $(this).text();
		if(jumpType == 'search') {
			window.location = "http://www.newhorizons.com/LocalWeb/catalog/CourseCatalog.aspx?TemplateId=17&keyword=" + keyword + "&GroupID=" + locationID;
        } else if (jumpType == 'banner') { // banner            
            window.location = "http://www.newhorizons.com/LocalWeb/US/WI/" + location + "/microsoft-kindle-promo.aspx";
		} else { // contact
			window.location = "http://www.newhorizons.com/LocalWeb/content/ContentThree.aspx?TemplateId=2&GroupId=" + locationID;
		}
	});
});

/*
 * jQuery Plugin: clearOnFocus
 * Version 1.0
 *
 * Copyright (c) 2009 David Comeau (http://www.davecomeau.net)
 * Licensed jointly under the GPL and MIT licenses.
 *
 */

(function($) {
	$.fn.clearOnFocus = function() {
		
		function clearOnFocusFocus(event)
		{
			if($(this).val() == $(this).data('clearOnFocus'))
			{
				$(this).val('');
				$(this).addClass('focus');
			}
		}
		
		function clearOnFocusBlur(event)
		{
			if($.trim($(this).val()) == '')
			{
				$(this).val($(this).data('clearOnFocus'));
				$(this).removeClass('focus');
			}
		}
		
		return this.each(function()
			{
				$(this).data('clearOnFocus', $(this).attr('value'));
				
				//	unbind any previous listeners
				$(this).unbind('focus', clearOnFocusFocus);
				$(this).unbind('blur', clearOnFocusBlur);
				
				//	bind listeners to the functions
				$(this).bind('focus', clearOnFocusFocus);
				$(this).bind('blur', clearOnFocusBlur);
			}
		);
	};
})(jQuery);
