﻿$(document).ready(function () {



	var searchBox = $('#search_query');
	var searchBoxText = 'Search our site...';

	searchBox.val(searchBoxText);

	searchBox.focus(function () {
		if ($(this).attr('value') == searchBoxText)
			$(this).val('');
	});

	searchBox.blur(function () {
		if ($(this).attr('value') == '')
			$(this).val(searchBoxText);
	});

	$('#search_queries').focus();
	$('#search_queries').select();

	$('.hover_shine').hover(function () {
		$(this).fadeTo('fast', 0.8);
	}, function () {
		$(this).fadeTo('fast', 1.0);
	});

	$('span.check').click(function () {
		var cb = $('input:checkbox[name*=' + $(this).attr('title') + ']');
		cb.attr('checked', true);
	});


	$('.text_size').click(function () {

		var ourText = $('#body').find('td, th, p, li, legend, div, h2, input, select, textarea');
		var currFontSize = ourText.css('fontSize');
		var finalNum = parseFloat(currFontSize, 10);
		var stringEnding = currFontSize.slice(-2);
		if (this.id == 'large') {
			finalNum *= 1.2;
		} else if (this.id == 'small') {
			finalNum /= 1.2;
			finalNum = finalNum < 14 ? 14 : finalNum;
		} else if (this.id == 'reset') {
			finalNum = 14;
		}

		ourText.css('fontSize', finalNum + stringEnding);
	});


	//Display Hidden JS Nodes
	$('.no_js').show();


	//ID Scroll Function. Any link with a hash (#) will scroll to that id on the page
	$('a.scroll').click(function () {

		if (location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '') && location.hostname == this.hostname) {

			var $target = $(this.hash);

			$target = $target.length && $target || $('[name=' + this.hash.slice(1) + ']');

			if ($target.length) {

				var targetOffset = $target.offset().top;
				$('html, body').animate({ scrollTop: targetOffset }, 1000);

				return false;
			}
		}
	});



});
