/**
 * remy sharp / http://remysharp.com
 * Twitter / @rem
 * http://remysharp.com/2007/05/18/add-twitter-to-your-blog-step-by-step/
 *
 * @params
 *   cssIdOfContainer: e.g. twitters
 *   options: 
 *       {
 *           id: {String} username,
 *           count: {Int} 1-20, defaults to 1 - max limit 20
 *           prefix: {String} '%name% said', defaults to blank
 *           clearContents: {Boolean} true, removes contents of element specified in cssIdOfContainer, defaults to true
 *           ignoreReplies: {Boolean}, skips over tweets starting with '@', defaults to false
 *           template: {String} HTML template to use for LI element (see URL above for examples), defaults to predefined template
 *           enableLinks: {Boolean} linkifies text, defaults to true,
 *           newwindow {Boolean} opens links in new window, defaults to false
 *           timeout: {Int} How long before triggering onTimeout, defaults to 10 seconds if onTimeout is set
 *           onTimeoutCancel: {Boolean} Completely cancel twitter call if timedout, defaults to false
 *           onTimeout: {Function} Function to run when the timeout occurs. Function is bound to element specified with 
 *           cssIdOfContainer (i.e. 'this' keyword)
 *           callback: {Function} Callback function once the render is complete, doesn't fire on timeout
 *
 *      CURRENTLY DISABLED DUE TO CHANGE IN TWITTER API:
 *           withFriends: {Boolean} includes friend's status
 *
 *       }
 *
 * @license MIT (MIT-LICENSE.txt)
 * @version 1.13.3 - ify now supports lists
 * @date $Date$
 */

