// JavaScript Document

$(function(){
    //alert('can someone please tell me what IE hates me?');
    
	$('.tabContent, .tabContentVertical').tabs();
	$('input[@type=text]', 'div.givingGallery div.form').addClass('type_text');
	
	// count how many paragraphs are found in the story body, divide by two to get the halfway point,
	// then subtract 1 so its more vertically alligned and visually appealing. then put the pullquote div after the nth p. w00t.
	var location = Math.floor( $('div.contentBody p', 'body.campaign').length / 2 ) - 1;
    $('div.contentBody', 'body.campaign').find('p:eq('+location+')').after( $("#pullquote")[0] );
   
	var timeoutId;
	var container = 'div.tabGiftsInAction';
	$(container).tabs().find('ul:eq(0)>li a').each(function(i) {
		$(this).bind('mouseover', function() {
			$(container).triggerTab(i + 1);
		});
	});
	 
	$(".dataTable tr").mouseover(function() {$(this).addClass("rowOver");}).mouseout(function() {$(this).removeClass("rowOver");});
	$(".dataTable tr:even").addClass("altRow");
    
    try {
        $('div.story a','div.givingGallery').prepend('<div class="cover"></div>').Tooltip({
    		delay: 0,
    		track: true,
    		event: "mouseover",
    		xtraClass: "storyToolTip",
    		track: true,
    		delay: 100,
    		showURL: false,
    		showBody: " ~ ",
    		fixPNG: false
    	});  
	} catch(e) {	
	    // I love Microsoft...    
	} 
    
	$('a.popup').click(function(){
		var rel = $(this).attr('rel');
		var href = $(this).attr('href');
		if(!rel){
			window.open(href,'newWindow');
		} else {
			var rel_split = rel.split(':');
			var w = rel_split[0];
			var h = rel_split[1];
			var leftPos=(screen.width-w)/2;
			var topPos=(screen.height-h)/2;
			window.open(href,'newWindow','width='+w+',height='+h+',left='+leftPos+',top='+topPos+',scrollbars=no,resizable=no,statusbar=no,menubar=no,toolbar=no');
		}
		return false;		
	});

    
});













