// JScript source code

	var currwidth;
	var timer;
	var load = 0;

	function displayfocuson() {
		document.getElementById('focuson').style.display = "block";
	}
	
	function setwidth() {
		currwidth = document.documentElement.clientWidth;
	}
	
	function settimer() {
		timer = setTimeout("settimer()",10000);
		if(load == 0)
			load = 1;
		else
			slideFolio(-2);
		//alert(document.getElementById('autoscroll').innerHTML);
		if(document.getElementById('autoscroll').innerHTML == "start autoscroll")
		{
			document.getElementById('autoscroll').innerHTML = "stop autoscroll";
			//document.getElementById('autoscroll').onclick = new Function('stoptimer()');
			document.getElementById('autoscroll').href = 'javascript:stoptimer()';
		}
	}
	
	function stoptimer() {
		clearTimeout(timer);
		load = 0;
		document.getElementById('autoscroll').innerHTML = "start autoscroll";
		//alert(document.getElementById('autoscroll').onclick);
		//document.getElementById('autoscroll').onclick = new Function('settimer()');
		document.getElementById('autoscroll').href = 'javascript:settimer()';
		//alert(document.getElementById('autoscroll').onclick);
	}

	function synch() {
		document.getElementById('iam').selectedIndex = 0;
	}
	
	window.onresize = function(){
		if(currwidth != document.documentElement.clientWidth)
		{
			window.location.reload();	
		}
		currwidth = document.documentElement.clientWidth;
	}

	var numresidents = 1, numresidentsmax = 2, numbusiness = 3, numbusinessmax = 4, numvisitors = 5, numvisitorsmax = 5, numdemocracy = 6, numdemocracymax = 6, numyoung = 7, numyoungmax = 7;
	function slideFolio(col){
		var max = 7;
		if(col < 0)
		{
			for(i=1;i<=max;i++)
			{
				//alert(document.getElementById('trigger' + i).className);
				if(document.getElementById('trigger' + i).className == 'current')
				{
					//alert('current = trigger' + i);
					if(col == -2)
						col = i+1;
					else
						col = i-1;
				}
			}
		}

		if(col <= max && col >=1)
		{
			//var x = ((col-1)*-505)
			//var x = ((col-1)*-555)
			var x = ((col-1)*-680)
			var folioChange = new Fx.Tween('folio', {duration:2000});
			folioChange.start('left',x);
			var cur = "trigger"+col;
			$(cur).addClass('current');

			for (i=1;i<=max;i++){
				var loopLI = "trigger"+i;
				if (cur==loopLI){}else{
					$(loopLI).removeClass('current');
				}
			}

			var back = "backwards";
			var forw = "forward";
			if(col == 1)
				$(back).addClass('disabled');
			else if(col == max)
				$(forw).addClass('disabled');
			else {
				$(back).removeClass('disabled');
				$(forw).removeClass('disabled');			
			}
			
			var iam = "iam";
			if(col <= numresidentsmax) {
				//document.getElementById('iam').options[0].selected = "selected";
				document.getElementById('iam').selectedIndex = 0;
				document.getElementById('morefor').href = "http://www.sholland.gov.uk/focuson/residents.htm";
				document.getElementById('morefor').innerHTML = "more for residents...";
			}
			else if(col <= numbusinessmax) {
				//document.getElementById('iam').options[1].selected = "selected";
				document.getElementById('iam').selectedIndex = 1;
				document.getElementById('morefor').href = "http://www.sholland.gov.uk/focuson/business.htm";
				document.getElementById('morefor').innerHTML = "more for business...";
			}
			else if(col <= numvisitorsmax) {
				//document.getElementById('iam').options[2].selected = "selected";
				document.getElementById('iam').selectedIndex = 2;
				document.getElementById('morefor').href = "http://www.sholland.gov.uk/focuson/visitors.htm";
				document.getElementById('morefor').innerHTML = "more for visitors...";
			}
			else if(col <= numdemocracymax) {
				//document.getElementById('iam').options[2].selected = "selected";
				document.getElementById('iam').selectedIndex = 3;
				document.getElementById('morefor').href = "http://www.sholland.gov.uk/focuson/democracy.htm";
				document.getElementById('morefor').innerHTML = "more for democracy...";
			}
			else if(col <= numyoungmax) {
				//document.getElementById('iam').options[2].selected = "selected";
				document.getElementById('iam').selectedIndex = 4;
				document.getElementById('morefor').href = "http://www.sholland.gov.uk/focuson/youngpeople.htm";
				document.getElementById('morefor').innerHTML = "more for young people...";
			}
		}

	}

	function showallfeatures(toggle) {
		if(toggle=="on") {
			slideFolio(1);
			document.getElementById('focuscontainer').id = "focuscontainerall";
			document.getElementById('folio').id = "folioall";
			document.getElementById('mask').id = "maskall";
			document.getElementById('focuschoice').id = "focusall";
			
			document.getElementById('showall').href = "javascript:showallfeatures('off');";
			document.getElementById('showall').innerHTML = "scroll features";
			
			
			//document.getElementById('focuscontainerall').removeClass('clearfix');
			document.getElementById('featurestitle').style.display = "none";
			document.getElementById('pagination').style.display = "none";
			document.getElementById('toggleautoscroll').style.display = "none";
			//document.getElementById('pagination').style.visibility = "hidden";
			//document.getElementById('note').style.visibility = "hidden";

		}
		else {
			document.getElementById('focuscontainerall').id = "focuscontainer";
			document.getElementById('folioall').id = "folio";
			document.getElementById('maskall').id = "mask";
			document.getElementById('focusall').id = "focuschoice";	

			document.getElementById('showall').href = "javascript:showallfeatures('on');";
			document.getElementById('showall').innerHTML = "show all";			
			
			//document.getElementById('focuscontainer').addClass('clearfix');
			document.getElementById('featurestitle').style.display = "block";
			document.getElementById('pagination').style.display = "block";
			document.getElementById('toggleautoscroll').style.display = "block";
			//slideFolio(2);
			//slideFolio(1);
			//document.getElementById('pagination').style.visibility = "visible";
			//document.getElementById('note').style.visibility = "visible";
			window.location.reload();
		}
	}

	function updateFeatures() {
		stoptimer();
		var iamvalue = document.getElementById('iam').options[document.getElementById('iam').selectedIndex].value
		//alert(iamvalue);
		if(iamvalue == "residents"){
			slideFolio(numresidents);
			document.getElementById('morefor').href = "http://www.sholland.gov.uk/#residents";
			document.getElementById('morefor').innerHTML = "more for residents...";
		}
		else if(iamvalue == "business"){
			slideFolio(numbusiness);
			document.getElementById('morefor').href = "http://www.sholland.gov.uk/#business";
			document.getElementById('morefor').innerHTML = "more for business...";
		}
		else if(iamvalue == "visitors"){
			slideFolio(numvisitors);
			document.getElementById('morefor').href = "http://www.sholland.gov.uk/#visitors";
			document.getElementById('morefor').innerHTML = "more for visitors...";
		}
		else if(iamvalue == "democracy"){
			slideFolio(numdemocracy);
			document.getElementById('morefor').href = "http://www.sholland.gov.uk/#democracy";
			document.getElementById('morefor').innerHTML = "more for democracy...";
		}
		else if(iamvalue == "young"){
			slideFolio(numyoung);
			document.getElementById('morefor').href = "http://www.sholland.gov.uk/#young";
			document.getElementById('morefor').innerHTML = "more for young people...";
		}
	}