/***
 * Twitter JS v1.13.3
 * http://code.google.com/p/twitterjs/
 * Copyright (c) 2009 Remy Sharp / MIT License
 * $Date$
 */
 /*
  MIT (MIT-LICENSE.txt)
 */
 typeof renderTwitters!="function"&&function(){function v(a){var c;for(c in a.user)a["user_"+c]=a.user[c];a.time=s(a.created_at);return a}function w(a){t?a.call():u.push(a)}function q(){t=true;for(var a;a=u.shift();)a.call()}function x(){if(document.addEventListener&&!r.webkit)document.addEventListener("DOMContentLoaded",q,false);else if(r.msie){document.write("<script id=__ie_init defer=true src=//:><\/script>");var a=document.getElementById("__ie_init");if(a)a.onreadystatechange=function(){if(this.readyState==
 "complete"){this.parentNode.removeChild(this);q.call()}};a=null}else if(r.webkit)var c=setInterval(function(){if(document.readyState=="loaded"||document.readyState=="complete"){clearInterval(c);c=null;q.call()}},10)}function s(a){function c(d){var h=d.getHours();d=d.getMinutes()+"";var f="AM";if(h==0)h=12;else if(h==12)f="PM";else if(h>12){h-=12;f="PM"}if(d.length==1)d="0"+d;return h+":"+d+" "+f}function g(d){d.toDateString().split(/ /);var h=y[d.getMonth()],f=d.getDate()+"",i=parseInt(f);d=d.getFullYear();
 var n=(new Date).getFullYear(),l="th";if(i%10==1&&f.substr(0,1)!="1")l="st";else if(i%10==2&&f.substr(0,1)!="1")l="nd";else if(i%10==3&&f.substr(0,1)!="1")l="rd";if(f.substr(0,1)=="0")f=f.substr(1);return h+" "+f+l+(n!=d?", "+d:"")}var b=a.split(" "),e=Date.parse(b[1]+" "+b[2]+", "+b[5]+" "+b[3]);b=new Date(e);var j=arguments.length>1?arguments[1]:new Date;e=parseInt((j.getTime()-e)/1E3);var m="";e+=j.getTimezoneOffset()*60;return m=e<5?"less than 5 seconds ago":e<30?"half a minute ago":e<60?"less than a minute ago":
 e<120?"1 minute ago":e<2700?parseInt(e/60).toString()+" minutes ago":e<10800?"about 1 hour ago":e<86400?"about "+parseInt(e/3600).toString()+" hours ago":e<172800?c(b)+" yesterday":c(b)+" "+g(b)}var r=function(){var a=navigator.userAgent.toLowerCase();return{webkit:/(webkit|khtml)/.test(a),opera:/opera/.test(a),msie:/msie/.test(a)&&!/opera/.test(a),mozilla:/mozilla/.test(a)&&!/(compatible|webkit)/.test(a)}}(),o=0,u=[],t=false,y=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];
 window.ify=function(){return{link:function(a){return a.replace(/[a-z]+:\/\/[a-z0-9-_]+\.[a-z0-9-_:~%&\?#\/.=]+[^:\.,\)\s*$]/ig,function(c){return'<a href="'+c+'">'+(c.length>25?c.substr(0,24)+"...":c)+"</a>"})},at:function(a){return a.replace(/(^|[^\w]+)\@([a-zA-Z0-9_]{1,15}(\/[a-zA-Z0-9-_]+)*)/g,function(c,g,b){return g+'@<a href="http://twitter.com/'+b+'">'+b+"</a>"})},hash:function(a){return a.replace(/(^|[^&\w'"]+)\#([a-zA-Z0-9_]+)/g,function(c,g,b){return g+'#<a href="http://search.twitter.com/search?q=%23'+
 b+'">'+b+"</a>"})},clean:function(a){return this.hash(this.at(this.link(a)))}}}();window.renderTwitters=function(a,c){function g(k){return document.createElement(k)}function b(k){return document.createTextNode(k)}var e=document.getElementById(c.twitterTarget),j=null,m=g("ul"),d,h,f,i,n=a.length>c.count?c.count:a.length;for(i=0;i<n&&a[i];i++){j=v(a[i]);if(c.ignoreReplies&&a[i].text.substr(0,1)=="@")n++;else{d=g("li");if(c.template)d.innerHTML=c.template.replace(/%([a-z_\-\.]*)%/ig,function(k,p){k=
 j[p]+""||"";if(p=="text"&&c.enableLinks)k=ify.clean(k);return k});else{h=g("span");h.className="twitterStatus";f=g("span");f.className="twitterTime";h.innerHTML=a[i].text;if(c.enableLinks==true)h.innerHTML=ify.clean(h.innerHTML);f.innerHTML=s(a[i].created_at);if(c.prefix){var l=g("span");l.className="twitterPrefix";l.innerHTML=c.prefix.replace(/%(.*?)%/g,function(k,p){return a[i].user[p]});d.appendChild(l);d.appendChild(b(" "))}d.appendChild(h);d.appendChild(b(" "));d.appendChild(f)}if(c.newwindow)d.innerHTML=
 d.innerHTML.replace(/<a href/gi,'<a target="_blank" href');m.appendChild(d)}}if(c.clearContents)for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(m);typeof c.callback=="function"&&c.callback()};window.getTwitters=function(a,c,g,b){o++;if(typeof c=="object"){b=c;c=b.id;g=b.count}g||(g=1);if(b)b.count=g;else b={};if(!b.timeout&&typeof b.onTimeout=="function")b.timeout=10;if(typeof b.clearContents=="undefined")b.clearContents=true;if(b.withFriends)b.withFriends=false;b.twitterTarget=a;if(typeof b.enableLinks==
 "undefined")b.enableLinks=true;window["twitterCallback"+o]=function(e){b.timeout&&clearTimeout(window["twitterTimeout"+o]);renderTwitters(e,b)};w(function(e,j){return function(){if(document.getElementById(e.twitterTarget)){var m="http://www.twitter.com/statuses/"+(e.withFriends?"friends_timeline":"user_timeline")+"/"+c+".json?callback=twitterCallback"+j+"&count=20&cb="+Math.random();if(e.timeout)window["twitterTimeout"+j]=setTimeout(function(){if(e.onTimeoutCancel)window["twitterCallback"+j]=function(){};
 e.onTimeout.call(document.getElementById(e.twitterTarget))},e.timeout*1E3);var d=document.createElement("script");d.setAttribute("src",m);document.getElementsByTagName("head")[0].appendChild(d)}}}(b,o))};x()}();


