// JavaScript Document
var scrolling=1;
var hidelr=1;
var news = Array();
var file = Array();
var image = Array();
var shorter=Array();
var ids=Array();
var push_count=0;
var intro_text='Use the pink arrows to see more of our latest news';
var fade_lr=-1;
var direction=0;
var scroll_offset=0;
pushnews("Information to download about how to stop flu spreading","Information<br/> about flu","news/flu information.pdf","Cold_blow_nose.jpg");
pushnews("Find out about your rights, health checks and health screening","S.A.M.S. Group<br/>Keeping Healthy Event","news/SAMS health event leaflet.pdf","SAMS health event leaflet.jpg");
pushnews("Download the 'Be prepared for cold weather' pamphlet","Be prepared for cold weather","news/be prepared for cold weather - web.pdf","be prepared for cold weather - web.jpg");
pushnews("Evergreen Theatre Company auditions for 'Much ado about Nothing'","Evergreen Theatre Auditions","news/auditions.pdf","auditions.jpg");
pushnews("Consultation on distribution of additional funding to local authorities","Consultation on Allocation Options","news/dh_129404.pdf","dh_129404.jpg");

pushnews("Presentation about our review of advocacy services","Advocacy in Surrey","news/advocacy presentation.pdf","advocacy presentation.jpg");
pushnews("Tips on staying safe when you're out and about","Staying Safe guide","news/staying safe handout.pdf","staying safe handout.jpg");
pushnews("Find out more about our work on Hate Crime in Surrey","Hate Crime Project Plan","news/Hate crime project plan - Easy Read.pdf","Hate crime project plan - Easy Read.jpg");

pushnews("The minutes of the first Autism Partnership Board in Surrey","Autism Partnership Board Minutes","news/Autism PB.pdf","Autism PB.jpg");
pushnews("Think about what you want to tell us"," Partnership Board Self Assessment","news/LDPB annual report template 6 April 2011.doc","report.jpg");
pushnews("A meeting on the 9th May 2011","Developing HealthWatch","news/Invitation & Booking Form.doc","link.jpg");
pushnews("Find out about changes to how to get your bus pass","Bus Pass scheme changes","news/bus pass scheme changes.doc","bus.jpg");
pushnews("Public Value Report Special Bulletin","Special Bulletin","archive/2011/PVR bulletin for web.pdf","PVR bulletin for web.jpg");
pushnews("SAMS is the self advocacy group in North East Surrey","SAMS Group","news/SAMS.pdf","SAMS.jpg");
pushnews("6th April hate crime meeting in Bletchingly","Hate crime meeting","news/hate crime poster -sevp - with border.pdf","hate crime poster -sevp - with border.jpg");
pushnews("Download the flyer and booking form here","Join the Mencap campaign aginst the cuts","news/Big Cuts booking form.pdf","Big Cuts booking form.jpg");
pushnews("Click to take the survey yourself","Out of Hours Health and Social Care services","http://www.surveymonkey.com/s/Surrey_LINk_Survey","slink.jpg");
pushnews("Download our be prepared for cold weather leaflet","Be prepared for cold weather","news/be prepared for cold weather - draft b.pdf","be prepared for cold weather - draft b.jpg");
pushnews("Specialist Disability Employment Consultation","DWP - Easy Read Consultation","consultation/15610_Specialist_DIS_EasyRead1.pdf","15610_Specialist_DIS_EasyRead1.jpg");
pushnews("Staying Strong self advocacy guide","Staying strong self advocacy guide","section3/advocacy/selfadvocacyguideweb.pdf","selfadvocacyguideweb.jpg");
pushnews("Government consultation about Disability Living Allowance","DLA Consultation","news/dla-reform-consultation-easyread.pdf","dla-reform-consultation-easyread.jpg");



pushnews("Download our Easy Read Self Assessment Report","Our self assessment","news/self assessment summary March 2010.pdf","self assessment summary March 2010.jpg");

//pushnews("Download the 'keep warm, keep well booklet'","Keep warm, keep well<br/> booklet","news/Keep Warm Keep Well booklet 16 page (2).pdf","Keep Warm Keep Well booklet 16 page (2).jpg");


