// scripts in this file do browser sniffing and slideshow functions

$(document).ready(function() {

$('a').focus(function() {
  this.blur();
});   

var browser = {
  version: parseInt(navigator.appVersion),
	isMicrosoft: navigator.appName.indexOf("Microsoft") != -1
	};
var fxSetting = 'fade'; // all but ie
/* ------------------------------------------------- */
if(browser.isMicrosoft){
	fxSetting = 'none'; // ie-only setting
 } // end msie if
/* ------------------------------------------------- */

$(function() {  
  $('#slideshow').cycle({
	prev: '#prev',
 	next: '#next',
	timeout: 0,
	speed: 750,
	fx: fxSetting
}); // end cycle()
}); // end closure()

$(function() {  
  $('#indexShow').cycle({
  random: true,
	timeout: 0,
	speed: 750,
	fx: fxSetting
}); // end cycle()
}); // end closure()

var i = 1;
var globalSlideCount = $('div', '#slideshow').length;
if (globalSlideCount < 1){
globalSlideCount = $('div', '#indexShow').length;
}

function updateCounter(){
  var counterTxt = (i) + ' / ' + globalSlideCount;
  $('#counterTxt').html(counterTxt);
}

updateCounter();

$('#prev').click(function(){
 i--;
 if( i < 1 ){ i = globalSlideCount; }
 updateCounter();
 }); // end #prev.click()

$('#next').click(function(){
 i++;
 if( i > globalSlideCount ){ i = 1; }
 updateCounter();
 }); // end #next.click()

}); // end ready

// the following operates the drop-down menus

$(document).ready(function() {
/* the following disables the CSS :hover property which
   allows function w/o JS but interferes with animate */
$('ul#navbar li.hoverEffect').removeClass('hoverEffect');       	

var openTime = 250; // length of down animation/show
var closeTime = 250; // length of up animation/hide

function showMenu(){
            $(this).children('ul').slideDown(openTime);
										}
function hideMenu(){
            $(this).children('ul').slideUp(closeTime);
            }

var hiConfig = {   // settings for hoverintent    
    sensitivity: 4, // number = sensitivity threshold (must be 1 or higher)    
    interval: 50, // number = milliseconds for onMouseOver polling interval    
    over: showMenu, // function = onMouseOver callback (REQUIRED)    
    timeout: 250, // number = milliseconds delay before onMouseOut    
    out: hideMenu // function = onMouseOut callback (REQUIRED)
};

$('#navbar li').hoverIntent( hiConfig );
   
$('#indexPg #indexShow > div > a > img').hover(
	function(){
		oldSrc = $(this).attr('src');
    var newSrc = oldSrc.slice(11);
    newSrc = "media/home/roll_" + newSrc ;
    $(this).attr('src', newSrc);
    },
   function(){
   	$(this).attr('src', oldSrc);
}); // end hover()

}); // end ready



