function newsRotator(newsContainer) {
	var container = newsContainer;
	var news = container.find("p");
	var current =  container.find("p:first");
	var timer = null;
	var startTimer = function() {
		timer = setTimeout('nwsRotate.rotate()', 5000);
	};
	this.rotate = function() {
		current.animate({ width: 0 }, 2000, function() {
			current.css("width","0").css("display","none");
			current = current.next("p");
			if(current.size() == 0) current = container.find("p:first");
			current.css("display","block").animate({ width: 800 }, 2000);
			startTimer();
		});
	};
	this.start = function() {
		startTimer();
	};
}

var visibleBlackBox = 0;
var firstBannerSkipped = false;
function rotateBanner(num) {
	if(!firstBannerSkipped) {
		firstBannerSkipped = true;
		return;
	}
	$("#blackbox_"+visibleBlackBox).fadeOut(500,function() {
		$("#blackbox_"+num).fadeIn(500);
	});
	visibleBlackBox = num;
}

function slideOrchestraUp() {
	if(this.slideTimer) clearTimeout(this.slideTimer);
	var orch = $(this);
	if(orch.hasClass("up") || orch.hasClass("sliding")) return false;
	orch.addClass("sliding");
	orch.animate( { top:"-96px" }, 100, "swing", function() {
		orch.addClass("up");
		orch.removeClass("sliding");
	});
	return true;
}

function slideOrchestraDown() {
	this.slideTimer = setTimeout("executeSlideOrchestraDown('"+this.id+"')",100);
}

function executeSlideOrchestraDown(orchId) {
	var orch = $("#"+orchId);
	if(orch.hasClass("up") && !orch.hasClass("sliding")) {
		orch.removeClass("up");
		orch.addClass("sliding");
		orch.animate( { top:"0px" }, 100, "swing", function() {
			orch.removeClass("sliding");											
		});
	}
	return true;
}

function clickOrchestra() {
	var a = $(this).find("a")[0];
	if(!a.onclick || (a.onclick()!=false)) location=a.href;
	return false;
}

$(document).ready(function() {
	if(n_country != null) {
		var cntryCode = (n_country.split("|"))[0];
		var countryOrchs = $("#orchseats ."+cntryCode);
		if(countryOrchs.length > 0) {
			$("#orchseats .global").css("display","none");
			$("#orchseats ."+cntryCode+", #orchseats ."+cntryCode+" div ").css("display","block");
		}
		var countryNews = $("#news ."+cntryCode);
		if(countryNews.length > 0) {
			$("#news .global").css("display","none");
			$("#news ."+cntryCode+", #news ."+cntryCode+" div ").css("display","block");
			nwsRotate = new newsRotator($("#news ."+cntryCode));
		}
		else {
			nwsRotate = new newsRotator($("#news .global"));
		}
	}
	else {
		nwsRotate = new newsRotator($("#news .global"));
	}
	
	//showHomeBanner(0);
	nwsRotate.start();
	
	if(n_lang && n_lang == "en-us") {
		var orchCount = 0;
		$(".orchestra_js").each(function() { this.id = "orch_"+orchCount; orchCount++; }).mouseover(slideOrchestraUp).mouseout(slideOrchestraDown).click(clickOrchestra);
	}
	else {
		$("#orchseats .colcontent").addClass("static");
	}
});