/* To load on ajax call for groups*/
function _loadTinyMCE() {
tinyMCE.init({
	// General options
	mode : "exact",
	elements : "editor",
	theme : "advanced",
	skin : "o2k7",
	skin_variant : "black",
	plugins : "safari,spellchecker,pagebreak,style,layer,table,advhr,advimage,advlink,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template",
	// Theme options
	theme_advanced_buttons1 : "forecolor,bold,italic,underline,strikethrough,sub,sup,|,justifyleft,justifycenter,justifyright,justifyfull,|,fontselect,fontsizeselect,formatselect",
	theme_advanced_buttons2 : "link,unlink,anchor,image,cleanup,|,bullist,numlist,|,tablecontrols,|,hr,removeformat,visualaid,|,charmap",
	theme_advanced_buttons3 : "styleprops,code,preview,|,search,replace,|,undo,redo",
	theme_advanced_toolbar_location : "top",
	theme_advanced_toolbar_align : "left",
	theme_advanced_statusbar_location : "bottom",
	theme_advanced_resizing : true,
	plugin_preview_width : "750",
	plugin_preview_height : "550",

	// Example content CSS (should be your site CSS)
	content_css : "css/User.css",

	// Drop lists for link/image/media/template dialogs
	valid_elements : "@[style|class|title|rel],"
+ "a[rev|charset|hreflang|type|name|href|target|title],strong/b,em/i,strike,u,"
+ "#p,-ol[type|compact],-ul[type|compact],-li,br,img[longdesc|usemap|"
+ "src|border|alt=|title|hspace|vspace|width|height|align],-sub,-sup,"
+ "-blockquote,-table[border=0|cellspacing=0|cellpadding|width|frame|rules|"
+ "height|align|summary|bgcolor|background|bordercolor],-tr[rowspan|width|"
+ "height|align|valign|bgcolor|background|bordercolor],tbody,thead,tfoot,"
+ "#td[colspan|rowspan|width|height|align|valign|bgcolor|background|bordercolor"
+ "|scope],#th[colspan|rowspan|width|height|align|valign|scope],caption,-div,"
+ "-span,-code,-pre,address,-h1,-h2,-h3[class],-h4,-h5,-h6,-div,hr[size|noshade],-font[face"
+ "|size|color],dd,dl,dt,cite,abbr,acronym,del[datetime|cite],area[shape|coords|href|alt|target],bdo,"
+ "button,col[align|char|charoff|span|valign|width],form[action|accept|accept-charset|enctype|method],"
+ "input[accept|alt|checked|disabled|maxlength|name|readonly|size|src|type|value],"
+ "kbd,option[disabled|label|selected|value],select[disabled|multiple|name|size],label[for]",
	template_external_list_url : "js/template_list.js",
	external_link_list_url : "js/link_list.js",
	external_image_list_url : "js/image_list.js",
	media_external_list_url : "js/media_list.js",
});
};

/**
 * jQuery Roundabout - v1.1
 * http://fredhq.com/projects/roundabout/
 *
 * Moves list-items of enabled ordered and unordered lists long
 * a chosen path. Includes the default "lazySusan" path, that
 * moves items long a spinning turntable.
 *
 * Terms of Use // jQuery Roundabout
 * 
 * Open source under the BSD license
 *
 * Copyright (c) 2010, Fred LeBlanc
 * All rights reserved.
 * 
 * Redistribution and use in source and binary forms, with or without 
 * modification, are permitted provided that the following conditions are met:
 * 
 *   - Redistributions of source code must retain the above copyright
 *     notice, this list of conditions and the following disclaimer.
 *   - Redistributions in binary form must reproduce the above 
 *     copyright notice, this list of conditions and the following 
 *     disclaimer in the documentation and/or other materials provided 
 *     with the distribution.
 *   - Neither the name of the author nor the names of its contributors 
 *     may be used to endorse or promote products derived from this 
 *     software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
 * POSSIBILITY OF SUCH DAMAGE.
 */

