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

function ajaxLoadContentDelayed() {
	//loading after load event because image is large
	jQuery("#footer-drippan-box").css("background-image","url('/fls/6100/site_graphics/2010/bg-footer.png')");
	/*
	var ajaxLoadSource = jQuery("img.ajax-load-image");	
	var currentImg = false;
	var total = ajaxLoadSource.length;
	for(var x=0;x<total;x++) {
		currentImg = jQuery("img.ajax-load-image:eq("+x+")");
		currentImg.attr("src",currentImg.attr("ajaxsource")).removeAttr("ajaxsource");
	}
	ajaxLoadSource.removeClass("ajax-load-image");
	*/
}

jQuery(document).ready(function () {

	jQuery('#more-headlines-module-content').cycle({ 
	   fx:      'scrollLeft', 
		speed:    300, 
		timeout:  5000,
		next:   '#more-headlines-module-left', 
		prev:   '#more-headlines-module-right',
		pause:   1
	});
	
	jQuery('#academic-community-module-content').cycle({ 
	   fx:      'scrollLeft', 
		speed:    300, 
		timeout:  5000,
		next:   '#academic-community-module-left', 
		prev:   '#academic-community-module-right',
		pause:   1
	});

	//jQuery("body.article #left-col form input")
	
	jQuery("#quick-links .link").mouseover(function() {
		jQuery(this).addClass('active');
	}).mouseout(function() {
		jQuery(this).removeClass('active');
	});
	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/6100/site_graphics/2010/bg-search.png)");
	});
	
	jQuery("#features .slider").easySlider({
		speed: 1000,
		prevId: "feature-prevId",
		nextId: "feature-nextId",
		prevText: "",
		nextText: "",
		continuous: true,
		pagination: true
	});
	
	jQuery("#video-features .slider").easySlider({
		speed: 1000,
		prevId: "features-prevId-button",
		nextId: "features-nextId-button",
		prevText: "",
		nextText: "",
		continuous: true,
		pagination: false,
		w:632
	});
	
	jQuery("#video-replays .slider").easySlider({
		speed: 1000,
		prevId: "replays-prevId-button",
		nextId: "replays-nextId-button",
		prevText: "",
		nextText: "",
		continuous: true,
		pagination: false,
		w:632
	});
	/**/
	jQuery("#video-highlights .slider").easySlider({
		speed: 1000,
		prevId: "highlights-prevId-button",
		nextId: "highlights-nextId-button",
		prevText: "",
		nextText: "",
		continuous: true,
		pagination: false,
		w:632
	});	
	jQuery("#video-live .slider").easySlider({
		speed: 1000,
		prevId: "live-prevId-button",
		nextId: "live-nextId-button",
		prevText: "",
		nextText: "",
		continuous: true,
		pagination: false,
		w:632
	});	
	
	jQuery("#features-prevId").click(function () {
		//jQuery("#features-prevId-button").trigger("click");
		razorVisionSlide('#video-features .slider','#features-prevId-button','prev','features');	
	});
	jQuery("#features-nextId").click(function () {
		//jQuery("#features-nextId-button").trigger("click");	
		razorVisionSlide('#video-features .slider','#features-nextId-button','next','features');	
	});
	jQuery("#replays-prevId").click(function () {
		//jQuery("#replays-prevId-button").trigger("click");	
		razorVisionSlide('#video-replays .slider','#replays-prevId-button','prev','replays');
	});
	jQuery("#replays-nextId").click(function () {
		//jQuery("#replays-nextId-button").trigger("click");	
		razorVisionSlide('#video-replays .slider','#replays-nextId-button','next','replays');
	});
	jQuery("#highlights-prevId").click(function () {
		//jQuery("#highlights-prevId-button").trigger("click");	
		razorVisionSlide('#video-highlights .slider','#highlights-prevId-button','prev','highlights');
	});
	jQuery("#highlights-nextId").click(function () {
		//jQuery("#highlights-nextId-button").trigger("click");	
		razorVisionSlide('#video-highlights .slider','#highlights-nextId-button','next','highlights');
	});
	jQuery("#live-prevId").click(function () {
		//jQuery("#highlights-prevId-button").trigger("click");	
		razorVisionSlide('#video-live .slider','#live-prevId-button','prev','live');
	});
	jQuery("#live-nextId").click(function () {
		//jQuery("#highlights-nextId-button").trigger("click");	
		razorVisionSlide('#video-live .slider','#live-nextId-button','next','live');
	});
	
	for(var x=0;x<jQuery("#razor-vision .tab-content .slider").length;x++) {
		var tempObject = jQuery("#razor-vision .tab-content .slider:eq("+x+") li:first").addClass("active");	
	}
		
	jQuery("#razor-vision .content .tab-bar .tab").click(function () {
		jQuery("#razor-vision .content .tab-bar .tab").removeClass('active');
		jQuery(this).addClass("active");
		for(x=0;x<jQuery("#razor-vision .content .tab-bar .tab").length;x++) {
			if(jQuery("#razor-vision .content .tab-bar .tab:eq("+x+")").hasClass("active")) {
				razorVisionTabLoad(x);
				break;	
			}
		}
		jQuery("#razor-vision .content .tab-content .videos").removeClass('active');	
		jQuery("#razor-vision .content .tab-content .videos:eq("+x+")").addClass("active");
	});
	
	//ajaxLoadContent();
});



