// Select box
$(document).ready(function(){

	var m=0;
	$("#selectBox label").each(function(){
		$(this).click(function(){
			if( m==0 ) {	// If menu is closed
				$("#selectBox label").css({	// Display all labels
						display: "block"
					});
				$("#selectBox")
					.css({	// Toggle menu background
						backgroundImage: "url(/images/sbc-bg-open.png)",
						height: "142px"
					});
				$("#selectBox.smallBox")
					.css({	// Toggle menu background
						backgroundImage: "url(/images/sbc-in-bg-open.png)",
						height: "142px"
					});
				$(this).attr("id", "");	// Remove id=open
				
				
				
				m=1; // Menu is open
			}
			else {	// If menu is open
				$(this).attr("id", "open");	// Add id=open
				$("#selectBox label").each(function(){
					if( !$(this).is("#open") ) {
						$(this).css({	// Hide all labels except the one with id=open
							display: "none"
						});
					}
				});
				$("#selectBox").css({	// Toggle menu background
					backgroundImage: "url(/images/sbc-bg.png)", 
					height: "25px"
				});
				$("#selectBox.smallBox").css({	// Toggle menu background
					backgroundImage: "url(/images/sbc-in-bg.png)", 
					height: "25px"
				});
				m=0;	// Menu is closed
				
				$("#"+$(this).attr("for")).attr("checked", "checked");
			}
		});
	});

});
