/* $CVS$ */
  function setClassName(targetDivClassName, className, classNameToRemove){
                var threads = $$(targetDivClassName);
                var i = 0;
                while (i < threads.length)
            	{
            		Element.addClassName(threads[i], className);
            		Element.removeClassName(threads[i], classNameToRemove);
            		i++;
            	}
                AjaxService.setThreadFont(className);
   } 

var sticky = function ( data )
{
 	images = document.images;
	source = !data ? "images/award_star_gold_2.png" : "images/award_star_silver_3.png";
	msg = data ? "Thread marked as sticky" : "Thread stickiness removed ";
	stickyTitle = data ? "Unsticky this thread" : "Mark this thread sticky";
	i = 0;
	
	while (i < images.length)
	{
		if ( images[i].alt=="stickiness_toggle") 
		{
			images[i].src= source;
			images[i].title= stickyTitle;
		}
		i++;
	}
	alert (msg);
}

function toggleAPod(toToggle, blindEffectOn,  podName)
{
	AjaxService.toggleView(podName);		 
	new Effect.toggle($(blindEffectOn), 'blind');
}

var reply0 = function(data)
{
	createADiv();
	divContents = constructString(data);
    showProfileDiv(divContents)
}

function createADiv()
{
	var div = document.createElement('div');
	div.id = "userprofile";
	document.body.appendChild(div);
}
function constructString(data) 
{
var profileString = "<div id=\"profileTitle\"><h2>"+ data.username +"'s Profile Summary</h2><a href=\"#\" onclick=\"HideContent('userprofile'); return false;\">x</a></div>" 
    profileString = profileString + "<div id=\"profileContent\">";
	profileString = profileString + "<p><a href=\"/" + window.location.href.split("/")[3] + "/pmpost!default.jspa?userID=" + data.ID + "\">Private message this user &raquo;</a></p>";
    profileString = profileString + "<p>Country:&nbsp;" + data.country + "</p>" ;
    profileString = profileString + "<p>Registered:&nbsp;" + data.creationDateFormatted + "</p>" ;
	profileString = profileString + "<p>Messages:&nbsp;" + data.userMessageCount + "</p>";
	profileString = profileString + "<p><a href=\"/members/" + data.username + "\">View full profile &raquo;</a></p></div>";
	
    return profileString;
}

/** Stuff to show/hide profile**/
function showProfileDiv(divContents)
{
	document.getElementById("userprofile").innerHTML = divContents;
	ShowContent('userprofile');	
}
var cX = 0; var cY = 0;
function UpdateCursorPosition(e){ cX = e.pageX; cY = e.pageY;}
function UpdateCursorPositionDocAll(e){ cX = event.clientX + document.body.scrollLeft
			+ document.documentElement.scrollLeft; cY = event.clientY + document.body.scrollTop
			+ document.documentElement.scrollTop;}
if(document.all) { document.onmousemove = UpdateCursorPositionDocAll; }
else { document.onmousemove = UpdateCursorPosition; }

function AssignPosition(d) {
d.style.left = (cX+10) + "px";
d.style.top = (cY+10) + "px";
}
function HideContent(d) {
if(d.length < 1) { return; }
document.getElementById(d).style.display = "none";
}
function ShowContent(d) {
if(d.length < 1) { return; }
var dd = document.getElementById(d);
AssignPosition(dd);
dd.style.display = "block";
}
function ReverseContentDisplay(d) {
if(d.length < 1) { return; }
var dd = document.getElementById(d);
AssignPosition(dd);
if(dd.style.display == "none") { dd.style.display = "block"; }
else { dd.style.display = "none"; }
}


/** Toggle Post / Save Draft / Discard Buttons to off and submit */

function doPostMessage(/*ElementID*/ postId, 
                       /*String*/ strPostButtonTitle, 
                       /*ElementID*/ saveDraftId,
                       /*ElementID*/ discardId, 
                       /*Element(Form)ID*/ postFormId)
{
   try
   {
     if (!postId)
     	return;
     
     if (!postFormId)
        return;
     
     var elePost = document.getElementById(postId);
     
     if (!elePost)
        return;
     
     if (strPostButtonTitle)
	  	elePost.value=strPostButtonTitle;

	 elePost.disabled='true';
	 
	 if (saveDraftId)
	 {
	    var eleSaveDraft = document.getElementById(saveDraftId);
		if (eleSaveDraft)
		  	eleSaveDraft.disabled='true';
	 }
	
	 if (discardId)
	 {
	 	var eleDiscard = document.getElementById(discardId);
	 	if (eleDiscard)
	  		eleDiscard.disabled='true';	
	 }
	 
	 
	 document.getElementById(postFormId).submit();
   }
   catch (e)
   {}
} 




