/* Detecting Iphone */
function isiPhone(){
    return (
        (navigator.platform.indexOf("iPhone") != -1) ||
        (navigator.platform.indexOf("iPod") != -1)
    );
}
/* Mega menu configuration and functions */
var megaConfig = { interval: 50, sensitivity: 4, over: addMega, timeout: 100, out: removeMega };
function addMega(){
	jQuery(this).find('div.mega').css('left','0px'); //Find sub and fade it in
	jQuery(this).find('div.mega').stop().fadeTo('fast', 1).show(); //Find sub and fade it in
}
function removeMega(){
	jQuery(this).find('div.mega').stop().fadeTo('fast', 0, function() { //Fade to 0 opactiy
		jQuery(this).hide();  //after fading, hide it
		jQuery(this).find('div.mega').css('left','-9999px'); //Find sub and fade it in
	});
}
jQuery(document).ready(function() {
	/* Activate hoverintent dropdown nav menu */
	jQuery('ul#menu li').hoverIntent(megaConfig);
	/* If IE6 then add hover class to li elements and add png fix */
	if(jQuery.browser.msie && jQuery.browser.version.substr(0,1)<7) {
		jQuery('ul#menu li').hover(function() {
			jQuery(this).addClass('hover');
		}, function() {
			jQuery(this).removeClass('hover');
		});
	}
	/* Hide all submenus so they fade proper when first hovered.  Otherwise the first hover is a snap, not a fade. */
	jQuery('ul#menu li').find('div.mega').stop().hide();
	/* Activate the Nivo Slider */
	jQuery('.nivoSlider').nivoSlider({
        effect:'fade', //Specify sets like: 'fold,fade,sliceDown'
        slices:15,
        animSpeed:500, //Slide transition speed
        pauseTime:5000,
        startSlide:0, //Set starting Slide (0 index)
        directionNav:true, //Next & Prev
        directionNavHide:true, //Only show on hover
        controlNav:true, //1,2,3...
        controlNavThumbs:true, //Use thumbnails for Control Nav
        controlNavThumbsFromRel:false, //Use image rel for thumbs
        controlNavThumbsSearch: '-900x504.jpg', //Replace this with...
        controlNavThumbsReplace: '-88x88.jpg', //...this in thumb Image src
        keyboardNav:true, //Use left & right arrows
        pauseOnHover:true, //Stop animation while hovering
        manualAdvance:false, //Force manual transitions
        captionOpacity:0.8, //Universal caption opacity
        beforeChange: function(){},
        afterChange: function(){},
        slideshowEnd: function(){}, //Triggers after all slides have been shown
        lastSlide: function(){}, //Triggers when last slide is shown
        afterLoad: function(){} //Triggers when slider has loaded
    });
	/* Activate the Nivo Slider for Folio Slideshows */
	jQuery('.nivoSlideshow').nivoSlider({
        effect:'fade', //Specify sets like: 'fold,fade,sliceDown'
        slices:15,
        animSpeed:500, //Slide transition speed
        pauseTime:7000,
        startSlide:0, //Set starting Slide (0 index)
        directionNav:false, //Next & Prev
        directionNavHide:true, //Only show on hover
        controlNav:false, //1,2,3...
        controlNavThumbs:false, //Use thumbnails for Control Nav
        controlNavThumbsFromRel:false, //Use image rel for thumbs
        controlNavThumbsSearch: '.jpg', //Replace this with...
        controlNavThumbsReplace: '.jpg', //...this in thumb Image src
        keyboardNav:false, //Use left & right arrows
        pauseOnHover:false, //Stop animation while hovering
        manualAdvance:false, //Force manual transitions
        captionOpacity:0.0, //Universal caption opacity
        beforeChange: function(){},
        afterChange: function(){},
        slideshowEnd: function(){}, //Triggers after all slides have been shown
        lastSlide: function(){}, //Triggers when last slide is shown
        afterLoad: function(){} //Triggers when slider has loaded
    });
	 if(isiPhone()) {
		 jQuery('.hidevideo').hover(function() {
			 $('video').hide();
		 },function() {
			 $('video').show();
		 });
	 }
});
