<!--
function updateHeadline(headline, id) {
	var queryString = 'headline=' + encodeURIComponent(headline);
	if (id) {
		queryString = queryString + '&id=' + id;
	}
	attach_file('ajax/profile_headline.php?'+queryString);
	//document.getElementById('profileHeadline').innerHTML = '<span class="txt_red">Headline Saved:</span><br />&ldquo;'+headline+'&rdquo;';
	document.getElementById('profileHeadline').innerHTML = '<span class="txt_red">Thought of the Day Saved:</span><br />&ldquo;'+headline+'&rdquo;';
	document.getElementById('headline').value = '';
}


// update the thought of the day (team specific)
function updateProfileThought(memberId, teamId, thought, action) {
	// construct the url for the ajax call that updates the database
	var sUrl = 'ajax/profile_thought.php';
	var postString = 'member_id=' + memberId + '&team_id=' + teamId + '&thought=' + thought;
    // optionally can pass an action to delete or edit the existing thought; default is to archive the old one and create a new
    if (action != '') {
        postString += '&action=' + action;
    }
	
	// making the call (no callback function)
	YAHOO.util.Connect.asyncRequest('POST', sUrl, null, postString);
}

// update one of the favorite team fields
function updateProfileFavInfo(memberId, teamId, fieldName) {
	// construct the url for the ajax call that updates the database
	var sUrl = 'ajax/profile_fav_update.php';
    var fieldValue = document.getElementById(fieldName+'_'+teamId).value;
	var postString = 'member_id=' + memberId + '&team_id=' + teamId + '&update=' + fieldName + '&value=' + fieldValue;
	
	// making the call (no callback function)
	YAHOO.util.Connect.asyncRequest('POST', sUrl, null, postString);
}

// update "about me" from the main profile view
function updateProfileAboutMe(text) {
	// construct the url for the ajax call that updates the database
	var sUrl = 'ajax/profile_aboutme.php';
	var postString = 'about_me=' + text;
	
	// making the call (no callback function)
	YAHOO.util.Connect.asyncRequest('POST', sUrl, null, postString);
}


function addShoutOut(message, memberID) {
	if (message == '') {
		alert('Please enter a Shout Out message!');
	} else {
        var commentType = document.getElementById('comment_type').value;
        var actionID = document.getElementById('action_id').value;
		attach_file('ajax/profile_comment.php?id='+memberID+'&message='+encodeURIComponent(message)+'&comment_type='+commentType+'&action_id='+actionID);
	}
}

function shoutoutClubhouseAction(message, actionID, memberID) {
    document.getElementById('comment_type').value = 'action';
    document.getElementById('action_id').value = actionID;
    addShoutOut(message, memberID);
}

// hide the points module on the profile page - this will only work for the logged-in member (uses the session member_id)
function hidePointsModule() {
	var sUrl = 'ajax/hide_points_module.php';
	// making the call (no callback function)
	new Ajax.Request(sUrl, {
		method: 'get'
	});
	// hide the module
	toggleLayer('block_member_points', 'off');
}

// show or hide the username change box
function toggleUsernameChangeModule(toggleType)
{
    if (toggleType == 'on')
    {
        toggleLayer('alertChangeScreenName','off'); 
        toggleLayer('alertChangeScreenNameDescr','on'); 
        toggleTableRow('rowChangeScreenName','on');
    }
    else
    {
        toggleLayer('alertChangeScreenName','on'); 
        toggleLayer('alertChangeScreenNameDescr','off'); 
        toggleTableRow('rowChangeScreenName','off');
    }
}

// confirm that the user does not want to change their username
function confirmNoUsernameChange()
{
    if (confirm('You will not have another chance to change your screen name.  By clicking OK, you are permanently keeping your current screen name.')) 
    { 
        toggleLayer('alertChangeScreenName','off'); 
        // kick off an ajax process to save the 'NO' to the db
        var sUrl = 'ajax/change_username.php';
	    var postString = 'change_username=N';
    	// make the call (no callback function)
    	YAHOO.util.Connect.asyncRequest('POST', sUrl, null, postString);
        // turn off the alert module
        toggleLayer('alertChangeScreenName','off'); 
    }
}

