jQuery.noConflict();
var splash_jp$ = jQuery;

var prevHeight;

splash_jp$(document).ready(function() {
	var d1=1500;
	var d2=3000;
	if(splash_jp$.browser.msie){
		d1=(7<splash_jp$.browser.version)?d2:0;
		d2=(7<splash_jp$.browser.version)?0:d2;
	}
	var splash_cookie = splash_jp$.cookie("splash");
	splash_jp$('body').css({overflow:'hidden'});
//	splash_jp$('#home_footer').css({visibility:'visible',display:'block'});
	splash_jp$('#container').css({visibility:'visible'}).hide(0);
	if(splash_cookie){
		splash_jp$('#container').fadeIn(2000);
//		splash_jp$('#container').show(0);
		splash_jp$('#home_footer').css({visibility:'visible'}).show(0);
//		splash_jp$('#container').css({visibility:'visible'});
//		splash_jp$('#home_footer').css({visibility:'visible'});
		startLotation();
	}else{
		splash_jp$('body').append('<div id="splash" style="visiblity:hidden;position:relative;"><img id="bg" src="/assets/images/loading_bg.jpg" style="width:100%;position:absolute;top:0;left:0;" /><a href="#" class="skip" style="position:absolute;display:block;width:100%;height:400px; background:url(/assets/images/loading_logo.gif) 50% 220px no-repeat;"></a></div>');
//		splash_jp$('#splash').hide(0).fadeIn(3000);
//		splash_jp$('#splash>A.skip').fadeOut(0)fadeIn(7000);
		splash_jp$('#splash').css({visibility:'visible'}).fadeOut(0);
		splash_jp$('#splash').fadeIn(d1,function(){
//		splash_jp$('#splash').css({visibility:'visible'}).fadeIn('slow',function(){
			setTimeout(
				function(){
//					splash_jp$('#splash').animate({opacity:0},function(){
					splash_jp$('#home_footer').css({visibility:'visible'}).hide(0);
					splash_jp$('#splash').hide(0).fadeOut(1500,function(){
						splash_jp$('#container').fadeIn(1500);
//						splash_jp$('#container').css({visibility:'visible'}).fadeIn('slow');
						startLotation();
					});
				}
				, d2
			);
/*
			splash_jp$('#splash').delay(3000).fadeOut('slow',function(){
				splash_jp$('#container').css({visibility:'visible'}).fadeIn('slow');
				startLotation();
			});
*/
		});
	}
//	var date = new Date();
//	date.setTime(date.getTime() + (7 * 24 * 60 * 60 * 1000));
	splash_jp$.cookie('splash','1',{path:"/",expires:"-1"});

});

function startLotation(){
	splash_jp$('#splash').remove();
	splash_jp$('DIV.strip_wrapper').remove();
	splash_jp$('DIV.loader').remove();
	splash_jp$('DIV.pointer').remove();
	splash_jp$('body').css('backgroundImage','url(/assets/images/bg_bottom.jpg)');

	splash_jp$('#home_footer').fadeIn('slow');
	splash_jp$.getFeed({
		url: '/news_topics/atom.xml',
		success: function(feed) {
			var html = '<uL>';
//			for(var i = 0; i < feed.items.length && i < 15; i++) {
			var max = (feed.items.length<3)?feed.items.length:3;
			for(var i = 0; i < max; i++) {
				var item = feed.items[i];
				var d = item.updated.slice(0,10).replace(/-/g,'/');
				html += '<li><a href="'+item.link+'"title="'+item.title+'">'+d +'&nbsp;&nbsp;'+item.title+'</a></li>';
			}
			html += '</ul>';
			splash_jp$("#news_ticker").append(html).find("ul").newsTicker(7000);
//			splash_jp$("#news_ticker").find("ul").newsTicker(7000);
		} 
	});

	startSlide();
}
