//window.alert('testing');
$(document).ready(function(){

	var ha = new Array();
	var ln = $('#fc');
	var listtop = 5;
	/*
		loop through all scrolling list li's and add heights to the ha array
	*/
	var it = 0;

	$("#fc li").each(function(idx){
		
		var h = $(this).height();
		it += h;
		itid = $(this).attr('id');
		obj = new Object()
		obj.name = itid;
		obj.height = h;
		ha.push(obj);
		
	});
	//window.alert(ha);
	$('#scrollbox').css({height: (it+5)});
	
	/*
		loop through all the links and set them up to scroll to the right list position
	*/
	$('area').each(function(idx){
		var id = "r"+($(this).attr('id')).substring(4);
		
		$(this).bind('click',function(){
			//window.alert($(this).attr('id'));
			var myid = id;
			//window.alert(myid);
			
			//alert(t);
			//delete this object in array and then add to the top and rebuild the array
			
			  for(var i=0; i<ha.length; i++) {
				if (ha[i].name == myid) {
					//alert(myid);
					e = ha[i];
					
					ha.splice(i,1);
					
					ha.unshift(e);
				};
			  }
			tval=0;
			for(var i=0; i<ha.length; i++) {
				
				r = '#'+ha[i].name;
				//alert(r);
				$(r).addClass("featureblur");
				$(r).removeClass("featurefocus");
				$(r).animate({top:tval},500);
				tval += ha[i].height;
				
				if(i==0){
					var cssObj = {
			        	'background-color'  : '#C1272D',
						'color'				: '#ffffff'
				      }
					//'background-image' : 'url(../assets/css/images/redstrip.jpg)'
					//'background-repeat' : 'repeat-x'
					$(r).addClass('featurefocus');
				}
				
				if(i==ha.length-1){
					$(r).css({borderBottom : '1px solid #ccc'});
				}
			}
			
			$('body').scrollTo({top:190,left:0},500);
			return false;
			
		});
		
	});
	
	//hide extra text for explanation and set up toggle
	$('#explnk').bind('click',function(){
		$('#explaintxt').toggle(200);
		$(this).toggle(200);
		$('#exphide').toggle(200);
	});
	$('#exphide').bind('click',function(){
		$('#explaintxt').toggle(200);
		$(this).toggle(200);
		$('#explnk').show();
	});
	$('#explnk, #exphide').css({color:'#c1272d'});
	$('#explaintxt').hide();
	$('#exphide').hide();
	
});
