Cufon.replace('h1');
Cufon.replace('h2');
Cufon.replace('.menu_parent_a');
Cufon.replace('#starmap_menu li div');
Cufon.replace('.button_grid');
Cufon.replace('.quote p');

$(document).ready(function() {
	$('#main_menu li')
		.hover(function(){
				$(this).addClass('hover');
				$(this).children('.sub_menu').show()
			}, function(){
				if ($(this).children('.sub_menu').length>0) {
					$(this).children('.sub_menu').slideUp(0, function(){
						$(this).parent('li').removeClass('hover');
					});
				} else {
					$(this).removeClass('hover');
				}
			}
		)
	;
	$('#main_menu li:gt(0)').addClass('after_first');
	$('.grid tr:even').addClass('every_other');

	// flash in opaque mode
	$('.object_container object').append('<param name="wmode" value="opaque">');
	$('.object_container embed').attr('wmode', "opaque");

	// flash in proper dimensions
	var width = $('object,embed').attr('width');
	var height = $('object,embed').attr('height');
	var new_width = Math.floor($('.main_column').width() * .65) - 10;
	var new_height = Math.floor(height * new_width/width) - 10;
	$('object,embed').attr('width', new_width);
	$('object,embed').attr('height', new_height);

	//set class for links to external sites and other document types
	$('a[href^="http://"]').addClass('external').attr('target', '_blank');
	$('a[href$=".pdf"]').addClass('pdf').attr('target','_blank');
	$('a[href$=".ppt"]').addClass('powerpoint').attr('target','_blank');
	$('a[href$=".doc"]').addClass('word').attr('target','_blank');
	$('a[href$=".xls"]').addClass('excel').attr('target','_blank');
	$('a[href$=".csv"]').addClass('excel').attr('target','_blank');

	// cluetip
	$('.cluetip').cluetip({showtitle:false, cluetipClass:'jtip'});
	$('#disclaimer').cluetip({width:'480', arrows:true, cursor:'pointer', cluetipClass:'jtip', positionBy:'bottomTop', showtitle:false});

	// facebox
	$('a[rel*=facebox]').facebox();
	
	// join/renew page
	changeJoinRenewOptions();
	$('input[name=member_type]').change(function() {
		changeJoinRenewOptions();
	});

	// edit profile tabs
	var $tabs = $("#profile_edit_panes")
		.tabs({
			cookie: { expires: 30 },
			spinner: '...' 
		});
	$('.select_tab').live('click', function(){
		$tabs.tabs('select', $(this).attr('href'));
		return false;
	});

	$('.profile_edit_pane h3:first-child').css('margin-top', '0px');
	
	// blinking message on profile edit
	setTimeout(function(){ 
		$('.message').hide();
		setTimeout(function(){ 
			$('.message').show();
			setTimeout(function(){ 
				$('.message').hide();
			}, 600);
		}, 600);
	}, 600);

	// rating_adjustment_application_showhide
	$(".rating_adjustment_application_show").click(function(){
		$("#rating_adjustment_application_showhide").show();
	});
	$(".rating_adjustment_application_hide").click(function(){
		$("#rating_adjustment_application_showhide").hide();
	});

	// news item "read more" control
	$(".read_more_control a").click(function(){
		$(this).closest(".read_more_control").hide();
		$(this).closest(".read_more").children(".read_more_contents").slideDown();
	});
});
function openWin(url) {
	window.open(url,'','scrollbars,resizable,width=780,height=620,left=200px,top=100px,toolbar=no');
}
function popupLocation(location_id) {
	popupwindow = window.open('location_detail.php?location_id='+location_id, 'locationpopup', 'width=850,height=650,scrollbars=yes,resizable=yes,toolbar=no');
	popupwindow.focus();
}
function changeJoinRenewOptions() {
	var checked = $('input[name=member_type]:checked').val();
	if(checked == 'NON-MEMBER') {
		$('#nonmember_section').show();
		$('#member_section').hide();
	} else {
		$('#nonmember_section').hide();
		$('#member_section').show();
	}
}

