$(function(){
	$('#rap').css('marginBottom',-$('#footer').height()+'px');
	$('#rap')
		.wrapInner('<div id="background-color"/>')
		.prepend('<br style="clear:both"/>');
	$('<div id="push"/>').appendTo('#rap').height($('#footer').height());
	$('#innerFooter li a').unwrap();
	blockheightfix();
//	placeholderFix();
	inputFodder();
	navAni();
});

$(window).load(function(){
		slideShow();
		sidebarHeightFix();
});

function inputFodder(){
	$('input[type="text"],textarea').addClass('input');
	$('input[type="submit"]').addClass('submit');
	$('input[name*="filter_"]').hide();
}

function placeholderFix(){
	$('.input').each(function(){
		var ph = $(this).attr('placeholder');
		v = $(this).val();
		if(v.length < 1) {
			$(this).val(ph);
		}
		$(this).css('color','#DADADA');
		$(this).focus(function(){
			$(this).css('color','#000');
			if($(this).val() == ph){
				$(this).val('');
			}
		}).blur(function(){
			if(this.value=='') {
				$(this).val(ph).css('color','#DADADA');
			}
		});
	});
}

function navAni(){
	$('#navigation>li').hover(function(){
		$(this)
			.stop()
			.css({backgroundPosition:'50% 45px'})
			.animate({top:'8px'},60)
			.animate({top:'-10px'},50)
			.animate({top:'0'},40)
			.animate({backgroundPosition:'50% -45px'},400);
	},function(){
		$(this)
			.stop()
			.css({backgroundPosition:'50% 45px',top:0});
	});
}

function blockheightfix(){
	var bh = $('#block1').height();
	$('#block2').css('minHeight',bh+'px');
}

function slideShow(){
	var imgs = $('#banner img'),
	cimgs = imgs.length,
	count = 0;
	
	imgs.hide();
	imgs.eq(0).show();
	
	setInterval(function(){
		if(count<=(cimgs-1)){
			count++,
			pcount=count-1;
		}
		if(count==cimgs){
			count=0,
			pcount=cimgs-1;
		}
		imgs.eq(pcount).fadeOut('slow');
		imgs.eq(count).fadeIn('slow');
	},5000);
	
	for(i=0; i<cimgs; i++){
		h = imgs.eq(i).height();
		imgs.eq(i).css({'marginTop':-h/2+'px'});
	}
	$('#banner #frame').addClass('frame');	
}

function sidebarHeightFix(){
	pt = parseInt($('#sidebar').css('paddingTop'));
	pb = parseInt($('#sidebar').css('paddingBottom'));
	h = $('#sidebar').height()+pt+pb-175;
	if (h >= 260) {
		$('#content').css('minHeight',h+'px');
	}
	$('#sidebar').css('visibility','visible');
}
