$(document).ready(function(){
	//INPUT ELEMENTS	
		var st = '#4c4c4c';
		var en = '#9a9a9a';
		
		$('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', st);
			}
		});
		
		//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);
		}
	});
	
	//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/calendar_alt.png', 'images/navbar/ministries_alt.png', 'images/navbar/contact_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')				
				}
			});
		}
	});
	
	//CLEANING UP MARGINS AND JUNK
	
	//CALENDAR
	$('#in-cal a').bind({
		mouseenter: function(){
			mainC = $(this).css('color');
			spC = $(this).children().css('color');
			$(this).children().css('color', '#ffffff');
			$(this).css('color', '#ffffff');
		},
		mouseleave: function(){
			$(this).children().css('color', spC);
			$(this).css('color', mainC);
		}
	});
	
	//CALENDAR SHOW
	$('.showDescription').toggle(function(){
		$(this).next().show(1000);
		$(this).css('font-weight', 'bold');
	},function(){
		$(this).next().hide('slow');
		$(this).css('font-weight', 'normal');
	});
});
