/*
    This script contains methods for working with default authentication service (Sys.Services.AuthenticationService). This service must be explicitely set up by:
   	<system.web.extensions>
        <scripting>
            <webServices>
                <authenticationService enabled="true" />
*/
// method for showing 
function ShowLogged(){
        
        var header_membership = $get('header_membership');
        header_membership.innerHTML = ''; //Reading status...(will not display at all)
        www.rferl.org.Services.MembershipService.GetDisplayName(ShowLoggedCallback,ErrorCallbackAuth);
}
function ShowLoggedCallback(result){
    
    var header_membership = $get('header_membership');
    if(result.length > 0)
    {
        header_membership.innerHTML = result;
    }
}
function ErrorCallbackAuth(error)
{
}
function RateComment(commentid,isagree){
    var ratingDiv = document.getElementById('rate'+commentid);
    if(ratingDiv!=null)
    {
		ratingDiv.className= 'item_hide';
    }
    www.rferl.org.Services.MembershipService.RateComment(commentid,isagree,RateCallback,ErrorCallbackAuth,commentid);
}
function RateCallback(result,commentid){
    if(result!=null && result.length==3)
    {
		if(result[0]=='none')
		{
			window.location='/login.aspx';
		}
		else
		{
			var ratingDiv = document.getElementById('rate'+commentid);
			if(ratingDiv!=null)
			{
				ratingDiv.className= 'ratediv';
			}
		    
			if(result[0]=='stay')
			{
				var ratingResultDiv = document.getElementById('thread'+commentid);
				if(ratingResultDiv!=null && result.length > 0)
				{
					ratingResultDiv.innerHTML= '<div class="forumMessageBox" ><table bgcolor="white" width=250 cellpadding=4 cellspacing=0  border=1 bordercolor="#FF850D" ><tr><td onclick="hideObject('+commentid+')"><b><a style="float:right;" href="javascript:hideObject('+commentid+');">X</a>&nbsp;&nbsp;'+result[2]+'</b></td></tr></table></div> '
				}
			}
			if(result[0]=='plus')
			{
				var rateicon = document.getElementById('rateplus'+commentid);
				if(rateicon!=null)
				{
					rateicon.className=rateicon.className.replace("rate","voted");
					rateicon.innerHTML = result[1];
				}
			}
			if(result[0]=='minus')    
			{
				var rateicon2 = document.getElementById('rateminus'+commentid);
				if(rateicon2!=null)
				{
					rateicon2.className=rateicon2.className.replace("rate","voted");
					rateicon2.innerHTML = result[1];
				}
			}
		}
	}	
}
function hideObject(commentid) {  
    var ratingResultDiv = document.getElementById('thread'+commentid);
    if(ratingResultDiv!=null)
    {
		ratingResultDiv.innerHTML='';
    }
}
// Notify ScriptManager that this is the end of the script.
if (typeof(Sys) !== 'undefined') Sys.Application.notifyScriptLoaded();