$(document).ready(function() {
	var w_img=1600, h_img=1075;
	var w,new_w,h, new_h, num;
	setWidth();
	setHeight();
	w=new_w;h=new_h;
	setSize();
	function setWidth(){
		new_w=$(window).width();
	}
	function setHeight(){
		new_h=$(window).height();
	}
	function setSize(){
		if ((w/w_img) > (h/h_img)) {
			w_img_new=w+20;
			h_img_new=~~((w+20)*h_img/w_img);
		} else {
			h_img_new=h+20;	
			w_img_new=~~((h+20)*w_img/h_img);
		}
		$('#bgSlider img').css({width:w_img_new, height:h_img_new});
		if (fl==0) {
			if (new_h>520) {
					p_top=~~(new_h-520)/2+30;
				} else {
					p_top=30
			}
		} else {
			if (new_h>830) {
					p_top=~~(new_h-830)/2+150;
				} else {
					p_top=150
			}	
		}
		$('#content').stop().animate({paddingTop:p_top})
	}
	setInterval(setNew,1);
	function setNew(){
		setWidth();
		setHeight();
		if ((w!=new_w)|(h!=new_h)) {
			w=new_w;h=new_h;
			setSize();
		}
	}
	$('.caption > div').css({opacity:0});
	$('.caption > div').eq(0).css({opacity:1});
	var number=0;
	$('.prev').click(function(){			  
		$('.caption > div').eq(number).stop().animate({opacity:0},1000);
		if (number==0) {number=$('.caption > div').length-1;}	else {number=number-1}	
		$('.caption > div').eq(number).stop().animate({opacity:1},1000, function(){$(this).css({opacity:'none'})});
		return false
	});
	$('.next').click(function(){			  
		$('.caption > div').eq(number).stop().animate({opacity:0},1000);
		if (number==$('.caption > div').length-1) {number=0;}	else {number=number+1}	
		$('.caption > div').eq(number).stop().animate({opacity:1},1000, function(){$(this).css({opacity:'none'})});
		return false
	});
})