/** 
* Jquery cookie plugin 
**/
eval(function(p,a,c,k,e,d){e=function(c){return(c<a?"":e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('j.5=u(9,a,2){6(h a!=\'v\'){2=2||{};6(a===m){a=\'\';2.3=-1}4 3=\'\';6(2.3&&(h 2.3==\'n\'||2.3.k)){4 7;6(h 2.3==\'n\'){7=w C();7.B(7.z()+(2.3*A*o*o*E))}l{7=2.3}3=\'; 3=\'+7.k()}4 8=2.8?\'; 8=\'+2.8:\'\';4 b=2.b?\'; b=\'+2.b:\'\';4 c=2.c?\'; c\':\'\';d.5=[9,\'=\',q(a),3,8,b,c].t(\'\')}l{4 g=m;6(d.5&&d.5!=\'\'){4 e=d.5.x(\';\');D(4 i=0;i<e.f;i++){4 5=j.r(e[i]);6(5.p(0,9.f+1)==(9+\'=\')){g=y(5.p(9.f+1));s}}}F g}};',42,42,'||options|expires|var|cookie|if|date|path|name|value|domain|secure|document|cookies|length|cookieValue|typeof||jQuery|toUTCString|else|null|number|60|substring|encodeURIComponent|trim|break|join|function|undefined|new|split|decodeURIComponent|getTime|24|setTime|Date|for|1000|return'.split('|'),0,{}))


/**
* Styleswitch stylesheet switcher built on jQuery
**/
$(document).ready(function() {
	var c = $.cookie('style');
	if (c) switchStylestyle(c);
});

function switchStylestyle(styleName) {
	$('link[@rel*=style][@title]').each(function(i) {
		this.disabled = true;
		if (this.getAttribute('title') == styleName) this.disabled = false;
	});
	$.cookie('style',styleName, {expires: 365});
}

// home carousel
hbfCarousel = {
    animating : 0,
    auto : 1, // is carousel to be automatically rotated?
    timer : 3500, // time in milliseconds to rotate carousel
    activeItem : 0, // which item in carousel is active at the moment
    numItems : 8 // number of items in the carousel
}

// click on a menu item
hbfCarousel.openItem = function(item,killAuto){

    if( killAuto == true){
        // kill timeOut
        clearInterval(hbfCarousel.t);
        hbfCarousel.auto = 0;
    }

    if( hbfCarousel.animating == 0){
        // change bg of menu
        hbfCarousel.animating = 1;
        $('.home_carousel_container #home_carousel_menu .home_carousel_item').removeClass('active');
        $(item).addClass('active');

        // copy content into overlay div
        $('#home_carousel_active').prepend('<div class="overlay"></div>');
        $(item).clone().prependTo('#home_carousel_active .overlay');
        // catcher over item
        $('.home_carousel_container #home_carousel_active .overlay .home_carousel_item').prepend('<div class="catcher"></div>');
        $('.home_carousel_container #home_carousel_active .overlay .catcher').click( function(){
            hbfCarousel.openLink($(this).parent());
        });
        $('#home_carousel_active .overlay').fadeIn('slow', function(){
            $('#home_carousel_active .overlay_original').remove();
            $(this).removeClass('overlay').addClass('overlay_original');
            hbfCarousel.animating = 0;
        });
    }
    return false;
}

// click on a main item
hbfCarousel.openLink = function(item){
       window.location = $(item).find('a:first').attr('href');
}

hbfCarousel.rotateCarousel = function(){
     if( hbfCarousel.auto == 1 ){
        hbfCarousel.activeItem += 1;
        if( hbfCarousel.activeItem == hbfCarousel["numItems"] ){
            hbfCarousel.activeItem = 0;
            //alert(hbfCarousel.activeItem );
        }

        hbfCarousel.openItem($('.home_carousel_container #home_carousel_menu .home_carousel_item:eq('+hbfCarousel.activeItem+')'),false);
        if ( hbfCarousel.activeItem == 4 ){
            $(".home_carousel_container #home_carousel_menu")[0].scrollTo(243);
        }
        if ( hbfCarousel.activeItem == 0 ){
            $(".home_carousel_container #home_carousel_menu")[0].scrollTo(0);
        }
    }
}


// Initialise Things
jQuery(function(){
	if ($.cookie('style') != "textonly") {
		// initialise things if not text-only
		htmlClose = '<img src="/fileadmin/template/main/hbf-3.0/img/menu_close.gif" width="9" height="9" alt="Expand Menu" />';
		htmlOpen = '<img src="/fileadmin/template/main/hbf-3.0/img/menu_close.gif" width="9" height="9" alt="Expand Menu" />';
		// menu expand
		$('#left_menu li.active .expand_menu:eq(0)').html(htmlClose).removeClass("closed").addClass("open");
		$('#left_menu li.active li.active .expand_menu:eq(0)').html(htmlClose).removeClass("closed").addClass("open");
		$('#left_menu li.active li.active li.active .expand_menu:eq(0)').html(htmlClose).removeClass("closed").addClass("open");
		$('.expand_menu').click(function() {
			$(this).next().slideToggle("fast");
			if($(this).hasClass("closed")) {
				$(this).removeClass("closed").addClass("open");
				$(this).html(htmlOpen);
			} else {
				$(this).removeClass("open").addClass("closed");
				$(this).html('<img src="/fileadmin/template/main/hbf-3.0/img/menu_open.gif" width="9" height="9" alt="Expand Menu" />');
			}
		});

		// home carousel
		    $('.home_carousel_container_default').removeClass('home_carousel_container_default').addClass('home_carousel_container');

		    $('.home_carousel_container #home_carousel_menu').jScrollPane({showArrows:false, scrollbarWidth: 15, animateTo:true, animateInterval:50, animateStep:5});

		    // catcher over menu items
		    $('.home_carousel_container .home_carousel_item').prepend('<div class="catcher"></div>');

		    // put first img and text into active
		    $('#home_carousel_active').prepend('<div class="overlay_original"></div>');
		    $('.home_carousel_container .home_carousel_item:first').clone().appendTo('#home_carousel_active .overlay_original').addClass('active');
		    $('.home_carousel_container #home_carousel_menu .home_carousel_item:first').addClass('active');

		    $('.home_carousel_container #home_carousel_active .catcher').click( function(){
			hbfCarousel.openLink($(this).parent());
		    });

		    $('.home_carousel_container #home_carousel_menu .home_carousel_item').click( function(){
			hbfCarousel.openItem($(this),true);
		    });

		    $('.home_carousel_container #home_carousel_menu .home_carousel_item .catcher').click( function(){
			hbfCarousel.openItem($(this).parent(),true);
			return false;
		    });

		    $('.home_carousel_container #home_carousel_menu .home_carousel_item .label a').click( function(){
			hbfCarousel.openItem($(this).parent().parent().parent(),true);
			return false;
		    });

		    $('.home_carousel_container #home_carousel_menu .home_carousel_item .image a').click( function(){
			hbfCarousel.openItem($(this).parent().parent(),true);
			return false;
		    });

		   // start timer
		  hbfCarousel.t = setInterval("hbfCarousel.rotateCarousel()",hbfCarousel.timer);


	}

	// Ajax news browser
	$('.tx-ttnews-browsebox a').click(ajaxNews);
	// Ajax News Search
	$(".news-search-form-submit input").click(ajaxNewsSearch);  

	// Hide calendar img without src
	$(".skcalendar-list-table #colNormal img[name='']").hide();


});

// Member login
function memberLogin(button) {
	$(button).attr("onClick","");
	$('#member_login').load('/index.php?id=2335', function() {
		$('#colRight .tx-newloginbox-pi1-forgotP').hide();
		$('#ajax_login_wrap #tx-newloginbox-pi1-login_submit').click(memberLoginSubmit);
		$('#member_login').fadeIn('fast');
	});
	return false;
}

function hideShowMemberLogin() {
	$('#ajax_login_wrap').hide();
	$('#login_banner a').click(
	    function () {
		$('#ajax_login_wrap').fadeIn('fast');
		$('#login_banner a').click(function (){
		    document.location = '/index.php?id=2348';
		});
		return false;
	    });
	    return false;
}

function memberLoginSubmit() {
	$('#ajax_login_wrap #tx-newloginbox-pi1-login_submit').replaceWith("<img src='/fileadmin/template/main/hbf-3.0/img/mini-throbber.gif' /> Logging in");
	jname = $("#tx-newloginbox-pi1-user").val();
	jpass = $("#tx-newloginbox-pi1-pass").val();
	$.post('/index.php?id=2335',{
		user: jname,
		pass: jpass,
		pid: '438',
		redirect_url: '',
		submit: 'login',
		logintype: 'login'
		}, function(data) {
			$('#member_login').html(data);
			$('#ajax_login_wrap #tx-newloginbox-pi1-login_submit').click(memberLoginSubmit);
	}, "html");
	return false;
}

// add classes to media centre box on media centre (twitter / blog / news)
function classifyMediaStories(id){
	div = $('#'+id);
	// filter object - first item is added as class to match of second string
	var filters = [ 
		['twitter','http://twitter.com'],
		['blog','index.php?id=1738&']
	]
	// first add meltwater class to all
	$('.news .title',div).addClass('meltwater');
	// now apply filters
	for (x=0 ; x < filters.length ; x++){
		$('a[href*='+filters[x][1]+']',div).parent().removeClass('meltwater').addClass(filters[x][0]);
	}
}

// Ajax News Browser function
function ajaxNews() {
	//alert("Ajax news box");
	link = $(this).attr('href');
	contentWrapper = $(this).parents().filter('.content_wrapper');
	contentId = $(contentWrapper).attr('id');
	$(contentWrapper).prepend('<div class="throbber"></div>');
	//alert(link + " - " + contentId);	
	$(contentWrapper).load(link+" #"+contentId, function() {
		$('.tx-ttnews-browsebox a').click(ajaxNews);
		// add classes to media centre news box
		classifyMediaStories('mediaCentre');
	});	

	return false;
}

// Ajax News Search
function ajaxNewsSearch() {  
	link = $(this).parent().parent().attr('action');
	swords = $(this).parent().prev().attr("value");
	//alert(swords);
	contentWrapper = $(this).parents().filter('.content_wrapper');
	contentId = $(contentWrapper).attr('id');
	$(contentWrapper).prepend('<div class="throbber"></div>');
	$(contentWrapper).load(link+" #"+contentId, {'tx_ttnews[swords]':swords}, function() {
		$('.news-search-form-submit input').click(ajaxNewsSearch);
		$('.tx-ttnews-browsebox a').click(ajaxNews);
	});	
	return false; 
}    

// Concertina and toggle Function
$(document).ready(function(){

	// add classes to media centre news box
	classifyMediaStories('mediaCentre');

        $(".csc-frame-07 h2 ~").hide();
        $(".csc-frame-07 h2").click(function(){
            $(".csc-frame-07 h2 ~").slideUp("fast");
            $(".concertina-open").removeClass("concertina-open");
            $(this).parent().addClass("concertina-open");
            $(this).siblings().slideDown("fast",function(){});
    	});
	
        $(".csc-frame-08 h2 ~").hide();
        $(".csc-frame-08 h2").click(function(){
            $(this).siblings().slideToggle("fast");
	    if( $(this).parent().hasClass("toggle-open") ){
                $(this).parent().removeClass("toggle-open");
	    } else {
                $(this).parent().addClass("toggle-open");
	    }
    	});
	
});

// NewsTicker
var newsitems1;
var curritem1=0;
var newsitems2;
var curritem2=0;
var newsitems3;
var curritem3=0;

/*
$(document).ready(function() {
	if ($.cookie('style') != "textonly") {
		$("#home_news_box_01 li").css("position","absolute");
		newsitems1 = $("#home_news_box_01 li").hide().size();
    
		$("#home_news_box_01 li:eq("+curritem1+")").fadeIn(1000);
		setInterval(ticknews1,6000); //time in milliseconds

		$("#home_news_box_02 li").css("position","absolute");
		newsitems2 = $("#home_news_box_02 li").hide().size();
    
		$("#home_news_box_02 li:eq("+curritem2+")").fadeIn(1000);
		setInterval(ticknews2,6000); //time in milliseconds

		$("#home_news_box_03 li").css("position","absolute");
		newsitems3 = $("#home_news_box_03 li").hide().size();
    
		$("#home_news_box_03 li:eq("+curritem3+")").fadeIn(1000);
		setInterval(ticknews3,6000); //time in milliseconds
	}
	});

function ticknews1() {
    $("#home_news_box_01 li:eq("+curritem1+")").fadeOut(1000);
    curritem1 = ++curritem1%newsitems1;
    $("#home_news_box_01 li:eq("+curritem1+")").fadeIn(1000);    
}

function ticknews2() {
    $("#home_news_box_02 li:eq("+curritem2+")").fadeOut(1000);
    curritem2 = ++curritem2%newsitems2;
    $("#home_news_box_02 li:eq("+curritem2+")").fadeIn(1000);    
}

function ticknews3() {
    $("#home_news_box_03 li:eq("+curritem3+")").fadeOut(1000);
    curritem3 = ++curritem3%newsitems3;
    $("#home_news_box_03 li:eq("+curritem3+")").fadeIn(1000);    
}
*/

function loadCarousels() {    
		var twitterItems = $('#twitters li')
		$('#home-news-box-05 ul').append(twitterItems);
}

function sortMediaStories(a,b){
	aJ = $(a).find('.news_title').text();
	bJ = $(b).find('.news_title').text();
	// strip times off end
	aT = aJ.split('(')[0];
	bT = bJ.split('(')[0];
	// Year
	aY = aT.split(',')[1].split(' ')[1];
	bY = bT.split(',')[1].split(' ')[1];
	// Month
	aM = aT.split(',')[0].split(' ')[1];
	bM = bT.split(',')[0].split(' ')[1];
	// Day
	aD = aT.split(',')[0].split(' ')[0];
	bD = bT.split(',')[0].split(' ')[0];

	aDate = new Date(aM+" "+aD+","+aY);
	bDate = new Date(bM+" "+bD+","+bY);
	if(aDate > bDate){ return -1; }
	if(bDate > aDate){ return 1; }
	//alert("equal");
	return 0;
}


$(document).ready(function() {	


	// NEW home news boxes
	homeNewsImages = new Array(
		"home-news-image-01.jpg",
		"home-news-image-02.jpg",
		"home-news-image-03.jpg",
		"home-news-image-04.jpg",
		"home-news-image-05.jpg",
		"home-news-image-06.jpg"
	);
	homeNewsImages.sort(function() {return 0.5 - Math.random()}) // Shuffle array

	shuffleX = 0;
	$(".home-news-box").not('#home-news-box-04').not('#home-news-box-05').find('.home-news-box-content').each( function(){
		$(this).prepend('<div class="home-news-box-image"><img src="/fileadmin/template/main/hbf-3.0/img/home-news-images/'+homeNewsImages[shuffleX]+'" /></div>');
			shuffleX += 1;
		});



	// NEW - grab a copy of media list and sort first using a custom function
	var mediaList = document.getElementById('mediaCentre');
	if(mediaList){
		var items = mediaList.childNodes;
		var itemsArr = [];
		for (var i in items) {
		    if (items[i].nodeType == 1) { // get rid of the whitespace text nodes
			itemsArr.push(items[i]);
		    }
		}
		// sort using the new function
		itemsArr.sort(sortMediaStories);
		// loop through sorted array and replace item order on page
		for (i = 0; i < itemsArr.length; ++i) {
		  mediaList.appendChild(itemsArr[i]);
		}
	}



		$("#home-news-box-01 .news_wrapper").jCarouselLite({ vertical: true, auto: 6000, speed: 1000 });
	    setTimeout('$("#home-news-box-02 .news_wrapper").jCarouselLite({ vertical: true, auto: 6000, speed: 1000 })',1200);
	    setTimeout('$("#home-news-box-03 .news_wrapper").jCarouselLite({ vertical: true, auto: 6000, speed: 1000 })',2400);
	    setTimeout('$("#home-news-box-04 .news_wrapper").jCarouselLite({ vertical: true, auto: 6000, speed: 1000 })',3600);
	    setTimeout('$("#home-news-box-05 .news_wrapper").jCarouselLite({ vertical: true, auto: 6000, speed: 1000 })',4800);
	    setTimeout('$("#home-news-box-06 .news_wrapper").jCarouselLite({ vertical: true, auto: 6000, speed: 1000 })',6000);

});

// NEW NewsTicker
/**
var homenewsitems1;
var homecurritem1=0;
var homenewsitems2;
var homecurritem2=0;
var homenewsitems3;
var homecurritem3=0;
var homenewsitems4;
var homecurritem4=0;
var homenewsitems5;
var homecurritem5=0;
var homenewsitems6;
var homecurritem6=0;

$(document).ready(function() {
	if ($.cookie('style') != "textonly") {
		//$("#home-news-box-01 li").css("position","absolute");
		homenewsitems1 = $("#home-news-box-01 li").hide().size();
    
		$("#home-news-box-01 li:eq("+homecurritem1+")").fadeIn(1000);
		setInterval(newticknews1,6000); //time in milliseconds

		//$("#home-news-box-02 li").css("position","absolute");
		homenewsitems2 = $("#home-news-box-02 li").hide().size();
    
		$("#home-news-box-02 li:eq("+homecurritem2+")").fadeIn(1000);
		setInterval(newticknews2,6000); //time in milliseconds

		//$("#home-news-box-03 li").css("position","absolute");
		homenewsitems3 = $("#home-news-box-03 li").hide().size();
    
		$("#home-news-box-03 li:eq("+homecurritem3+")").fadeIn(1000);
		setInterval(newticknews3,6000); //time in milliseconds

		//$("#home-news-box-04 li").css("position","absolute");
		homenewsitems4 = $("#home-news-box-04 li").hide().size();
    
		$("#home-news-box-04 li:eq("+homecurritem4+")").fadeIn(1000);
		setInterval(newticknews1,6000); //time in milliseconds

		//$("#home-news-box-05 li").css("position","absolute");
		homenewsitems5 = $("#home-news-box-05 li").hide().size();
    
		$("#home-news-box-05 li:eq("+homecurritem5+")").fadeIn(1000);
		setInterval(newticknews2,6000); //time in milliseconds

		//$("#home-news-box-06 li").css("position","absolute");
		homenewsitems6 = $("#home-news-box-06 li").hide().size();
    
		$("#home-news-box-06 li:eq("+homecurritem6+")").fadeIn(1000);
		setInterval(newticknews6,6000); //time in milliseconds
	}



	});

function newticknews1() {
    $("#home-news-box-01 li:eq("+homecurritem1+")").fadeOut(1000);
    homecurritem1 = ++homecurritem1%homenewsitems1;
    $("#home-news-box-01 li:eq("+homecurritem1+")").fadeIn(1000);    
}

function newticknews2() {
    $("#home-news-box-02 li:eq("+homecurritem2+")").fadeOut(1000);
    homecurritem2 = ++homecurritem2%homenewsitems2;
    $("#home-news-box-02 li:eq("+homecurritem2+")").fadeIn(1000);    
}

function newticknews3() {
    $("#home-news-box-03 li:eq("+homecurritem3+")").fadeOut(1000);
    homecurritem3 = ++homecurritem3%homenewsitems3;
    $("#home-news-box-03 li:eq("+homecurritem3+")").fadeIn(1000);    
}

function newticknews4() {
    $("#home-news-box-04 li:eq("+homecurritem4+")").fadeOut(1000);
    homecurritem4 = ++homecurritem4%homenewsitems4;
    $("#home-news-box-04 li:eq("+homecurritem4+")").fadeIn(1000);    
}

function newticknews5() {
    $("#home-news-box-05 li:eq("+homecurritem5+")").fadeOut(1000);
    homecurritem5 = ++homecurritem5%homenewsitems5;
    $("#home-news-box-05 li:eq("+homecurritem5+")").fadeIn(1000);    
}

function newticknews6() {
    $("#home-news-box-06 li:eq("+homecurritem6+")").fadeOut(1000);
    homecurritem6 = ++homecurritem6%homenewsitems6;
    $("#home-news-box-06 li:eq("+homecurritem6+")").fadeIn(1000);    
}
**/

