$(window).bind('scroll',adjust_footer);
$(window).bind('resize',adjust_footer);
function adjust_footer() {
	if ($('#navigation_wrapper').is(':visible')) {
		//adjust the footer
		var new_top=($(window).height()-50);
		var max_top=$('#header_wrapper').height()+$('#navigation_wrapper').height()+$('#wrapper').height()+$('#footer_wrapper').height()+($('#wrapper').hasClass('home')?-30:33);
		if (new_top<=max_top) {
			$('#footer_wrapper').css('top',(max_top)+'px');
		}else{
			$('#footer_wrapper').css('top',new_top+'px');
		}
		
	}
}

function switch_size(new_size)
{
	$('.font_size').removeClass('small_a large_a xlarge_a');
	switch (new_size) {
		case 'small':
			asize='100';
			break;
		case 'large':
			asize='120';
			break;
		case 'xlarge':
			asize='140';
			break;
		default:
			return;
	}
	$('body').css('font-size',asize+'%');
	$('.font_size').addClass(new_size+'_a');
	$.cookie('font_size',new_size);
}

$(function(){
	//font size
	if($.cookie('font_size')){
		switch_size($.cookie('font_size'));
	}


	//sizes hover() doesn't work in ie, have to use mouseovers
	$('.font_size a').bind('mouseover',function(){
		clean_sizes();
		$('.font_size').addClass($(this).attr('class'));
	});
	$('.font_size a').bind('mouseout',function(){
		clean_sizes();
		$('.font_size').removeClass($(this).attr('class'));
	});
	$('.font_size a').bind('click',function(e){		
		switch_size($(this).attr('class'));
		e.preventDefault();
		return false;		
	});
	//top hovers
	$('#navigation li:not(.current) a').hover(function(){	
		$(this).parent().animate({height:'45px'},{queue: false,duration: 100});
	},function(){
		$(this).parent().animate({height:'35px'},{queue: false,duration: 100});
	});
	//right hovers
	$('#wrapper ul.right_nav li:not(.current)').hover(function(){	
		$(this).animate({left:'-10px',paddingLeft:'10px'},{queue: false,duration: 100});
	},function(){
		$(this).animate({left:'0px',paddingLeft:'0px'},{queue: false,duration: 100});
	});
	
	//right click-through
	$('#wrapper ul.right_nav li').bind('click',function(e){
		if (!$(e.target).attr('href')) {
			window.location.href=$(this).find('a').attr('href');
		}
	});
	
	adjust_footer();
	
	//focus first
	$('input[type="text"]:first').focus();
	
	//lightbox
	$('a[@rel*=lightbox]').lightBox({
		imageLoading: '/project/html/images/lightbox/loading.gif',
		imageBtnClose: '/project/html/images/lightbox/close.gif',
		imageBtnPrev: '/project/html/images/lightbox/prev.gif',
		imageBtnNext: '/project/html/images/lightbox/next.gif'
	})
	
	//enlarge left images
	

});
function clean_sizes() {
	$('.font_size').removeClass('small').removeClass('large').removeClass('xlarge');
}
