jQuery(document).ready(function($){
    var rotator = jQuery('div.pic ul').cycle({
        fx: 'fade',
	pause: 1,
        timeout: 25000,
        speed: 1300,
	cleartypeNoBg: true,
	pager: 'div.inner-nav ul',
	pagerAnchorBuilder: function(idx, slide){
	    return 'div.inner-nav li:eq(' + idx + ') h3 a';
	},
	before: function() {
	    for(i=0;i<=2;i=i+1) { // Sort out which slide is open
		if ($(this).html() == $('div.pic ul li:eq('+i+')').html()) {
		    var slide = i;
		}
	    }
	    var slideNav = 'div.inner-nav li:eq(' + slide + ')'; // selector for the LI of the selected slide
	    
	    $('div.inner-nav li div.content:visible').addClass('closing'); // mark the old one as closing
	    if (slide == 0){ // make sure it doesn't close the first one on accident.
		$('div.inner-nav li:eq(0) div.content').removeClass('closing');
	    }
	    $(slideNav).addClass('open').children('div.content').slideDown().addClass('open'); // show the new one
	    
	    jQuery('div.inner-nav li div.closing').removeClass('closing').removeClass('open').slideUp().parent().removeClass('open');
	}
    });
    $('div.inner-nav div.content').hide();
    $('div.inner-nav li:eq(0)').addClass('open').children('div.content').show().addClass('open');
});