function ajaxLoadContent() {
	
}

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

function getBaseUrl() {
 	urlTokens = window.location.href.split('/');
 	url = urlTokens[0]+'//'+urlTokens[2];
 	return url;
}

function scheduleResultsTab(num) {
	jQuery("#schedule-results .button").removeClass("active");
	jQuery("#schedule-results .button:eq("+num+")").addClass("active");
	jQuery("#schedule-results .content .tab").removeClass("active");
	jQuery("#schedule-results .content .tab:eq("+num+")").addClass("active");
	if(jQuery("#schedule-results .results").hasClass("ajax")) {
		jQuery.ajax({
			type:"POST",
			url:"/ajax.dbml",
			data:"DB_OEM_ID="+ajaxOemId+"&_MODE_=GET_RESULTS&SPID="+ajaxSpid,
			success: function(data) {
				jQuery("#schedule-results .results").removeClass("ajax").html(data);
			}
			,error: function(XMLHttpRequest, textStatus, errorThrown) {
				jQuery("#schedule-results .results").removeClass("ajax");
				//alert("errorThrown:"+errorThrown);
			}
		});
	}
	
}

function storeTab(num) {
	if(jQuery("#store-tabs .ad:eq("+num+")").hasClass('ajax')) {
		jQuery.ajax({
			type:"POST",
			url:"/ajax.dbml",
			data:"DB_OEM_ID="+ajaxOemId+"&_MODE_=STORE_AD"+num+"&SPID="+ajaxSpid,
			success: function(data) {
				jQuery("#store-tabs .ad:eq("+num+")").html(data).removeClass("ajax");
			}
			,error: function(XMLHttpRequest, textStatus, errorThrown) {
				jQuery("#store-tabs .ad:eq("+num+")").removeClass("ajax");
				alert("errorThrown:"+errorThrown);
			}
		});	
	}

	jQuery("#store-tabs .ad").removeClass("active");
	jQuery("#store-tabs .ad:eq("+num+")").addClass("active");
	jQuery("#store-tabs .tabs img").css('top','-'+(num*34)+'px');
}

