var pages = [["",""], ["home"], ["about", "aboutpss", "news", "testimonials", "features"], ["products", "psslive", "weblog", "smartphones", "functions"], ["customers", "contractors", "localauthorities", "parishcouncils", "inspectors"], ["help", "faqs", "videos", "training", "contact"], ["../about", "../aboutpss", "../news", "../testimonials", "../features"], ["", "login"]];  

function setPage(page, subPage){ // Sets up the current page
	
	if(page > 0){
		var btn = pages[page][0] + "btnfocus.png";													// Changes the button for the link
		var id = document.getElementById(pages[page][0]);											// of the current page to be its
		id.innerHTML = '<img src="images/header/links/' + btn + '" alt="' + pages[page][0] + '">'	// focus button
	
		if(subPage > 0){
			var sub = document.getElementById(pages[page][subPage]);
			sub.style.color = '#039BD4';
		}
	}
		
	// array of testimonials
	var quotes = ["We managed our Play Site Inspections and Maintenance, using PlaySafe, successfully for three years before migrating to PSSLive and have found it to be a much improved management tool. PSSLive is an excellent tool with a wide range of functions that enable us to record inspections and maintenance and to monitor budgets. The fact that the data is always up to date for all users when they access the software eliminates any confusion. The reporting element is invaluable for planning improvements to or replacement of equipment. PSSLive has also eliminated the need to keep paper records as the Web-enabled software holds the records so that they are immediately available when required, particularly at times when supporting data is required for a claim when there has been an accident",
				"The system provides a paperless record of all inspections carried out, It is a great asset management tool that assists with the production of planned maintenance schedules and much more. There is a good audit trail which is required should a claim for injury arise",
				"This has really helped in managing beach car parks, local halls, recreation facilities and land. I use only a small fraction of the features available but for a clerk whose needs are to handle variety, rather than quantity of the same thing, it simplifies so much",
				"At Lewes District Council, we have recently started using StaySafe for logging all of our tree stock. Our inspectors using the PDAs carry out inspections of the trees to ensure that they are healthy and safe. Any arboriculture work required on the tree will be 'tasked' at the same time. We have found the software to be very user friendly; and it's always good to know that there is a fast response from PSS if we need a helping hand!",
				"With so many play areas and records that have to be kept for over 20 years PlaySafe has saved paper, storage and time required to search for records. Not only that, it has made staff accountable and the play areas safer and more attractive place to be.  A versatile tool that can be used by all personnel (from cleansing staff to RPII inspectors) at a level they are comfortable with which produces vital information for the operation of our 500 play sites, an important part of our landscape accountability and input in to the Green Flag Scheme",
				"Using Public Sector's Software we successfully and paperlessly manage the inspection and reporting on a wide range of Council assets, including Play areas, Housing, Parks and Open Spaces, Trees, School Sites, Cemeteries and Health and Safety site issues and our PAT Electrical Tests",
				"Public Sector Software are single handedly changing the face of quality monitoring in the grounds maintenance sector, the increased use of information technology at home has impacted on our work in a positive way improving our productivity and our customer relationships through innovation. Glendale will continue to seek innovative partners to drive forward the performanceof our industry and offer clients an affordable usable technological solution"
				]; 
	
	//array of authors
	var authors = ["Peter Jones",
				"Rushden Town Council",
				"David Menday",
				"Andy Frost",
				"Philip Snell",
				"John Hopkins",
				"Adrian Wickham",
				];
	
	id = document.getElementById('quote');
	var auth = document.getElementById('author');
	var len = quotes.length
	var num = Math.floor(Math.random()*len);	// Generates a random number such that 0 < n < len, where n is the random number and len is the length of the array. The number
												// generated will decide which testimonial is shown and which author goes with it
	
	if((num >= 0) && (num < quotes.length)){				// Double-checks that the random number generated falls within the bounds of the array
		id.innerHTML = '&quot;' + quotes[num] + '&quot;';	// if so, the corresponding testimonial is displayed
		auth.innerHTML = authors[num];
	}else{													// The else statement here is used so that if the random number fails the check,
		id.innerHTML = '&quot;' + quotes[0] + '&quot;';		// the first testimonial will be displayed, rather than displaying nothing
		auth.innerHTML = authors[0];
	}
}

count = 0;
news = [ "", "news1",  "news2", "news3",  "news4",  "news5", "news6", "news7", "news8", "news9", "news10", "news11", "news12", "news13", "news14", "news15", "news16", "news17", "news18", "news19", "news20", "news21",
			"news22", "news23", "news24", "news25", "news26", "news27", "news28", "news29", "news30", "news31", "news32", "news33"];

older = ["", "news1",  "news2",  "news3",  "news4",  "news5",  "news6",  "news7"]
jun11 = ["", "news8",  "news9", "news10", "news11", "news12"]
jul11 = ["", "news13"]
aug11 = ["", "news14", "news15", "news16", "news17", "news18", "news19"]
sep11 = ["", "news20", "news21", "news22", "news23", "news24", "news25", "news26", "news27", "news28", "news29"]
oct11 = [""]
nov11 = [""]
dec11 = ["", "news30", "news31", "news32", "news33"]

function chooseMonthlyNews(mnth, num){
	var choice;
	
	switch(mnth){
		
		case 0100:
			choice = older[num];
			break;
			
		case 0611:
			choice = jun11[num];
			break;
		
		case 0711:
			choice = jul11[num];
			break;
			
		case 0811:
			choice = aug11[num];
			break;
			
		case 0911:
			choice = sep11[num];
			break;
		
		case 1011:
			choice = oct11[num];
			break;
		
		case 1111:
			choice = nov11[num];
			break;
			
		case 1211:
			choice = dec11[num];
			break;
	}

	setMonthlyNews()
}

function setMonthlyNews(){



}

function chooseNews(num){
	count = num;
	setNews(0);
	
	hide('newsindex');
	show(news[num]);
	show('newsnav');
}

function chooseIndex(){
	for(i=1; i < news.length; i++){
		hide(news[i]);
	}
	hide('newsnav');
	show('newsindex');
	count = 0;
}

function setNews(){
	var elem = document.getElementById('newsprev');
	elem.innerHTML = '<a href="#main" onclick="navNews(-1)"><< previous news</a>';
	elem = document.getElementById('newsnext');
	elem.innerHTML = '<a href="#main" onclick="navNews(1)">next news >></a>';
	
	if(count == 1){
		elem = document.getElementById('newsprev');
		elem.innerHTML = '<i>no earlier news</i>';
	}else if(count == (news.length - 1)){
		elem = document.getElementById('newsnext');
		elem.innerHTML = '<i style="float: right;">no more news</i>';
	}
}

function navNews(direction){
	hide(news[count]);

	if(direction > 0){
		count++;
	}else if(direction < 0){
		count--;
	}
	
	setNews();
	show(news[count]);
}

function hide(id){ // hides an element when the div id is passed to it
	var e = document.getElementById(id);
	e.style.display = 'none';
}

function choosebox(id){
	
	switch(id){
		case 1:
			show('box1');
			hide('box2');
			break;
		case 2:
			show('box2');
			hide('box1');
			break;
	};
	
}


function show(id){ // hides an element when the div id is passed to it
	var e = document.getElementById(id);
	e.style.display = 'block';
}
