/*$(document).ready(function(){ 

    $("li.one").click( function(){ $
	("#navigation").removeClass('bg2, bg3').addClass("bg1");
	});

	$("li.two").click( function(){ $
		("#navigation").removeClass("bg2, bg3").addClass("bg2");
	});

	$("li.three").click( function(){ $
		("#navigation").removeClass("bg1, bg2").addClass("bg3");
	}); 
});*/

$(function()
{
	$('#resources_docs, #resources_docs2, #resources_docs3, #resources_docs4, #resources_docs5, #resources_docs6').jScrollPane();
});



function badBrowser(){
	if($.browser.msie && parseInt($.browser.version) <= 6){ return true;}
	
	return false;
}

function getBadBrowser(c_name)
{
	if (document.cookie.length>0)
	{
	c_start=document.cookie.indexOf(c_name + "=");
	if (c_start!=-1)
		{ 
		c_start=c_start + c_name.length+1; 
		c_end=document.cookie.indexOf(";",c_start);
		if (c_end==-1) c_end=document.cookie.length;
		return unescape(document.cookie.substring(c_start,c_end));
		} 
	}
	return "";
}	

function setBadBrowser(c_name,value,expiredays)
{
	var exdate=new Date();
	exdate.setDate(exdate.getDate()+expiredays);
	document.cookie=c_name+ "=" +escape(value) + ((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}

if(badBrowser() && getBadBrowser('browserWarning') != 'seen' ){
	$(function(){
		$("<div id='browserWarning'>You are using an unsupported browser. Please switch to <a href='http://getfirefox.com'>FireFox</a>, <a href='http://www.opera.com/download/'>Opera</a>, <a href='http://www.apple.com/safari/'>Safari</a> or <a href='http://www.microsoft.com/windows/downloads/ie/getitnow.mspx'>Internet Explorer 7</a>. Thanks!&nbsp;&nbsp;&nbsp;[<a href='#' id='warningClose'>close</a>] </div> ")
			.css({
				backgroundColor: '#fcfdde',
				'width': '100%',
				'border-top': 'solid 1px #000',
				'border-bottom': 'solid 1px #000',
				'text-align': 'center',
				padding:'5px 0px 5px 0px'
			})
			.prependTo("body");
		
		$('#warningClose').click(function(){
			setBadBrowser('browserWarning','seen');
			$('#browserWarning').slideUp('slow');
			return false;
		});
	});	
}
$(function() {
		$("#various1").click(function() {
		if ($("#prominentwomen").is(":hidden")) {
		$("#prominentwomen").slideDown("slow");
		} else {
		$("#prominentwomen").hide();
		}
		});
	});

$(function() {		
		$("#various2").click(function() {
		if ($("#womensgroups").is(":hidden")) {
		$("#womensgroups").slideDown("slow");
		} else {
		$("#womensgroups").hide();
		}
		});
		});
		$(function() {		
		$("#various3").click(function() {
		if ($("#mentalhealth").is(":hidden")) {
		$("#mentalhealth").slideDown("slow");
		} else {
		$("#mentalhealth").hide();
		}
		});
		});
		$(function() {		
		$("#various4").click(function() {
		if ($("#womensdiaries").is(":hidden")) {
		$("#womensdiaries").slideDown("slow");
		} else {
		$("#womensdiaries").hide("slow");
		}
		});
		});
		$(function() {		
		$("#various5").click(function() {
		if ($("#correspondance").is(":hidden")) {
		$("#correspondance").slideDown("slow");
		} else {
		$("#correspondance").hide("slow");
		}
		});
		});
		$(function() {		
		$("#various6").click(function() {
		if ($("#womenspolitics").is(":hidden")) {
		$("#womenspolitics").slideDown("slow");
		} else {
		$("#womenspolitics").hide("slow");
		}
		});
		});
		$(function() {		
		$("#various7").click(function() {
		if ($("#womenwork").is(":hidden")) {
		$("#womenwork").slideDown("slow");
		} else {
		$("#womenwork").hide("slow");
		}
		});
		});
		$(function() {		
		$("#various8").click(function() {
		if ($("#womenwar").is(":hidden")) {
		$("#womenwar").slideDown("slow");
		} else {
		$("#womenwar").hide("slow");
		}
		});
		});

$(function() {
$('#various1, #various2, #various3, #various4, #various5, #various6, #various7, #various8').click(function() {
   var elementClicked = $(this).attr("href");
   var destination = $(elementClicked).offset().top;
   $("html:not(:animated),body:not(:animated)").animate({ scrollTop: destination-20}, 1000 );
   return false;
});
});

$(document).ready(function() {
	
	// set easing type					   
	//jQuery.easing['jswing'] = jQuery.easing['swing'];
	
	// add changepage functions to nav links
	$('#various1, #various2, #various3, #various4, #various5, #various6, #various7, #various8').click(function(){
		// get the hash tag of the new content
		var hashtag = $(this).attr("id").replace("_","");						  
		changePage(hashtag);
		return false;
	});
	
	// deeplinking
	//
	// Override the default behavior of all `a` elements so that, when
  // clicked, their `href` value is pushed onto the history hash
  // instead of being navigated to directly.
  $('#various1, #various2, #various3, #various4, #various5, #various6, #various7, #various8').click(function(){
	// get the hashtag
	var hashtag = $(this).attr("id").replace("_","");
	
    // Push this URL "state" onto the history hash.
    $.bbq.pushState({ url: hashtag });

    // Prevent the default click behavior.
    return false;
  });

  // Bind a callback that executes when document.location.hash changes.
  $(window).bind( "hashchange", function(e) {
    // In jQuery 1.4, use e.getState( "url" );
    var url = $.bbq.getState("url") ? $.bbq.getState("url") : "folio";

    changePage(url);

    // You probably want to actually do something useful here..
  });

  // Since the event is only triggered when the hash changes, we need
  // to trigger the event now, to handle the hash the page may have
  // loaded with.
  $(window).trigger( "hashchange" );
	
});





// set var to track current page
var curpage = "folio";

function changePage(hashtag) {
	
	if (hashtag != curpage) {	

		//do the ie change
		if ($.browser.msie) {
				
			//fade out current page in ie
			$('#'+curpage).fadeOut(1000);
	
			
			//fade in new page in ie
			$('#'+hashtag).fadeIn(1000);
			}
			//other browsers do the right thing...	
			else {

			// move the current page offscreen upwards
			$('#'+curpage).animate({top: -$(window).height(), opacity:0.0}, 1000);
			
			// load new content into appropriate div
			$('#'+hashtag).animate({top: '0px', opacity:1.0},1000);
			}
		// reset curpage to the new hashtag
		//
		curpage = hashtag;
		
		// show / hide nav arrows
		if (hashtag == "folio") {
			$('#arrow1, #arrow2').fadeIn(1000);
		} else {
			$('#arrow1, #arrow2').fadeOut(1000);
		
		}
	}
}
