/**
 * My Profile Module JS Files
 * @author Pathfinder Solutions India
 * @link http://www.pathfindersolutions.biz
 * @version 1.0
 * @package justmeans
 * @subpackage User
 */

var ajaxObjects = new Array();
var opencommentdiv = false;

/*THIS VARIABLE IS USE TO SHOW USER'S COMMENT COUNT*/
var enmShowProfileConversation = 0;

function fnShowChangePhoto()
{
	document.getElementById('id_changephoto').style.display = "";
}

function fnHideChangePhoto()
{
	document.getElementById('id_changephoto').style.display = "none";
}

function fnShowChangeImageBox(strDivId,boolAlwaysShow)
{
	window.scroll(0,0);
	try
	{
		if (boolAlwaysShow == 0)
			document.getElementById('id_changephoto').style.display = "none";	
		
		Lightbox.showBoxByID(strDivId, 475,325);
		fnShowInfoLoadingImage(strDivId);
		ajaxObjects[40] = new sack();
		ajaxObjects[40].requestFile = sitename+"/index.php?action=myprofile&mode=ajax&ajax_action=changephotoframe";
		ajaxObjects[40].onCompletion = function(){ 
													document.getElementById(strDivId).innerHTML = ajaxObjects[40].response;
												};
		ajaxObjects[40].runAJAX();
	}
	catch (e)
	{}
}

function fnValidatePostData()
{
	var strErrorMessage = "";
	if (document.getElementById('id_txtUserPhoto').value == "")
		strErrorMessage = "Enter Profile picture.\n";
		
	if (strErrorMessage == "")
	{
		alert(strErrorMessage);
		return false;
	}
	return true;
}

function fnShowEditInfoLink()
{
	document.getElementById("id_EditAboutInfoLink").style.display = "";
}

function fnHideEditInfoLink()
{
	document.getElementById("id_EditAboutInfoLink").style.display = "none";
}

function fnShowEditInfoBox()
{
	fnToggleMenu(3,4);
	fnShowInfoLoadingImage("id_container_3");
	
	ajaxObjects[2] = new sack();
	ajaxObjects[2].requestFile = sitename+"/index.php?action=edituserinfo&byajax=1";
	ajaxObjects[2].onCompletion = function(){ 
												try{
												document.getElementById("id_LeftEditProfileLink").style.display = "none";
												}
												catch(e)
												{}
												document.getElementById("id_container_3").innerHTML = ajaxObjects[2].response;
												fnScrollWindow("id_container_3");
												var userlookupCity_323 = "userregioncity_323";
												//autoCom.add("userlookupCity_323","http://192.168.10.60/jmwhite/modules/geography/inc/ajax_cities.php");
												autoCom.add("userlookupCity_323",sitename+"/modules/geography/inc/ajax_cities.php");
												window.scroll(0,0);
												try
												{
													ajaxObjects[41] = new sack();
													ajaxObjects[41].requestFile = sitename+"/index.php?action=myprofile&mode=ajax&ajax_action=changeprofilephotoframe";
													ajaxObjects[41].onCompletion = function(){ 
																								document.getElementById("id_changeprofilephoto1").innerHTML = ajaxObjects[41].response;
																							};
													ajaxObjects[41].runAJAX();
												}
												catch (e)
												{}
											};
	ajaxObjects[2].runAJAX();
}

function fnShowProfileInfo()
{
	fnShowInfoLoadingImage("id_container_3");
	try{
		if (document.getElementById("id_LeftEditProfileLink").style.display == "none")
			document.getElementById("id_LeftEditProfileLink").style.display = ""
	}
	catch(e)
	{}
		
	
	ajaxObjects[3] = new sack();
	ajaxObjects[3].requestFile = sitename+"/index.php?action=myprofile&mode=ajax&ajax_action=showallprofileinfo";
	ajaxObjects[3].onCompletion = function(){
														document.getElementById("id_container_3").innerHTML = ajaxObjects[3].response;
														fnScrollWindow("id_container_3");
											};
	ajaxObjects[3].runAJAX();
}

function fnHideEditInfoBox(intSessionUserId)
{
	document.frmEditOrgAboutMeInfo.reset();
	fnChangeUserInfo(intSessionUserId);
}

function fnChangeUserInfo(intSessionUserId)
{
	strText = document.getElementById('id_txtUserAbout').value;
	if(500 - strText.length  < 0)
	{			
		ajax_showTooltip('id_ErrorMsgCntExceedDiv',document.getElementById("id_submitbio"),300,65);
		return false;		
	}
	
	strUserEmployerName = "";
	intUserEmployerId = 0;
	strAboutUserText = "";
	
	strUserEmployerName = document.getElementById("userlookupcompany").value;
	intUserEmployerId   = document.getElementById("txtUserEmployer").value;
	
	strAboutUserText    = document.getElementById("id_txtUserAbout").value;
	strAboutUserText 	= Base64.encode(strAboutUserText);
	
	if (strUserEmployerName == "" && strAboutUserText == "")
	{
		alert("Please enter at least your organisation name or important work.");
		return false;
	}
	
	ajaxObjects[0] = new sack();
	//ajaxObjects[0].requestFile = sitename+'/index.php?action=newmyprofile&mode=ajax&ajax_action=changeuserinfo&employer='+strUserEmployerName+'&about='+strAboutUserText+'&user='+intSessionUserId+'&intemployer='+intUserEmployerId
	ajaxObjects[0].requestFile = sitename+'/index.php?action=myprofile&mode=ajax&ajax_action=changeuserinfo&employer='+strUserEmployerName+'&about='+strAboutUserText+'&user='+intSessionUserId+'&intemployer='+intUserEmployerId;
	ajaxObjects[0].onCompletion = function(){ fnShowUserInformation(ajaxObjects[0].response); };
	ajaxObjects[0].runAJAX();
}

function fnShowUserInformation(response)
{
	// SET RETURN HTML TO CENTER TAB
	document.getElementById("id_edituserinfo").innerHTML = response;
	
	// SET RETURN HTML TO LEFT PANEL
	fnSetLeftPanelUserInfo(1);
}

function fnSetLeftPanelUserInfo(intShowEditLink)
{
	ajaxObjects[1] = new sack();
	ajaxObjects[1].requestFile = sitename+"/index.php?action=myprofile&mode=ajax&ajax_action=setleftinformation&showeditlink="+intShowEditLink;
	ajaxObjects[1].onCompletion = function(){ 
												document.getElementById("id_LeftInformationBox").innerHTML = ajaxObjects[1].response; 
											};
	ajaxObjects[1].runAJAX();
}

function fnToggleMenu(intSelectedMenu, intMenuCount)
{
	for (i = 1; i <= intMenuCount; i++)
	{
		if (i == intSelectedMenu)
		{
			document.getElementById("id_submenu_"+i).className = "active";
			document.getElementById("id_container_"+i).style.display = "";
		}
		else
		{
			document.getElementById("id_submenu_"+i).className = "";
			document.getElementById("id_container_"+i).style.display = "none";
		}
	}
	fnHideShowLeftAddUpdateLink();
}

function fnToggleMyMenu(intSelectedMenu, intMenuCount,strProfileUserId)
{
	intProfileUserId = strProfileUserId;
	var ajaxData ='';
	if(intSelectedMenu && intProfileUserId)
	{
		for (i = 1; i <= intMenuCount; i++)
		{
			if (i == intSelectedMenu)
			{
				document.getElementById("id_submenu_"+i).className = "active";
				document.getElementById("id_container_"+i).style.display = "";
				fnShowInfoLoadingImage('id_container_'+i);
			}
			else
			{
				document.getElementById("id_submenu_"+i).className = "";
				document.getElementById("id_container_"+i).style.display = "none";
			}
			document.getElementById("id_submenu_"+i).href = "javascript:;";
		}
		ajaxObjects[6] = new sack();
		ajaxObjects[6].requestFile = sitename+"/index.php?action=myprofile&mode=ajax&ajax_action=showselectedmenudata&userprofileid="+intProfileUserId+"&intmenu="+intSelectedMenu;
		ajaxObjects[6].onCompletion = function(){
												ajaxData = ajaxObjects[6].response;
												try{
													for (i = 1; i <= intMenuCount; i++)
													{
														if (i == intSelectedMenu)
														{
															document.getElementById("id_submenu_"+i).className = "active";
															document.getElementById("id_container_"+i).style.display = "";
															document.getElementById("id_container_"+i).innerHTML = ajaxData;
														}
														else
														{
															document.getElementById("id_submenu_"+i).className = "";
															document.getElementById("id_container_"+i).style.display = "none";
															document.getElementById("id_submenu_"+i).href = "javascript: fnToggleMyMenu("+i+",4,'"+intProfileUserId+"');void(0);";
														}
													}
													fnHideShowLeftAddUpdateLink();												
												}
												catch(e){}
											}
		ajaxObjects[6].runAJAX();	
	}
	if(intSelectedMenu != 3)
	{
		if(document.getElementById("id_LeftEditProfileLink"))
			document.getElementById("id_LeftEditProfileLink").style.display = "";
	}
}

function fnAddUpdateRequest(intProfileUserId)
{
	pattern = new RegExp(/\d/);
	
	if (pattern.test(intProfileUserId) == false || intProfileUserId == 0)
	{
		alert("Invalide Request.")
		return false;
	}
	
	var ajaxObjects = new Array();
	var ajaxIndex = ajaxObjects.length;
	ajaxObjects[ajaxIndex] = new sack();
	ajaxObjects[ajaxIndex].requestFile = sitename+'/index.php?action=myprofile&mode=ajax&ajax_action=addupdaterequest&profileuser='+intProfileUserId
	ajaxObjects[ajaxIndex].onCompletion = function(){ fnShowSendRequestHtml(ajaxObjects[ajaxIndex].response); };
	ajaxObjects[ajaxIndex].runAJAX();
}

