$(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 = 'index.htm';	
		}
	});
	
	//FADE
	$('#fade').innerfade({
		speed: 2500,
		timeout: 6000,
		type: 'sequence',
		containerwidth: '988px',
		containerheight: '500px'
	});	
	
	//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/buttons/map_main_alt.jpg', 'images/buttons/vbs_2011_alt.jpg', 'images/buttons/Pastor_Luis_alt.jpg');
	
	//buttons hover
	$('.buttons').hover(function(){
		myimg = $(this).children().children().attr('src');
		imgalt = $(this).children().children().attr('alt');
		imgalt = 'images/buttons/'+imgalt+'_alt.jpg';
		$(this).children().children().attr('src', imgalt);
	},function(){
		$(this).children().children().attr('src', myimg);	
	});
	
	//calendar buttons
	$('#cal_mid a').hover(function(){
		if($(this).attr('class') != 'more-cal'){
			$(this).find('span').css('font-weight', 'bold').end().css('color', '#000000');
		}		
	},function(){
		if($(this).attr('class') != 'more-cal'){
			$(this).find('span').css('font-weight', 'normal').end().css('color', '#444444');
		}			
	});
	
	//margins
	$('#inner a').last().css({'margin-bottom' : '0px', 'padding-bottom' : '0px', 'border-bottom' : 'none'});
	
	//button margin
	$('.buttons').last().css('margin-right', '0px');
	
	//SHOW HIDDEN
	$('.showDescription').toggle(function(){
		$(this).next().slideDown('slow');
	},function(){
		$(this).next().slideUp('fast');	
	});
});
