$(document).ready( 
	function () {		
		if($.cookie('stayOpen') == 'no') {
			$('.options').hide();
			$('[name=stayOpen][value=no]').click();
			$('.tab a').removeClass('selected');
		}		
		bd_expr = '[id^=bd]';
		$(bd_expr).click(
			function () {
				if( $(this).attr('id') != $(bd_expr).eq(0).attr('id') && $(bd_expr).eq(0).attr('checked') == true) {
					$(bd_expr).eq(0).attr('checked', '');
				}
				if ( $(this).attr('id') == $(bd_expr).eq(0).attr('id') && $(bd_expr).filter('[checked]').not(':first').length > 0) {
					$(bd_expr).not(':first').attr('checked', '');
				}
			}
		);
		bt_expr = '[id^=bt]';
		$(bt_expr).click(
			function () {
				if( $(this).attr('id') != $(bt_expr).eq(0).attr('id') && $(bt_expr).eq(0).attr('checked') == true) {
					$(bt_expr).eq(0).attr('checked', '');
				}
				if ( $(this).attr('id') == $(bt_expr).eq(0).attr('id') && $(bt_expr).filter('[checked]').not(':first').length > 0) {
					$(bt_expr).not(':first').attr('checked', '');
				}
			}
		);
		cp_expr = '[id^=cp]';
		$(cp_expr).click(
			function () {
				if( $(this).attr('id') != $(cp_expr).eq(0).attr('id') && $(cp_expr).eq(0).attr('checked') == true) {
					$(cp_expr).eq(0).attr('checked', '');
				}
				if ( $(this).attr('id') == $(cp_expr).eq(0).attr('id') && $(cp_expr).filter('[checked]').not(':first').length > 0) {
					$(cp_expr).not(':first').attr('checked', '');
				}
			}
		);
		$('.tab a').click(
			function () {
				so_handler();
				$('.options').focus();
				return false
			}
		);
		function so_handler () {
			$('.tab a').toggleClass('selected');
			$('.options').toggle(250);			
		}		
		$('.tab a').hover( 
			function () { 
				$(this).addClass('hover') 
			}, 
			function () { 
				$(this).removeClass('hover') 
			}
		);
		$('[name=stayOpen]').click(
			function () {
				if($(this).val() == 'yes') {
					$.cookie('stayOpen', 'yes');
				} else {
					$.cookie('stayOpen', 'no');
				}
			} 
		);
	} 
);
