function resizeme() {
	//alert('hw');
	var $winwidth = $(window).width();
	$(".bg").attr({
		width: $winwidth
	});
	var imgheight= $(".bg").height();
	var $winheight= $(".wrapper").height();
	if ($winheight>imgheight) {
		$winheight-=imgheight;
		$(".bg").css("top",$winheight+"px");
	} else {
		$winheight=imgheight-$winheight+33;
		$(".bg").css("top","-"+$winheight+"px");
	}
}
var resizeTimer = null;
$(window).bind("resize", function(){
	if (resizeTimer) clearTimeout(resizeTimer);
	resizeTimer = setTimeout(resizeme, 700);
});

$(document).ready(function(){
	if ($(".bg").length)
	{
		resizeme();
	}
	if ($("#menu").length) {
		$(".opened ul").slideDown("slow");
		$("#menu a").click(function(e){
			var ul=$(this).parent().find("ul");
			if (ul.length != 0) {
				$("#menu ul").slideUp();
				e.stopPropagation();
				if (ul.is(":visible")) {
					ul.slideUp("normal",function(){
						resizeme();
					});
				} else {
					ul.slideDown("slow",function(){
						resizeme();
					});
				}
				return false;
			}
			return true;
		});
	}
	if ($(".slider").length) {
		var slider = $('.slider').bxSlider({controls: false, auto:true, autodelay:8,autoHover: true,pause:5000});
		$('.bannerlist a').click(function(){
			var thumbIndex = $('.bannerlist a').index(this);
			slider.goToSlide(thumbIndex);
			$('.bannerlist a').removeClass('pager-active');
			$(this).addClass('pager-active');
			return false;
		});
		$('.bannerlist a:first').addClass('pager-active');
	}
});