//pushnews("Recognised, valued and supported: Next steps for the Carers Strategy","Next steps for the Carers Strategy","news/Next Steps for the Carers Strategy.pdf","Next Steps for the Carers Strategy.jpg");
//pushnews("Valuing People Now - a new 3 year strategy","Valuing People<br/>Now","news9.html","news9.jpg");
//pushnews("Download the Valuing People Now Summary Report","Valuing People<br/>Now Summary","news/valuing people now summary report.pdf","valuing people now summary report.jpg");
//pushnews("Find out about the Transfer of commissioning","Transfer of commissioning","news/Commissioning Responsibilities presentation 100805.pdf","Commissioning Responsibilities presentation 100805.jpg");
//pushnews("Visit the SeeAbility Easy Read Factsheets","SeeAbility Easy Read Factsheets","http://www.lookupinfo.org/easy_read_information/default.aspx","SeeAbility & Look Up Logo together.jpg");
//pushnews("Download the Just Advocacy Quarterly Newsletter","Just Advocacy Quarterly Newsletter","news/Just Advocacy Newsletter - July 2010.pdf","Just Advocacy Newsletter - July 2010.jpg");
//pushnews("Download the Surrey Disabled People's Partnership Newsletter","Surrey Disabled People's Partnership Newsletter","news/summer newsletter 2010.pdf","summer newsletter 2010.jpg");
//pushnews('Download the Stop Adult Abuse Week 2010 Event Listing','Stop Adult<br/>Abuse Week ','news/SAAW 2010 events listing 1_6pages.pdf','saaw.jpg');
//pushnews('Download the flyer for the Break the silence DVD launch','Break the silence<br/>DVD launch','news/invitation flyer.pdf','invitation flyer.jpg');
// pushnews("Download the expression of interest for bids information.","LDDF <br/>2010 / 2011","news/Expression of interest  LDDF 2010.pdf","Cash_hand.jpg");
//pushnews("Download information about our meeting for 2010 – 2011","Our meetings 2010 – 2011","news/workplan 2010 - print.pdf","workplan 2010 - print.jpg");
//pushnews("Download our Technology Day information","Technology Day information","news/tech day.pdf","tech day.jpg");
//pushnews("Download the 2010 Health Action Planning Training Dates"," Health Action Planning training dates","news/HAP Flyer  10.pdf","NHS_Trainers.jpg");
//pushnews("'Ours to own' - A booklet about human rights","'Ours to own'","http://www.equalityhumanrights.com/uploaded_files/publications/ours_to_own_easy_read.pdf","ours_to_own_easy_read.jpg");
//pushnews("The University of Cambridge wants people to help with research","Down's <br/>Syndrome Research","news/Cambridge DS research.pdf","Cambridge DS research.jpg");
//pushnews("Support the Changing Places Toilet campaign - email your MP","Changing Places<br/>Toilet campaign","news/changing places.pdf","install_toilet.jpg");
//pushnews("Information about how we are spending this years LDDF money","LDDF 2009 <br/>- 2010","news/LDDF 2009 - 2010.pdf","lddf2009.jpg");
function pushnews(news_i,shorter_i,file_i,image_i)
{
	news.push(news_i);
	shorter.push(shorter_i);
	file.push(file_i);
	image.push(image_i);
	ids.push(push_count);
	push_count++;

}
var offset=0;
var selected=0;
var start_id=0;
var news_count=4;
var content="<table><tr>";
var clip_left=0;
function loadNews()
{
var ntcontent=document.getElementById("news_ticker_content");
var news_count=4;
content='<div  style="	position:relative; left:0px; top:0px; width:560px;	height:157px; overflow:hidden;	z-index:0" onmouseover="scrolling=0;"  onmouseout="scrolling=1; reselectitem();" >';
//<div style="	position:relative; left:0px; top:-75px; width:700px;	height:167px; overflow:hidden;	z-index:0" onmouseover="scrolling=0; leftright(1);"  onmouseout="scrolling=1; reselectitem(); fade_lr=106" >';
for (var i in ids)
{
	content=content+'<div style="	position:relative; left:'+(140*(i-1))+'px; text-align:center;  top:'+(-0+(-167*(i)))+'px; width:140px;	height:167px; 	z-index:'+i+'; font-size:0.7em" onmouseover="highlight(\''+ids[i]+'\');" id="news_box_'+ids[i]+'"><a href="'+file[i]+'"><img hspace="0" vspace="10"  src="news/'+image[i]+'" id="news_link_'+ids[i]+'" border="5" style="border-color:#FFFFDD"></a><br/><strong><a href="'+file[i]+'">'+shorter[i]+'</a></strong></div>';
	//content=content+'<td width="'+100/news_count+'%" align="center" valign="top"><a href="'+file[i]+'"><img hspace="30" vspace="10"  src="news/'+image[i]+'" id="news_link_'+i+'" border="5" style="border-color:#FFFFDD"></a><br/><strong><a href="'+file[i]+'">'+shorter[i]+'</a></strong></td>';
}

 ntcontent.innerHTML=content+'</div></div>';
 

//var nt_link=document.getElementById('news_link_1');
var nt=document.getElementById('news_ticker');
nt.innerHTML=intro_text;
}


