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').slideDown(110);
			}, function(){
				if ($(this).children('.sub_menu').length>0) {
					$(this).children('.sub_menu').slideUp(110, 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();
	$('#disclaimer').cluetip({width:'480', arrows:true, cursor: 'pointer', cluetipClass:'jtip', positionBy: 'bottomTop'});

	// facebox
	$('a[rel*=facebox]').facebox();
	
	$('.profile_edit_pane h3:first-child').css('margin-top', '0px');

	$('input[name=member_type]').change(function() {
		var checked = $('input[name=member_type]:checked').val();
		if(checked == 'NON-MEMBER') {
			$('#nonmember_section').show();
			$('#member_section').hide();
		} 
		if(
			checked == 'INDIVIDUAL' 
			|| checked == 'PREMIER' 
			|| checked == 'STUDENT'
		) {
			$('#nonmember_section').hide();
			$('#member_section').show();
		}
	});
	if (post_member_type) {
		$('input[name=member_type]').trigger('change');
	}
	
	// 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;
	});

	// blinking messages
	setTimeout(function(){ 
		$('.message').hide();
		setTimeout(function(){ 
			$('.message').show();
			setTimeout(function(){ 
				$('.message').hide();
			}, 600);
		}, 600);
	}, 600);

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

	$(".read_more_control a").each(function(){
		$(this).click(function(){
			$(this).parents(".read_more").children(".read_more_contents").show();
			$(this).parents(".read_more_control").hide();
		});
	});
});
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();
}