function razorVisionSlide(jSelector,clickSelector,direction,tab) {
	var jObject = jQuery(jSelector);
	var start = 0;
	var end = 0;
	var total = 0;
	var current = 0;
	
	var total = jQuery("li",jObject).length;
	for(var x=0;x<total;x++) {
		if(jQuery("li:eq("+x+")",jObject).hasClass("active")) {
			current = x;
			break;	
		}	
	}
	if(direction=='next') {
		if(current!=(total-1)) 
			current ++;
		else 
			current = 0;
	}
	else {
		//prev	
		if(current!=0)
			current --;
		else 
			current = total-1;	
	}
	
	if(!jQuery("li",jObject).hasClass('ajax')) {
		//no ajax
		jQuery("li",jObject).removeClass("active");
		jQuery("li:eq("+current+")",jObject).addClass("active");
		jQuery(clickSelector).trigger("click");
	}
	else {
		//ajax
		jQuery("li",jObject).removeClass("active");
		jQuery("li:eq("+current+")",jObject).addClass("active");
		jQuery(clickSelector).trigger("click");
		
		if(jQuery("li:eq("+current+")",jObject).hasClass('ajax')) {
			jQuery("li:eq("+current+") .data",jObject).html('');
			//var maxSize = jQuery(jSelector+" li:eq(0) div.video").length;
			var maxSize = 4;
			start = ((current+1) * maxSize) - maxSize + 1;
			var end = start + (maxSize-1);
			//end = start + total;
			//console.log("maxSize:"+maxSize);
			//console.log("start:"+start);
			//console.log("end:"+end);
			jQuery.ajax({
				type:"POST",
				url:"/ajax.dbml",
				data:"DB_OEM_ID="+ajaxOemId+"&_MODE_=GET_RAZOR_VISION&SPID="+ajaxSpid+"&START="+start+"&END="+end+"&TAB="+tab,
				success: function(data) {
					jQuery(jSelector+" li:eq("+current+") .data").html(data);
					jQuery(jSelector+" li:eq("+current+")").removeClass("ajax");
					//jQuery("#features li:eq("+index+")").html(data);
					razorVisionReplaceLoading(jQuery(jSelector+" li:eq("+current+")"),0);
				}
				,error: function(XMLHttpRequest, textStatus, errorThrown) {
					jQuery(jSelector+" li:eq("+current+")").removeClass("ajax");
					alert("errorThrown:"+errorThrown);
				}
			});	
		}
	}
}

function razorVisionTabLoad(num) {
	var jSelector = '';
	var tab = ''
	switch (num) {
		case 1:
			tab = 'replays';
			jSelector = '#video-replays .slider';
			//razorVisionReplaceLoading(jQuery('#video-replays .slider li:eq(0)'),0,0)
			break;
		case 2:
			tab = 'highlights';
			jSelector = '#video-highlights .slider';
			//razorVisionReplaceLoading(jQuery('#video-highlights .slider li:eq(0)'),0,0)
			break;
		case 3:
			tab = 'live';
			jSelector = '#video-live .slider';
			//razorVisionReplaceLoading(jQuery('#video-highlights .slider li:eq(0)'),0,0)
			break;
		
	}
	
	var jObject = jQuery(jSelector);
	//var maxSize = jQuery(jSelector+" li:eq(0) div.video").length;
	var maxSize = 4;
	var start = 1;
	var end = start + (maxSize-1);
	//console.log("start:"+start);
	//console.log("end:"+end);
	if(jQuery("li:first",jObject).hasClass('ajax')) {
		jQuery.ajax({
			type:"POST",
			url:"/ajax.dbml",
			data:"DB_OEM_ID="+ajaxOemId+"&_MODE_=GET_RAZOR_VISION&SPID="+ajaxSpid+"&START="+start+"&END="+end+"&TAB="+tab,
			success: function(data) {
				jQuery(jSelector+" li:eq(0) .data").html(data);
				jQuery(jSelector+" li:eq(0)").removeClass("ajax");
				//jQuery("#features li:eq("+index+")").html(data);
				razorVisionReplaceLoading(jQuery(jSelector+" li:eq(0)"),0);
			}
			,error: function(XMLHttpRequest, textStatus, errorThrown) {
				jQuery(jSelector+" li:eq(0)").removeClass("ajax");
				alert("errorThrown:"+errorThrown);
			}
		});	
	}
}

function sliderPagination(num) {
	var index = num - 1;
	if(jQuery("#features li:eq("+index+")").hasClass("ajax")) {
		var start = 0;
		var end = 0;
		var maxSize = jQuery("#features li:eq(0) div.item").length;
		var total = jQuery("#features li:eq("+index+") div.item").length;
		start = (num * maxSize) - maxSize + 1;
		end = start + total - 1;
		jQuery.ajax({
			type:"POST",
			url:"/ajax.dbml",
			data:"DB_OEM_ID="+ajaxOemId+"&_MODE_=GET_FEATURES&SPID="+ajaxSpid+"&START="+start+"&END="+end,
			success: function(data) {
				jQuery("#features li:eq("+index+") .data").html(data);
				//jQuery("#features li:eq("+index+")").removeClass("ajax");
				//jQuery("#features li:eq("+index+")").html(data);
				featuresReplaceLoading(jQuery("#features li:eq("+index+")"),0,0);
			}
			,error: function(XMLHttpRequest, textStatus, errorThrown) {
				jQuery("#features li:eq("+index+")").removeClass("ajax");
				alert("errorThrown:"+errorThrown);
			}
		});
	}
	else {
		//do nothing	
	}
}