function fnSendConnectRequest(loginuserid,recieverid)
{
	if(recieverid != "" || recieverid != 0)
	{
		var ajaxIndex = ajaxObjects.length;	
		ajaxObjects[ajaxIndex] = new sack();
		ajaxObjects[ajaxIndex].requestFile = sitename+"/index.php?action=setunsetsessionvars&mode=ajax&ajax_action=setsessionparams&settoparams=forconnectuser&connectrecieverid="+recieverid;
		ajaxObjects[ajaxIndex].onCompletion = function(){ 
															if(loginuserid == 0 || loginuserid == "")
															{
																//Lightbox.showBoxByID("divRegisterLogin", intLoginPopupWidth, intLoginPopupHeight);
																fnNewRegisterLogin(0,0);
																//return false;
															}
															else
															{
																if(loginuserid == recieverid)
																{
																	document.getElementById("relationsipdiv").style.display="";
																	document.getElementById("relationsipdiv").innerHTML="<br /><br /><b><font color='#FF0000'>Sorry, you can not connect with yourself</font></b>"; 
																}
																else
																{
																	fnAjaxCaller("relationsipdiv","sendconnecttouser","","&isbyajax=1","","");
																	document.getElementById("relationsipdiv").style.display="none";
																}
															}
															
														};	// Specify function that will be executed after file has been found
		ajaxObjects[ajaxIndex].runAJAX();
	}
}

function fnShowEditProfileInfo(objInfoDiv)
{
	var strEditId;
	strEditId = objInfoDiv.id+"edit";
	
	try
	{
		document.getElementById(strEditId).style.visibility = 'visible';
	}
	catch(err)
	{
		//alert(err.message);
	}
}

function fnHideEditProfileInfo(objInfoDiv)
{
	var strEditId;
	strEditId = objInfoDiv.id+"edit";
	
	try{
		document.getElementById(strEditId).style.visibility = 'hidden';
	}
	catch(err)
	{
		//alert(err.message);
	}
}

var ajaxObjects = new Array();

function fnSendRequestToConnect(loginuserid, recieverid)
{
	if(recieverid != "" || recieverid != 0)
	{
		var ajaxIndex = ajaxObjects.length;	
		ajaxObjects[ajaxIndex] = new sack();
		ajaxObjects[ajaxIndex].requestFile = sitename+"/index.php?action=setunsetsessionvars&mode=ajax&ajax_action=setsessionparams&settoparams=forconnectuser&connectrecieverid="+recieverid;
		ajaxObjects[ajaxIndex].onCompletion = function(){ 
		
															if(loginuserid == 0 || loginuserid == "")
															{
																//Lightbox.showBoxByID("divRegisterLogin", intLoginPopupWidth, intLoginPopupHeight);
																fnNewRegisterLogin(0,0);
																//return false;
															}
															else
															{
																if(loginuserid == recieverid)
																{
																	document.getElementById("divmessagebox").style.display="";
																	document.getElementById("divmessagebox").innerHTML="<br /><font color='#FF0000'>Sorry, you can not connect with yourself</font></b>"; 
																}
																else
																{
																	fnAjaxCaller("divmessagebox","sendconnecttouser","","&isbyajax=1","","");
																	document.getElementById("divmessagebox").style.display="none";
																}
															}
															
														};	// Specify function that will be executed after file has been found
		ajaxObjects[ajaxIndex].runAJAX();
	}
	
}

function fnShowUserProfileInfo(strShowSection)
{
	switch (strShowSection)
	{
		case "generalinfo":
		strReturnDivId = "id_EditGeneralInfo";
		arrDivPosition = fnFindPos(document.getElementById("id_GeneralInfoHeader"));
		break;
		
		case "contactinfo":
		strReturnDivId = "id_EditContactInfo";
		arrDivPosition = fnFindPos(document.getElementById("id_ContactInfoHeader"));
		break;
		
		case "workeduinfo":
		strReturnDivId = "id_EditWorknEducation";
		arrDivPosition = fnFindPos(document.getElementById("id_WorkEduInfoHeader"));
		break;
	}
	
	window.scroll(0,arrDivPosition[1]);
	
	var ajaxIndex = ajaxObjects.length;	
	ajaxObjects[ajaxIndex] = new sack();
	ajaxObjects[ajaxIndex].requestFile = sitename+"/index.php?action=myprofile&mode=ajax&ajax_action=showuserprofileinfo&section="+strShowSection;
	ajaxObjects[ajaxIndex].onCompletion = function(){
														document.getElementById(strReturnDivId).innerHTML = ajaxObjects[ajaxIndex].response;
													};
	ajaxObjects[ajaxIndex].runAJAX();
}

function fnFindPos(obj)
{
    var curleft = curtop = 0;  
    if (obj.offsetParent)
	{  
        curleft = obj.offsetLeft  
        curtop = obj.offsetTop  
        while (obj = obj.offsetParent)
		{  
            curleft += obj.offsetLeft  
            curtop += obj.offsetTop  
        }  
    }  
    return Array(curleft, curtop);
}

function fnScrollWindow(strObjectId)
{
	arrDivPosition = fnFindPos(document.getElementById(strObjectId));
	window.scroll(0,arrDivPosition[1]);
}

function fnAboutCharCnt()
{	
	var strText;
	strText = document.getElementById('id_txtUserAbout').value;

	//if(strText != "Share your ideas here...")
	
	if(500 - strText.length >= 20)
	{	
		//document.getElementById('id_chartextcnt').innerHTML = 140 - strText.length;
		document.getElementById('id_charcount').className = "charcount";
	}
	else if((500 - strText.length < 20) &&  (500 - strText.length > 10) )
	{					
		document.getElementById('id_charcount').className = "charcount20";
	}
	else
	{
		document.getElementById('id_charcount').className = "charcountnegative";
	}
	if(strText == "Enter your about you text here...")
		document.getElementById('id_charcount').innerHTML = 500;
	else
		document.getElementById('id_charcount').innerHTML = 500 - strText.length;		
	
}

function fnSetAboutText()
{	
	var strabouttext = document.getElementById('id_txtUserAbout').value;
	if(strabouttext == "" || strabouttext == "Enter your about you text here...")
	{
		document.getElementById('id_txtUserAbout').value = "";
	}
}


function fnDeleteUserUpdates(intStatusMsgId)
{
	ajax_hideTooltip();
	window.location = sitename+"/deletetweet?tweetid="+intStatusMsgId+"&location=myprofile";		
	return true;
}
	
function fnShowEditProfileHtml()
{
	fnToggleMenu(3,4);
	fnShowUserEditHTML('generalinfo','id_EditGeneralInfo','');
	arrDivPosition = fnFindPos(document.getElementById("id_GeneralInfoHeader"));
	window.scroll(0,arrDivPosition[1]);
}

function fnShowInfoLoadingImage(strContainerHtml)
{
	document.getElementById(strContainerHtml).innerHTML = "<div style='text-align:center; padding: 40px;'><span style='font-size: 20px; font-weight: bold; color: #AAAAAA;'>Loading...</span><br /><br /><img src='images/big_slide_loader.gif' align='absmiddle'></div>";
}

function fnHideInfoLoadingImage(strContainerHtml)
{
	document.getElementById(strContainerHtml).innerHTML = "";
}

function fnClearBoxText(strTextBoxId)
{
	
	
	if (document.getElementById(strTextBoxId).value == strEnterText)
	{
		
		//document.getElementById(strTextBoxId).style.height = "";
		//document.getElementById(strTextBoxId).className 	= "input";
		document.getElementById(strTextBoxId).value = "";
		document.getElementById(strTextBoxId).focus();
	}
	fnCheckCharCnt();
}

function fnAddWhatGoodWork(strTextBoxId, intLoginUserId, objButton)
{
	/*if (parseInt(intLoginUserId) == 0)
	{
		alert("INVALID INPUT");
		return false;
	}*/
	
	var string = document.getElementById(strTextBoxId).value;
	string = trim(string);
	if(string == "")
	{
		ajax_showTooltip('id_GoodWorkError',document.getElementById(objButton),200,48);
		return false;
	}	
	var myarry = new Array();
	myarry = string.split(' '); 
	for (i=0;i<myarry.length;i++)
	{	
		if((myarry[i].length) >= 50)
		{	
			if((!myarry[i].match("http://")) && (!myarry[i].match("www")) && (!myarry[i].match("http://www")) && (!myarry[i].match("https://")))
			{
				ajax_showTooltip('id_GoodWorkNewsFeedLengthError',document.getElementById(objButton),200,40);
				return false;
			}
		}
	}
	
	if (document.getElementById(strTextBoxId).value == strEnterText)
	{
		ajax_showTooltip('id_GoodWorkError',document.getElementById(objButton),200,40);
		document.getElementById(strTextBoxId).focus();
		return false;
	}
	else if (document.getElementById(strTextBoxId).value == "")
	{
		ajax_showTooltip('id_GoodWorkError',document.getElementById(objButton),200,40);
		document.getElementById(strTextBoxId).focus();
		return false;
	}
	else
	{
		if (document.getElementById(strTextBoxId).value.length > 140)
		{
			ajax_showTooltip('id_GoodWorkLengthError',document.getElementById(objButton),200,50);
		}
		else
		{
			ajaxObjects[38] = new sack();
			ajaxObjects[38].requestFile = sitename+"/index.php?action=myprofile&mode=ajax&ajax_action=increasegoodworkcount&user="+intLoginUserId;
			ajaxObjects[38].onCompletion
			{
				return fnValidateInputForWAU(intLoginUserId,'myprofile','','','');	
			}
			
			ajaxObjects[38].runAJAX();
		}
	}
	fnCheckCharCnt();
}

function fnSetPreviousValue(objText)
{
	if (objText.value == "")
	{
		objText.value 		   = strEnterText;
		objText.className 	   = "input";
		//objText.style.overflow = "auto";
		//objText.style.height = "";
	}
	(objText.style.overflow);
}

