$(document).ready(function(){

if($('.slideshow').length){$('.slideshow').cycle({fx:'fade'});}

if($('.news_slideshow').length){$('.news_slideshow').cycle({fx:'fade',speed:1000,timeout:5000,sync:0,pause:1});}

function formatTitle(title, currentArray, currentIndex, currentOpts) {
	if(title && title.length){
		var theDate=new Date()
    	return "<div id='fancybox-title-over'><span style='float:right; text-align:right'>Right-click image to save/copy<br/>© Ocean Outdoor " + theDate.getFullYear() + "</span>" +  title +  "</div>";
	}
};

$.localScroll();

if($('.lightbox').length){$('.lightbox').fancybox({'padding':0,'transitionIn':'elastic','transitionOut':'elastic','speedIn':750,'speedOut':500,'overlayShow':true,'overlayColor':'#000','easingIn':"easeInOutExpo",'easingOut':"easeInOutExpo","titlePosition":"over",'titleFormat': formatTitle});}
if($('.iframe-video').length){$('.iframe-video').fancybox({'padding':0,'transitionIn':'elastic','transitionOut':'elastic','speedIn':750,'speedOut':500,'overlayShow':true,'overlayColor':'#000','easingIn':"easeInOutExpo",'easingOut':"easeInOutExpo",'width':640,'height':360,'scrolling':'no','type':'iframe'});}
if($('.iframe-youtube').length){$('.iframe-youtube').fancybox({'padding':0,'transitionIn':'elastic','transitionOut':'elastic','speedIn':750,'speedOut':500,'overlayShow':true,'overlayColor':'#000','easingIn':"easeInOutExpo",'easingOut':"easeInOutExpo",'width':640,'height':390,'scrolling':'no','type':'iframe'});}
if($('.iframe-voting').length){$('.iframe-voting').fancybox({'padding':0,'transitionIn':'none','transitionOut':'fade','speedIn':750,'speedOut':500,'overlayShow':true,'overlayColor':'#000','width':420,'height':150,'scrolling':'no','type':'iframe'});}
if($('.inline-lightbox').length){$('.inline-lightbox').fancybox({'overlayShow':true,'overlayColor':'#000'});}
if($('#photoviewer').length){$('#photoviewer').cycle({fx:'fade',timeout:0,speed:200,sync:0});}});function cycleControl(x){$('#photoviewer').cycle(x);$('.selected').removeClass('selected');$('#thumb'+x).addClass('selected');$f().pause()}

function playhtml5movie(h5moviesrc, h5width, h5height, soundOn) {
    if ((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)) || (navigator.userAgent.match(/iPad/i))) {
        document.write('<video src="' + h5moviesrc + '" width="' + h5width + '" height="' + h5height + '"controls ></video>');
    } else {
        document.write('<a href="' + h5moviesrc + '" style="display:block;width:' + h5width + 'px;height:' + h5height + 'px" id="player"></a>');
		if(soundOn){
	        flowplayer("player", "http://www.oceanoutdoor.com/site/wp-content/themes/whiteboard/whiteboard/js/flowplayer-3.2.5.swf", {
	            clip: {
	                autoBuffering: true,
	                volume: 75,
	                onBeforeFinish: function() {
	                    return false;
	                },
	                onStart: function() {
	                    this.setVolume(75);
	                }
	            }
	        });			
		}else{
	        flowplayer("player", "http://www.oceanoutdoor.com/site/wp-content/themes/whiteboard/whiteboard/js/flowplayer-3.2.5.swf", {
	            clip: {
	                autoBuffering: true,
	                volume: 0,
	                onBeforeFinish: function() {
	                    return false;
	                },
	                onStart: function() {
	                    this.setVolume(0);
	                }
	            }
	        });
		}
    }
}