// check for a valid username and update the display with the results
function checkValidUsername()
{
    var newUsername = document.getElementById('checkUsernameValue').value;
    var sUrl = 'ajax/change_username.php';
    var postString = 'change_username=check&new_username=' + newUsername; 
    
    // setup callback function to update the display with the results
    var thisCallback =
    {
        success: function(o) 
        {
            var checkResult = YAHOO.lang.JSON.parse(o.responseText);
            var errMsg = '';
            // the username is not a valid format
            if (! checkResult.usernameValid)
            {
                errMsg = 'Format Error';
            }
            // the username is already taken
            else if (checkResult.usernameExists)
            {
                errMsg = 'Not Available';
            }
            
            // if there was an error, display the error alert icon and message
            if (errMsg != '')
            {
                toggleLayer('checkUsernameResult','on');
                document.getElementById('checkUsernameResult').innerHTML = '<div class="iconCircleRedX mrgR5"></div> ' + errMsg;
                document.getElementById('btnSaveScreenName').style.display = 'none';
                document.getElementById('btnCheckScreenName').className = document.getElementById('btnCheckScreenName').className.replace('btnSilver', 'btnOrange');
            }
            // everything is ok, display the OK icon/message and show the save button
            else
            {
                toggleLayer('checkUsernameResult','on');
                document.getElementById('checkUsernameResult').innerHTML = '<div class="iconCircleGreenCheck mrgR5"></div> Available ';
                document.getElementById('btnSaveScreenName').style.display = 'block';
                document.getElementById('btnCheckScreenName').className = document.getElementById('btnCheckScreenName').className.replace('btnOrange', 'btnSilver');
            }
        },
        failure:null
    };
    
	// make the call
	YAHOO.util.Connect.asyncRequest('POST', sUrl, thisCallback, postString);
    
}

// save the new username to the database
function saveUsernameChange(oldUsername)
{
    // make sure the username is still valid before proceeding (in case they typed again after checking)
    checkValidUsername();
    
    var newUsername = document.getElementById('checkUsernameValue').value;
    if (confirm('Caution:  Screen names can only be changed once. By clicking OK, you are permanently changing your screen name from ' + oldUsername + ' to ' + newUsername + '.'))
    {
        var sUrl = 'ajax/change_username.php';
	    var postString = 'change_username=Y&new_username=' + newUsername + '&old_username=' + oldUsername;
    	
        // setup callback function to update the display with the results
        var thisCallback =
        {
            success: function(o) 
            {
                // display the confirmation
                toggleLayer('changeScreenNameSuccess', 'on');
                toggleLayer('alertChangeScreenNameDescr','off'); 
                toggleLayer('rowChangeScreenName','off');
                document.getElementById('currentUsername').innerHTML = newUsername;
                document.getElementById('currentUsernameFormField').value = newUsername;
            },
            failure: null
        }
        
        // make the call 
    	YAHOO.util.Connect.asyncRequest('POST', sUrl, thisCallback, postString);
    }
}

// if saving basic info, check for a username change and show a confirmation if needed
function confirmSaveBasicInfo(theForm)
{
    var checkUsername = document.getElementById('checkUsernameValue');
    if (checkUsername)
    {
        var newUsername = checkUsername.value;
        var oldUsername = document.getElementById('currentUsername').innerHTML;
    }
    if (checkUsername && newUsername != '' && newUsername != oldUsername)
    {
        if (confirm('Caution:  Screen names can only be changed once. By clicking OK, you are permanently changing your screen name from ' + oldUsername + ' to ' + newUsername + '.'))
        {
            theForm.submit();
        }
        else
        {
            return false;
        }
    }
    else
    {
        theForm.submit();
    }
}

// -->
