/*
Function to stripe rows or columns of a table
*/
var foo;


$.tfxStripeTable = function(options) {
	var defaults = {
		tableClassName: 'striped',
		headerClassName: 'header-row',
		oddClassName: 'odd-row',
		evenClassName: 'even-row',
		highlightRow: true,
		highlightRowClassName: 'highlight-row',
		highlightColumn: false,
		highlightColumnClassName: 'highlight-column'
	};

	var opts = $.extend(defaults, options);
	
	//Add stripes to table rows ignoring headings + rows with opts.headerClassName class
	var tableString="table."+opts.tableClassName+" > tbody";
	
	$(tableString).each(function() {
		foo=$(this).children().siblings().andSelf();
								 
		var rowString = "tr[class!="+opts.headerClassName+"]:not(:has(th))";

		$(this).find(rowString+':odd').addClass(opts.oddClassName);
		$(this).find(rowString+':even').addClass(opts.evenClassName);
	});

	//enable row mouseovers if desired
	if(opts.highlightRow) {
		var tableString = "table."+opts.tableClassName+" tr:not(:has(th))";

		$(tableString).hover(function() {
			$(this).addClass(opts.highlightRowClassName);
		}, function() {
			$(this).removeClass(opts.highlightRowClassName);
		});
	}
	
	//enable column mouseovers -- We do not highlight headings!
	if(opts.highlightColumn) {
		$('td').hover(function() {
			var index = $(this).parent().children().index(this); 
			
			var tableString = "table."+opts.tableClassName+" tr[class!="+opts.headerClassName+"]:not(:has(th))";
			
			$(tableString).each(function() {
				$(':nth-child(' + (index + 1) + ')' ,this).addClass(opts.highlightColumnClassName);
			});
		}, function() {
	    	var index = $(this).parent().children().index(this);
		    $(tableString).each(function() {
				$(':nth-child(' + (index + 1) + ')' ,this).removeClass(opts.highlightColumnClassName);		
			});
	  	});
	}

};

/*
Function to swap captcha image when clicked
*/
$.tfxSwapCaptcha = function() {
		$('#captchaTip').show();
	
		$('#captcha').click(function () { 
			$(this).hide();
			$(this).attr('src', 'http://www.teleflex.com/captcha/captcha.jpg?'+ new Date() );
			$(this).fadeIn(); 
		});
		
		$('#captcha').hover(
			function () { 
				$(this).css('cursor','pointer'); 
			},
			function () {
				$(this).css('cursor','default'); 
			}
		);
};