// Iowa.gov Global Javascript
// Version 1
function photoSetup() {
	jQuery('div#photos img').each(function(index){
		jQuery(this).attr('id','photo'+index)
		jQuery(this).css('opacity','0.7');
		jQuery(this).hover(function(){
			jQuery(this).animate({'opacity':'1'},300);
		},
		function() {
			jQuery(this).animate({'opacity':'0.7'},500);
		});
	});
}
function togsInit() {
	var hash=window.location.hash;
	var currentTarget=hash.replace('/','');
	jQuery('ul.tabnav a').each(function(index){
		var target=$(this).attr('href').replace('/','');
		if (hash!="") {
			if (target==currentTarget) {
				$(this).addClass('current');
				$(target).addClass('open');
			} else {
				$(target).hide();
			}
		} else if (index==0) {
			$(this).addClass('current');
			$(target).addClass('open');
		} else {
			$(target).hide();
		}
		$(this).click(function(){
			$(target).show().siblings('.tabContentArea').hide();
			$(this).addClass('current').parent().siblings().find('a.current').removeClass('current');
		});
	}); 
}
function searchTextThing() {
	jQuery('#ss_tbox').each(function(){
		initVal=jQuery(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();
	searchTextThing();
});