$(function() {
    var offset = $("#sidearea").offset();
    var topPadding = 20;
    $(window).scroll(function() {
        if ($(window).scrollTop() > offset.top) {
            $("#sidearea").stop().animate({
                marginTop: $(window).scrollTop() - offset.top + topPadding
            });
        } else {
            $("#sidearea").stop().animate({
                marginTop: 0
            });
        };
    });
});

$(function(){
	$("a[href^=#]").click(function(){
		var Hash = $(this.hash);
		var HashOffset = $(Hash).offset().top;
		$("html,body").animate({
			scrollTop: HashOffset
		}, 1000);
		return false;
	});
});

$(function(){
$("p,li").css("font-size",$.cookie('fsize'));
});
function font(size){
$("p,li").css("font-size",size);
$.cookie("fsize",size,{expires:30,path:'/'});
}

$(document).ready(function() {
$('#slideshow').coinslider({
width: 820, //width of slider panel
height: 137, //height of slider panel
spw: 9, //squares per width
sph: 3, //squares per height
effect: 'random', // random, swirl, rain, straight
delay: 4000, // delay between images in ms
sDelay: 45, // delay beetwen squares in ms
opacity: 0.8, // opacity of title and navigation
titleSpeed: 500, // speed of title appereance in ms
navigation: false, // prev next and buttons
links : false, // show images as links
hoverPause: false // pause on hover
});
});

$(document).ready(function(){
$(".iframe").colorbox({iframe:true, width:"580px", height:"440px"});
});

$(document).ready(function(){
	$("#explan h4").each(function(){
		$(this).addClass("resting");
		$(this).click(function(){
			var question = $(this).attr("class");
			var answer = $(this).next();
			if(question === "resting"){
				$(this).removeClass("resting");
				$(this).addClass("active");
				}
			else{
				$(this).removeClass("active");
				$(this).addClass("resting");
				}
			$(answer).slideToggle();			
		});
	});
});
