// JavaScript Document

var next = 0; 

function toggleSubmenu(id, height){
	if($(id).css("height")=='0px')
	{
		$(id).animate({height : height});
	}else{
		$(id).animate({height: '0px'});
	}
}

function getNewsFeed(){
	$("#ticker h2").fadeOut();
	$("#ticker b").fadeOut("slow",function(){
		$.ajax({url: '/calls/ajax_ticker.php', data : {id:next}, cache: false, success: function(e){showNewsFeed(e)} });
	});
}

function showNewsFeed(e){
	$("#ticker h2").css({"display":"none"});
	$("#ticker b").css({"display":"block","width":"0px"});
	
	var stuff = e.split("||");
	//console.log(e);
	$("#ticker h2").html(stuff[0]);
	$("#ticker b").html(stuff[1]);
	
	$("#ticker h2").fadeIn("slow",function(){
		$("#ticker b").animate({"width":"780px"},1400,"linear",function() { next = stuff[2]; refreshTicker(); });							   });
}


function getTimes(){
	$.ajax({url: '/calls/ajax_time.php', cache: false, success: function(e){showTimes(e)} });
}

function showTimes(e){
	var stuff = e.split("||");

	$("#uk_time").html(stuff[0]);
	$("#japan_time").html(stuff[1]);
	
	refreshClock();
}

function refreshTicker(){
	setTimeout(getNewsFeed,10000);
}

function refreshClock(){
	setTimeout(getTimes,60000);
}

window.onload = function(){
	getNewsFeed();
	refreshClock();
};