jQuery.fn.rTabs = function(){
	var elm  = this;
	var $tabs = elm.children('ul.tabs').children('li').children('a');
	var $divs = elm.children('div.item');
	
	var $first = elm.children('div.tab-'+jQuery($tabs[0]).attr('rel').toString());
	
	jQuery($tabs[0]).attr('class','selected');
	jQuery($first).css('display','block');
	
	jQuery($tabs).click(function(){
		jQuery($divs).css('display','none');
		$tabs.removeAttr('class','selected');
		jQuery(this).attr('class','selected');
		jQuery(elm.children('div.tab-'+jQuery(this).attr('rel').toString())).css('display','block');
	});
};
jQuery.fn.sideTabs = function(){
	var elm		= this;
	
	var jtitles = elm.children('.jtabs_title').children('li');
	jQuery('#'+jQuery(jtitles[0]).attr('title').toString()).show();
	
	jQuery(jtitles).click(function(){
		elm.children('.jtabs_panel').hide();
		jQuery('#'+jQuery(this).attr('title').toString()).show();
	});
	
};
jQuery.fn.equalHeight = function() {
	tallest = 0;

	this.each(function() {
		thisHeight = jQuery(this).height();
		if(thisHeight > tallest) {
			tallest = thisHeight;
		}
	});
	this.height(tallest);
}
function replyTo(user, id) {
 var x=document.getElementById("comment");
 var text = "<a href=\"#comment-" + id +"\">@"+ user+"</a>";
 var current = x.value;
 if(current!='') current = current + '\n\n';
 x.value = current+''+text+': ';
 x.focus();
altlinies(x,10);
}
/** INPUT RADIO SKINNING **/
var jqTransformGetLabel = function(objfield){
		var selfForm = jQuery(objfield.get(0).form);
		var oLabel = objfield.next();
		if(!oLabel.is('label')) {
			oLabel = objfield.prev();
			if(oLabel.is('label')){
				var inputname = objfield.attr('id');
				if(inputname){
					oLabel = selfForm.find('label[for="'+inputname+'"]');
				} 
			}
		}
		if(oLabel.is('label')){return oLabel.css('cursor','pointer');}
		return false;
	};
jQuery.fn.jqTransRadio = function(){
	return this.each(function(){
		var $input = jQuery(this);
		var inputSelf = this;
			
		if($input.hasClass('jqTransformHidden')) {return;}

		oLabel = jqTransformGetLabel($input);
		$input.addClass('jqTransformHidden').wrap('<span class="jqTransformRadioWrapper"></span>');
		var $wrapper = $input.parent();
		var aLink = jQuery('<a href="#" class="jqTransformRadio" rel="'+ this.name +'"></a>');
		$wrapper.prepend(aLink);
		// Click Handler
		aLink
			.each(function(){
				this.radioElem = inputSelf;
				$(this).click(function(){
					var $a = jQuery(this).addClass('jqTransformChecked');
					inputSelf.checked = true;

					// uncheck all others of same name
					jQuery('a.jqTransformRadio[rel="'+ $a.attr('rel') +'"]',inputSelf.form).not($a).each(function(){
						$(this).removeClass('jqTransformChecked');
						this.radioElem.checked = false;
					});
					
					inputSelf.onchange && inputSelf.onchange();
					return false;					
				});
			});
		oLabel && oLabel.click(function(){aLink.trigger('click');});
		// set the default state
		inputSelf.checked && aLink.addClass('jqTransformChecked');
	});
};
