//functions to be executed on page load
$(function(){
	
	//Open all links with rel="external" in new window
	
	$(function(){
		var body = $("body").attr("class");
		if (!body.match(/childcare-registration/)) {
			$('a').filter(function(){
				return (!this.target && (this.href.indexOf(window.location.hostname) == -1 || this.href.match(/\.pdf$/i)));
			}).attr('target', '_blank');
		}
	});


	//Clear value in search input box
	swapValues = [];
	$("#T_EMAIL").each(function(i){
		swapValues[i] = $(this).val();
		$(this).focus(function(){
			if ($(this).val() == swapValues[i]) {
				$(this).val("");
			}
		}).blur(function(){
			if ($.trim($(this).val()) == "") {
				$(this).val(swapValues[i]);
			}
		});
	});
	

	$("#SearchBox1_LocationTextBox").focus(function() {
		$(this).css("color","#666");
		$(this).val("");
	});	
	
	$(".increase").click(function() {
		var currentSize = $('#primary-content p').css('font-size');
		var number = parseFloat(currentSize);
		var reSize = number += 2;
		$('p, li , a, h3').css('font-size',reSize + 'px');
		return false;
	});
	
	$(".decrease").click(function() {
		var currentSize = $('#primary-content p').css('font-size');
		var number = parseFloat(currentSize);
		var reSize = number -= 2;
		$('p, li, a, h3').css('font-size',reSize + 'px');
		return false;
	});

	
	$(".group-dropdown,.group-sites").hover(function() {
		$(".group-sites").css("display","block");
		$("a.group-dropdown").addClass("sites-hover");
	},function() {
		$(".group-sites").css("display","none");
		$("a.group-dropdown").removeClass("sites-hover");		
	});
	
	$(".gallery-img .img-left").hide();
	$(".gallery-img .img-left:first").show();
	$(".gallery-right ul li a:first").addClass("current");
	
		$("#thumbnails li a").click(function() {
		var clicked = $(this).attr("href");
		$(".img-left").hide();
		$(clicked).fadeIn(250);
		$(".gallery-right ul li a").removeClass("current");		
		$(this).addClass("current");
		return false;
	});
	
	$(".printable-version").click(function(e) {
		window.print();
		e.preventDefault();
	});
	
	if ($("#FacilityPanel").length) {	
		$("input#DateFromTextBox").val("Date From");
		$("input#DateToTextBox").val("Date To");
		$("input#FacilitySearchKeywords").val("Keywords");
		
		changeVals = [];
		$("#FacilityPanel input[type=text]").each(function(t) {
			changeVals[t] = $(this).val();
			$(this).focus(function() {
				if ($(this).val() == changeVals[t]) {
					$(this).val("");					
				}
			}).blur(function() {
				if ($(this).val() == '') {
					$(this).val(changeVals[t]);
				}
			});
		});
	}
	
	if ($(".cost-info").length) {
		$("a.help-info").hover(function() {
			$(".cost-info").show();
			/*if ($("#ChildmindingUnder2PerHourTextBox,ChildmindingUnder2PerWeekTextBox").val() == '') {
				$("#ChildmindingUnder2PerHourTextBox").val("0.50");
				$("#ChildmindingUnder2PerWeekTextBox").val("10.00");
			}*/
		}, function() {
			$(".cost-info").hide();
			/*if ($("#ChildmindingUnder2PerHourTextBox,ChildmindingUnder2PerWeekTextBox").val() == '') {
				$("#ChildmindingUnder2PerHourTextBox").val("");
				$("#ChildmindingUnder2PerWeekTextBox").val("");
			}*/					
		});
	}
});

//functions to be executed inline
var mylib =
{
	function_name :
	{
		init : function()
		{
			alert('First Function Initialized');
		}
	},
	another_function_name :
	{
		init : function()
		{
			alert('Second Function Initialized');
		}
	}
}
