jQuery(window).load(function () {
	setTimeout("clearInput('#search-input')",100);	//clear search box after page load
	setTimeout("clearInput('#login-username')",100);	
	setTimeout("clearInput('#login-password')",100);	
});

jQuery(document).ready(function(){
	jQuery("#search-input").focus(function() {
		jQuery("#search-input").css("background","#ffffff");
	});	
	jQuery("#search-input").blur(function() {
		if(jQuery("#search-input").val()=='') 
			jQuery("#search-input").css("background-image","url(/fls/14100/site_graphics/bg-search-box.jpg)").css("background-repeat","no-repeat");
	});
	jQuery("#login-username").focus(function() {
		jQuery("#login-username").css("background","#ffffff");
	});	
	jQuery("#login-username").blur(function() {
		if(jQuery("#login-username").val()=='') 
			jQuery("#login-username").css("background-image","url(/fls/14100/site_graphics/bg-email.jpg)").css("background-repeat","no-repeat");
	});
	jQuery("#login-password").focus(function() {
		jQuery("#login-password").css("background","#ffffff");
	});	
	jQuery("#login-password").blur(function() {
		if(jQuery("#login-password").val()=='') 
			jQuery("#login-password").css("background-image","url(/fls/14100/site_graphics/bg-password.jpg)").css("background-repeat","no-repeat");
	});
});

function clearInput(jSelector) {
	jQuery(jSelector).val('');
}

/******************************************************************************
	START Fix Column height
******************************************************************************/

jQuery(document).ready(function(){
	leftColumnHeight = jQuery("#content .inner .left-col").height();
	rightColumnHeight = jQuery("#content .inner .right-col").height();
	if(rightColumnHeight>leftColumnHeight)
		jQuery("#content .inner .left-col").css("height",rightColumnHeight+"px");
});

/******************************************************************************
	END Fix Column height
******************************************************************************/

/******************************************************************************
	START Section Menu Fix
******************************************************************************/

jQuery(document).ready(function(){
	c_sectionMenu = jQuery("#section-menu");	//cache obj for jquery
	c_sectionMenuContainer = jQuery("#section-menu-contianer");	//cache obj for jquery
	c_sectionMenuAutoPosition = jQuery("#content");	//cache obj for jquery
	
	/*Auto Absolute position menu from body tag, gets menu on top of all over site content*/
	if(c_sectionMenu.length>0) {
		c_sectionMenuContainer.css({'position':'absolute'});
		jQuery("body").prepend(c_sectionMenuContainer);
		c_listMenuAutoPosition();
		jQuery(window).resize(function () { 
	     	c_listMenuAutoPosition();;
	   	});
	}
});

jQuery(window).load(function() {
	if(c_sectionMenu.length>0)
		c_listMenuAutoPosition();
});

function c_listMenuAutoPosition() {
	menuPos = c_sectionMenuAutoPosition.position();
	menuHeight = c_sectionMenuContainer.height();
	menuNewTop = menuPos.top - menuHeight;
	newMenuTop = menuPos.top;
	newMenuTop = 270;
	c_sectionMenuContainer.css({
		'position':'absolute',
		'z-index':'9000',
		'top':newMenuTop+'px',
		'left':menuPos.left+'px',
		'display':'block'
	});
}
/******************************************************************************
	END Section Menu Fix
******************************************************************************/

/******************************************************************************
	START Rotator
******************************************************************************/
var rotActive = true;
var rotCurrent = 0;
var rotSeconds = 8;
var rotVideoPlaying = false;
var rotTime = 1000 * rotSeconds;
jQuery(document).ready(function(){
	if(jQuery("#rotator .story").length>1)
		rotStartRotate();
});

function rotStartRotate() {
	
	if(rotActive)
		setInterval("rotRotate()",rotTime);	
}

function rotRotate() {
	if(rotActive) {
		total = jQuery("#rotator .story").length;
		if((rotCurrent + 1) == total) {
			rotCurrent = 0;
			rotSelectArticle(rotCurrent);
		}
		else {
			rotCurrent ++;
			rotSelectArticle(rotCurrent);
		}	
	}
}

function rotClickArticle(num) {
	rotActive = false;
	rotSelectArticle(num);
}