function razorVisionReplaceLoading(jObject,num2) {
	//console.log("featuresReplaceLoading");
	//console.log("num:"+num);
	//console.log("num2:"+num2);
	var total = jQuery(".data .video",jObject).length;
	//console.log("total:"+total);
	var tempHtml = jQuery(".data .video:eq("+num2+")",jObject).html();
	//console.log("tempHtml:"+tempHtml);

	jQuery(".video:eq("+num2+")",jObject).animate({
		opacity:'0'
	},200,function () {
		//jQuery(this).html(tempHtml).css("opacity","1");
		jQuery(this).html(tempHtml).animate({
			opacity:'1'
		},100);
		if(num2<(total-1)) {
			razorVisionReplaceLoading(jObject,num2+1);	
		}
		else {
			jObject.removeClass("ajax");
		}
	});
	//console.log("--------------");
}

function featuresReplaceLoading(jObject,num,num2) {
	//console.log("featuresReplaceLoading");
	//console.log("num:"+num);
	//console.log("num2:"+num2);
	var total = jQuery(".data:eq("+num+") .item",jObject).length;
	//console.log("total:"+total);
	var tempHtml = jQuery(".data:eq("+num+") .item",jObject).html();
	//console.log("tempHtml:"+tempHtml);

	jQuery(".item:eq("+num2+")",jObject).animate({
		opacity:'0'
	},200,function () {
		//jQuery(this).html(tempHtml).css("opacity","1");
		jQuery(this).html(tempHtml).animate({
			opacity:'1'
		},100);
		if(num2<(total-1)) {
			featuresReplaceLoading(jObject,num,num2+1);	
		}
		else {
			jObject.removeClass("ajax");
		}
	});
}

/******************************************************************************
	START rotator
******************************************************************************/

var rotObject = {
	current : 0,
	last : 0,
	total : 5,
	interval : 10000,
	rotate : true,
	playingVideo : false,
	next : 1,
	previous : 4,
	oemid : 6100,
	videoIcon : '<img class="play" src="'+ajaxFlsPath+'small-play-button.png">'
};

jQuery(document).ready(function () {
	buildRotator();
	jQuery("#rotator .play-button").click(function () {
		rotPlayVideo();	
	});
	jQuery("#rotator .video-close").click(function () {
		rotStopVideo();
	});	
	if(jQuery("#rotator").length) {
		setInterval("rotRotator()",rotObject.interval);
	}
	jQuery("#rotator .sub-stories .image").click(function () {
		//console.log(jQuery(this));
		jQuery(this).addClass("active");
		var totalStories = jQuery("#rotator .sub-stories .image").length;
		for(var x=0;x<totalStories;x++) {
			if(jQuery("#rotator .sub-stories .image:eq("+x+")").hasClass("active")) {
				break;
			}
		}
		rotObject.rotate = false;
		rotObject.last = rotObject.current;
		rotObject.current = x;
		jQuery(this).removeClass("active");
		rotStory();
	});
});

function rotRotator() {
	if(rotObject.rotate) {
		rotForward();	
	}
}


