// Iowa.gov Global Javascript
// Version 1
function photoSetup() {
	$('div#photos img').each(function(index){
		$(this).attr('id','photo'+index)
		$(this).css('opacity','0.7');
		$(this).hover(function(){
			$(this).animate({'opacity':'1'},300);
		},
		function() {
			$(this).animate({'opacity':'0.7'},500);
		});
	});
}
function urgentAlertSetup() {
	$('a.close').click(function(){
		$(this).parents('div.moduleContent').parent().attr('id','die').animate({
			'height':0,
			'padding':0
		}, 1000, function(){$('#die').remove()});
	});
	$('div.urgent_alert').animate({
		'backgroundColor':'#FFE8C4'
	},3000);
}
function togsInit() {
	jQuery('.handle').each(function(index){
		jQuery(this).attr('id','handle_'+index);
		var areaId='area_'+index;
		jQuery(this).next('div.togArea').attr('id',areaId);
		if (index>0) {$('#'+areaId).hide();}
		if (index==0) {$(this).addClass('open');}
		jQuery(this).click(function(){
			jQuery('.handle').not(this).removeClass('open');
			jQuery(this).addClass('open');
			jQuery('div.togArea').not($('div#'+areaId)).slideUp('fast');
			jQuery('div#'+areaId).slideDown('fast');
		});
	}); 
}
function togsOpenAll() {
	jQuery('.togArea').slideDown('slow');
	jQuery('.handle').addClass('open');
}
function searchTextThing() {
	jQuery('#ss_tbox').each(function(){
		initVal=$(this).val();
		jQuery(this).focus(function(){
			if (jQuery(this).val()==initVal) {
				jQuery(this).val('');	
			}
		});
		jQuery(this).blur(function(){
			if (jQuery(this).val()=="") {
				jQuery(this).val(initVal);	
			}
		});
	});	
}
jQuery(function(){
	togsInit();
	photoSetup();
	urgentAlertSetup();
	searchTextThing();
});