ghl = {};
ghl.picarr = ['h_1.jpg','h_4.jpg','h_3.jpg','h_2.jpg','h_5.jpg'];
ghl.altarr = ['Leadership','Cash','Credit Crunch','Recession','Profit'];
ghl.newsarr = ["<h1>Developing our capability</h1><p>In the last year we have increased the size of the Greenlys team and in particular the number of people who act as Corporate Finance and Business Advisors. <br />All our Business Advisors have 2 important attributes - experience in their specialist field and the knowledge of what it is like to create wealth by being an owner of a business.</p>","<h1>Could there still be a double dip (a W)?</h1><p>This is the question we considered a year ago and the answer is still not sure.  Now it is uncertainties about the US that is unsettling the markets. <br />Whatever the outcome, for people who work in owner led businesses, there is still an opportunity to create wealth by improving business performance.  There are also  companies actively seeking to make acquisitions and with the cash to do so.</p>","<h1>Is your company really worth what you think it is?</h1><p>Contrary to what you might read, valuing a private company is an art much more than a science.  Beauty is in the eye of a beholder and understanding why a company might want to buy your business is a matter of looking at it through their eyes, not yours.<br />Greenly’s process - A Fresh Pair of Eyes Review© – does just this. </p>","<h1>Vacancies</h1><p>We have filled the job share PA role and are delighted that Erica Moore has now completed 4 weeks with us. She is a graduate of Southampton University and speak 4 languages including Russian.</p>"];
ghl.scrolldelay = 8000;
ghl.totnws = 0;
ghl.oldnws = 0;
ghl.curnws = 0;
ghl.nwsint = 0;

$(function() {
	var img = new Image;
	
	$("#tl").html('<img src="img/' + ghl.picarr[0] + '" alt="' + ghl.altarr[0] + '" title="' + ghl.altarr[0] + '" />');
	for(var i = 1; i < ghl.picarr.length; i++)
	{
		img.src = 'img/' +  ghl.picarr[i];
		$("#tl").append('<img src="img/' + ghl.picarr[i] + '" alt="' + ghl.altarr[i] + '" title="' + ghl.altarr[i] + '" />');
	}
	$("#tl").cycle();
	
	$("#hnews").html(ghl.newsarr[0]);
	$("#hnews").html("<div id='nscroll' style='position:relative;width:150px;height:228px;overflow:hidden;'></div>");
	ghl.totnws = ghl.newsarr.length;
	for(var i = 0; i < ghl.totnws; i++) $("#nscroll").append(ghl.newSliderHtml(ghl.newsarr[i]));
	$("#nscroll div.ncont").eq(ghl.curnws).css('top', '0');
	ghl.oldnws = ghl.curnws;
	ghl.nwsint = setInterval(ghl.nextNews, ghl.scrolldelay);
	$('#nscroll').hover(function(){
		clearInterval(ghl.nwsint);
		$('#nscroll div.ncont').stop(true,true);
		}, function(){
		ghl.nwsint = setInterval(ghl.nextNews, ghl.scrolldelay); 
		ghl.nextNews();
	});
});

ghl.nextNews = function(){
	ghl.curnws = (ghl.oldnws + 1) % ghl.totnws;
	$("#nscroll div.ncont:eq(" + ghl.oldnws + ")")
    .animate({top:'-228px'},"slow", "linear", function() {
      $(this).css('top', '228px');
    });
  $("#nscroll div.ncont:eq(" + ghl.curnws + ")")
    .animate({top: '0'},"slow");
	ghl.oldnws = ghl.curnws;
};

ghl.newSliderHtml = function(s){
	return("<div class='ncont' style='position:absolute;top:228px'>" + s + "</div>");
};
