if (null != ning.CurrentProfile) {  //Only when logged-in

if ($('#gixawconnect').length !== 0){ //Only for group connect page

if ($.getURLParam("group")==null) {
  $('#gixawconnect').html('<h1 style="font-size:20px">Logged in as Member</h1>');
} else {

var gUrl = $.getURLParam("group");

$.ajax({
	type: "POST",
	data: "data=" + $("#data").val(),
	//url: "http://tasandbox.ning.com/group/"+gUrl+"/invitation/new",
	url: "http://www.trackahead.com/group/"+gUrl+"/invitation/new",
	success: function(msg){
	$("#content").html(msg)
		//var re_title = new RegExp("<h1>Invite to [\n\r\s]*(.*)[\n\r\s]*</h1>");
		//var content = msg;


                var x = $(msg).find("#invite_by_emails").html();
                var sessionError = false;
                if(x){
                  if(x.length !==0 ) {

				var gn = $(msg).find("h1").html();
				var groupName= gn.replace("Invite to","");
 
				sessionError = true;
				$('#gixawconnect').html('<h1 style="font-size:20px;color:green">'+groupName+' Group Session Active.</h1><p style="font-size:18px">You are now connected to this group. To browse through your chatroom, click on the button below to go to the main chat page. Once you entered the "Getting Started" screen, you can find your selected group by clicking the chatroom tab as shown below<br><center><img src="http://api.ning.com/files/MvvAFBcRuPmagcWX6G37HsuqM1l700d4OstdEvUc1t1LcBaq3uEV1LG3aT2yX8JwgnzMrJsZWzLYCqVkrnS7qBt2CwbvzvrG/image004.png" /><img src="http://api.ning.com:80/files/nAcKYoFIvWq2DZmWfdo0ex7YkLm7IJLoiB51kPjeOyQ_/disclaimer.gif" alt=""></center> </p><center><a onclick="window.open(\'http://trackahead.gixawchat.com/index.php?request=index\',\'TrackAhead Chat\',\'width=900,height=800,toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,copyhistory=yes,resizable=yes\');"><img src="http://trackaheadapps.com/gixaw/startchat.png" /></a></center><br/><br/><br/><p style="font-size:16px">If you need to log in to another group, you can do this by going to the <a href="/page/group-chatroom-connect">Group Chatroom Connect</a> page</p>'); 

				$('#xg_foot').append('<iframe style="display:none" id="gixawc" />');
				$('#gixawc').attr('src', 'http://trackaheadapps.com/gixaw/session.php?gcon='+gUrl);


                  }
                }
        if(sessionError == false) $("#gixawconnect").html('<h1 style="font-size:20px;color:red">Connection Error:</h1><p style="font-size:18px">You must join this <a style="color:green" href="/group/'+gUrl+'">group</a> to participate in this chatroom session.</h1>');
	}

});

}//
}//Only for group connect page
}//Only when logged-in