function fnToggleNewsFeed(strFeedType,strUserId)
{
	if (strFeedType == "")
		return "";

	document.getElementById("id_AllUpdatelink").href= "javascript:;";
	document.getElementById("id_UserUpdatelink").href = "javascript:;";
	document.getElementById("id_UserConversationlink").href = "javascript:;";
	
	document.getElementById("id_AllUpdatelinklist").className = "";
	document.getElementById("id_UserUpdatelinklist").className = "";
	document.getElementById("id_UserConversationlinklist").className = "";
	

	if(strFeedType=='all')
		{
			document.getElementById("id_AllUpdatelinklist").className = "active";
			//document.getElementById("id_AllUpdatelinklist").className = "background:url(../images/bbl_greenArrow2.gif) ";
		}
	else if(strFeedType=='usergoodwork')
		document.getElementById("id_UserUpdatelinklist").className = "active";	
	else
		document.getElementById("id_UserConversationlinklist").className = "active";
	
	fnShowInfoLoadingImage("id_NewsFeedTab");
	
	ajaxObjects[4] = new sack();
	//ajaxObjects[4].requestFile = sitename+"/index.php?action=newmyprofile&mode=ajax&ajax_action=togglenewsfeed&feedtype="+strFeedType+"&feeduser="+strUserId;
	ajaxObjects[4].requestFile = sitename+"/index.php?action=myprofile&mode=ajax&ajax_action=togglenewsfeed&feedtype="+strFeedType+"&feeduser="+strUserId;
	ajaxObjects[4].onCompletion = function(){
												document.getElementById("id_AllUpdatelink").href= "javascript:fnToggleNewsFeed('all','"+strUserId+"');";
												document.getElementById("id_UserUpdatelink").href = "javascript:fnToggleNewsFeed('usergoodwork','"+strUserId+"');";
												document.getElementById("id_UserConversationlink").href = "javascript:fnToggleNewsFeed('user','"+strUserId+"');";
												document.getElementById("id_NewsFeedTab").innerHTML = ajaxObjects[4].response;
											};
	ajaxObjects[4].runAJAX();
}

function fnAddGoodWork(strUpdateId, strUpdateType, strGotoLink, strSessionUserId, strProfileUserId, strParentId, strOutputDivId)
{
	intProfileUserId = Base64.decode(strProfileUserId);
	
	ajaxObjects[5] = new sack();
	ajaxObjects[5].requestFile = sitename+"/index.php?action=setunsetsessionvars&mode=ajax&ajax_action=setsessionparams&settoparams=markgoodwork&activity=add&updateid="+strUpdateId+"&updatetype="+strUpdateType+"&gotolink="+strGotoLink;
	ajaxObjects[5].onCompletion = function(){
												if (strSessionUserId == "")
												{
													//Lightbox.showBoxByID("divRegisterLogin", intLoginPopupWidth, intLoginPopupHeight);
													fnNewRegisterLogin(0,0);
													return false;
												}
												
												// FOR SHOW GOOD WORK DATA
												ajaxObjects[6] = new sack();
												ajaxObjects[6].requestFile = sitename+"/index.php?action=addremovegoodwork&mode=ajax&ajax_action=addremovegoodwork&byajax=1";
												ajaxObjects[6].onCompletion = function(){
																								fnShowGoodWorkData(strUpdateId, strUpdateType, intProfileUserId, strParentId);
																								
																								// FOR SHOW COMMEN BOX OPEN
																								try{
																									if (document.getElementById('id_AddComment_'+strOutputDivId).style.display == "none")
																										fnShowCommentBox('id_AddComment_'+strOutputDivId, strOutputDivId, 0);
																								}
																								catch(e)
																								{}
																								fnOpenInternalCommentBox(strOutputDivId, 0);
																								
																						}
												ajaxObjects[6].runAJAX();
											}
	ajaxObjects[5].runAJAX();
}

function fnRemoveGoodWork(strUpdateId, strUpdateType, strGotoLink, strSessionUserId, strProfileUserId, strParentId)
{
	intProfileUserId = parseInt(Base64.decode(strProfileUserId));
	
	ajaxObjects[5] = new sack();
	ajaxObjects[5].requestFile = sitename+"/index.php?action=setunsetsessionvars&mode=ajax&ajax_action=setsessionparams&settoparams=markgoodwork&activity=remove&updateid="+strUpdateId+"&updatetype="+strUpdateType+"&gotolink="+strGotoLink;
	ajaxObjects[5].onCompletion = function(){
												if (parseInt(Base64.decode(strSessionUserId)) == 0 || strSessionUserId == "")
												{
													//Lightbox.showBoxByID("divRegisterLogin", intLoginPopupWidth, intLoginPopupHeight);
													fnNewRegisterLogin(0,0);
													return false;
												}
												
												ajaxObjects[6] = new sack();
												ajaxObjects[6].requestFile = sitename+"/index.php?action=addremovegoodwork&mode=ajax&ajax_action=addremovegoodwork&byajax=1";
												ajaxObjects[6].onCompletion = function(){
																								fnShowGoodWorkData(strUpdateId, strUpdateType, intProfileUserId, strParentId);
																						}
												ajaxObjects[6].runAJAX();
											}
	ajaxObjects[5].runAJAX();
}

function fnShowGoodWorkData(strUpdateId, strUpdateType, intProfileUserId, strParentId)
{
	ajaxObjects[7] = new sack();
	ajaxObjects[7].requestFile = sitename+"/index.php?action=myprofile&mode=ajax&ajax_action=showupdatelink&user="+intProfileUserId+"&updateid="+strUpdateId+"&updatetype="+strUpdateType+"&parent="+strParentId;
	ajaxObjects[7].onCompletion = function(){
												strDivId = "id_"+Base64.decode(strUpdateType)+"_"+Base64.decode(strUpdateId)+"_"+Base64.decode(strParentId);
												document.getElementById(strDivId).innerHTML = ajaxObjects[7].response;
											};
	ajaxObjects[7].runAJAX();
	
	ajaxObjects[8] = new sack();
	ajaxObjects[8].requestFile = sitename+"/index.php?action=myprofile&mode=ajax&ajax_action=showupdatedata&user="+intProfileUserId+"&updateid="+strUpdateId+"&updatetype="+strUpdateType+"&parent="+strParentId;
	ajaxObjects[8].onCompletion = function(){
												strDivId = "id_Person_"+Base64.decode(strUpdateId)+"_"+Base64.decode(strUpdateType)+"_"+Base64.decode(strParentId);
												document.getElementById(strDivId).innerHTML = ajaxObjects[8].response;
											};
	ajaxObjects[8].runAJAX();
}

function fnShowOlderNews(intLimit, intUserId, strUpdateType)
{
	fnShowInfoLoadingImage("id_NewsFeed_"+intLimit);
	//document.getElementById("id_OlderUpdatesArrow_"+intLimit).src = "images/olderupdate_arrow.gif";

	ajaxObjects[9] = new sack();
	//ajaxObjects[9].requestFile = sitename+"/index.php?action=newmyprofile&mode=ajax&ajax_action=showoldernews&limit="+Base64.encode(intLimit)+"&user="+intUserId+"&updatetype="+strUpdateType;
	ajaxObjects[9].requestFile = sitename+"/index.php?action=myprofile&mode=ajax&ajax_action=showoldernews&limit="+Base64.encode(intLimit)+"&user="+intUserId+"&updatetype="+strUpdateType;
	ajaxObjects[9].onCompletion = function(){
												document.getElementById("id_OlderTabLink_"+intLimit).style.display = "none";
												document.getElementById("id_NewsFeed_"+intLimit).innerHTML = ajaxObjects[9].response;
											};
	ajaxObjects[9].runAJAX();
}

function fnShowAddUpdateBox()
{
	fnToggleMenu(1,4);
	document.getElementById("id_txtWhatAreUWorking").focus();
}

function fnIncreaseHieghtofTA(elementid)
{
	elementid.style.height = elementid.scrollHeight + 'px';
}

function fnResetProfilePhotoTab(intUserId,intShowEditLink)
{
	ajaxObjects[10] = new sack();
	//ajaxObjects[10].requestFile = sitename+"/index.php?action=newmyprofile&mode=ajax&ajax_action=resetprofilephoto&user="+intUserId;
	ajaxObjects[10].requestFile = sitename+"/index.php?action=myprofile&mode=ajax&ajax_action=resetprofilephoto&user="+intUserId+"&showeditlink="+intShowEditLink;
	ajaxObjects[10].onCompletion = function(){
												document.getElementById("id_LeftProfilePhotoTab").innerHTML = ajaxObjects[10].response;
											};
	ajaxObjects[10].runAJAX();
}

function fnHideShowLeftAddUpdateLink()
{
	try{
			if (document.getElementById("id_container_1").style.display == "none")
			{
				document.getElementById("id_LeftAddUpdateLink").style.display = "";
			}
			else
			{
				document.getElementById("id_LeftAddUpdateLink").style.display = "none";
			}
	}
	catch(e)
	{}
}

function fnSendFollowRequest(intLoginInUserId, intContactUserId, strContactUserType, strNewsType, intNewsId, intParentId)
{
	fnShowInfoLoadingImage("id_AddComment_"+strNewsType+"_"+intNewsId+"_"+intParentId);
	
	ajaxObjects[11] = new sack();
	ajaxObjects[11].requestFile = sitename+"/index.php?action=setunsetsessionvars&mode=ajax&ajax_action=setsessionparams&settoparams=followuser&contactuserid="+intContactUserId+"&contactusertype="+strContactUserType;
	ajaxObjects[11].onCompletion = function(){ 
													if(intLoginInUserId == 0 || intLoginInUserId == "")
													{
														Lightbox.refreshAfterClose = 1;
														//Lightbox.showBoxByID("divRegisterLogin", intLoginPopupWidth, intLoginPopupHeight);
														fnNewRegisterLogin(0,0);
													}
													else
													{
														ajaxObjects[12] = new sack();
														ajaxObjects[12].requestFile = sitename+"/index.php?action=addfollowuser&mode=ajax&isbyajax=1&rand=9086";
														ajaxObjects[12].onCompletion = function(){ 
																										opencommentdiv = true;
																										fnGetAddNewsFeedCommentBox(intLoginInUserId, strNewsType,intNewsId,intParentId);
																								 };
														ajaxObjects[12].runAJAX();
													}
											 };
	ajaxObjects[11].runAJAX();
}

