$(document).ready(function() { hideStreams(); } );

function hideStreams() {

	// Hide all streambox div's at startup
	$('div.streamsbox').hide();
	
	// Uncheck all streambox showing checkboxes
	$('input.streams_checkbox').attr('checked',false);
	
	// Add event to show streambox divs
	$('input.streams_checkbox').each(
		function() {
			$(this).click(
				function() {
				
					//Hide all open lightboxes
					$('div.streamsbox').hide(100);
					
					var recheck = false;
					
					// Check of the current checkbox is being checked
					if($(this).attr('checked') == true) {
						var recheck = true;
					}
					
					// Uncheck all checkboxes, including this one
					$('input.streams_checkbox').attr('checked',false);
					
					// Recheck the checkbox if originally being checked
					if(recheck) {
						$(this).attr('checked', true);
					}
					
					// Grab id value and lop off 'checkbox', giving lightbox number
					/*
					var id = $(this).attr('id');
					id = id.substring(8);
					*/
					
					
					// Show or hide streambox
					if($(this).attr('checked') == true) {
						$(this).siblings('div.streamsbox').show(200);
					}
					else {
						$('div.streamsbox').hide(100);
					}
				}
			);
		}
	);
	$('input.closebutton').each(
		function() {
			$(this).click(
				function() {
				
					//Hide all open lightboxes
					$('div.streamsbox').hide(100);
					
					// Uncheck all checkboxes, including this one
					$('input.streams_checkbox').attr('checked',false);
				}
			);
		}
	);	
}
