$(document).ready(function(){
	//DROPDOWN
	var timeout = 500;
	var closetimer = 0;
	var ddmenuitem = 0;

	function jsddm_open()
	{	jsddm_canceltimer();
		jsddm_close();
		ddmenuitem = $(this).find('ul').eq(0).css('visibility', 'visible');}
	
	function jsddm_close()
	{	if(ddmenuitem) ddmenuitem.css('visibility', 'hidden');}
	
	function jsddm_timer()
	{	closetimer = window.setTimeout(jsddm_close, timeout);}
	
	function jsddm_canceltimer()
	{	if(closetimer)
		{	window.clearTimeout(closetimer);
			closetimer = null;}}
	
	$(document).ready(function()
	{	$('#jsddm > li').bind('mouseover', jsddm_open);
		$('#jsddm > li').bind('mouseout',  jsddm_timer);});
	
	document.onclick = jsddm_close;

	//INPUT ELEMENTS	
		//remove styles from hidden inputs
		$('input[type=hidden]').each(function(){$(this).css('display', 'none');});
		
		//change color unless typed in	
		$(':input').focus(function(){
			if($(this).val() == $(this).attr('rel')){
				$(this).fadeTo(500, 0.5);
				$(this).keydown(function(){
					if($(this).val() == $(this).attr('rel')){					
						$(this).val('');
						$(this).fadeTo(500, 1.0);
					}
				});
			}
		}).blur(function(){
			if($(this).val() == '' || $(this).val() == $(this).attr('rel')){
				var atty = $(this).attr('rel');
				$(this).val(atty).fadeTo(500, 1.0);
			}
		});
		
		//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';	
		}
	});
	
	$('#footLogo').css('cursor', 'pointer').bind({
		click: function(){
			window.location = './?page=home';	
		},
		mouseenter: function(){
			$(this).fadeTo(500, 0.5);
		},
		mouseleave: function(){
			$(this).fadeTo(500, 1.0);
		}
	});
	
	//inner margin
		$('#inner a').last().css({'border-bottom':'none', 'padding-bottom':'0px', 'margin-bottom':'0px'});
	//inner margin
	
	//resources
		$('#buttons a').last().css('margin-right', '0px').end().hover(function(){
			$(this).find('img').fadeTo(500, 0.5);
		},function(){
			$(this).find('img').fadeTo(500, 1.0);
		});
	//resources
	
	//calendar
		$('#homeCal a').hover(function(){
			$(this).css({'background-color':'#ad3424', 'color':'#e1b6b0'}).find('span').css({'color':'#ffffff', 'font-weight':'bold'});
		},function(){
			$(this).css({'background-color':'#d7aba5', 'color':'#4d4342'}).find('span').css({'color':'#242424', 'font-weight':'normal'});		
		});
	//calendar
	
	//button
		$('.button').hover(function(){
			$(this).css({'color':'#ffffff', 'background-color':'#000000'});
		},function(){
			$(this).css({'color':'#000000', 'background-color':'#ad3424'});		
		});
	//button
	
	//showNext
		$('.showNext').css({'cursor':'pointer'}).hover(function(){
			$(this).css('color', 'black');
		},function(){
			$(this).css('color', '#b94f41');		
		}).toggle(function(){
			$(this).next().slideDown('slow');
		},function(){
			$(this).next().slideUp('slow');
		})
	//showNext
});