jQuery.extend({roundabout_shape:{def:'lazySusan',lazySusan:function(r,a,t){return{x:Math.sin(r+a),y:(Math.sin(r+3*Math.PI/2+a)/8)*t,z:(Math.cos(r+a)+1)/2,scale:(Math.sin(r+Math.PI/2+a)/2)+0.5}}}});jQuery.fn.roundabout=function(){var options=(typeof arguments[0]!='object')?{}:arguments[0];options={bearing:(typeof options.bearing=='undefined')?0.0:jQuery.roundabout_toFloat(options.bearing%360.0),tilt:(typeof options.tilt=='undefined')?0.0:jQuery.roundabout_toFloat(options.tilt),minZ:(typeof options.minZ=='undefined')?100:parseInt(options.minZ,10),maxZ:(typeof options.maxZ=='undefined')?400:parseInt(options.maxZ,10),minOpacity:(typeof options.minOpacity=='undefined')?0.40:jQuery.roundabout_toFloat(options.minOpacity),maxOpacity:(typeof options.maxOpacity=='undefined')?1.00:jQuery.roundabout_toFloat(options.maxOpacity),minScale:(typeof options.minScale=='undefined')?0.40:jQuery.roundabout_toFloat(options.minScale),maxScale:(typeof options.maxScale=='undefined')?1.00:jQuery.roundabout_toFloat(options.maxScale),duration:(typeof options.duration=='undefined')?600:parseInt(options.duration,10),btnNext:options.btnNext||null,btnPrev:options.btnPrev||null,easing:options.easing||'swing',clickToFocus:(options.clickToFocus!==false),focusBearing:(typeof options.focusBearing=='undefined')?0.0:jQuery.roundabout_toFloat(options.focusBearing%360.0),shape:options.shape||'lazySusan',debug:options.debug||false,childSelector:options.childSelector||'li',startingChild:(typeof options.startingChild=='undefined')?null:parseInt(options.startingChild,10),reflect:(typeof options.reflect=='undefined'||options.reflect===false)?false:true};this.each(function(i){var ref=jQuery(this);var period=jQuery.roundabout_toFloat(360.0/ref.children(options.childSelector).length);var startingBearing=(options.startingChild===null)?options.bearing:options.startingChild*period;ref.addClass('roundabout-holder').css('padding',0).css('position','relative').css('z-index',options.minZ);ref.data('roundabout',{'bearing':startingBearing,'tilt':options.tilt,'minZ':options.minZ,'maxZ':options.maxZ,'minOpacity':options.minOpacity,'maxOpacity':options.maxOpacity,'minScale':options.minScale,'maxScale':options.maxScale,'duration':options.duration,'easing':options.easing,'clickToFocus':options.clickToFocus,'focusBearing':options.focusBearing,'animating':0,'childInFocus':-1,'shape':options.shape,'period':period,'debug':options.debug,'childSelector':options.childSelector,'reflect':options.reflect});if(options.clickToFocus===true){ref.children(options.childSelector).each(function(i){jQuery(this).click(function(e){var degrees=(options.reflect===true)?360.0-(period*i):period*i;degrees=jQuery.roundabout_toFloat(degrees);if(!jQuery.roundabout_isInFocus(ref,degrees)){e.preventDefault();if(ref.data('roundabout').animating===0){ref.roundabout_animateAngleToFocus(degrees)}return false}})})}if(options.btnNext){jQuery(options.btnNext).bind('click.roundabout',function(e){e.preventDefault();if(ref.data('roundabout').animating===0){ref.roundabout_animateToNextChild()}return false})}if(options.btnPrev){jQuery(options.btnPrev).bind('click.roundabout',function(e){e.preventDefault();if(ref.data('roundabout').animating===0){ref.roundabout_animateToPreviousChild()}return false})}});this.roundabout_startChildren();if(typeof arguments[1]==='function'){var callback=arguments[1],ref=this;setTimeout(function(){callback(ref)},0)}return this};jQuery.fn.roundabout_startChildren=function(){this.each(function(i){var ref=jQuery(this);var data=ref.data('roundabout');var children=ref.children(data.childSelector);children.each(function(i){var degrees=(data.reflect===true)?360.0-(data.period*i):data.period*i;jQuery(this).addClass('roundabout-moveable-item').css('position','absolute');jQuery(this).data('roundabout',{'startWidth':jQuery(this).width(),'startHeight':jQuery(this).height(),'startFontSize':parseInt(jQuery(this).css('font-size'),10),'degrees':degrees})});ref.roundabout_updateChildPositions()});return this};jQuery.fn.roundabout_setTilt=function(newTilt){this.each(function(i){jQuery(this).data('roundabout').tilt=newTilt;jQuery(this).roundabout_updateChildPositions()});if(typeof arguments[1]==='function'){var callback=arguments[1],ref=this;setTimeout(function(){callback(ref)},0)}return this};jQuery.fn.roundabout_setBearing=function(newBearing){this.each(function(i){jQuery(this).data('roundabout').bearing=jQuery.roundabout_toFloat(newBearing%360,2);jQuery(this).roundabout_updateChildPositions()});if(typeof arguments[1]==='function'){var callback=arguments[1],ref=this;setTimeout(function(){callback(ref)},0)}return this};jQuery.fn.roundabout_adjustBearing=function(delta){delta=jQuery.roundabout_toFloat(delta);if(delta!==0){this.each(function(i){jQuery(this).data('roundabout').bearing=jQuery.roundabout_getBearing(jQuery(this))+delta;jQuery(this).roundabout_updateChildPositions()})}if(typeof arguments[1]==='function'){var callback=arguments[1],ref=this;setTimeout(function(){callback(ref)},0)}return this};jQuery.fn.roundabout_adjustTilt=function(delta){delta=jQuery.roundabout_toFloat(delta);if(delta!==0){this.each(function(i){jQuery(this).data('roundabout').tilt=jQuery.roundabout_toFloat(jQuery(this).roundabout_get('tilt')+delta);jQuery(this).roundabout_updateChildPositions()})}if(typeof arguments[1]==='function'){var callback=arguments[1],ref=this;setTimeout(function(){callback(ref)},0)}return this};jQuery.fn.roundabout_animateToBearing=function(bearing){bearing=jQuery.roundabout_toFloat(bearing);var currentTime=new Date();var duration=(typeof arguments[1]=='undefined')?null:arguments[1];var easingType=(typeof arguments[2]=='undefined')?null:arguments[2];var passedData=(typeof arguments[3]!=='object')?null:arguments[3];this.each(function(i){var ref=jQuery(this),data=ref.data('roundabout'),timer,easingFn,newBearing;var thisDuration=(duration===null)?data.duration:duration;var thisEasingType=(easingType!==null)?easingType:data.easing||'swing';if(passedData===null){passedData={timerStart:currentTime,start:jQuery.roundabout_getBearing(ref),totalTime:thisDuration}}timer=currentTime-passedData.timerStart;if(timer<thisDuration){data.animating=1;if(typeof jQuery.easing.def=='string'){easingFn=jQuery.easing[thisEasingType]||jQuery.easing[jQuery.easing.def];newBearing=easingFn(null,timer,passedData.start,bearing-passedData.start,passedData.totalTime)}else{newBearing=jQuery.easing[thisEasingType]((timer/passedData.totalTime),timer,passedData.start,bearing-passedData.start,passedData.totalTime)}ref.roundabout_setBearing(newBearing,function(){ref.roundabout_animateToBearing(bearing,thisDuration,thisEasingType,passedData)})}else{bearing=(bearing<0)?bearing+360:bearing%360;data.animating=0;ref.roundabout_setBearing(bearing)}});return this};jQuery.fn.roundabout_animateToDelta=function(delta){var duration=arguments[1],easing=arguments[2];this.each(function(i){delta=jQuery.roundabout_getBearing(jQuery(this))+jQuery.roundabout_toFloat(delta);jQuery(this).roundabout_animateToBearing(delta,duration,easing)});return this};jQuery.fn.roundabout_animateToChild=function(childPos){var duration=arguments[1],easing=arguments[2];this.each(function(i){var ref=jQuery(this),data=ref.data('roundabout');if(data.childInFocus!==childPos&&data.animating===0){var child=jQuery(ref.children(data.childSelector)[childPos]);ref.roundabout_animateAngleToFocus(child.data('roundabout').degrees,duration,easing)}});return this};jQuery.fn.roundabout_animateToNearbyChild=function(passedArgs,which){var duration=passedArgs[0],easing=passedArgs[1];this.each(function(i){var data=jQuery(this).data('roundabout');var bearing=jQuery.roundabout_toFloat(360.0-jQuery.roundabout_getBearing(jQuery(this)));var period=data.period,j=0,range;var reflect=data.reflect;var length=jQuery(this).children(data.childSelector).length;bearing=(reflect===true)?bearing%360.0:bearing;if(data.animating===0){if((reflect===false&&which==='next')||(reflect===true&&which!=='next')){bearing=(bearing===0)?360:bearing;while(true&&j<length){range={lower:jQuery.roundabout_toFloat(period*j),upper:jQuery.roundabout_toFloat(period*(j+1))};range.upper=(j==length-1)?360.0:range.upper;if(bearing<=range.upper&&bearing>range.lower){jQuery(this).roundabout_animateToDelta(bearing-range.lower,duration,easing);break}j++}}else{while(true){range={lower:jQuery.roundabout_toFloat(period*j),upper:jQuery.roundabout_toFloat(period*(j+1))};range.upper=(j==length-1)?360.0:range.upper;if(bearing>=range.lower&&bearing<range.upper){jQuery(this).roundabout_animateToDelta(bearing-range.upper,duration,easing);break}j++}}}});return this};jQuery.fn.roundabout_animateToNextChild=function(){return this.roundabout_animateToNearbyChild(arguments,'next')};jQuery.fn.roundabout_animateToPreviousChild=function(){return this.roundabout_animateToNearbyChild(arguments,'previous')};jQuery.fn.roundabout_animateAngleToFocus=function(target){var duration=arguments[1],easing=arguments[2];this.each(function(i){var delta=jQuery.roundabout_getBearing(jQuery(this))-target;delta=(Math.abs(360.0-delta)<Math.abs(0.0-delta))?360.0-delta:0.0-delta;delta=(delta>180)?-(360.0-delta):delta;if(delta!==0){jQuery(this).roundabout_animateToDelta(delta,duration,easing)}});return this};jQuery.fn.roundabout_updateChildPositions=function(){this.each(function(i){var ref=jQuery(this),data=ref.data('roundabout');var inFocus=-1;var info={bearing:jQuery.roundabout_getBearing(ref),tilt:data.tilt,stage:{width:Math.floor(ref.width()*0.9),height:Math.floor(ref.height()*0.9)},animating:data.animating,inFocus:data.childInFocus,focusBearingRad:jQuery.roundabout_degToRad(data.focusBearing),shape:jQuery.roundabout_shape[data.shape]||jQuery.roundabout_shape[jQuery.roundabout_shape.def]};info.midStage={width:info.stage.width/2,height:info.stage.height/2};info.nudge={width:info.midStage.width+info.stage.width*0.05,height:info.midStage.height+info.stage.height*0.05};info.zValues={min:data.minZ,max:data.maxZ,diff:data.maxZ-data.minZ};info.opacity={min:data.minOpacity,max:data.maxOpacity,diff:data.maxOpacity-data.minOpacity};info.scale={min:data.minScale,max:data.maxScale,diff:data.maxScale-data.minScale};ref.children(data.childSelector).each(function(i){if(jQuery.roundabout_updateChildPosition(jQuery(this),ref,info,i)&&info.animating===0){inFocus=i;jQuery(this).addClass('roundabout-in-focus')}else{jQuery(this).removeClass('roundabout-in-focus')}});if(inFocus!==info.inFocus){jQuery.roundabout_triggerEvent(ref,info.inFocus,'blur');if(inFocus!==-1){jQuery.roundabout_triggerEvent(ref,inFocus,'focus')}data.childInFocus=inFocus}});return this};jQuery.roundabout_getBearing=function(el){return jQuery.roundabout_toFloat(el.data('roundabout').bearing)%360};jQuery.roundabout_degToRad=function(degrees){return(degrees%360.0)*Math.PI/180.0};jQuery.roundabout_isInFocus=function(el,target){return(jQuery.roundabout_getBearing(el)%360===(target%360))};jQuery.roundabout_triggerEvent=function(el,child,eventType){return(child<0)?this:jQuery(el.children(el.data('roundabout').childSelector)[child]).trigger(eventType)};jQuery.roundabout_toFloat=function(number){number=Math.round(parseFloat(number)*1000)/1000;return parseFloat(number.toFixed(2))};jQuery.roundabout_updateChildPosition=function(child,container,info,childPos){var ref=jQuery(child),data=ref.data('roundabout'),out=[];var rad=jQuery.roundabout_degToRad((360.0-ref.data('roundabout').degrees)+info.bearing);while(rad<0){rad=rad+Math.PI*2}while(rad>Math.PI*2){rad=rad-Math.PI*2}var factors=info.shape(rad,info.focusBearingRad,info.tilt);factors.scale=(factors.scale>1)?1:factors.scale;factors.adjustedScale=(info.scale.min+(info.scale.diff*factors.scale)).toFixed(4);factors.width=(factors.adjustedScale*data.startWidth).toFixed(4);factors.height=(factors.adjustedScale*data.startHeight).toFixed(4);ref.css('left',((factors.x*info.midStage.width+info.nudge.width)-factors.width/2.0).toFixed(1)+'px').css('top',((factors.y*info.midStage.height+info.nudge.height)-factors.height/2.0).toFixed(1)+'px').css('width',factors.width+'px').css('height',factors.height+'px').css('opacity',(info.opacity.min+(info.opacity.diff*factors.scale)).toFixed(2)).css('z-index',Math.round(info.zValues.min+(info.zValues.diff*factors.z))).css('font-size',(factors.adjustedScale*data.startFontSize).toFixed(2)+'px').attr('current-scale',factors.adjustedScale);if(container.data('roundabout').debug===true){out.push('<div style="font-weight: normal; font-size: 10px; padding: 2px; width: '+ref.css('width')+'; background-color: #ffc;">');out.push('<strong style="font-size: 12px; white-space: nowrap;">Child '+childPos+'</strong><br />');out.push('<strong>left:</strong> '+ref.css('left')+'<br /><strong>top:</strong> '+ref.css('top')+'<br />');out.push('<strong>width:</strong> '+ref.css('width')+'<br /><strong>opacity:</strong> '+ref.css('opacity')+'<br />');out.push('<strong>z-index:</strong> '+ref.css('z-index')+'<br /><strong>font-size:</strong> '+ref.css('font-size')+'<br />');out.push('<strong>scale:</strong> '+ref.attr('current-scale'));out.push('</div>');ref.html(out.join(''))}return jQuery.roundabout_isInFocus(container,ref.data('roundabout').degrees)};

