 (function($) {
	$.fn.customFadeIn = function(speed, callback) {
		$(this).fadeIn(speed, function() {
			if(jQuery.browser.msie)
				$(this).get(0).style.removeAttribute('filter');
			if(callback != undefined)
				callback();
		});
	};
	$.fn.customFadeOut = function(speed, callback) {
		$(this).fadeOut(speed, function() {
			if(jQuery.browser.msie)
				$(this).get(0).style.removeAttribute('filter');
			if(callback != undefined)
				callback();
		});
	};
})(jQuery);
 
 
 $(document).ready
(
	function() 
	{
		$('img#card').hover(function() {
									
		$(this).attr("src",cardBack);
			}, function() {
		$(this).attr("src",cardFront);
		});
		
		
		$('.choose_thanks').click(
		function() {
			testimonyID=$(this).attr('id');
			testimonyID=testimonyID.replace(/t_/, '');
			var choose_layer = '#layer_card_'+testimonyID;
			$('.candidate_cards').hide();
			$(choose_layer).show();
			$('.top_cat_float').removeClass('thumb_on');
			$(this).parent().addClass('thumb_on');
			return false;
		}
		);
		
		$('.text_pick').click(
		function() {
			testimonyID=$(this).attr('id');
			testimonyID=testimonyID.replace(/t_/, '');
			var choose_layer = '#text_div_'+testimonyID;
			$(this).parent().parent().children('.text_div').hide();
			$(choose_layer).show();
			return false;
		}
		);
		
		
		
		$('.hover_logo').hover(
		function() {
		
		available_top = $(this).position().top;
		offset = $(this).offset();
		contentOffset = $('.content').offset();//offset();
		//alert(' contentOffset '+contentOffset.top+' offset: '+offset.top);
		thisTop = offset.top;
		thisLeft = offset.left;
		thisHeight=$(this).height();
		thisWidth=$(this).width();
		middleWidth = thisWidth/2;
		arrowLeft = (thisLeft-contentOffset.left)+middleWidth-17;
		testimonyID=$(this).attr('id');
		testimonyID=testimonyID.replace(/t_/, '');
		testimony = '<p>'+text[testimonyID]+'</p>';
		attributee = '<p><strong>'+attrib[testimonyID]+'</strong>'+attrib_name[testimonyID]+'</p>';
		combinedHTML = testimony+attributee;
		
		$('.testimonial_box   .test_mon_text').html(combinedHTML);
		var height = $('.testimonial_box').height();
		//alert(height+' top: '+available_top);
		//if($(this).hasClass('show_below'))
		if(height > available_top)
		{
			place = thisTop-contentOffset.top;
			$('.testimonial_box').css('top',place+thisHeight);
			$('.up_arrow > img').css('left',arrowLeft);
			$('.up_arrow').show();
			$('.down_arrow').hide();
			//alert(arrowLeft)
		}
		else
		{
			test_boxHeight=$('.testimonial_box').height();
			place = thisTop-contentOffset.top-test_boxHeight+15;
			$('.testimonial_box').css('top',place);
			$('.down_arrow > img').css('left',arrowLeft);
			$('.up_arrow').hide();
			$('.down_arrow').show();
		}
		
		$('.testimonial_box').customFadeIn('fast', function() { 
			   //no more fiddling with attributes here
			});
		},
		function() {
			
			$('.up_arrow').show();
			$('.down_arrow').hide();
			$('.testimonial_box').hide();
		
			
		}
		);
		
		
		
		
	}
	
);


function showTestimonial(t,inRow,out)
 {
 	
	if(window.text[t])
	{
		offset = $(this).offset();
		alert(offset.top)
		$('.testimonial_box').hide();
		
		if(arguments.length==2)//click event
		{
			
			$('.testimonial_box > .test_mon_text').html(text[t]);
			$('.testimonial_box').show();
		}
	}
 
 }