var selectIdName;
var selectVisibilityList;

var selectForms = new Object();

openFs = new Object();

	function toggleList (fs,selId){
		
		choices = fs.getElementsByTagName("div").item(0);
		closeFs();
		selectIdName = selId.id;
		
		
		if (choices.className == 'fsHiddenChoices'){ choices.className = 'fsShownChoices'; openFs = fs; selectVisibilityList = choices.className;
			$("#"+selectIdName).css( {borderBottom:"0px"} );
			return; }
		if (choices.className == 'fsHiddenChoices2'){ choices.className = 'fsShownChoices2'; openFs = fs; selectVisibilityList = choices.className;
			$("#"+selectIdName).css( {borderBottom:"0px"} );
			return; }
		if (choices.className == 'fsHiddenChoices3'){ choices.className = 'fsShownChoices3'; openFs = fs; selectVisibilityList = choices.className; 
			$("#"+selectIdName).css( {borderBottom:"0px"} );
			return; }
		if (choices.className == 'fsHiddenChoices4'){ choices.className = 'fsShownChoices4'; openFs = fs; selectVisibilityList = choices.className; 
			$("#"+selectIdName).css( {borderBottom:"0px"} );
			return; }
		if (choices.className == 'fsHiddenChoices5'){ choices.className = 'fsShownChoices5'; openFs = fs; selectVisibilityList = choices.className; 
			$("#"+selectIdName).css( {borderBottom:"0px"} );
			return; }
		if (choices.className == 'fsHiddenChoices6'){ choices.className = 'fsShownChoices6'; openFs = fs; selectVisibilityList = choices.className; 
			$("#"+selectIdName).css( {borderBottom:"0px"} );
			return; }
		if (choices.className == 'fsHiddenChoices7'){ choices.className = 'fsShownChoices7'; openFs = fs; selectVisibilityList = choices.className; 
			$("#"+selectIdName).css( {borderBottom:"0px"} );
			return; }
		if (choices.className == 'fsHiddenChoices8'){ choices.className = 'fsShownChoices8'; openFs = fs; selectVisibilityList = choices.className; 
			$("#"+selectIdName).css( {borderBottom:"0px"} );
			return; }
		if (choices.className == 'fsShownChoices') { choices.className = 'fsHiddenChoices'; $("#"+selectIdName).css( {borderBottom:"3px solid #d9d5ce"} ); }
		if (choices.className == 'fsShownChoices2') { choices.className = 'fsHiddenChoices2'; $("#"+selectIdName).css( {borderBottom:"3px solid #d9d5ce"} ); }
		if (choices.className == 'fsShownChoices3') { choices.className = 'fsHiddenChoices3'; $("#"+selectIdName).css( {borderBottom:"1px solid #FFF"} ); }
		if (choices.className == 'fsShownChoices4') { choices.className = 'fsHiddenChoices4'; $("#"+selectIdName).css( {borderBottom:"3px solid #d9d5ce"} ); }
		if (choices.className == 'fsShownChoices5') { choices.className = 'fsHiddenChoices5'; $("#"+selectIdName).css( {borderBottom:"1px solid #e6e1da"} ); }
		if (choices.className == 'fsShownChoices6') { choices.className = 'fsHiddenChoices6'; $("#"+selectIdName).css( {borderBottom:"1px solid #e6e1da"} ); }
		if (choices.className == 'fsShownChoices7') { choices.className = 'fsHiddenChoices7'; $("#"+selectIdName).css( {borderBottom:"1px solid #e6e1da"} ); }
		if (choices.className == 'fsShownChoices8') { choices.className = 'fsHiddenChoices8'; $("#"+selectIdName).css( {borderBottom:"1px solid #FFF"} ); }
		
	}

	function fsChoose(item){

		fs = item.parentNode.parentNode;
		//hidden = fs.getElementsByTagName("input").item(0);
		selected = fs.getElementsByTagName("a").item(0);
		//hidden.value = item.getAttribute("vl");
		if (selectVisibilityList == 'fsShownChoices')
			$("#"+selectIdName).css( {color:"#000",borderBottom:"3px solid #d9d5ce"} );
		if (selectVisibilityList == 'fsShownChoices1')
			$("#"+selectIdName).css( {color:"#000",borderBottom:"3px solid #d9d5ce"} );
		if (selectVisibilityList == 'fsShownChoices2')
			$("#"+selectIdName).css( {color:"#000",borderBottom:"3px solid #d9d5ce"} );
		if (selectVisibilityList == 'fsShownChoices3')
			$("#"+selectIdName).css( {color:"#000",borderBottom:"1px solid #FFF"} );
		if (selectVisibilityList == 'fsShownChoices4')
			$("#"+selectIdName).css( {color:"#000",borderBottom:"3px solid #d9d5ce"} );
		if (selectVisibilityList == 'fsShownChoices5')
			$("#"+selectIdName).css( {color:"#000",borderBottom:"1px solid #e6e1da"} );
		if (selectVisibilityList == 'fsShownChoices6')
			$("#"+selectIdName).css( {color:"#000",borderBottom:"1px solid #e6e1da"} );
		if (selectVisibilityList == 'fsShownChoices7')
			$("#"+selectIdName).css( {color:"#000",borderBottom:"1px solid #e6e1da"} );
		if (selectVisibilityList == 'fsShownChoices8')
			$("#"+selectIdName).css( {color:"#000",borderBottom:"1px solid #FFF"} );
		selectForms[selectIdName] = item.innerHTML;
		selected.innerHTML = item.innerHTML;
		toggleList(fs,0);

	}

	function closeFs(){
		if (selectVisibilityList == 'fsShownChoices')  {
			openFs.getElementsByTagName("div").item(0).className = 'fsHiddenChoices'; $("#"+selectIdName).css( {borderBottom:"3px solid #d9d5ce"} ); }
		if (selectVisibilityList == 'fsShownChoices1')  {
			openFs.getElementsByTagName("div").item(0).className = 'fsHiddenChoices1'; $("#"+selectIdName).css( {borderBottom:"3px solid #d9d5ce"} ); }
		if (selectVisibilityList == 'fsShownChoices2')  {
			openFs.getElementsByTagName("div").item(0).className = 'fsHiddenChoices2'; $("#"+selectIdName).css( {borderBottom:"3px solid #d9d5ce"} );  }
		if (selectVisibilityList == 'fsShownChoices3')  {
			openFs.getElementsByTagName("div").item(0).className = 'fsHiddenChoices3';  $("#"+selectIdName).css( {borderBottom:"1px solid #FFF"} ); }
		if (selectVisibilityList == 'fsShownChoices4')  {
			openFs.getElementsByTagName("div").item(0).className = 'fsHiddenChoices4';  $("#"+selectIdName).css( {borderBottom:"3px solid #d9d5ce"} ); }
		if (selectVisibilityList == 'fsShownChoices5')  {
			openFs.getElementsByTagName("div").item(0).className = 'fsHiddenChoices5';  $("#"+selectIdName).css( {borderBottom:"1px solid #e6e1da"} ); }
		if (selectVisibilityList == 'fsShownChoices6')  {
			openFs.getElementsByTagName("div").item(0).className = 'fsHiddenChoices6';  $("#"+selectIdName).css( {borderBottom:"1px solid #e6e1da"} ); }
		if (selectVisibilityList == 'fsShownChoices7')  {
			openFs.getElementsByTagName("div").item(0).className = 'fsHiddenChoices7';  $("#"+selectIdName).css( {borderBottom:"1px solid #e6e1da"} ); }
		if (selectVisibilityList == 'fsShownChoices8')  {
			openFs.getElementsByTagName("div").item(0).className = 'fsHiddenChoices8';  $("#"+selectIdName).css( {borderBottom:"1px solid #FFF"} ); }
	}
	
	globalBodyOnClickList = Array();
	function addToBodyOnClick(funct){
		document.onclick = bodyOnClick;
		globalBodyOnClickList[globalBodyOnClickList.length] = funct;
	}
	function bodyOnClick(){
		for (var i=0;i<globalBodyOnClickList.length;i++){
			globalBodyOnClickList[i]();
		}
	}

	addToBodyOnClick(closeFs);