function rotSelectArticle(num) {
	var rotator = jQuery("#rotator");
	jQuery(".main-image",rotator).removeClass("active");
	jQuery(".main-image:eq("+num+")",rotator).addClass("active");
	jQuery(".text",rotator).removeClass("active");
	jQuery(".text:eq("+num+")",rotator).addClass("active");
	jQuery(".story",rotator).removeClass("active");
	jQuery(".story:eq("+num+")",rotator).addClass("active");
}

function rotPlayVideo(videoId) {
	rotActive = false;
	rotVideoPlaying = true;
	jQuery("#neulion-video").css("display","block");
    neulionPlayer(videoId);
    jQuery("#rotator .video-close").show();
}
	
function rotStopVideo() {
	rotVideoPlaying = false;
	if(jQuery("#jtvshlembed").length>0) {
		try {document.getElementById('jtvshlembed').pauseVideo();}
		catch(ex) {setTimeout("rotStopVideo()",1000);}
	}
	jQuery("#neulion-video").hide();
	jQuery("#jtvshlAdContainer").hide();
	jQuery("#rotator .video-close").hide();
}
/******************************************************************************
	END Rotator
******************************************************************************/




/******************************************************************************
	START schedule-results
******************************************************************************/

jQuery(document).ready(function(){
	scheduleSlider = jQuery("#schedule-results #schedule");
	resultsSlider = jQuery("#schedule-results #results");
	
	setupScrollEvents(scheduleSlider,'.scroll-up','.scroll-down','.slide',5,20);
	setupScrollEvents(resultsSlider,'.scroll-up','.scroll-down','.slide',5,20);
});

/*
	IN:
	jParent - jQuery object containing the scrolling area
	jUp - jQuery object that you click for slide up
	jDown - jQuery object that you click for slide down
	jScroller - jQuery object that actually slides up/down
	increment - number of pixels to move by
	time - how often to move
*/
function setupScrollEvents(jParent,jUp,jDown,slider,increment,time) {
	var jScroller = jQuery(slider,jParent);
	jQuery(jUp,jParent).mousedown(function() {
		jScroller.addClass("sliding-up");
		slideUpDown(jScroller,increment,time,'up');
	}).mouseup(function() {
		jScroller.removeClass("sliding-up");
	}).dblclick(function() {
		jScroller.css("top","0px");
	});
	jQuery(jDown,jParent).mousedown(function() {
		jScroller.addClass("sliding-down");
		slideUpDown(jScroller,increment,time,'down')
	}).mouseup(function() {
		jScroller.removeClass("sliding-down");
	}).dblclick(function() {
		scrollerParentHeight = jScroller.parent().height();
		scrollerHeight = jScroller.height();
		maxScroll = scrollerHeight - scrollerParentHeight;
		jScroller.css("top","-"+maxScroll+"px");
	});
}

function slideUpDown(jScroller,increment,time,direction) {
	local_jScroller = jScroller;local_increment = increment;local_time = time;local_direction = direction;
	scrollerTop = parseInt(jScroller.css("top").substr(0,jScroller.css("top").length-2));
	scrollerParentHeight = jScroller.parent().height();
	scrollerHeight = jScroller.height();
	maxScroll = scrollerHeight - scrollerParentHeight;
	if( (direction=='up') && (jScroller.hasClass("sliding-up")) ) {
		if(Math.abs(scrollerTop)>increment) {
			jScroller.css("top",(scrollerTop + increment)+"px");
			setTimeout('slideUpDown(local_jScroller,local_increment,local_time,local_direction)',local_time);
		}
		else { jScroller.css("top","0px"); }	
	}
	else if( (direction=='down') && (jScroller.hasClass("sliding-down")) ) {
		if((maxScroll-increment) > Math.abs(scrollerTop)) {
			jScroller.css("top",(scrollerTop - increment)+"px");
			setTimeout('slideUpDown(local_jScroller,local_increment,local_time,local_direction)',local_time);
		}
		else { jScroller.css("top","-"+maxScroll+"px"); }
	}
}



/******************************************************************************
	END schedule-results
******************************************************************************/