function fnGetAddNewsFeedCommentBox(intLoginInUserId, strNewsType,intNewsId, intParentId)
{
	ajaxObjects[13] = new sack();
	ajaxObjects[13].requestFile = sitename+"/index.php?action=myprofile&mode=ajax&ajax_action=resetaddcommentbox&user="+intLoginInUserId+"&newsid="+intNewsId+"&newstype="+strNewsType+"&parent="+intParentId;
	ajaxObjects[13].onCompletion = function(){ 
													document.getElementById("id_AddComment_"+strNewsType+"_"+intNewsId+"_"+intParentId).innerHTML = ajaxObjects[13].response;
													if (opencommentdiv)
														fnOpenInternalCommentBox(strNewsType+'_'+intNewsId+'_'+intParentId, 0);
											 };
	ajaxObjects[13].runAJAX();
}

function fnCkeckCommentText(objTextBox, intWordlimit, strButtonId, strTextChar, strErrorDiv, strDisableButton, strEnableButton)
{ 
	var strText;
	var strTextLen;		
	strText = objTextBox.value;
	if(intWordlimit - strText.length >= 20)
	{
		document.getElementById(strTextChar).className = "charcount";
	}
	else if((intWordlimit - strText.length < 20) &&  (intWordlimit - strText.length > 10) )
	{					
		document.getElementById(strTextChar).className = "charcount20";
	}
	else
	{
		document.getElementById(strTextChar).className = "charcountnegative";
	}
			
	if(intWordlimit - strText.length  < 0)
	{
		document.getElementById(strButtonId).src = strDisableButton;
	}
	else
	{
		document.getElementById(strButtonId).src = strEnableButton;
	}	
	
	/*if(intWordlimit - strText.length  < 0)
	{
		ajax_showTooltip(strErrorDiv,document.getElementById(strButtonId),250,50);
	}
	else
	{
			try{
					ajax_hideTooltip();
			}
			catch(e){}
	}*/

	document.getElementById(strTextChar).innerHTML = intWordlimit - strText.length;
}


function fnAddNewsFeedComment(intSessionUserId, strNewsType, intNewsId, intParentId, intProfileUser)
{ 
	if (intSessionUserId == "" || intSessionUserId == 0)
	{
		//Lightbox.showBoxByID("divRegisterLogin", intLoginPopupWidth, intLoginPopupHeight);
		fnNewRegisterLogin(0,0);
		return false;
	}
	
	strCommentText = document.getElementById("id_txtNewsFeedComment_"+strNewsType+"_"+intNewsId+"_"+intParentId).value;
	
	if (strCommentText == "")
	{
		ajax_showTooltip("id_Div_EmptyCommentError_"+strNewsType+"_"+intNewsId+"_"+intParentId,document.getElementById("id_Enter_"+strNewsType+"_"+intNewsId+"_"+intParentId),160,38);
		return false;
	}
	//// to check word character count
	var myarry = new Array();
	myarry = strCommentText.split(' '); 
	for (i=0;i<myarry.length;i++)
	{	
		if((myarry[i].length) >= 50)
		{	
			if((!myarry[i].match("http://")) && (!myarry[i].match("www")) && (!myarry[i].match("http://www")) && (!myarry[i].match("https://")))
			{ 
				ajax_showTooltip("id_GoodWorkWordLengthError",document.getElementById("id_txtNewsFeedComment_"+strNewsType+"_"+intNewsId+"_"+intParentId),200,48);
				return false;
			}
		}
	}	
	////
	
	
	if (strCommentText.length > 240)
	{
		ajax_showTooltip("id_Error_"+strNewsType+"_"+intNewsId+"_"+intParentId,document.getElementById("id_Enter_"+strNewsType+"_"+intNewsId+"_"+intParentId),250,50);
		return false;
	}
	
	if (strNewsType == "" || intNewsId == "")
	{
		alert("INVALID INPUTS");
		return false;
	}
	
	document.getElementById("id_Enter_"+strNewsType+"_"+intNewsId+"_"+intParentId+"_Span").style.display = "none";
	document.getElementById("id_Loading_"+strNewsType+"_"+intNewsId+"_"+intParentId+"_Span").style.display = "";
	
	strCommentText = Base64.encode(strCommentText);
	strNewsType    = Base64.encode(strNewsType);
	strNewsId      = Base64.encode(intNewsId);
	strParentId    = Base64.encode(intParentId);
	
	ajaxObjects[14] = new sack();
	//ajaxObjects[14].requestFile = sitename+"/index.php?action=newmyprofile&mode=ajax&ajax_action=addnewsfeedcomment&user="+intProfileUser+"&news="+strNewsId+"&type="+strNewsType+"&text="+strCommentText+"&parent="+strParentId;
	ajaxObjects[14].requestFile = sitename+"/index.php?action=myprofile&mode=ajax&ajax_action=addnewsfeedcomment&user="+intProfileUser+"&news="+strNewsId+"&type="+strNewsType+"&text="+strCommentText+"&parent="+strParentId;
	ajaxObjects[14].onCompletion = function(){														
														/*
														var intCommentId = ajaxObjects[14].response;
														fnShowListCommentBox(intSessionUserId, strNewsType, intNewsId, intProfileUser, intCommentId,intParentId,'last');
														fnGetAddNewsFeedCommentBox(intSessionUserId, Base64.decode(strNewsType),intNewsId,intParentId)
														*/
														
														var lookup = ajaxObjects[14].response;
														arrLookup = lookup.split(" | ");
														var intCommentId = parseInt(arrLookup[0]);
														var intResponseId = parseInt(arrLookup[1]);
														 
														 switch(intCommentId)
														 {
															case 666:
																document.getElementById('id_ErrorMessageSpam').innerHTML = "<b>Your account has been blocked for adding any new comment.</b>";
																boolAutoHide = true;
																ajax_showTooltip("id_ErrorMessageSpam",document.getElementById("id_txtNewsFeedComment_"+strNewsType+"_"+intNewsId+"_"+intParentId),200,45);
																setTimeout("fnHideMessage("+"'id_ErrorMessageSpam')",3000);
																fnGetAddGoodWorkCommentBox(intSessionUser, intGoodworkId, intProfileUserId, intGoodWorkUser);
																return false;																
															break;
															
															case 555:
																document.getElementById('id_ErrorMessageSpam').innerHTML = "<b>Your IP has been blocked for adding any new comment.</b>";
																boolAutoHide = true;
																ajax_showTooltip("id_ErrorMessageSpam",document.getElementById("id_txtNewsFeedComment_"+strNewsType+"_"+intNewsId+"_"+intParentId),200,45);
																setTimeout("fnHideMessage("+"'id_ErrorMessageSpam')",3000);
																fnGetAddGoodWorkCommentBox(intSessionUser, intGoodworkId, intProfileUserId, intGoodWorkUser);
																return false;																
															break;
															
															case 999:
																location.href = sitename+"/index.php?action=logout";
															break;
															
															case 88:
																document.getElementById('id_ErrorMessageSpam').innerHTML = "<b>This is your last chance to add a comment.</b>";
																boolAutoHide = true;
																ajax_showTooltip("id_ErrorMessageSpam",document.getElementById("id_txtNewsFeedComment_"+strNewsType+"_"+intNewsId+"_"+intParentId),200,45);
																setTimeout("fnHideMessage("+"'id_ErrorMessageSpam')",3000);
																fnShowGoodworkCommentBox(intGoodworkId, intProfileUserId, 'last', intResponseId)
																fnGetAddGoodWorkCommentBox(intSessionUser, intGoodworkId, intProfileUserId, intGoodWorkUser);
															break;
															
															default:
																fnShowListCommentBox(intSessionUserId, strNewsType, intNewsId, intProfileUser, intCommentId,intParentId,'last');
																fnGetAddNewsFeedCommentBox(intSessionUserId, Base64.decode(strNewsType),intNewsId,intParentId)
															break;
														 }											
													
											 };
	ajaxObjects[14].runAJAX();
}

function fnShowListCommentBox(intSessionUserId, strNewsType, intNewsId, intProfileUser, intCommentId, intParentId, strShowComment)
{
	ajaxObjects[15] = new sack();
	ajaxObjects[15].requestFile = sitename+"/index.php?action=myprofile&mode=ajax&ajax_action=resetcomments&user="+intProfileUser+"&news="+intNewsId+"&type="+strNewsType+"&parent="+intParentId+"&showcomment="+strShowComment;
	ajaxObjects[15].onCompletion = function(){ 
													document.getElementById("id_ListComment_"+Base64.decode(strNewsType)+"_"+intNewsId+"_"+intParentId).innerHTML = ajaxObjects[15].response;
													if (intCommentId > 0)
														fnSetFadeEffects("id_Comment_Div_"+intCommentId);
														
													if (strShowComment == "all")
													{
														fnScrollOverWindow("id_ListComment_"+Base64.decode(strNewsType)+"_"+intNewsId+"_"+intParentId, "id_AddComment_"+Base64.decode(strNewsType)+"_"+intNewsId+"_"+intParentId);
													}
											 };
	ajaxObjects[15].runAJAX();
}


function fnSetFadeEffects(strDivId)
{
	if (strDivId != "")
	{
		try{
		document.getElementById(strDivId).style.backgroundColor = '#FFEFAF'
		setTimeout("fnChangeColorOfElement('"+strDivId+"','#FFF2BF')",1000);
		setTimeout("fnChangeColorOfElement('"+strDivId+"','#FFF5CF')",1080);
		setTimeout("fnChangeColorOfElement('"+strDivId+"','#FFF9DF')",1160);
		setTimeout("fnChangeColorOfElement('"+strDivId+"','#FFFCEF')",1240);
		setTimeout("fnChangeColorOfElement('"+strDivId+"','')",1320);
		}
		catch(e)
		{}
	}
}

