$(function(){
/***************************/





$("#logos").click(function(){
	window.location = "http://nuclearweaponsfree.org/community.cfm";
});






if ($("#home").length == 0) {
	$.getScript("scripts/jquery.dropshadow.js",function(){
		$("img").dropShadow({
			left:5,
			top:5,
			blur:5,
			opacity:.2
		});
	});
}






// functionality for semi slick form inputs
$(":text, textarea").each(function(){
	// store the default value of each form input as a property of itself
	this.default_value = $(this).val();
	// when the form is clicked in/tabbed to
	$(this).focus(function(){
		// check the value is the default, if so clear the input. this prevents clearing something already entered
		if ($(this).val() == this.default_value){
			$(this).val("");
		}
	});
	// when clicked off or tabbed out, reset the form to initial value if it hasnt been typed in.
	$(this).blur(function(){
		if ($(this).val() == ""){
			$(this).val(this.default_value);
		}
	});
});






// modified fade to make one fade time (ft) argument.
function crossFader(sel,ft,pt){
	function swap(el){
		var els=$(sel);
		if(els.length>1){
			var next=(jQuery.inArray(el,els)+1)%els.length;
			$(el).fadeOut(ft);
			$(els.get(next)).fadeIn(ft,function(){
				var self=this;
				setTimeout( function(){swap(self);} , pt );
			});
		}
	}
	$(sel).hide().slice(0,1).show();
	setTimeout( function(){swap($(sel).get(0));} , pt );
};
$(window).load(function(){
	crossFader("#freshbox .entry",1000,7000);
	crossFader("#logos p",500,3000);
});





// community functionality for state by state resources
$(".states h4").wrapInner("<a href='#' title='Click to expand'/>").find("a").click(function(){
    $(this).parent().next().slideToggle("fast");
    $(this).blur();
    return false;
}).end().next("ul").hide();




// lazy transparency workaround...  
// ie 6 and earlier, hide the leaf image in the footer.
if ($.browser.msie && parseFloat($.browser.version)<7) {
	$("#footer .wrap.inner").css("background-image","none");
}



$("img").each(function(){
	if($(this).css("float") == "right") $(this).addClass("right");
	if($(this).css("float") == "left") $(this).addClass("left");
});



/***************************/
});
