$(document).ready(function(){
	//INPUT ELEMENTS	
		var st = '#263035';
		var en = '#636a6e';
		var fn = '#999da0';
		
		$('input[type=hidden]').each(function(){
			$(this).css('display', 'none');
		});
			
		$(':input').focus(function(){
			if($(this).val() == $(this).attr('rel')){
				$(this).css('color', en);
				$(this).keydown(function(){
					if($(this).val() == $(this).attr('rel')){					
						$(this).val('');
						$(this).css('color', st);
					}
				});
			}
		}).blur(function(){
			if($(this).val() == '' || $(this).val() == $(this).attr('rel')){
				var atty = $(this).attr('rel');
				$(this).val(atty).css('color', fn);
			}
		});
		
		//CHECKBOX
		$('input[type=checkbox]').each(function(){
			$(this).css({'display' : 'inline', 'width' : 'auto', 'padding' : '0px', 'margin-right' : '5px'});
		});
	//INPUT ELEMENTS
	
	//FIND LOGO
	$('#logo').css('cursor', 'pointer').bind({
		click: function(){
			window.location = './?page=home';	
		},
		mouseenter: function(){
			$(this).fadeTo(500, 0.5);
		},
		mouseleave: function(){
			$(this).fadeTo(500, 1.0);
		}
	});
	
	$('#foot_logo').css('cursor', 'pointer').bind({
		click: function(){
			window.location = './?page=home';	
		},
		mouseenter: function(){
			$(this).fadeTo(500, 0.5);
		},
		mouseleave: function(){
			$(this).fadeTo(500, 1.0);
		}
	});
	
	
	//PRELOAD IMAGES
	(function($){
		var cache = [];
		// Arguments are image paths relative to the current page.
		$.preLoadImages = function() {
			var args_len = arguments.length;
			for (var i = args_len; i--;) {
				var cacheImage = document.createElement('img');
				cacheImage.src = arguments[i];
				cache.push(cacheImage);
			}
		}
	})(jQuery)
	
	$.preLoadImages('images/navbar/home_alt.png', 'images/navbar/about_alt.png', 'images/navbar/media_alt.png', 'images/navbar/contact_alt.png', 'images/navbar/saved_alt.png');

	
	//FINDING NAV STUFF
	$('#navbar a').each(function(initIndex){
		if($(this).attr('rel') == 'true'){
			$(this).children().attr('src', 'images/navbar/'+$(this).children().attr('alt')+'_alt.png')
		}else{
			$(this).bind({
				mouseenter: function(){
					$(this).children().attr('src', 'images/navbar/'+$(this).children().attr('alt')+'_alt.png')
				},
				mouseleave: function(){
					$(this).children().attr('src', 'images/navbar/'+$(this).children().attr('alt')+'.png')				
				}
			});
		}
	});
	
	//Home Calendar
	$('.cal-container').css('cursor', 'pointer').bind({
		click: function(){
			window.location = './?page=calendar&'+$(this).attr('rel');	
		},
		mouseenter: function(){
			$(this).children(':first').css({
				'background-color' : '#141d22',
				'color' : '#fffff'
			}).end().children().eq(1).css({
				'color' : '#ffffff'
			});
		},
		mouseleave: function(){
			$(this).children(':first').css({
				'background-color' : '#28353c',
				'color' : '#999fa3'
			}).end().children().eq(1).css({
				'color' : '#a4a5a5'
			});
		}
	});
	
	//set cal width
	cW = 0;
	$('.cal-button').each(function(){
		if($(this).width() > cW){
			cW = $(this).width();
		}
	}).css('width', cW+'px');
	
	//margins
	$('#inner a:last').css({
		'margin-bottom' : '0px',
		'padding-bottom' : '0px',
		'border-bottom' : 'none'
	});
	
	//SHOW HIDDEN
	$('.show_hidden').toggle(function(){
		$(this).next().slideDown('slow');
	},function(){
		$(this).next().slideUp('fast');	
	});
});