function fnChangeColorOfElement(intIdOfElement,strColor)
{
	document.getElementById(intIdOfElement).style.backgroundColor = strColor;
}

function fnDeleteComment(intSessionUserId, intProfileUser, strNewsType, intNewsId, intCommentId, intParentId)
{
	if (confirm("Are you sure? You want to delete comment?"))
	{
		ajaxObjects[16] = new sack();
		ajaxObjects[16].requestFile = sitename+"/index.php?action=myprofile&mode=ajax&ajax_action=deletecomments&user="+intProfileUser+"&commentid="+intCommentId;
		ajaxObjects[16].onCompletion = function(){ 
														fnShowListCommentBox(intSessionUserId, Base64.encode(strNewsType), intNewsId, intProfileUser, 0,intParentId,'all');
														
														strMessageDiv = "id_Message_"+strNewsType+"_"+intNewsId+"_"+intParentId;
														
														document.getElementById(strMessageDiv).style.display = "";
														fnScrollWindow(strMessageDiv);
														document.getElementById(strMessageDiv).innerHTML = "Comment deleted successfully!";
														
														fnSetFadeEffects(strMessageDiv);
														setTimeout("fnHideMessageDiv('"+strMessageDiv+"')",1400);
												 };
		ajaxObjects[16].runAJAX();
	}
	
	return false;
}

function fnHideMessageDiv(strMessageDiv)
{
	try{
		document.getElementById(strMessageDiv).innerHTML = "";
		document.getElementById(strMessageDiv).style.display = "none";
	}
	catch(e)
	{}
}

function fnShowFullComment(intProfileUser, intCommentId)
{
	ajaxObjects[17] = new sack();
	ajaxObjects[17].requestFile = sitename+"/index.php?action=myprofile&mode=ajax&ajax_action=viewfullcomment&user="+intProfileUser+"&commentid="+intCommentId;
	ajaxObjects[17].onCompletion = function(){
													document.getElementById("id_Comment_"+intCommentId).innerHTML = ajaxObjects[17].response;
													document.getElementById("id_ViewCommentLink_"+intCommentId).style.display = "none";
													document.getElementById("id_ViewLessCommentLink_"+intCommentId).style.display = "";
											 };
	ajaxObjects[17].runAJAX();
}

function fnShowLessComment(intProfileUserId, intCommentId)
{
	ajaxObjects[31] = new sack();
	ajaxObjects[31].requestFile = sitename+"/index.php?action=myprofile&mode=ajax&ajax_action=viewlesscomment&user="+intProfileUserId+"&commentid="+intCommentId;
	ajaxObjects[31].onCompletion = function(){
													document.getElementById("id_ViewCommentLink_"+intCommentId).style.display = "";
													document.getElementById("id_ViewLessCommentLink_"+intCommentId).style.display = "none";
													document.getElementById("id_Comment_"+intCommentId).innerHTML = ajaxObjects[31].response;
											 };
	ajaxObjects[31].runAJAX();
}

function fnShowGoodWorkPplBox(intUpdateId,strUpdateType, intParentId)
{
	if(document.getElementById("id_tbl_goodwork_"+intUpdateId+"_"+strUpdateType+"_"+intParentId).style.display == "none")
	{
		document.getElementById("id_tbl_goodwork_"+intUpdateId+"_"+strUpdateType+"_"+intParentId).style.display = "";
	}
	else
	{
		document.getElementById("id_tbl_goodwork_"+intUpdateId+"_"+strUpdateType+"_"+intParentId).style.display = "none";
	}
}

function fnOpenInternalCommentBox(strElementId, isSetFocus)
{
	try{
		document.getElementById("id_txtNewsFeedDiv_"+strElementId).style.display = "none";
		document.getElementById("id_txtNewsFeedTbl_"+strElementId).style.display = "";

		if (isSetFocus == 1)
			document.getElementById("id_txtNewsFeedComment_"+strElementId).focus();
	}
	catch(e)
	{
		//alert(e.message);
	}
}





function fnCancelNewsFeedComment(strElementId)
{
	try{
		document.getElementById("id_Enter_"+strElementId+"_Span").style.display = "";
		document.getElementById("id_Loading_"+strElementId+"_Span").style.display = "none";
	}
	catch(e)
	{}
	document.getElementById("id_txtNewsFeedDiv_"+strElementId).style.display = "";
	document.getElementById("id_txtNewsFeedTbl_"+strElementId).style.display = "none";
	document.getElementById("id_txtNewsFeedComment_"+strElementId).value = "";
	document.getElementById("id_txtNewsFeedComment_"+strElementId).style.height = "45px";
}

function fnPlayYoutubeVideo(strContentId,strVideoId)
{
	document.getElementById("id_arrvideo_"+strContentId).style.display = "none";
	document.getElementById("id_VideoImage_"+strContentId).innerHTML = "<img src='images/big_slide_loader.gif' />";
	
	ajaxObjects[18] = new sack();
	ajaxObjects[18].requestFile = sitename+"/index.php?action=myprofile&mode=ajax&ajax_action=showvideo&id="+strVideoId;
	ajaxObjects[18].onCompletion = function(){
													document.getElementById("id_VideoImage_"+strContentId).innerHTML = "";
													document.getElementById("id_VideoImage_"+strContentId).style.display = "none";
													
													document.getElementById("id_VideoPlayer_"+strContentId).style.display = "";
													document.getElementById("id_VideoPlayer_"+strContentId).innerHTML = "<span></span>"+ajaxObjects[18].response;
													document.getElementById("id_VideoPlayer_"+strContentId).style.width = "380px";
											 };
	ajaxObjects[18].runAJAX();
}

function fnAddGoodworkComment(intSessionUser, intGoodworkId, intProfileUserId, intGoodWorkUser)
{ 
	var strExtraParam = "";
	
	strCommentText = document.getElementById("id_txtNewsFeedComment_Goodwork_"+intGoodworkId).value;
	
	if (strCommentText == "")
	{
		ajax_showTooltip("id_Div_EmptyCommentError_Goodwork_"+intGoodworkId,document.getElementById("id_Enter_Goodwork_"+intGoodworkId),160,38);
		return false;
	}
	
	if (strCommentText.length > 5000)
	{
		ajax_showTooltip("id_Error_Goodwork_"+intGoodworkId,document.getElementById("id_Enter_Goodwork_"+intGoodworkId),250,50);
		return false;
	}
	
	//// to check word character count
	var myarry = new Array();
	myarry = strCommentText.split(' '); 
	for (i=0;i<myarry.length;i++)
	{	
		if((myarry[i].length) >= 50)
		{	
			if((!myarry[i].match("http://")) && (!myarry[i].match("www")) && (!myarry[i].match("http://www")) && (!myarry[i].match("https://")))
			{  
				ajax_showTooltip("id_GoodWorkWordLengthError",document.getElementById("id_txtNewsFeedComment_Goodwork_"+intGoodworkId),200,48);
				return false;
			}
		}
	}	
	////
	
	if (intGoodworkId < 0)
	{
		alert("INVALID INPUTS");
		return false;
	}
	
	document.getElementById("id_Enter_Goodwork_"+intGoodworkId+"_Span").style.display = "none";
	document.getElementById("id_Loader_Goodwork_"+intGoodworkId+"_Span").style.display = "";

	strCommentText = Base64.encode(strCommentText);
	strGoodworkId  = Base64.encode(intGoodworkId);
	
	ajaxObjects[19] = new sack();
	ajaxObjects[19].requestFile = sitename+"/index.php?action=setunsetsessionvars&mode=ajax&ajax_action=setsessionparams&settoparams=goodworkcomment&goodwork="+strGoodworkId+"&text="+strCommentText;
	ajaxObjects[19].onCompletion = function(){
												if (intSessionUser == "" || intSessionUser == 0)
													fnAddGoodworkCommentText(intSessionUser, intGoodworkId, intProfileUserId, intGoodWorkUser, strExtraParam);
												else
													fnCheckGoodworkCommentAdmin(intSessionUser, intGoodworkId, intProfileUserId, intGoodWorkUser);
											 }
	ajaxObjects[19].runAJAX();
}

function fnAddGoodworkCommentText(intSessionUser, intGoodworkId, intProfileUserId, intGoodWorkUser, strExtraParam)
{
	if (intSessionUser == "" || intSessionUser == 0)
	{
		//Lightbox.showBoxByID("divRegisterLogin", intLoginPopupWidth, intLoginPopupHeight);
		fnNewRegisterLogin(0,0);
		return false;
	}
	else
	{
		ajaxObjects[29] = new sack();
		ajaxObjects[29].requestFile = sitename+"/index.php?action=addgoodworkcomment&byajax="+1+strExtraParam;
		ajaxObjects[29].onCompletion = function(){
														var intCommentId = parseInt(ajaxObjects[29].response);
														//fnShowGoodworkCommentBox(intGoodworkId, intProfileUserId, 'last', intCommentId)
														//fnGetAddGoodWorkCommentBox(intSessionUser, intGoodworkId, intProfileUserId, intGoodWorkUser);
														
														 var lookup = ajaxObjects[29].response;
														 arrLookup = lookup.split(" | ");
														 var intCommentId = parseInt(arrLookup[0]);
														 var intResponseId = parseInt(arrLookup[1]);														
														 switch(intCommentId)
														 {
															case 666:
																document.getElementById('id_ErrorMessageSpam').innerHTML = "<b>Your account has been blocked for adding good work reply.</b>";
																boolAutoHide = true;
																ajax_showTooltip("id_ErrorMessageSpam",document.getElementById("id_txtNewsFeedComment_Goodwork_"+intGoodworkId),200,45);
																setTimeout("fnHideMessage("+"'id_ErrorMessageSpam')",3000);
																fnGetAddGoodWorkCommentBox(intSessionUser, intGoodworkId, intProfileUserId, intGoodWorkUser);
																return false;																
															break;
															
															case 555:
																document.getElementById('id_ErrorMessageSpam').innerHTML = "<b>Your IP has been blocked for adding good work reply.</b>";
																boolAutoHide = true;
																ajax_showTooltip("id_ErrorMessageSpam",document.getElementById("id_txtNewsFeedComment_Goodwork_"+intGoodworkId),200,45);
																setTimeout("fnHideMessage("+"'id_ErrorMessageSpam')",3000);
																fnGetAddGoodWorkCommentBox(intSessionUser, intGoodworkId, intProfileUserId, intGoodWorkUser);
																return false;																
															break;
															
															case 999:
																location.href = sitename+"/index.php?action=logout";
															break;
															
															case 88:
																document.getElementById('id_ErrorMessageSpam').innerHTML = "<b>This was your last chance to add good work reply.</b>";
																boolAutoHide = true;
																ajax_showTooltip("id_ErrorMessageSpam",document.getElementById("id_txtNewsFeedComment_Goodwork_"+intGoodworkId),200,45);
																setTimeout("fnHideMessage("+"'id_ErrorMessageSpam')",3000);
																fnShowGoodworkCommentBox(intGoodworkId, intProfileUserId, 'last', intResponseId)
																fnGetAddGoodWorkCommentBox(intSessionUser, intGoodworkId, intProfileUserId, intGoodWorkUser);
															break;
															
															default:
																fnShowGoodworkCommentBox(intGoodworkId, intProfileUserId, 'last', intCommentId)
																fnGetAddGoodWorkCommentBox(intSessionUser, intGoodworkId, intProfileUserId, intGoodWorkUser);
															break;
														 }
														
												 };
		ajaxObjects[29].runAJAX();
	}
}

