$(document).ready(function() {

$('ul#recentposts').newsticker().slideDown();

		var fade = $('> div', $('div.fade'));
		fade.show();
                $('#dtit').hide().fadeIn(320,
			function() {
			            if (fade.is(':animated')) {
			                fade.stop().fadeTo(2050, 1);
			            } else {
			                fade.fadeOut(3000);
			            }
			}
		);

        $('.page_item').addClass('ui-state-default ui-corner-top');
        $('.page_item').mouseover(function() { $(this).addClass('ui-state-hover'); }).mouseout(function() { $(this).removeClass('ui-state-hover') } );
        $('.current_page_item, .current_page_parent').addClass('ui-state-active');
        $('.page_item a, #dtit a, #bioLink, #hdBiolink').click(function() { 
                var whichurl = $(this).attr('href');
			$('div.fade').html($('div.fade div').html());
                $('div#content').fadeOut('normal',function() { 
			$('#laccordion div.xontent').hide('fast');
                        /*$('#loading').html('Loading...').fadeIn('slow', function() { */
                        $('#loading').fadeIn('fast', function() { 
                                setTimeout(function() { 
                                        location.href=whichurl; 
                                }, 1); 
                        }) 
                });
                return false;
                });

	$('#laccordion').css('visibility','visible');
	var oOpac = $('#laccordion div.xontent').css('opacity');
	$('#laccordion div.xontent img').mouseover(function() { $('#laccordion div.xontent').css('opacity','1.0'); }).mouseout(function() { $('#laccordion div.xontent').css('opacity',oOpac) });

	$('a.ttop').click(function() { $('#outwrap').ScrollTo(800); $(this).blur(); return false; });

	$('#idSiteMeterHREF').attr('target','_blank').click(function() { $(this).blur(); return false; }).css('cursor','default');
	$('a:has(img)').attr('title', function() { if ($(this).attr('title') == '') { $(this).attr('title', $('img', this).attr('title')) }}); 

	$('.xontent').append('<div class="ffcap">CLICK ON THE PHOTO FOR MORE!</div>');
	var elems = $('.widget_text');
	var randomNum = Math.floor(Math.random() * elems.length);
	$('.widget_text:eq(' + randomNum + ')').css('display','block');
	var cFF = $('.widget_text:eq(' + randomNum + ') img.ffimg');
	var bigFF = '<div style="text-align:center;"><img style="max-width:100%;" src="' + cFF.attr('src') + '" /></div>';
	$('.widget_text:eq(' + randomNum + ') .ffdialog').prepend(bigFF);
        $('.widget_text img.ffimg').css('cursor','pointer').click(function() { 
		$('.widget_text:eq(' + randomNum + ') .ffdialog').dialog({ autoOpen: false, modal: true, resizable: false, draggable: false }); 
		$(".ffdialog").dialog('open'); 
	});

	$("#laccordion div.xeader").click(function() { $('#laccordion div.xontent').toggle('slow'); });


	if ($.browser.msie) {
			if (!$.cookie("msienote")) {
                        	$('#msienote').show();
			}
                        $('#closemsienote').click(function(){
				$('#msienote').hide();
				$.cookie("msienote", "closed", {path: '/'});
			});
                        $('#downloadfirefox').click(function(){window.location='http://firefox.com';});
	}

/*
       var buttz = '<div style="position:absolute;bottom:0;float:left;font-size:90%;"><a href="#carouselPrev" class="leftarrow" title="Previous"><span class="ui-icon ui-icon-circle-arrow-w"></span></a> <a href="#carouselNext" class="rightarrow" title="Next"><span class="ui-icon ui-icon-circle-arrow-e"></span></a></div>';
	$('.accordionInner').prepend(buttz);

$('div.widget_text').fadeOut(0);
$('div.widget_text:first').fadeIn(500);

$('a.leftarrow, a.rightarrow').click( function (ev) {
    //prevent browser jumping to top
    ev.preventDefault();

    //get current visible item
    var $visibleItem = $('div.widget_text:visible');

    //get total item count
    var total =  $('div.widget_text').length;

    //get index of current visible item
    var index = $visibleItem.prevAll().length;

    //if we click next increment current index, else decrease index
    $(this).attr('href') === '#carouselNext' ? index+1 : index-1;

    //if we are now past the beginning or end show the last or first item
    if (index === -1){
       index = total-1;
    }
    if (index === total){
       index = 0
    }

    //hide current show item
    $visibleItem.hide();

    //fade in the relevant item
    $('div.widget_text:eq(' + index + ')').fadeIn(500);

});
*/


}); /* ready */
