$(document).ready(function(){
//In browser-detect.js we check to see if there's any know flash playing browsers, and ff the browser is something unknown (aka mobile) then we run this...
if (BrowserDetect.OS == "an unknown OS")
{
//find all links with .mov in them and...
$("a[href*=.mov]").each(function(){
//replace the .mov with a mobile friendly format of .3gp
this.href = this.href.replace(/\.mov/, ".3gp");
});
};
//Search submission corrections:
$("#ctl00_Top_tm_searchstr").keypress(function(e) {
if ((e.which && e.which == 13) || (e.keyCode && e.keyCode == 13)) {
__doPostBack('ctl00$Top$tm$lbSearch', '')
return false;
} else {
return true;
}
});  
//initiate inFieldLabels plugin and assign to search label in header
$(".search_form label").inFieldLabels();
/*-----------------------------------------
Marquee News Ticker		
-----------------------------------------*/		
//initiate cycle slideshow plugin
$('.news_items').cycle({
speed:		1000,
timeout:	4000,
sync:		0,
pause:		true,
next:   	'.btn_next', 
prev:   	'.btn_prev' 
});
//pause function
pauseTicker = function(){
$('.news_items').cycle('pause');
//swap pause-play button
$('.news_nav .btn_pause').css('display','none');
$('.news_nav .btn_play').css('display','block');
};
//resume function
resumeTicker = function(){
$('.news_items').cycle('resume', true);
//swap pause-play button
$('.news_nav .btn_play').css('display','none');
$('.news_nav .btn_pause').css('display','block');
};
//pause whenever user clicks prev/next/pause nav
$('.news_nav .btn_next').click(function() { 	pauseTicker(); });
$('.news_nav .btn_prev').click(function() { 	pauseTicker(); });
$('.news_nav .btn_pause').click(function() {	pauseTicker(); });
//resume whenever user clicks play btn
$('.news_nav .btn_play').click(function() { 	resumeTicker(); });
/*-----------------------------------------
Marquee Slideshow
-----------------------------------------*/
//FF first slide fix...
slideHeight = $('.slides li').height();
$('.slides li').height(slideHeight);
slideWidth = $('.slides li').width();
$('.slides li').width(slideWidth);
//initiate cycle slideshow plugin
$('.slides').cycle({
speed:		1000,
timeout: 10000,
//pause: true,
pager:		'.slide_nav',
pagerEvent:	'click',
fastOnEvent: 500
});
//pause slideshow whenever user clicks on a slide
$('.slides a').click(function(){ 
$('.marquee .slides').cycle('pause');
});		
//initiate flowplayer plugin on all links on the page that link to a .mov file
//$("a[href*=.mov]").flowplayer("scripts/flowplayer/flowplayer-3.1.5.swf", {
$("a[href*=.mov]").flowplayer("scripts/flowplayer/flowplayer.commercial-3.1.5.swf", {        
key: '#$44cfc423a799358165f',
clip: {
scaling: 'fit'
},       
plugins:  { 
controls: { 
//hide-show controls on unhover-hover
autoHide: 'always', 
//hide all controls and only show play,volume,mute,scrubber, & fullscreen
all: false,
play: true,
volume: true,
mute: true,
scrubber: true,
fullscreen: true,
//controlbar styling
timeColor: '#01DAFF',
volumeSliderColor: '#000000',
tooltipColor: '#5F747C',
backgroundGradient: 'low',
volumeSliderGradient: 'none',
buttonOverColor: '#3b3b3b',
tooltipTextColor: '#ffffff',
sliderGradient: 'none',
sliderColor: '#fafafa',
borderRadius: '0',
buttonColor: '#6b6b6b',
backgroundColor: '#000000',
progressColor: '#303030',
bufferColor: '#4f4f4f',
timeBgColor: '#555555',
bufferGradient: 'none',
durationColor: '#ffffff',
progressGradient: 'medium',
height: 24,
opacity: 0.8
}
},
// perform custom stuff before default click action 
onBeforeClick: function() {       
// unload previously loaded player 
$f().unload();
// get wrapper element as jQuery object 
var wrap = $(this.getParent()); 
//fade starting image out before loading video player
wrap.find("img").fadeOut(1000);
$(".marquee .slide_nav").fadeOut(1000);
//animate flowplayer to full size of container element
wrap.animate({width:"100%", height:"100%"}, 1000, function() { 
// when animation finishes we load our player 
$f(this).load();
}); 
//ignore default click action and do above stuff instead		         
return false;  
}, 
//when loading the flash video player do this stuff
onLoad: function() {
//show "play" btn (in case this is the second video the user is playing)	
this.getPlugin("play").show();		
},
// when playback finishes do this stuff 
onFinish: function() { 
//hide the "replay video" btn
this.getPlugin("play").hide();
//fade out the entire player via container element
$(this.getParent()).fadeOut(1000, function() { 
//swap player with original image
$f().unload();
});
},
// unload action resumes to original state         
onUnload: function() { 
$(".marquee .slide_nav").fadeIn(1000);
//fade in previous hidden container element
$(this.getParent()).fadeIn(1000, function(){
//start the slideshow again
$('.marquee .slides').cycle('resume');
});
}  
});
//unload the video if user clicks on the slideshow page nav
$('.slide_nav a').click(function(){
$f().unload();
});
//initiate cycle slideshow plugin
$('.featureSlideshow').cycle({
fx: 'scrollHorz',
speed: 800,
timeout: 0,
next: '.featureSlideNav .btn_feature-next',
prev: '.featureSlideNav .btn_feature-prev'
		});
	
});