function fnGetAddGoodWorkCommentBox(intSessionUser, intGoodworkId, intProfileUserId, intGoodWorkUser)
{
	ajaxObjects[20] = new sack();
	ajaxObjects[20].requestFile = sitename+"/index.php?action=myprofile&mode=ajax&ajax_action=addgoodworkcommentbox&user="+intProfileUserId+"&goodwork="+intGoodworkId+"&goodworkuser="+intGoodWorkUser;
	ajaxObjects[20].onCompletion = function(){
													document.getElementById("id_AddComment_Goodwork_"+intGoodworkId).innerHTML = ajaxObjects[20].response;
													if (opencommentdiv)
														fnOpenInternalCommentBox('Goodwork_'+intGoodworkId, 0);
											 };
	ajaxObjects[20].runAJAX();
}

function fnShowGoodworkCommentBox(intGoodworkId, intProfileUserId, strCommentType, intCommentId)
{
	try{
		enmShowProfileConversation = document.getElementById("enmShowProfileConversation").value;
	}
	catch(e)
	{
		enmShowProfileConversation = 0;
	}
	
	ajaxObjects[21] = new sack();
	ajaxObjects[21].requestFile = sitename+"/index.php?action=myprofile&mode=ajax&ajax_action=showgoodworkcommentbox&user="+intProfileUserId+"&goodwork="+intGoodworkId+"&comment="+strCommentType+"&enmshowprofileconversation="+enmShowProfileConversation;
	ajaxObjects[21].onCompletion = function(){
													document.getElementById("id_ListComment_Goodwork_"+intGoodworkId).innerHTML = ajaxObjects[21].response;
													if (intCommentId > 0)
														fnSetFadeEffects("id_GComment_Div_"+intCommentId);
														
													if (strCommentType == "all")
													{
														fnScrollOverWindow("id_ListComment_Goodwork_"+intGoodworkId, "id_AddComment_Goodwork_"+intGoodworkId);
													}
											 };
	ajaxObjects[21].runAJAX();
}



function fnShowFullGComment(intProfileUserId, intCommentId)
{
	ajaxObjects[22] = new sack();
	ajaxObjects[22].requestFile = sitename+"/index.php?action=myprofile&mode=ajax&ajax_action=viewfullgcomment&user="+intProfileUserId+"&comment="+intCommentId;
	ajaxObjects[22].onCompletion = function(){
													document.getElementById("id_ViewGCommentLink_"+intCommentId).style.display = "none";
													document.getElementById("id_ViewLessGCommentLink_"+intCommentId).style.display = "";
													document.getElementById("id_GComment_"+intCommentId).innerHTML = ajaxObjects[22].response;
											 };
	ajaxObjects[22].runAJAX();
}


function fnShowLessGComment(intProfileUserId, intCommentId)
{
	
	ajaxObjects[28] = new sack();
	ajaxObjects[28].requestFile = sitename+"/index.php?action=myprofile&mode=ajax&ajax_action=viewlessgcomment&user="+intProfileUserId+"&comment="+intCommentId;
	ajaxObjects[28].onCompletion = function(){
													document.getElementById("id_ViewGCommentLink_"+intCommentId).style.display = "";
													document.getElementById("id_ViewLessGCommentLink_"+intCommentId).style.display = "none";
													document.getElementById("id_GComment_"+intCommentId).innerHTML = ajaxObjects[28].response;
											 };
	ajaxObjects[28].runAJAX();
}

function fnDeleteGComment(intGoodworkId, intProfileUserId, intCommentId)
{
	ajax_hideTooltip();
	ajaxObjects[23] = new sack();
	ajaxObjects[23].requestFile = sitename+"/index.php?action=myprofile&mode=ajax&ajax_action=deletegcomment&user="+intProfileUserId+"&comment="+intCommentId;
	ajaxObjects[23].onCompletion = function(){
													fnShowGoodworkCommentBox(intGoodworkId, intProfileUserId, "all", 0)
													document.getElementById("id_Message_Goodwork_"+intGoodworkId).style.display = "";
													document.getElementById("id_Message_Goodwork_"+intGoodworkId).innerHTML = "Comment Deleted Successfully!";
													fnSetFadeEffects("id_Message_Goodwork_"+intGoodworkId);
													setTimeout("fnHideMessageDiv('"+"id_Message_Goodwork_"+intGoodworkId+"')",1400);
											 };
	ajaxObjects[23].runAJAX();
}

function fnSendGoodworkFollowRequest(intLoginInUserId, intContactUserId, strContactUserType, intGoodworkId, intProfileUserId)
{
	fnShowInfoLoadingImage("id_AddComment_Goodwork_"+intGoodworkId);
	
	ajaxObjects[24] = new sack();
	ajaxObjects[24].requestFile = sitename+"/index.php?action=setunsetsessionvars&mode=ajax&ajax_action=setsessionparams&settoparams=followuser&contactuserid="+intContactUserId+"&contactusertype="+strContactUserType;
	ajaxObjects[24].onCompletion = function(){
													if(intLoginInUserId == 0 || intLoginInUserId == "")
													{
														Lightbox.refreshAfterClose = 1;
														//Lightbox.showBoxByID("divRegisterLogin", intLoginPopupWidth, intLoginPopupHeight);
														fnNewRegisterLogin(0,0);
													}
													else
													{
														ajaxObjects[25] = new sack();
														ajaxObjects[25].requestFile = sitename+"/index.php?action=addfollowuser&mode=ajax&isbyajax=1&rand=9086";
														ajaxObjects[25].onCompletion = function(){ 
																									opencommentdiv = true;
																									fnGetAddGoodWorkCommentBox(intLoginInUserId, intGoodworkId, intProfileUserId, intContactUserId);
																								 };
														ajaxObjects[25].runAJAX();
													}
											 };
	ajaxObjects[24].runAJAX();
}

function fnShowCommentBox(strAddCommentDiv, strAddCommentBox, isSetFocus)
{
	try{
			document.getElementById(strAddCommentDiv).style.display = "";
			fnOpenInternalCommentBox(strAddCommentBox, isSetFocus);
	}
	catch(e)
	{}
	/*if (document.getElementById(strAddCommentDiv).style.display == "none")
	{
		document.getElementById(strAddCommentDiv).style.display = "";
		fnOpenInternalCommentBox(strAddCommentBox);
	}
	else
	{
		document.getElementById(strAddCommentDiv).style.display = "none";
	}*/
}

function fnViewFullUpdate(strContentDiv, strUpdateType, intUpdateId, strCommentDiv, strCommentBox)
{
	fnShowInfoLoadingImage(strContentDiv);
	ajaxObjects[26] = new sack();
	ajaxObjects[26].requestFile = sitename+"/index.php?action=myprofile&mode=ajax&ajax_action=viewfullupdatetext&updatetype="+strUpdateType+"&updateid="+intUpdateId;
	ajaxObjects[26].onCompletion = function(){ 
													document.getElementById("id_Full_"+strContentDiv).style.display = "none";
													document.getElementById("id_Short_"+strContentDiv).style.display = "";
													
													document.getElementById(strContentDiv).innerHTML = ajaxObjects[26].response;
													fnShowCommentBox(strCommentDiv, strCommentBox, 0);
													fnScrollWindow("id_Container_"+strContentDiv);
											 };
	ajaxObjects[26].runAJAX();
}

function fnViewLessUpdate(strContentDiv, strUpdateType, intUpdateId)
{
	fnShowInfoLoadingImage(strContentDiv);
	ajaxObjects[27] = new sack();
	ajaxObjects[27].requestFile = sitename+"/index.php?action=myprofile&mode=ajax&ajax_action=viewlessupdatetext&updatetype="+strUpdateType+"&updateid="+intUpdateId;
	ajaxObjects[27].onCompletion = function(){ 
													document.getElementById("id_Full_"+strContentDiv).style.display = "";
													document.getElementById("id_Short_"+strContentDiv).style.display = "none";
													
													document.getElementById(strContentDiv).innerHTML = ajaxObjects[27].response;
													fnScrollWindow("id_Container_"+strContentDiv);
											 };
	ajaxObjects[27].runAJAX();
}