jQuery.extend(jQuery.roundabout_shape,{theJuggler:function(r,a,t){return{x:Math.sin(r+a),y:Math.tan(Math.exp(Math.log(r))+a)/(t-1),z:(Math.cos(r+a)+1)/2,scale:(Math.sin(r+Math.PI/2+a)/2)+0.5}},figure8:function(r,a,t){return{x:Math.sin(r*2+a),y:(Math.sin(r+Math.PI/2+a)/8)*t,z:(Math.cos(r+a)+1)/2,scale:(Math.sin(r+Math.PI/2+a)/2)+0.5}},waterWheel:function(r,a,t){return{x:(Math.sin(r+Math.PI/2+a)/8)*t,y:Math.sin(r+a)/(Math.PI/2),z:(Math.cos(r+a)+1)/2,scale:(Math.sin(r+Math.PI/2+a)/2)+0.5}},square:function(r,a,t){var sq_x,sq_y,sq_z;if(r<=Math.PI/2){sq_x=(2/Math.PI)*r;sq_y=-(2/Math.PI)*r+1;sq_z=-(1/Math.PI)*r+1}else if(r>Math.PI/2&&r<=Math.PI){sq_x=-(2/Math.PI)*r+2;sq_y=-(2/Math.PI)*r+1;sq_z=-(1/Math.PI)*r+1}else if(r>Math.PI&&r<=(3*Math.PI)/2){sq_x=-(2/Math.PI)*r+2;sq_y=(2/Math.PI)*r-3;sq_z=(1/Math.PI)*r-1}else{sq_x=(2/Math.PI)*r-4;sq_y=(2/Math.PI)*r-3;sq_z=(1/Math.PI)*r-1}return{x:sq_x,y:sq_y*t,z:sq_z,scale:sq_z}},conveyorBeltLeft:function(r,a,t){return{x:-Math.cos(r+a),y:(Math.cos(r+3*Math.PI/2+a)/8)*t,z:(Math.sin(r+a)+1)/2,scale:(Math.sin(r+Math.PI/2+a)/2)+0.5}},conveyorBeltRight:function(r,a,t){return{x:Math.cos(r+a),y:(Math.cos(r+3*Math.PI/2+a)/8)*t,z:(Math.sin(r+a)+1)/2,scale:(Math.sin(r+Math.PI/2+a)/2)+0.5}},goodbyeCruelWorld:function(r,a,t){return{x:Math.sin(r+a),y:(Math.tan(r+3*Math.PI/2+a)/8)*(t+0.5),z:(Math.sin(r+a)+1)/2,scale:(Math.sin(r+Math.PI/2+a)/2)+0.5}},diagonalRingLeft:function(r,a,t){return{x:Math.sin(r+a),y:-Math.cos(r+Math.tan(Math.cos(a)))/(t+1.5),z:(Math.cos(r+a)+1)/2,scale:(Math.sin(r+Math.PI/2+a)/2)+0.5}},diagonalRingRight:function(r,a,t){return{x:Math.sin(r+a),y:Math.cos(r+Math.tan(Math.cos(a)))/(t+1.5),z:(Math.cos(r+a)+1)/2,scale:(Math.sin(r+Math.PI/2+a)/2)+0.5}},rollerCoaster:function(r,a,t){return{x:Math.sin(r+a),y:Math.sin((2+t)*r),z:(Math.cos(r+a)+1)/2,scale:(Math.sin(r+Math.PI/2+a)/2)+0.5}},tearDrop:function(r,a,t){return{x:Math.sin(r+a),y:-Math.sin(r/2+t)+0.35,z:(Math.cos(r+a)+1)/2,scale:(Math.sin(r+Math.PI/2+a)/2)+0.5}}});

