// JavaScript Document
var up = true;
jQuery(document).ready(function() {
	jQuery(window).load(function () {
		float_banners();
	});
	
	jQuery(window).resize(function() {
		float_banners();
	});
	
	change_icon_updown();
	
	jQuery('#bb_close').click(function() {
		jQuery("#float_bottom").hide();
	});
	
	jQuery('#bb_up').click(function() {
		animate_bb('up');
	});
	
	jQuery('#bb_down').click(function() {
		animate_bb('down');
	});
	
	setTimeout(function() { animate_bb('up'); }, 15000);
	setTimeout(function() { animate_bb('down'); }, 30000);
});

function float_banners() {
	if (jQuery(window).width() >= 1250) {
		if (jQuery("#float_left").length > 0) jQuery("#float_left").show();
		if (jQuery("#float_right").length > 0) jQuery("#float_right").show();
		if (jQuery("#float_bottom").length > 0) show_bb();
	} else {
		if (jQuery("#float_left").length > 0) jQuery("#float_left").hide();
		if (jQuery("#float_right").length > 0) jQuery("#float_right").hide();
		if (jQuery("#float_bottom").length > 0) jQuery("#float_bottom").hide();
	}
}

function show_bb() {
	jQuery("#float_bottom").show();
//	animate_bb('up');
}

function change_icon_updown() {
	if (up) {
		jQuery("#bb_up").show();
		jQuery("#bb_down").hide();
	} else {
		jQuery("#bb_up").hide();
		jQuery("#bb_down").show();
	}
}

function switch_bb() {
	up = !up;
	change_icon_updown();
}

function animate_bb(option) {
	if (option == 'up') {
		jQuery("#float_bottom").animate({height: "250px"}, 'slow', 'swing', switch_bb());
	} else {
		jQuery("#float_bottom").animate({height: "20px"}, 'slow', 'swing', switch_bb());
	}	
}

