
jQuery(window).load(function () {
	setTimeout("clearInput('#login-box .email')",10);
	setTimeout("clearInput('#login-box .password')",10);
	setTimeout("clearInput('#search-input')",10);
});

jQuery(document).ready(function(){
	sectionMenu = jQuery("#section-menu");
	if(sectionMenu.length>0) {
		ulWidth = 0;
		startWidth = sectionMenu.width();
		for(x=0;x<jQuery("li",sectionMenu).length;x++) 
			ulWidth = ulWidth + jQuery("li:eq("+x+")",sectionMenu).width();
		ulMarginLeft = (startWidth - ulWidth) / 2;
		sectionMenu.css("margin-left",ulMarginLeft+"px");
	}
	
	positionBgEffect();
	jQuery(window).resize(function(){
		positionBgEffect();
	});
	
	jQuery("#login-box .email").focus(function() {
		jQuery("#login-box .email").css("background","#ffffff");
	});	
	jQuery("#login-box .email").blur(function() {
		if(jQuery("#login-box .email").val()=='') 
			jQuery("#login-box .email").css({'background-image':'url(/fls/2600/site_graphics/bg-email.png)','background-repeat':'no-repeat'});
	});
	jQuery("#login-box .password").focus(function() {
		jQuery("#login-box .password").css("background","#ffffff");
	});	
	jQuery("#login-box .password").blur(function() {
		if(jQuery("#login-box .password").val()=='') 
			jQuery("#login-box .password").css({'background-image':'url(/fls/2600/site_graphics/bg-password.png)','background-repeat':'no-repeat'});
	});
	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/2600/site_graphics/bg-search.png)','background-repeat':'no-repeat'});
	});
});

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

function positionBgEffect() {
	bgImageWidth = 734;
	leftMin = 255;	
	pos = jQuery("#site-container").position();
	if(pos.left>leftMin) {
		newLeftPos = pos.left - leftMin;
		jQuery("#container").css("background-position",newLeftPos+"px 0px");
	}
}

/******************************************************************************
	START Rotator
******************************************************************************/
var rotObject = {
	current : 0,
	last : 0,
	total : 4,
	interval : 8000,
	rotate : true,
	playingVideo : false
};

jQuery(document).ready(function(){
	rotObject.total = jQuery("#rotator .story").length;
	jQuery("#rotator .story").click(function() {
		jQuery("#rotator .story").removeClass("active");
		jQuery(this).addClass("active");
		for(x=0;x<rotObject.total;x++) {
			if(jQuery("#rotator .story:eq("+x+")").hasClass("active")) {
				rotObject.current = x;
				break;
			}
		}
		rotObject.rotate = false;
		if(rotObject.playingVideo)
			rotStopVideo();
		rotSelectStory();
	});
	if(jQuery("#rotator .story").length>0)
		setInterval("rotAuto()",rotObject.interval);
});

function rotAuto() {
	if(rotObject.rotate) {
		if(rotObject.current!=(rotObject.total - 1))
			rotObject.current  = rotObject.current + 1;
		else
			rotObject.current=0;
		jQuery("#rotator .story").removeClass("active");
		jQuery("#rotator .story:eq("+rotObject.current+")").addClass("active");
		rotSelectStory();
	}
}

function rotPlayVideo(videoId) {
	rotObject.rotate = false;
	rotObject.playingVideo = true;
	jQuery("#neulion-video").css("display","block");
    neulionPlayer(videoId);
    //jQuery("#rotator .video-close").show();
}


function rotSelectStory() {
	jQuery("#rotator .main-image").removeClass("active").css("display","none");
	jQuery("#rotator .overlay-headline").removeClass("active");
	jQuery("#rotator .overlay-headline:eq("+rotObject.current+")").addClass("active");
	jQuery("#rotator .main-image:eq("+rotObject.current+")").fadeIn(500).addClass("active");
}

function rotStopVideo() {
	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("#rotator .video-close").hide();
}

/******************************************************************************
	END Rotator
******************************************************************************/

/******************************************************************************
	START rebel-vision
******************************************************************************/

jQuery(document).ready(function(){
	jQuery("#rebel-vision .button").click(function() {
		jQuery("#rebel-vision .button").removeClass("active");
		jQuery(this).addClass("active");
		for(x=0;x<jQuery("#rebel-vision .button").length;x++) {
			if(jQuery("#rebel-vision .button:eq("+x+")").hasClass("active")) {
				jQuery("#rebel-vision .content .tab-content").removeClass("active");
				jQuery("#rebel-vision .content .tab-content:eq("+x+")").addClass("active");
				break;
			}	
		}
	});
});

/******************************************************************************
	END rebel-vision
******************************************************************************/

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

function articlePlayVideo(videoId) {
	rotObject.rotate = false;
	rotObject.playingVideo = true;
	jQuery("#neulion-video").css("display","block");
    neulionPlayer(videoId);
    //jQuery("#rotator .video-close").show();
}

function articleStopVideo() {
	rotObject.playingVideo = false;
	if(jQuery("#jtvshlembed").length>0) {
		try {document.getElementById('jtvshlembed').pauseVideo();}
		catch(ex) {setTimeout("articleStopVideo()",1000);}
	}
	jQuery("#neulion-video").hide();
	jQuery("#jtvshlAdContainer").hide();
	jQuery("#artile-image .video-close").hide();
}