/******************************************************************************
	START corp-sponsors
******************************************************************************/
jQuery(document).ready(function(){
	buildCorpSponsorsSlider();
	jQuery("#slider-corp-ads").easySlider({
		trigger: 'slider-corp-ads-data',
		firstShow: true,
		lastShow: true,
		auto: false,
		continuous: true,
		pause: 10000,
		speed: 1000
	});
	jQuery("#corporate-sponsors .control-left").click(function () {
		jQuery("#prevBtn").trigger("click");	
	});
	jQuery("#corporate-sponsors .control-right").click(function () {
		jQuery("#nextBtn").trigger("click");	
	});
});
function buildCorpSponsorsSlider() {
	objAds = jQuery("#corporate-sponsors div.ad-loader div.ad");	
	current = 1;currentGroup = 1;groupSize = 6;
	for(x=0;x<objAds.length;x++) {
		if(current==1) {jQuery("#corporate-sponsors ul").append('<li class="group'+currentGroup+'"></li>');	}
		jQuery("#corporate-sponsors ul li.group"+currentGroup).append(jQuery(objAds)[x]);
		if((current==1) || (current==2) || (current==3) || (current==4) || (current==5)) {jQuery("#corporate-sponsors ul li.group"+currentGroup).append('<div class="divider"></div>');}
		if(current==groupSize) {current = 1;currentGroup ++;}
		else {current ++;	}
	}
	jQuery("#corporate-sponsors").animate({height:"143px",opacity:"1"},1000);	
}
/******************************************************************************
	END corp-sponsors
******************************************************************************/

/******************************************************************************
	START our-sponsors
******************************************************************************/
jQuery(document).ready(function(){
	
	var ourSponsorsAds = jQuery("#our-sponsors .content .ad-our-sponsors");
	var totalOurSponsorAds = ourSponsorsAds.length;
	var currentOurSponsorsAd = jQuery("#our-sponsors .data .current").html();
	jQuery("#our-sponsors .header .scroll-up").click(function() {
		if(totalOurSponsorAds>0) {
			if(currentOurSponsorsAd==0) {
				currentOurSponsorsAd = totalOurSponsorAds - 1;
				ourSponsorsAds.hide();
				jQuery("#our-sponsors .content .ad-our-sponsors:eq("+currentOurSponsorsAd+")").show();
			}
			else {
				currentOurSponsorsAd --;
				ourSponsorsAds.hide();
				jQuery("#our-sponsors .content .ad-our-sponsors:eq("+currentOurSponsorsAd+")").show();	
			}
		}
	});	
	jQuery("#our-sponsors .header .scroll-down").click(function() {
		if(totalOurSponsorAds>0) {
			if(currentOurSponsorsAd==(totalOurSponsorAds-1)) {
				currentOurSponsorsAd = 0;
				ourSponsorsAds.hide();
				jQuery("#our-sponsors .content .ad-our-sponsors:eq("+currentOurSponsorsAd+")").show();
			}
			else {
				currentOurSponsorsAd ++;
				ourSponsorsAds.hide();
				jQuery("#our-sponsors .content .ad-our-sponsors:eq("+currentOurSponsorsAd+")").show();	
			}
		}
	});	
});

/******************************************************************************
	END our-sponsors
******************************************************************************/

/******************************************************************************
	START exclusively-on-goislanders
******************************************************************************/
jQuery(document).ready(function(){
	buildExclusielyModeule();
});

function sliderPagination(i) {
	i = i-1;
	jQuery("#exclusively-on-goislanders .dot").removeClass("active");
	jQuery("#exclusively-on-goislanders .dot:eq("+i+")").addClass("active");
}

function buildExclusielyModeule() {
	contents = jQuery("#exclusively-on-goislanders .exclusivley-module").html();
	jQuery("#exclusively-on-goislanders .content ul").html(contents);
	
	jQuery("#exclusively-on-goislanders .content").easySlider({
		trigger: 'slider-exclusively-data',
		firstShow: true,
		lastShow: true,
		auto: false,
		continuous: true,
		pause: 10000,
		speed: 1000,
		nextId : 'exclusivelyNextBtn',
		prevId : 'exclusivelyPrevBtn',
		pagination : true
	});
	jQuery("#exclusively-on-goislanders .control-left").click(function () {
		jQuery("#exclusivelyPrevBtn").trigger("click");	
	});
	jQuery("#exclusively-on-goislanders .control-right").click(function () {
		jQuery("#exclusivelyNextBtn").trigger("click");	
	});
}

/******************************************************************************
	END exclusively-on-goislanders
******************************************************************************/

/******************************************************************************
	START sport-schedule-results
******************************************************************************/
jQuery(document).ready(function(){
	sportScheduleScroll = jQuery("#sport-schedule-results .sport-schedule");
	setupScrollEvents(sportScheduleScroll,'#schedule-scroll-up','#schedule-scroll-down','.scroll',5,20);
});

/******************************************************************************
	END sport-schedule-results
******************************************************************************/