function fnAddExternalComment(strSessionUserId, strMediaId, strMediaType, strProfileUserId)
{ 
	intMediaId 		 = Base64.decode(strMediaId);
	strMediaType 	 = Base64.decode(strMediaType);
	intSessionUserId = Base64.decode(strSessionUserId);
	intProfileUserId = Base64.decode(strProfileUserId);
	
	var strExtraParam = "";
	
	strCommentText = document.getElementById("id_txtNewsFeedComment_"+strMediaType+"_"+intMediaId).value;
	
	if (strCommentText == "")
	{
		ajax_showTooltip("id_Div_EmptyCommentError_"+strMediaType+"_"+intMediaId,document.getElementById("id_Enter_"+strMediaType+"_"+intMediaId),160,38);
		return false;
	}
	
	if (strCommentText.length > 5000)
	{
		ajax_showTooltip("id_Error_"+strMediaType+"_"+intMediaId,document.getElementById("id_Enter_"+strMediaType+"_"+intMediaId),250,50);
		return false;
	}
	//// to check word character count
	var myarry = new Array();
	myarry = strCommentText.split(' '); 
	for (i=0;i<myarry.length;i++)
	{	
		if((myarry[i].length) >= 50)
		{	
			if((!myarry[i].match("http://")) && (!myarry[i].match("www")) && (!myarry[i].match("http://www")) && (!myarry[i].match("https://")))
			{ 
				ajax_showTooltip("id_GoodWorkWordLengthError",document.getElementById("id_txtNewsFeedComment_"+strMediaType+"_"+intMediaId),200,45);
				return false;
			}
		}
	}	
	////
	if (strMediaType == "" || intMediaId == "")
	{
		alert("INVALID INPUTS");
		return false;
	}
	
	document.getElementById("id_Enter_"+strMediaType+"_"+intMediaId+"_Span").style.display = "none";
	document.getElementById("id_Loading_"+strMediaType+"_"+intMediaId+"_Span").style.display = "";
	
	strEnCommentText = Base64.encode(strCommentText);
	strEnMediaType   = Base64.encode(strMediaType);
	strEnMediaId     = Base64.encode(intMediaId);
	
	ajaxObjects[31] = new sack();
	ajaxObjects[31].requestFile = sitename+"/index.php?action=setunsetsessionvars&mode=ajax&ajax_action=setsessionparams&settoparams=forexternalcomment&media="+strEnMediaId+"&type="+strEnMediaType+"&text="+strEnCommentText;
	ajaxObjects[31].onCompletion= function(){
												if (intSessionUserId == "" || intSessionUserId == 0)
													fnAddExternalCommentText(strSessionUserId, strMediaId, strMediaType, strProfileUserId, strExtraParam);
												else
													fnCheckExternalCommentAdmin(strSessionUserId, strMediaId, strMediaType, strProfileUserId);
											}
	ajaxObjects[31].runAJAX();
}

function fnAddExternalCommentText(strSessionUserId, strMediaId, strMediaType, strProfileUserId, strExtraParam)
{
	if (intSessionUserId == "" || intSessionUserId == 0)
	{
		//Lightbox.showBoxByID("divRegisterLogin", intLoginPopupWidth, intLoginPopupHeight);
		fnNewRegisterLogin(0,0);
		return false;
	}
	else
	{
		document.getElementById("id_Enter_"+strMediaType+"_"+intMediaId+"_Span").style.display = "none";
		document.getElementById("id_Loading_"+strMediaType+"_"+intMediaId+"_Span").style.display = "";
	
		ajaxObjects[32] = new sack();
		ajaxObjects[32].requestFile = sitename+"/index.php?action=addexternalcomment&byajax=1"+strExtraParam;
		ajaxObjects[32].onCompletion = function(){
														var lookup = ajaxObjects[32].response;
														arrLookup = lookup.split(" | ");
														var intCommentId = parseInt(arrLookup[0]);
														var intResponseId = parseInt(arrLookup[1]);
														 
														 switch(intCommentId)
														 {
															case 666:
																document.getElementById('id_ErrorMessageSpam').innerHTML = "<b>Your account has been blocked for adding any new comment.</b>";
																boolAutoHide = true;
																ajax_showTooltip("id_ErrorMessageSpam",document.getElementById("id_txtNewsFeedComment_"+strMediaType+"_"+intMediaId),200,45);
																setTimeout("fnHideMessage("+"'id_ErrorMessageSpam')",3000);
																fnAddExternalCommentBox(intMediaId, strMediaType, intProfileUserId);
																return false;																
															break;
															
															case 555:
																document.getElementById('id_ErrorMessageSpam').innerHTML = "<b>Your IP has been blocked for adding any new comment.</b>";
																boolAutoHide = true;
																ajax_showTooltip("id_ErrorMessageSpam",document.getElementById("id_txtNewsFeedComment_"+strMediaType+"_"+intMediaId),200,45);
																setTimeout("fnHideMessage("+"'id_ErrorMessageSpam')",3000);
																fnAddExternalCommentBox(intMediaId, strMediaType, intProfileUserId);
																return false;																
															break;
															
															case 999:
																location.href = sitename+"/index.php?action=logout";
															break;
															
															case 88:
																document.getElementById('id_ErrorMessageSpam').innerHTML = "<b>This is your last chance to add a comment.</b>";
																boolAutoHide = true;
																ajax_showTooltip("id_ErrorMessageSpam",document.getElementById("id_txtNewsFeedComment_"+strMediaType+"_"+intMediaId),200,45);
																setTimeout("fnHideMessage("+"'id_ErrorMessageSpam')",3000);
																fnAddExternalCommentBox(intMediaId, strMediaType, intProfileUserId);
																fnShowExternalCommentBox(intMediaId, strMediaType, intProfileUserId, 'last', intResponseId);
															break;
															
															default:
																if (lookup == "request send")
																{
																	fnAddExternalCommentBox(intMediaId, strMediaType, intProfileUserId);
																	fnCommentSendForApproval(intMediaId, strMediaType);
																}
																else
																{
																	fnAddExternalCommentBox(intMediaId, strMediaType, intProfileUserId);
																	fnShowExternalCommentBox(intMediaId, strMediaType, intProfileUserId, 'last', intCommentId);
																}
															break;
														 }
												 };
		ajaxObjects[32].runAJAX();
	}
}

function fnAddExternalCommentBox(intMediaId, strMediaType, intProfileUserId)
{
	ajaxObjects[33] = new sack();
	ajaxObjects[33].requestFile = sitename+"/index.php?action=myprofile&mode=ajax&ajax_action=addexternalcommentbox&user="+intProfileUserId+"&media="+intMediaId+"&type="+strMediaType;
	ajaxObjects[33].onCompletion = function(){
													document.getElementById("id_AddComment_"+strMediaType+"_"+intMediaId).innerHTML = ajaxObjects[33].response;
											 };
	ajaxObjects[33].runAJAX();
}

function fnShowExternalCommentBox(intMediaId, strMediaType, intProfileUserId, strShowType, intCommentId,isHideUserUrl)
{
	var strIsHideUserUrl = ""
	if(isHideUserUrl !="")
	{
		strIsHideUserUrl = "&ishideurl="+isHideUserUrl;
	}
	try{
		enmShowProfileConversation = document.getElementById("enmShowProfileConversation").value;
	}
	catch(e)
	{
		enmShowProfileConversation = 0;
	}
	
	ajaxObjects[34] = new sack();
	ajaxObjects[34].requestFile = sitename+"/index.php?action=myprofile&mode=ajax&ajax_action=showexternalcomment&user="+intProfileUserId+"&media="+intMediaId+"&type="+strMediaType+"&show="+strShowType+"&enmshowprofileconversation="+enmShowProfileConversation+strIsHideUserUrl;
	ajaxObjects[34].onCompletion = function(){
													document.getElementById("id_ListComment_"+strMediaType+"_"+intMediaId).innerHTML = ajaxObjects[34].response;
													if (intCommentId > 0)
														fnSetFadeEffects("id_EComment_Div_"+intCommentId);
														
													if (strShowType == "all")
														fnScrollOverWindow("id_ListComment_"+strMediaType+"_"+intMediaId, "id_AddComment_"+strMediaType+"_"+intMediaId);
											 };
	ajaxObjects[34].runAJAX();
}

function fnDeleteEComment(intMediaId, strMediaType, intProfileUser, intCommentId)
{
	ajax_hideTooltip();
	ajaxObjects[35] = new sack();
	ajaxObjects[35].requestFile = sitename+"/index.php?action=myprofile&mode=ajax&ajax_action=deleteecomment&user="+intProfileUser+"&commentid="+intCommentId;
	ajaxObjects[35].onCompletion = function(){ 
													fnShowExternalCommentBox(intMediaId, strMediaType, intProfileUser, "all", 0)

													if (ajaxObjects[35].response)
													{
														strMessageDiv = "id_Message_"+strMediaType+"_"+intMediaId;
														document.getElementById(strMessageDiv).style.display = "";
														document.getElementById(strMessageDiv).innerHTML = "Comment deleted successfully!";
														fnSetFadeEffects(strMessageDiv);
														
														fnScrollWindow(strMessageDiv);
														setTimeout("fnHideMessageDiv('"+strMessageDiv+"')",1400);
													}
											 };
	ajaxObjects[35].runAJAX();
	return false;
}

function fnShowFullEComment(intProfileUser, intCommentId)
{
	ajaxObjects[36] = new sack();
	ajaxObjects[36].requestFile = sitename+"/index.php?action=myprofile&mode=ajax&ajax_action=viewfullecomment&user="+intProfileUser+"&commentid="+intCommentId;
	ajaxObjects[36].onCompletion = function(){ 
													document.getElementById("id_ViewECommentLink_"+intCommentId).style.display = "none";
													document.getElementById("id_ViewLessECommentLink_"+intCommentId).style.display = "";
													
													document.getElementById("id_EComment_"+intCommentId).innerHTML = ajaxObjects[36].response;
											 };
	ajaxObjects[36].runAJAX();
}