function buildRotator() {
	var jRotator = jQuery("#rotator");
	var largeImage = '';
	var subStory = '';
	var subStoryImage = '';
	var sportName = '';
	var headline = '';
	var videoId = '';
	var buyPhoto = '';
	var teaser = '';
	var articleId = '';
	var videoIds = '';
	var photoAlbumId = '';
	var fullstory = '';
	var videoIcon = '';
	var totalStories = jQuery(".data .large-image",jRotator).length;
	var articleImageLink = '';
	var relatedLinks = '';
	var liveNow = '';
	
	for(var x=0;x<totalStories;x++) {
		videoIcon = '';
		articleId = jQuery(".data:eq("+x+") .articleId",jRotator).html();
		headline = jQuery(".data:eq("+x+") .headline",jRotator).html();
		largeImage = jQuery(".data:eq("+x+") .large-image",jRotator).html();
		subStoryImage = jQuery(".data:eq("+x+") .small-image",jRotator).html();
		sportName = jQuery(".data:eq("+x+") .sport-name",jRotator).html();
		buyPhoto = jQuery(".data:eq("+x+") .buyPhoto",jRotator).html();
		teaser = jQuery(".data:eq("+x+") .teaser",jRotator).html();
		fullstory = jQuery(".data:eq("+x+") .fullstory",jRotator).html();
		photoAlbumId = jQuery(".data:eq("+x+") .photoAlbumId",jRotator).html();	
		videoId = jQuery(".data:eq("+x+") .videoId",jRotator).html();	
		relatedVideos = jQuery(".data:eq("+x+") .relatedVideos",jRotator).html();	
		articleImageLink = jQuery(".data:eq("+x+") .articleImageLink",jRotator).html();	
		relatedLinks = jQuery(".data:eq("+x+") .related-links",jRotator).html();	
		liveNow = jQuery(".data:eq("+rotObject.current+") .livenowbutton",jRotator).html();	
		
		if(x==0) {
			if(videoId>0) {
				jQuery(".play-button",jRotator).show();
				videoIcon = rotObject.videoIcon;
			}
			jQuery(".overlay .title",jRotator).html(headline);
			jQuery(".overlay .teaser",jRotator).html(teaser+fullstory);
			//largeImage = '<img class="rot-image active" src="'+largeImage+'">';
			largeImage = articleImageLink;
			subStory = '<li class="sub-story inactive"><div class="content-sub-story"><div class="image">'+videoIcon+'<img src="'+subStoryImage+'"></div><div class="sport">'+sportName+'</div></div></li>';
			/*
			if(relatedVideos>'') {
				videoIds = relatedVideos.split("|");
				jQuery(".overlay .links",jRotator).append('<a class="overlay-link" href="/mediaPortal/player.dbml?DB_OEM_ID='+ajaxOemId+'&id='+videoIds[1]+'">&gt; Video</a>&nbsp;');
			}
			
			if(photoAlbumId>'') {
				jQuery(".overlay .links",jRotator).append('<a class="overlay-link" href="/PhotoAlbum.dbml?DB_OEM_ID='+ajaxOemId+'&PALBID='+photoAlbumId+'">&gt; Photo Album</a>&nbsp;');
			}
			*/
			
			jQuery("#livenow-button").html(liveNow);
			
			if(buyPhoto>'') {
				//Pictopia
				photoVars = buyPhoto.split("|");
				jQuery("#buy-this-photo").html('<a href="javascript:goPtp(\''+photoVars[0]+'\',\''+photoVars[1]+'\',\''+photoVars[2]+'\',\''+photoVars[3]+'\',\''+photoVars[4]+'\');">&gt; Buy This Photo</a>');
				/*
				//Replay Photos
				jQuery("#buy-this-photo").append('<a href="javascript:goToReplayPhotos('+buyPhoto+');">&gt; Buy This Photo</a>');
				*/
				jQuery("#buy-this-photo").show();
			}
			if(relatedLinks>'') {
				jQuery(".overlay .links",jRotator).append(relatedLinks);
			}
		}
		else {
			if(videoId>0) {
				videoIcon = rotObject.videoIcon;	
			}
			//largeImage = '<img class="rot-image ajax-load-image" src="'+largeImage+'">';
			largeImage = articleImageLink;
			subStory = '<li class="sub-story"><div class="content-sub-story"><div class="image">'+videoIcon+'<img src="'+subStoryImage+'"></div><div class="sport">'+sportName+'</div></div></li>';
		}
		jQuery(".count",jRotator).html('<span class="current">1</span>/'+totalStories);
		jQuery("div.main-image",jRotator).append(largeImage);
		jQuery("div.sub-stories ul",jRotator).append(subStory);
	}
	
	rotObject.current = rotFindCurrent();
	rotObject.total = totalStories;
	
	//show built rotator
	var rotatorHeight = jRotator.height();
	jRotator.css("height","0px").css("display","block").animate({
		height:rotatorHeight+"px"
	},500);
}

function rotFindCurrent() {
	var totalStories = jQuery("#rotator .data .large-image").length;
	for(var x=0;x<totalStories;x++) {
		if(jQuery("#rotator .rot-image:eq("+x+")").hasClass("active")) {
			break;
		}
	} 
	return x;
}