$(document).ready(function() {
/*
 * Ajax plugin for www.rphaven.com
 * Copyright (c) www.rphaven.com
 * Not for use on any other site without permission.  rp.chatroom@gmail.com
*/
	var loadTimer

	$.fn.animateLoad = function() {
		$("#rph_loading > div").css('top', (loadFrame * -40) + 'px');
		loadFrame = (loadFrame + 1) % 12;
	};

	$.fn.buildLoader = function() {
		loadFrame = 1;
		var html = '';
		var halfHeight = $(this).height()/2;
		var halfHeightAdjusted = halfHeight - 0;

		html += '<div style="width:40px;height:40px;margin:0 auto;margin-top:'+halfHeightAdjusted+'px;">';
		html += '<div id="rph_loading" style="display:block;"><div style="display:block;"></div></div>';
		html += '</div>';

		$(html).appendTo(this);
		$.fn.animateLoad();
		loadTimer = setInterval($.fn.animateLoad, 66);
	};
/*
 *
 * For Profiles
 *
 */
/*	
/* Profiles Ajax */
	var $helpBtn = $('<a class="bigBtn light ui-corner-all" href="#">View Help</a>')
	$('#editor').before($helpBtn);
	$helpBtn.bind('click', function(ev){
		ev.preventDefault();
		$.ajax({
			type: "POST", url: 'help.php',
			success : function (data) {
				var $helpDialog = $('<div />');
				$helpDialog.dialog({
			  						width: 700, height: 400, title: 'Help', top: 150
								});
				$helpDialog.html(data);
				setCollapsables();
				setTabs();
				setCarousel();
				setUnicorns();
				//console.log(data);
			}
		});
	});
	
	
	$("#profileBody *").filter(function(index) {
		return $(this).css('position') == 'fixed';
	}).css('position', 'static');

	$("#profileBody").find("*").each(function(index) {
		if( parseInt($(this).css('top')) < 0 )
			$(this).css('top', '0');
		if( parseInt($(this).css('margin-top')) < 0 )
			$(this).css('margin-top', '0');
	});

	$("a#clean, #dirty").click(function(){
		clearInterval(loadTimer);
		$("div#voteResultContainer").empty().buildLoader();
		$("div#voteResultContainer").load(this.href);
		return false;
	});
	
	$("a#miniGroup").live("click", function(){
		clearInterval(loadTimer);
		$("div#groupLoad").buildLoader();
		$.ajax({
			url: this.href,
			cache: false,
			success: function(html){
				$("div#rph_loading").parent().remove();
				$("div#profileContainer").prepend(html);
			}
		});
		return false;
	});
	
	$("a#miniGroupClose").live("click", function(){
		$("div#miniGroup").remove();
		return false;
	});	
	
/* 
 *
 * New messages stuff on all.
 *
 */
	/* For collapsing */
	$("a.collapse").toggle(
      function () {
        $("div#newmsgs dl.toggleExpand:hidden").slideDown("slow");
		$("a.collapse").empty().text("- Collapse");
      },
      function () {
        $("div#newmsgs dl.toggleExpand:visible").slideUp("slow");
		$("a.collapse").empty().text("+ Expand");
      }
    );
	
	/* mark as read link */
	$("dd.posts, dd.invites").hover(
      function () {
        $('.msgManipContainer', this).css("visibility","visible");
      }, 
      function () {
        $('.msgManipContainer', this).css("visibility","hidden");
      }
    );
	
	$(".msgManipContainer a.acceptinvite").click(function(){
	  $(this).parent().parent().load(this.href);
	  return false;
	});
	
	$(".msgManipContainer a.markread").click(function(){
	  var thisElement = this;
	  $.get(thisElement.href, function(){
		$(thisElement).parent().parent().fadeOut("slow");
	  });
	  return false;
	});
	
	$("div#newmsgs a.markall").click(function(){
	  $.get(this.href, function(){
		$("dd.posts").fadeOut("slow");
		$("div#newmsgs a.markall").before("<span>There are no longer any new messages to list here.</span>").empty();
		$("span.msgcount").removeClass("light").empty().text("You no longer have any unread messages.");
	  });
	  return false;
	});
/*
 *
 * For Groups.
 *
 */  
	
	/* Mini Profile view on Groups*/
	$(".groupMembers, .groupModerators, .groupOwners")
	  .hover(
		function () {
		  $('.miniProContainer', this).css("visibility","visible");
	  },
		function () {
		  $('.miniProContainer', this).css("visibility","hidden");
	  }
	);
  
	/* Ajax for Groups */
	$("#editSettings, #joinGroup, #leaveGroup").click(function(){
	  clearInterval(loadTimer);
	  $("div#headLoad").empty().buildLoader();
	  $("div#headLoad").load(this.href);
	  return false;
	});
  
	$("#editBody").click(function(){
	  clearInterval(loadTimer);
	  $("div#editArea").css("min-height",$("div#editArea").height()).empty().buildLoader();
	  $("div#editArea").load(this.href, function(){
		_loadTinyMCE();
	  });
	  return false;
	});
	
	$(".adminButtons").click(function(){
	  clearInterval(loadTimer);
	  $(this).nextAll('.miniProRight:first').empty().buildLoader();
	  $(this).nextAll('.miniProRight:first').load(this.href);
	  return false;
	});
	
/*
 *
 * Generic
 *
 */	
	$('ul.jsdropdown > li > a').live("click", function(){
		$(this).next('ul').toggle();
	});
	
	/* Close drop down on blur */
	$(document).bind("click", function(ev){
		var $clicked = $(ev.target);
		if( $clicked != $('ul.jsdropdown ul') && !$clicked.closest('ul.jsdropdown > li').length )
			$("ul.jsdropdown > li > ul").hide();
	});
 
	$("ul.jsdropdown > li > ul").find("a.chooseGroup").live("click", function(){
		clearInterval(loadTimer);
		$("ul.jsdropdown > li > ul").empty().buildLoader();
		$("ul.jsdropdown > li > ul").load(this.href);
		$("ul.jsdropdown > li a").text("Now select name to invite from");
		return false;
	})
	
	$("ul.jsdropdown > li > ul").find("a.chooseUser").live("click", function(){
		clearInterval(loadTimer);
		$("ul.jsdropdown > ul > li > ul").empty().buildLoader();
		$.ajax({
			url: this.href,
			cache: false,
			success: function(html){
				$("div#rph_loading").parent().remove();
				$("ul.jsdropdown").replaceWith(html);
				_bindForm();
				_clearme();
			}
		});
		return false;
	});
	
	function _bindForm() {
		$("form.ajaxSubmit").submit(function(){
			// 'this' refers to the current submitted form
			var str = $(this).serialize();
				$.ajax({
				type: "POST",
				url: this.action,
				data: str,
				success: function(html){
					$("form.ajaxSubmit").replaceWith(html);
				}
			});
			return false;
		});
	};

	/* clear text on click. */
	function _clearme() {
		$(".clearme").focus(function(){
			if ($(this).val() == this.defaultValue) {
				$(this).val() = ''; }
		})
		.blur(function(){
			if ($(this).val().length === 0) { 
				$(this).val(this.defaultValue); }
		});
	};
	
	/*
	 * Unicorns button for profiles
	 */
	setUnicorns = function(){
		$.getScript('http://www.cornify.com/js/cornify.js',function(){
			$('.unicorns').bind('click', function(){
				unicorns();
			});
			unicorns = function() {
				cornify_add();
				window.setTimeout("unicorns()", 3000);
			}
		});
	}
	
	/*
	 * Collapsable for profiles and groups
	 */
	
	setCollapsables = function(){
		/*var $collapsables = $('.collapsable');
		
		$collapsables.prepend('<span class="plusminus">+ </span>')
		$collapsables.toggle(function(){
			var $this = $(this);
			$this.find('.plusminus').text('- ');
			$this.next().slideDown();
		}, function(){
			var $this = $(this);
			$this.find('.plusminus').text('+ ');
			$this.next().slideUp();
		});
		$collapsables.next().hide();*/
		
		var $collapsables = $('.collapsable, .collapsableBefore');
		
		$collapsables.prepend('<span class="plusminus">+ </span>')
		$collapsables.toggle(function(){
			var $this = $(this);
			
			var speed = parseInt($this.attr('rel'));
			if (!speed) 
				var speed = 400;
			
			$this.find('.plusminus').text('- ');
			if ($this.hasClass('collapsable')) 
				$this.next().slideDown(speed);
			if ($this.hasClass('collapsableBefore')) 
				$this.prev().slideDown(speed);
		}, function(){
			var $this = $(this);
			
			var speed = parseInt($this.attr('rel'));
			if (!speed) 
				var speed = 400;
			
			$this.find('.plusminus').text('+ ');
			if ($this.hasClass('collapsable')) 
				$this.next().slideUp(speed);
			if ($this.hasClass('collapsableBefore')) 
				$this.prev().slideUp(speed);
		});
		$('.collapsable').next().hide();
		$('.collapsableBefore').prev().hide();	
	}
	
	/*
	 * Tabbed pages for profiles and groups.
	 */
	$.fn.equalizeHeights = function(){
		return this.outerHeight( Math.max.apply(this, $(this).map(function(i,e){ return $(e).outerHeight() }).get() ) )
	}
	setTabs = function() {
		var $pageContainers = $('.pages');
		if ($pageContainers.length > 0) {
			$pageContainers.each(function(i, el){
				var $container = $(this);
				var $tabs = $container.find('.tabs > li');
				var $pages = $container.find('.sections > div');
				var $pageContainer = $container.find('.sections');
				$tabs.each(function(i, el){
					$(this).data('eq', i)
				});
				
				$pages.equalizeHeights();
				var maxPageHeight = $pages.filter(':first').height();
				$container.find('.sections').height(maxPageHeight);
				var combinedHeights = ($tabs.parent().outerHeight() + $pageContainer.outerHeight());
				$container.height(combinedHeights);
				$container.width($container.parent().width());
				$pages.width($container.width());
				$pages.height($pageContainer.height());
				
				var offset = $container.width();
				var interval = $pages.length;
				var speed = parseInt($container.attr('rel'));
				if (!speed) 
					var speed = 500;
				
				var switchTabs = function($tab){
					var $activeTab = $tab;
					$tabs.each(function(i, el){
						var $this = $(this);
						if ($this.children().length == 2) {
							if ($this.data('eq') == $activeTab.data('eq')) {
								$this.children().eq(1).show();
								$this.children().eq(0).hide();
							}
							else {
								$this.children().eq(0).show();
								$this.children().eq(1).hide();
							}
						}
					});
				}
				$tabs.each(function(i, el){
					if (i < interval) {
						var $this = $(this);
						$this.bind('click', function(ev){
							ev.preventDefault;
							$pageContainer.animate({
								'left': '-' + (offset * i) + 'px'
							}, speed);
							switchTabs($this);
						});
					}
				});
				
				var $activeTab = $tabs.eq(0);
				switchTabs($activeTab);
				
			});
		}
	}
	
	setSwaps = function(){
		var $swapContainers = $('.swap');
		if ($swapContainers.length > 0) {
			$swapContainers.each(function(i){
				var $this = $(this);
				var $default = $swapContainers.find('.default');
				var $clicked = $swapContainers.find('.clicked');
				var $hover = $swapContainers.find('.hover');
				
				$this.hover(
					function(){
						$hover.show();
						$default.hide();
					}, 
					function () {
						$hover.hide();
						$default.show();
					});
					
				$this.toggle(
					function(){
						$clicked.show();
						$default.hide();
					}, 
					function () {
						$clicked.hide();
						$default.show();
					});
			});
		}
	}
	
	setCarousel = function(){
		$('.carousel').each(function(i){
			var $this = $(this);
			//options
			var otilt = 0.0;
			var ominOpacity = 0.4;
			var osmallest = 0.4;
			var oduration = 600;
			var oshape = 'lazySusan';
			var ostartspeed = 0.0;
			if( $this.find('.tilt').attr('rel') )
				otilt = $this.find('.tilt').attr('rel');
			if( $this.find('.opacity').attr('rel') )
				ominOpacity = $this.find('.opacity').attr('rel');
			if( $this.find('.smallest').attr('rel') )
				osmallest = $this.find('.smallest').attr('rel');
			if( $this.find('.duration').attr('rel') )
				oduration = $this.find('.duration').attr('rel');
			if( $this.find('.shape').attr('rel') )
				oshape = $this.find('.shape').attr('rel');
			if( $this.find('.startspeed').attr('rel') )
				ostartspeed = $this.find('.startspeed').attr('rel');
			$this.roundabout({
				minOpacity: ominOpacity,
				tilt: otilt,
				minScale: osmallest,
				duration: oduration,
				shape: oshape
			});
				
			setInterval(function() {
				$this.roundabout_adjustBearing(ostartspeed);
			}, 50);

		});
	}
	
	if( $("#profileBody").css('position') != 'relative' || $("#groupBody").length > 0 || $("#profileContainerEdit").length > 0 ){
		setUnicorns();
		setCollapsables();
		setTabs();
		setCarousel();
		setSwaps();
	}
	
});