function fnShowLessEComment(intProfileUser, intCommentId)
{
	ajaxObjects[37] = new sack();
	ajaxObjects[37].requestFile = sitename+"/index.php?action=myprofile&mode=ajax&ajax_action=viewlessecomment&user="+intProfileUser+"&commentid="+intCommentId;
	ajaxObjects[37].onCompletion = function(){ 
													document.getElementById("id_ViewECommentLink_"+intCommentId).style.display = "";
													document.getElementById("id_ViewLessECommentLink_"+intCommentId).style.display = "none";
													
													document.getElementById("id_EComment_"+intCommentId).innerHTML = ajaxObjects[37].response;
											 };
	ajaxObjects[37].runAJAX();
}

function fnRavePlayerVideo(intUpdateId)
{
	document.getElementById("id_VideoImage_"+intUpdateId).style.display = "none";
	
	document.getElementById("id_VideoImage_"+intUpdateId).innerHTML = "<img src='images/big_slide_loader.gif' />";
	ajaxObjects[44] = new sack();
	ajaxObjects[44].requestFile = sitename+"/index.php?action=myprofile&mode=ajax&ajax_action=showravevideo&raveid="+intUpdateId;
	ajaxObjects[44].onCompletion = function(){
												document.getElementById("id_VideoImage_"+intUpdateId).innerHTML = "";
												document.getElementById("id_VideoImage_"+intUpdateId).style.display = "none";
												
												document.getElementById("id_VideoPlayer_"+intUpdateId).style.display = "";
												document.getElementById("id_VideoPlayer_"+intUpdateId).innerHTML = eval("'"+ajaxObjects[44].response+"'");
												//document.getElementById("id_VideoPlayer_"+strContentId).style.width = "350px";
										 	};
	ajaxObjects[44].runAJAX();
	
	//document.getElementById("id_VideoPlayer_"+intUpdateId).style.display = "";
}

function fnScrollOverWindow(strStartObjectId, strObjectId)
{
	return "";
	
	arrStartDivPosition = fnFindToPos(document.getElementById(strStartObjectId));
	arrDivPosition = fnFindToPos(document.getElementById(strObjectId));
	
	for (var i=arrStartDivPosition[1]; i<arrDivPosition[1]; i=i+1)
	window.scrollTo(0,i-425);
}

function fnFindToPos(obj)
{
	var curleft = curtop = 0;  
	if (obj.offsetParent)
	{  
		curleft = obj.offsetLeft  
		curtop = obj.offsetTop  
		while (obj = obj.offsetParent)
		{  
			curleft += obj.offsetLeft  
			curtop += obj.offsetTop  
		}  
	}  
	return Array(curleft, curtop);
}

function fnCommentSendForApproval(intMediaId, strMediaType)
{
	strMessageDiv = "id_Message_"+strMediaType+"_"+intMediaId;
	document.getElementById(strMessageDiv).style.display = "";
	document.getElementById(strMessageDiv).innerHTML = "Your comment has been sent for approval!";
	fnSetFadeEffects(strMessageDiv);
	setTimeout("fnHideMessageDiv('"+strMessageDiv+"')",2000);
}

function fnShowSimilarPosts(intLimit, intGoodWorkId, intUserId)
{
	fnShowInfoLoadingImage("id_SimilarPost_"+intGoodWorkId);
	ajaxObjects[42] = new sack();
	ajaxObjects[42].requestFile = sitename+"/index.php?action=myprofile&mode=ajax&ajax_action=showsimilarpost&intLimit="+intLimit+"&similarpost=similarpost&intGoodWorkId="+intGoodWorkId+"&user="+intUserId;
	ajaxObjects[42].onCompletion = function(){
												document.getElementById("id_SimilarPost_"+intGoodWorkId).style.display = "none";
												document.getElementById("id_Show_SimilarPost_"+intGoodWorkId).style.display = "";
												document.getElementById("id_Show_SimilarPost_"+intGoodWorkId).innerHTML = ajaxObjects[42].response;
												fnSetFadeEffects("id_Show_SimilarPost_"+intGoodWorkId);
											};
	ajaxObjects[42].runAJAX();
	return false;
}

function fnSetTollTipForDeleteEComment(strElementId)
{
	isCloseBtnEnable = false;
	ajax_showTooltip('id_divDeleteMediaComment_'+strElementId,document.getElementById('id_imgDeleteMediaComment_'+strElementId),290,55);
}

function fnSetTollTipForDeleteGComment(strElementId)
{
	isCloseBtnEnable = false;
	ajax_showTooltip('id_divDeleteGoodWorkComment_'+strElementId,document.getElementById('id_imgDeleteGoodWorkComment_'+strElementId),290,55);
}

function fnSetTollTipForDeleteUserUpdates(strElementId)
{
	isCloseBtnEnable = false;
	ajax_showTooltip('id_divDeleteUserUpdates_'+strElementId,document.getElementById('id_imgDeleteUserUpdates_'+strElementId),290,55);
}

// Added by umeshk 10th nov 09 ---- Start

function fnCheckGoodworkCommentAdmin(intSessionUser, intGoodworkId, intProfileUserId, intGoodWorkUser)
{
	// AJAX CALL TO CHECK COMMENT ADMIN TYPE
	// THIS WILL RETURN COMMENT ADMIN FORM IF USER IS COMMENT ADMIN
	// ELSE IT WILL REQUEST TO ADD A GOOD WORK
	var strExtraParam = "";
	strExtraParam = "&intSessionUser="+intSessionUser+"&intGoodworkId="+intGoodworkId+"&intProfileUserId="+intProfileUserId+"&intGoodWorkUser="+intGoodWorkUser;
	ajaxObjects[38] = new sack();
	ajaxObjects[38].requestFile = sitename+"/index.php?action=commentadminbox"+strExtraParam;
	ajaxObjects[38].onCompletion = function(){
												if (ajaxObjects[38].response != "")
												{
													document.getElementById('divRegisterLogin').innerHTML = ajaxObjects[38].response;
													Lightbox.showBoxByID("divRegisterLogin", intLoginPopupWidth, intLoginPopupHeight);
													return false;
												}
												else
												{
													strExtraParam = "";
													// FOR SINGLE USER ACCOUNT TO ADD GOOD WORK COMMENT
													fnAddGoodworkCommentText(intSessionUser, intGoodworkId, intProfileUserId, intGoodWorkUser, strExtraParam);
												}
											 }
	ajaxObjects[38].runAJAX();
	
}

function fnAddAdminGoodworkUpdate(intSessionUser, intGoodworkId, intProfileUserId, intGoodWorkUser)
{
	var strCommenterType = "";
	var intCompanyId = 0;
	var strExtraParam = "";

	for( i = 0; i < document.frmAdminType.rdbSelectType.length; i++ )
	{
		if( document.frmAdminType.rdbSelectType[i].checked == true )
		{
			strCommenterType = document.frmAdminType.rdbSelectType[i].value;
			if (strCommenterType != "i")
			{
				intCompanyId = strCommenterType;
				strCommenterType = "ca";
				strExtraParam = "&selectcommenttype="+intCompanyId;
				break;
			}
		}
	}
	
	if (strCommenterType == "")
	{
		alert("Choose \"Display this comment as\" from following options.");
		return false;
	}
	
	//document.getElementById("id_SubmitButton").style.display = "none";
	//document.getElementById("id_SubmitLoader").style.display = "";
	
	fnAddGoodworkCommentText(intSessionUser, intGoodworkId, intProfileUserId, intGoodWorkUser, strExtraParam);
	
	Lightbox.hideBox();
}

function fnCheckExternalCommentAdmin(strSessionUserId, strMediaId, strMediaType, strProfileUserId)
{
	// AJAX CALL TO CHECK COMMENT ADMIN TYPE
	// THIS WILL RETURN COMMENT ADMIN FORM IF USER IS COMMENT ADMIN
	// ELSE IT WILL REQUEST TO ADD A GOOD WORK
	var strExtraParam = "";
	strExtraParam = "&strSessionUserId="+strSessionUserId+"&strMediaId="+strMediaId+"&strMediaType="+strMediaType+"&strProfileUserId="+strProfileUserId;
	ajaxObjects[38] = new sack();
	ajaxObjects[38].requestFile = sitename+"/index.php?action=commentadminbox"+strExtraParam;
	ajaxObjects[38].onCompletion = function(){
												if (ajaxObjects[38].response != "")
												{
													document.getElementById('divRegisterLogin').innerHTML = ajaxObjects[38].response;
													Lightbox.showBoxByID("divRegisterLogin", intLoginPopupWidth, intLoginPopupHeight);
													return false;
												}
												else
												{
													strExtraParam = "";
													// FOR SINGLE USER ACCOUNT TO ADD GOOD WORK COMMENT
													fnAddExternalCommentText(strSessionUserId, strMediaId, strMediaType, strProfileUserId, strExtraParam);
												}
											 }
	ajaxObjects[38].runAJAX();
	
}

function fnAddAdminExternalUpdate(strSessionUserId, strMediaId, strMediaType, strProfileUserId)
{
	var strCommenterType = "";
	var intCompanyId = 0;
	var strExtraParam = "";

	for( i = 0; i < document.frmAdminType.rdbSelectType.length; i++ )
	{
		if( document.frmAdminType.rdbSelectType[i].checked == true )
		{
			strCommenterType = document.frmAdminType.rdbSelectType[i].value;
			if (strCommenterType != "i")
			{
				intCompanyId = strCommenterType;
				strCommenterType = "ca";
				strExtraParam = "&selectcommenttype="+intCompanyId;
				break;
			}
		}
	}
	
	if (strCommenterType == "")
	{
		alert("Choose \"Display this comment as\" from following options.");
		return false;
	}
	
	//document.getElementById("id_SubmitButton").style.display = "none";
	//document.getElementById("id_SubmitLoader").style.display = "";
	
	fnAddExternalCommentText(strSessionUserId, strMediaId, strMediaType, strProfileUserId, strExtraParam);
	
	Lightbox.hideBox();
}

// Added by umeshk 10th nov 09 ---- End