/*######################
  Norfolk County Sheriff's Office
	© 2010 NCSO
	Master JS File
	Created : 2.10.2010 by Mike Kivikoski
	Last Modified  :
	
	Please keep Last Modified up to date
	
	Table of Contents
		
		Font resizer
		
		When DOM is ready:
			// 1. Font Resizer
			// 2. Input text hints.
			
########################*/



$(document).ready(function(){
						   
	// 1.
	
	var resize = ('#font-resize');
	$(resize).css('display','block');
	
	var content = $('#content p');
	var controls = $('#font-resize a');
	
	$(controls).each(function(i){
		$(this).click(function() {
			var current = $(content).css("font-size");
			var number = parseFloat(current, 10);
	
			if($(this).hasClass('.increase')){
				var newSize = number*1.2;
				$(content).css("font-size", newSize);
			}else if($(this).hasClass('.decrease')){
				var newSize = number*0.8;
				$(content).css("font-size", newSize);
			}else{
				$(content).css("font-size", "14px");
			};
			return false;
		})
	});


	// 2.
	
			inputHints();
				// displays hint text on any input element with the 'title' attribute set
		
				function inputHints() {
					var el = $('input[title]');
					var value = $('input[value]');
						
						value.each(function(j){
							if($(this).attr('value') !== $(this).attr('title')){
								$(this).addClass('value-defined');	
								return true
  							}
						});
						
						el.each(function(i){
							if($(this).attr('value') !== ''){				
								$(this).attr('value' , $(this).attr('value'));		
							} else if ($(this).attr('value') == ''){
								$(this).attr('value' , $(this).attr('title'));
							}
						 });
					
						el.focus(function() {
							if ($(this).attr('value') == $(this).attr('title'))
								$(this).attr('value', '');
								$(this).addClass('value-defined');
						}).blur(function() {
							if ($(this).attr('value') == '')
								$(this).attr('value', $(this).attr('title'));
								if ($(this).attr('value') == $(this).attr('title'))
									$(this).removeClass('value-defined');
						});
				}
				
				// 3.
					$('#slideshow').cycle({
						fx: 'fade',
						after: function() {
							$('#caption').html(this.alt);
						} // choose your transition type, ex: fade, scrollUp, shuffle, etc...
					});						   
						   
						   
});//End jQuery