function rotPlayVideo() {
	rotObject.current = rotFindCurrent();
	rotObject.rotate = false;
	rotObject.playingVideo = true;
	jQuery("#neulion-video").css("display","block");
	videoId = jQuery("#rotator .data:eq("+rotObject.current+") .videoId").html();
	neulionPlayer(videoId);
 	jQuery("#rotator .video-close").show();
}
	
function rotStopVideo() {
	rotObject.playingVideo = false;
	if(jQuery("#jtvshlembed").length>0) {
		try {document.getElementById('jtvshlembed').pauseVideo(); 
		/*slProxy("hide")*/;
		}
		catch(ex) {/*setTimeout("rotStopVideo()",1000);*/}
	}
	jQuery("#neulion-video").hide();
	jQuery("#jtvshlAdContainer").hide();
	jQuery("#rotator .video-close").hide();
	
}

function rotStory() {
	//jQuery(".overlay .links",jRotator).html('');
	var headline = '';
	var jRotator = jQuery("#rotator");
	var relatedVideos = jQuery(".data:eq("+rotObject.current+") .relatedVideos",jRotator).html();	
	var photoAlbumId = jQuery(".data:eq("+rotObject.current+") .photoAlbumId",jRotator).html();
	var videoId = jQuery(".data:eq("+rotObject.current+") .videoId",jRotator).html();	
	var relatedLinks = jQuery(".data:eq("+rotObject.current+") .related-links",jRotator).html();
	var liveNow = jQuery(".data:eq("+rotObject.current+") .livenowbutton",jRotator).html();		
	//main image
	if(videoId>0) {
		jQuery(".play-button",jRotator).fadeIn(500);
	}
	else {
		jQuery(".play-button",jRotator).fadeOut(500);
	}
	
	jQuery("#livenow-button").html(liveNow);
	
	jQuery(".rot-image:eq("+rotObject.current+")",jRotator).addClass("next");
	jQuery(".rot-image:eq("+rotObject.last+")",jRotator).animate({
		opacity:"0"	
	},1000,function() {
		jQuery(".rot-image:eq("+rotObject.current+")",jRotator).addClass("active").removeClass("next");
		jQuery(this).removeClass("active").css("opacity",1);
	});
	/*
	if(relatedVideos>'') {
		videoIds = relatedVideos.split("|");
		jQuery(".overlay .links",jRotator).append('<a class="overlay-link" href="/mediaPortal/player.dbml?DB_OEM_ID='+ajaxOemId+'&id='+videoIds[1]+'">&gt; Video</a>&nbsp;');
	}
	if(photoAlbumId>'') {
		jQuery(".overlay .links",jRotator).append('<a class="overlay-link" href="/PhotoAlbum.dbml?DB_OEM_ID='+ajaxOemId+'&PALBID='+photoAlbumId+'">&gt; Photo Album</a>&nbsp;');
	}
	*/
	/*
	if(relatedLinks>'') {
		
	}
	*/
	//buy photo
	jQuery("#buy-this-photo").animate({
		height:"0px"
	},500,function() {
		var buyPhoto = jQuery(".data:eq("+rotObject.current+") .buyPhoto",jRotator).html();
		if(buyPhoto>'') {
			//Pictopia
			photoVars = buyPhoto.split("|");
			jQuery("#buy-this-photo").html('<a href="javascript:goPtp(\''+photoVars[0]+'\',\''+photoVars[1]+'\',\''+photoVars[2]+'\',\''+photoVars[3]+'\',\''+photoVars[4]+'\');">&gt; Buy This Photo</a>');
			/*
			//Replay Photos
			jQuery("#buy-this-photo").append('<a href="javascript:goToReplayPhotos('+buyPhoto+');">&gt; Buy This Photo</a>');
			*/
			//jQuery("#buy-this-photo").show();
			jQuery(this).animate({
				height:"23px"
			},500);	
		}
		else {
			jQuery("#buy-this-photo").html('');
		}
	});
	
	//overlay content
	var overlayHeight = jQuery(".overlay",jRotator).height();
	jQuery(".overlay",jRotator).animate({
		height:"0px"
	},500,function() {
		
		jQuery(".sub-stories ul li",jRotator).removeClass("inactive");
		jQuery(".sub-stories ul li:eq("+rotObject.current+")",jRotator).addClass("inactive");
		headline = jQuery(".data:eq("+rotObject.current+") .headline",jRotator).html();
		teaser = jQuery(".data:eq("+rotObject.current+") .teaser",jRotator).html();
		fullstory = jQuery(".data:eq("+rotObject.current+") .fullstory",jRotator).html();
		jQuery(".overlay .title",jRotator).html(headline);
		jQuery(".overlay .teaser",jRotator).html(teaser+fullstory);
		jQuery(".overlay .count .current",jRotator).html(rotObject.current+1);
		jQuery(".overlay .links",jRotator).html(relatedLinks);
		jQuery(this).animate({
			height:overlayHeight+"px"
		},500);
	});
}