function d2h(d) {return d.toString(16);}
function h2d(h) {return parseInt(h,16);}


function shuffleback()
{
	if (direction==0)
	{
		direction=-1;
		scroll_offset=0;
	}
}
function shuffleforward()
{
	if (direction==0)
	{
		direction=1;
		scroll_offset=0;
	}
}
function deselectall()
{
	for (var i in ids)
	{
		var col1=d2h(255);
		var col2=d2h(255);
		var col3=d2h(221);
		var nt_link=document.getElementById('news_link_'+ids[i]);
		var colour="#"+col1+col2+col3;
		nt_link.style.borderColor=colour;
	}
	var nt=document.getElementById('news_ticker');
	nt.innerHTML='';
	

}
function left()
{
/*	clip_left=clip_left+160;
	selected=ids[2];
	*/

	var send_to_back=ids.shift();
	ids.push(send_to_back);
	for (var i in ids)
	{
		var nb=document.getElementById('news_box_'+(ids[i]));
		nb.style.left=((160*(i))-clip_left)+"px";
	}
	highlight(ids[2]);
}
function right()
{
	var send_to_front=ids.pop();
	ids.unshift(send_to_front);
	for (var i in ids)
	{
		var nb=document.getElementById('news_box_'+(ids[i]));
		nb.style.left=((160*(i))-clip_left)+"px";
	}
	highlight(ids[2]);
}
function leftright(on)
{
	var left=document.getElementById('left');
	var right=document.getElementById('right');
		

	if (on==0)
	{
		left.innerHTML='<img src="news/left_h.gif"/>';
		right.innerHTML='<img src="news/right_h.gif"/>';
		fade_lr=105;
	}
	else
	{
		left.innerHTML='<img src="news/left.gif" onclick="left();"/>';
		right.innerHTML='<img src="news/right.gif"  onclick="right();" />';
		//fade_lr=-1;
	//	nt.style.left="80px";
	//	nt.style.width="610px";
	}		
}
function reselectitem()
{
	deselectall();	
	/*var col1=d2h(255-(20*2));
	var col2=d2h(255-(20*11));
	var col3=d2h(221-(20*5));
	var nt_link=document.getElementById('news_link_'+ids[selected]);
	var colour="#"+col1+col2+col3;
	if (offset>=20)
	{ nt_link.style.borderColor=colour; }
	*/
	var nt=document.getElementById('news_ticker');
	nt.innerHTML=intro_text;
}
function highlight(id)
{
	deselectall();
	
	
	//alert(id);
	var col1=d2h(255-(20*2));
	var col2=d2h(255-(20*11));
	var col3=d2h(221-(20*5));
	var nt_link=document.getElementById('news_link_'+id);
	//alert(nt_link.src);
	var colour="#"+col1+col2+col3;
	nt_link.style.borderColor=colour;
	var nt=document.getElementById('news_ticker');
	nt.innerHTML=news[id];
}
function update()
{
	if (direction==1)
	{
		scroll_offset=scroll_offset-20;
		for (var i in ids)
		{
			var nb=document.getElementById('news_box_'+(ids[i]));
			nb.style.left=((140*(i-1))-scroll_offset)+"px";
		}
		if (scroll_offset==-140)
		{
			direction=0;
			var send_to_front=ids.pop();
			ids.unshift(send_to_front);
			for (var i in ids)
			{
				var nb=document.getElementById('news_box_'+(ids[i]));
				nb.style.left=((140*(i-1)))+"px";
			}
		}
	}
	if (direction==-1)
	{
		scroll_offset=scroll_offset+20;
		for (var i in ids)
		{
			var nb=document.getElementById('news_box_'+(ids[i]));
			nb.style.left=((140*(i-1))-scroll_offset)+"px";
		}
		if (scroll_offset==140)
		{
			direction=0;
			var send_to_back=ids.shift();
			ids.push(send_to_back);
			for (var i in ids)
			{
				var nb=document.getElementById('news_box_'+(ids[i]));
				nb.style.left=((140*(i-1)))+"px";
			}
		}
	}
	/*if (scrolling==1)
	{
		
		clip_left=clip_left+2;
		/*for (var i in ids)
		{
			var nb=document.getElementById('news_box_'+(ids[i]));
			nb.style.left=((160*(i))-clip_left)+"px";
		}*/
	/*	if (79>offset)
		{
			var nt=document.getElementById('news_ticker');
			if (offset<20)
			{
				var col1=d2h(255-(offset*2));
				var col2=d2h(255-(offset*11));
				var col3=d2h(221-(offset*5));
				var nt_link=document.getElementById('news_link_'+ids[selected]);
				var colour="#"+col1+col2+col3;
				nt_link.style.borderColor=colour;
			}
			offset++;
			//if (news[selected].length<offset) nt.innerHTML=news[ids[selected]].substring(0,offset)
			// else nt.innerHTML=news[ids[selected]].substring(0,offset)+"_";
			//showtime=setInterval('update()',100);
			var nt_link1=document.getElementById('news_link_1');
			//this.parentNode.firstChild=news[selected];
		}
		else
		{
			var nt_link_old=document.getElementById('news_link_'+ids[selected]);
			nt_link_old.style.borderColor="#FFFFDD";
			selected++;
			// this is the line to change when the next bunch are selected.... maybe.....
			offset=0;
		}
	}
	if (selected==4) selected=0;
		if (scrolling==2)
	{
		
		if (fade_lr==106) leftright(0);
		fade_lr=fade_lr-1;
		clip_left=clip_left+2;
		selected=ids[2];
		/*for (var i in ids)
		{
			var nb=document.getElementById('news_box_'+(ids[i]));
			nb.style.left=((160*(i))-clip_left)+"px";
		}*/
	/*	if (79>offset)
		{
			var nt=document.getElementById('news_ticker');
			if (offset<20)
			{
				var col1=d2h(255-(offset*2));
				var col2=d2h(255-(offset*11));
				var col3=d2h(221-(offset*5));
				var colour="#"+col1+col2+col3;
				var nt_link=document.getElementById('news_link_1');
				nt_link.style.borderColor=colour;
				var nt_link=document.getElementById('news_link_2');
				nt_link.style.borderColor=colour;
				var nt_link=document.getElementById('news_link_3');
				nt_link.style.borderColor=colour;
			}
			offset++;
			if (news[selected].length<offset) nt.innerHTML=intro_text.substring(0,offset)
			 else nt.innerHTML=intro_text.substring(0,offset)+"_";
			//showtime=setInterval('update()',100);
			var nt_link1=document.getElementById('news_link_1');
			//this.parentNode.firstChild=news[selected];
		}
		else
		{
			var nt_link_old=document.getElementById('news_link_'+selected);
			nt_link_old.style.borderColor="#FFFFDD";
			offset=0;
			selected++;
			//var send_to_back=ids.shift();
			//ids.push(send_to_back);
			scrolling=1;
			clip_left=0;
			deselectall();
			//showtime=setInterval('update()',1000);
			
		}
	}
	*/
}
function hidediv(id) {
	//safe function to hide an element with a specified id
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'none';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'none';
		}
		else { // IE 4
			document.all.id.style.display = 'none';
		}
	}
}

function showdiv(id) {
	//safe function to show an element with a specified id
		  
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'block';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'block';
		}
		else { // IE 4
			document.all.id.style.display = 'block';
		}
	}
}

