// Cryobank global.js


//start Global jquery functions

$(document).ready(function() {				

	//open links with rel="external" in a new window.  ick.
	$("a[@rel='external']").click( function () {
		window.open(this.href);return false
	});
	
	var myURL = 'www.cryobank.com';
	$('a[href^=http://]').not('[href*='+myURL+']').attr('rel','nofollow');
	$('a[href^=http://]').not('[href*='+myURL+']').attr('target','_blank');


	// Button Hover for < IE6
	$("button").not(".dp_tallbtn").hover(function(){
		$(this).addClass("iehover");
	 		},function(){
 			$(this).removeClass("iehover");
		});
	// IE6 hover for tall buttons
	$("button.dp_tallbtn").hover(function(){
		$(this).addClass("iehovertall");
	 		},function(){
 			$(this).removeClass("iehovertall");
		});


	// tabbed pages. donor_search.js unbinds tabs on donorsearch pages
		if ($('body.donorsearch').length<1){
		$('#tabwrap > ul').tabs({fxFade: true, fxSpeed: 'slow'});
		}
	
	// tab Hover for < IE6
	$("#tabs li").hover(function(){
		$(this).addClass("tabiehover");
	 		},function(){
 			$(this).removeClass("tabiehover");
		});
	
	// Dropdown Hover for < IE6
	$("#navigation li").hover(function(){
		$(this).addClass("dropdownhover");
	 		},function(){
 			$(this).removeClass("dropdownhover");
		});
	
	// Get drop downs to go over select element
	$('#aboutus-dropdown').bgiframe({src: '/_resources/js/bgiframe.html'});
	$('#learningcenter-dropdown').bgiframe({src: '/_resources/js/bgiframe.html'});

	//	$('##tabwrap').tabs({remote: true});

	//stripe donor results tables by adding a class to each even row
   	//$(".myaccount table tbody tr:even").addClass("evenrow");
		$(".myaccount table tbody, #mySavedSearches tbody").each(function() {
			$(this).find("tr:even").addClass("evenrow");
		});

     //modal alert boxes
	$(".statusMsgBox").jqm().jqmShow();

	//enable rating system on forms with the class 'rating'
	// breaks on pages without the form so making sure it exists first


	if ($('form.rating').length > 0 && !(document.all)) {
			$('form.rating').rating();
	};

	//registration form hides/shows
	if ($('#registerUser').length>0){
	$('#registerUser #hearAboutUsOther, #registerUser [@for="hearAboutUsOther"]').wrap('<span class="hide hearAboutUsOther"></span>');
	$('#registerUser #hearAboutUs option').not('[@value="5004"]').click(function(){$('.hearAboutUsOther').hide('fast');});
	$('#registerUser #hearAboutUs option[@value="5004"]').click(function(){$('.hearAboutUsOther').show('fast');});
	}
	
	// classing special form elements for ie6
		$("input[type='checkbox']").addClass('checkbox');
		$("input[type='radio']").addClass('radio');
	
	$(".overflow p").click(function(){
		$("link").each(function() {
			$(this).attr("media", ($(this).attr("media") == "print")?"screen":$(this).attr("media"));
		});
	});


/* This disables the submit new topic/new reply button in the forums after the first click, which prevents the same post from being (accidentally or otherwise) posted repeatedly. */
$(".forums #addpost").submit(function(){ $("#addpost input.formbutton").attr("disabled", "disabled"); });

	//tooltips on the registration page
	$(".login_page a.tooltip").Tooltip({track: true, showURL: false});

/************ some formatting things *****************/


/*ensures that sidebar is always high enoughto display backgrounds properly*/
$("#subnavwrap").each(function(){
	var subnavheight = $(this).height();
	if(subnavheight < 525) {
		$("#lowerbtnwrap").css("margin-top", 525-subnavheight+"px");
	}
});

}); //doc ready
 