function rotForwardButton() {
	rotObject.rotate = false;
	rotForward()
}

function rotBackButton() {
	rotObject.rotate = false;
	rotBack()
}

function rotForward() {
	rotObject.last = rotObject.current;
	if(rotObject.current==(rotObject.total-1)) {
		rotObject.current = 0;
		rotStory();
	}
	else {
		rotObject.current = rotObject.current + 1;
		rotStory();
	}
}

function rotBack() {
	rotObject.last = rotObject.current;
	if(rotObject.current==0) {
		rotObject.current = rotObject.total-1;
		rotStory();
	}
	else {
		rotObject.current = rotObject.current - 1;
		rotStory();
	}
}

function rotPausePlay() {
	if(rotObject.rotate)
		rotObject.rotate = false;
	else
		rotObject.rotate = true;
}

/******************************************************************************
	END rotator
******************************************************************************/

/******************************************************************************
	START article
******************************************************************************/

function articlePlayVideo(videoId) {
	rotObject.current = rotFindCurrent();
	rotObject.rotate = false;
	rotObject.playingVideo = true;
	jQuery("#neulion-video").css("display","block");
    neulionPlayer(videoId);
    jQuery("#article-image .video-close").show();
}
	
function articleStopVideo() {
	rotObject.playingVideo = false;
	if(jQuery("#jtvshlembed").length>0) {
		try {document.getElementById('jtvshlembed').pauseVideo();}
		catch(ex) {/*setTimeout("rotStopVideo()",1000);*/}
	}
	jQuery("#neulion-video").hide();
	jQuery("#jtvshlAdContainer").hide();
	jQuery("#article-image .video-close").hide();
}


/******************************************************************************
	END article
******************************************************************************/

/******************************************************************************
	START Single Video
******************************************************************************/
jQuery(function() {
	var boxWidth = 724;
	var boxHeight = 499;
	
	jQuery("#site-overlay-box .close").click(function() {
		jQuery("#site-overlay").fadeOut();
	  	jQuery("#site-overlay-box").fadeOut();
	  	if (jQuery("#jtvshlembed") && document.getElementById('jtvshlembed').pauseVideo){
			document.getElementById('jtvshlembed').pauseVideo();
		}
	});
	
	jQuery("#single-display .image .play-button").click(function() {
		neulionPlayer(jQuery(this).attr("videoid"));
    	overlayUpdatePosition(true);
		setTimeout(function() {
			overlayUpdatePosition(false);
		},100);
		jQuery(window).resize(function () { 
    		overlayUpdatePosition(false);
   		});
   		jQuery(window).scroll(function () { 
    		overlayUpdatePosition(false);
   		});
	});
	
	function overlayUpdatePosition(first) {
		
		var siteOverlay = jQuery("#site-overlay");
	  	var boxOverlay = jQuery("#site-overlay-box");
		var windowH = jQuery(window).height();
		var windowW = jQuery(window).width();
		var boxTop = Math.round((windowH - boxOverlay.height() )/2);
		var boxLeft = Math.round((windowW - boxOverlay.width() )/2);
		
		siteOverlay.css({
			"width":windowW+"px",
			"height":windowH+"px",
			"opacity":".7"
		});
		
		
		boxOverlay.css({
			"top":boxTop+"px",
			"left":boxLeft+"px"
		});
		if(first) {
			siteOverlay.fadeIn();
			boxOverlay.fadeIn();
		}
	}
});
/******************************************************************************
	END Single Video
******************************************************************************/

