/**
 * HOME Module JS Files
 * @author Pathfinder Solutions India
 * @link http://www.pathfindersolutions.biz
 * @version 1.0
 * @package justmeans
 * @subpackage Home
 */

var ajaxObjects = new Array();
var opencommentdiv = false;
var intCurrentSessionUser = 0;

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 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 fnClearBoxText(strTextBoxId)
{
	if (document.getElementById(strTextBoxId).value == strEnterText)
	{
		document.getElementById(strTextBoxId).className = "input";
		document.getElementById(strTextBoxId).value = "";
		document.getElementById(strTextBoxId).focus();
	}
	//fnCheckCharCnt();
}

function fnShowFullCommentMessage(cuserid, cstatusid)
{ 	
	document.getElementById("id_Comment_"+cstatusid).style.display = "none";
	document.getElementById("id_ViewCommentLink_"+cstatusid).style.display = "none";
	document.getElementById("id_ViewLessCommentLink_"+cstatusid).style.display = "";
	document.getElementById("id_Comment_Full_"+cstatusid).style.display = "";
}

function fnShowLessCommentMessage(cuserid, cstatusid)
{
	document.getElementById("id_Comment_"+cstatusid).style.display = "";
	document.getElementById("id_ViewCommentLink_"+cstatusid).style.display = "";
	document.getElementById("id_ViewLessCommentLink_"+cstatusid).style.display = "none";
	document.getElementById("id_Comment_Full_"+cstatusid).style.display = "none";
}

function fnAddWhatGoodWork(strTextBoxId, intLoginUserId, objButton)
{
	fnCheckCharCnt(document.getElementById("id_txtWhatAreUWorking"),140,'btnEnter','id_chartextcnt','id_GoodWorkLengthError','images/btn_gwUpdateDisable.gif','images/btn_gwUpdate.gif');
	
	var string = document.getElementById(strTextBoxId).value;
	
	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_GoodWorkWordLengthError',document.getElementById(objButton),200,48);
				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,40);
			return false;
		}
	}
	
	document.getElementById("id_GoodworkEnter").style.display = "none";
	document.getElementById("id_GoodworkLoader").style.display = "";
	
	strGoodWorkText = document.getElementById("id_txtWhatAreUWorking").value;
	strGoodWorkText = Base64.encode(strGoodWorkText);
	
	// CALL TO SET TEXT INTO SESSION
	ajaxObjects[0] = new sack();
	ajaxObjects[0].requestFile = sitename+"/index.php?action=setunsetsessionvars&mode=ajax&ajax_action=setsessionparams&settoparams=forwgwrud&location=userhomepageV6&txtWhatAreUWorking="+strGoodWorkText+"&approveflag=a";
	ajaxObjects[0].onCompletion = function(){  
												if (parseInt(intLoginUserId) > 0)
													fnChechCommentAdmin();
												else
													Lightbox.showBoxByID("divRegisterLogin", intLoginPopupWidth, intLoginPopupHeight);
											};
	ajaxObjects[0].runAJAX();
	
	// FUNCTION TO SHOW WORD COUNT
	//fnCheckCharCnt();
}

function fnChechCommentAdmin(intLoginUserId)
{
	// SET CURRENT SESSION USER ID TO INCREASE GOOD WORK COUNT
	intCurrentSessionUser = intLoginUserId;
	
	// 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
	ajaxObjects[38] = new sack();
	ajaxObjects[38].requestFile = sitename+"/index.php?action=commentadminbox";
	ajaxObjects[38].onCompletion = function(){
												if (ajaxObjects[38].response != "")
												{
													document.getElementById('divRegisterLogin').innerHTML = ajaxObjects[38].response;
													Lightbox.showBoxByID("divRegisterLogin", intLoginPopupWidth, intLoginPopupHeight);
													return false;
												}
												else
												{
													// FOR SINGLE USER ACCOUNT TO ADD GOODWORK
													fnAddUpdateText();
												}
											 }
	ajaxObjects[38].runAJAX();
	
}

function fnAddUpdateText()
{
	// CALL TO INCREASE GOODWORK UPDATE COUNT
	ajaxObjects[39] = new sack();
	ajaxObjects[39].requestFile = sitename+"/index.php?action=addgoodworkupdate";
	ajaxObjects[39].onCompletion = function(){
													arrLookup = new Array();
													var lookup;
													var parentlookup;
													var intResponse;
													lookup = ajaxObjects[39].response.toString();
													arrLookup = lookup.split(" | ");
													
													intResponse = (isNaN(arrLookup[0])) ? "" : parseInt(arrLookup[0]);
													parentlookup = (isNaN(arrLookup[1])) ? "" : parseInt(arrLookup[1]);
													
													if (intResponse != "" && parentlookup != "")
													{
														fnProcessSpamMessage(intResponse, parentlookup)
													}
													else
													{
														fnIncreaseGoodWorkCount();
														fnUpdateFinalProcess(intResponse);
													}
											 }
	ajaxObjects[39].runAJAX();
}

function fnAddAdminUpdate()
{
	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 = "&admin="+Base64.encode(strCommenterType)+"&company="+Base64.encode(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 = "";
	
	// CALL TO INCREASE GOODWORK UPDATE COUNT
	ajaxObjects[41] = new sack();
	ajaxObjects[41].requestFile = sitename+"/index.php?action=addgoodworkupdate"+strExtraParam;
	ajaxObjects[41].onCompletion = function(){
													var lookup = ajaxObjects[41].response;
													arrLookup = lookup.split(" | ");
													
													var intResponse = parseInt(arrLookup[0]);
													var parentlookup = parseInt(arrLookup[1]);	
													
													if (intResponse > 0 && parentlookup > 0)
														fnProcessSpamMessage(intResponse, parentlookup)
													else
													{
														Lightbox.hideBox();
														fnIncreaseGoodWorkCount();
														fnUpdateFinalProcess(intResponse);
													}
											 }
	ajaxObjects[41].runAJAX();
}

function fnUpdateFinalProcess(intGoodWorkId)
{
	// FOR DISPLAY SUBMIT BUTTON
	document.getElementById("id_GoodworkEnter").style.display = "";
	document.getElementById("id_GoodworkLoader").style.display = "none";
	
	// FOR CLEAR GOOD WORK TEXTBOX
	document.getElementById("id_txtWhatAreUWorking").value = "";
	document.getElementById("id_txtWhatAreUWorking").style.height = "30px";
	
	// FOR GOOD WORK CHAR COUNT BOX
	document.getElementById("id_chartextcnt").innerHTML = "140";
	document.getElementById("id_chartextcnt").className = "charcount";
	
	if (document.getElementById("id_CommunityClass").className != "")
		fnShowLatestGoodWorkUpdate(intGoodWorkId);
	else
		fnToggleNewsFeed('community');
}

function fnIncreaseGoodWorkCount()
{
	// CALL TO INCREASE GOODWORK UPDATE COUNT
	ajaxObjects[40] = new sack();
	ajaxObjects[40].requestFile = sitename+"/index.php?action=myprofile&mode=ajax&ajax_action=increasegoodworkcount&user="+intCurrentSessionUser;
	ajaxObjects[40].runAJAX();
}

function fnShowLatestGoodWorkUpdate(intGoodWorkId)
{
	var strGoodWorkUpdateText;
	var strGoodWorkId;
	strGoodWorkId = intGoodWorkId.toString();
	ajaxObjects[42] = new sack();
	ajaxObjects[42].requestFile = sitename+"/index.php?action=myprofile&mode=ajax&ajax_action=showlatestgoodwork&update="+Base64.encode(strGoodWorkId);
	ajaxObjects[42].onCompletion = function(){
													strGoodWorkUpdateText = document.getElementById("id_GoodWorkUpdates").innerHTML;
													strGoodWorkUpdateText = ajaxObjects[42].response + strGoodWorkUpdateText;
													document.getElementById("id_GoodWorkUpdates").innerHTML = strGoodWorkUpdateText;
													fnSetFadeEffects("id_Container_id_Contentgoodwork_"+intGoodWorkId);
											 }
	ajaxObjects[42].runAJAX();
}

function fnProcessSpamMessage(intResponse, parentlookup)
{
	switch (intResponse)
	{
		case 555:																	
			var strPageLocation = window.location;
			strPageLocation = strPageLocation.toString();
			
			if (strPageLocation.indexOf("myprofile") != -1)
				strPageLocation = sitename+"/myprofile?feed=1&se="+parentlookup;
			else if (strPageLocation == sitename+"/" || strPageLocation == sitename)
				strPageLocation = sitename+"/index.php?action=userhomepageV6&isnewu=1&se="+parentlookup;
			else if (strPageLocation.indexOf("userhomepageV6") != -1)
				strPageLocation = sitename+"/index.php?action=userhomepageV6&isnewu=1&se="+parentlookup;
			else if (strPageLocation.indexOf("#") == -1)
				strPageLocation = window.location+"&se="+parentlookup;
			else
			{
				strTmpLocation = strPageLocation.replace(sitename+"/", "");
		
				strTmpLocation = strTmpLocation.replace("?", "&");
				strPageLocation = sitename+"/index.php?action="+strTmpLocation+"&se="+parentlookup;
			}
			
			window.location.href = strPageLocation;																
		break;
		
		case 666:
		var strPageLocation = window.location;
			strPageLocation = strPageLocation.toString();
			
			
			if (strPageLocation.indexOf("myprofile") != -1)
				strPageLocation = sitename+"/myprofile?feed=1&se="+parentlookup;
			else if (strPageLocation == sitename+"/" || strPageLocation == sitename)
				strPageLocation = sitename+"/index.php?action=userhomepageV6&isnewu=1&se="+parentlookup;
			else if (strPageLocation.indexOf("userhomepageV6") != -1)
				strPageLocation = sitename+"/index.php?action=userhomepageV6&isnewu=1&se="+parentlookup;
			else if (strPageLocation.indexOf("#") == -1)																																			
				strPageLocation = window.location+"&se="+parentlookup;
			else
			{
				strTmpLocation = strPageLocation.replace(sitename+"/", "");
				strTmpLocation = strTmpLocation.replace("?", "&");
				strPageLocation = sitename+"/index.php?action="+strTmpLocation+"&se="+parentlookup;
			}
			
			window.location.href = strPageLocation;
		break;
		
		case 999:
		location.href = sitename+"/index.php?action=logout&spamerror=1";
		break;
		
		case 88:
			var strPageLocation = window.location;
			strPageLocation = strPageLocation.toString();
			
			if (strPageLocation.indexOf("myprofile") != -1)
				strPageLocation = sitename+"/myprofile?feed=1&se="+parentlookup;
			else if (strPageLocation == sitename+"/" || strPageLocation == sitename)
				strPageLocation = sitename+"/index.php?action=userhomepageV6&isnewu=1&se="+parentlookup;
			else if (strPageLocation.indexOf("userhomepageV6") != -1)
				strPageLocation = sitename+"/index.php?action=userhomepageV6&isnewu=1&se="+parentlookup;
			else if (strPageLocation.indexOf("#") == -1)
				strPageLocation = window.location+"&se="+parentlookup;
			else
			{
				strTmpLocation = strPageLocation.replace(sitename+"/", "");
				strTmpLocation = strTmpLocation.replace("?", "&");
				strPageLocation = sitename+"/index.php?action="+strTmpLocation+"&se="+parentlookup;
			}
			
			window.location.href = strPageLocation;
		break;
	}
}

function fnShowOlderNews(intLimit, strFeedType)
{
	fnShowInfoLoadingImage("id_NewsFeed_"+intLimit);
	//document.getElementById("id_OlderUpdatesArrow_"+intLimit).src = "images/olderupdate_arrow.gif";

	ajaxObjects[1] = new sack();
	ajaxObjects[1].requestFile = sitename+"/index.php?mode=ajax&ajax_action=showoldernews&limit="+Base64.encode(intLimit)+"&feedtype="+strFeedType;
	ajaxObjects[1].onCompletion = function(){
												document.getElementById("id_OlderTabLink_"+intLimit).style.display = "none";
												document.getElementById("id_NewsFeed_"+intLimit).innerHTML = ajaxObjects[1].response;
											};
	ajaxObjects[1].runAJAX();
}

function fnToggleNewsFeed(strFeedType)
{
	if (strFeedType == "")
		return "";
	
	if (document.getElementById("id_UserLink").href == "javascript:fnToggleNewsFeed('user');")
		document.getElementById("id_UserLink").href = "javascript:;";
	document.getElementById("id_CommunityLink").href = "javascript:;";
	document.getElementById("id_MediaLink").href = "javascript:;";
	document.getElementById("id_EditorialLink").href = "javascript:;";
		
	document.getElementById("id_UserClass").className = "";
	document.getElementById("id_CommunityClass").className = "";
	document.getElementById("id_MediaClass").className = "";
	document.getElementById("id_EditorialClass").className = "";
	
	if (strFeedType == "community")
		document.getElementById("id_CommunityClass").className = "active";
	else if (strFeedType == "media")
		document.getElementById("id_MediaClass").className = "active";
	else if (strFeedType == "editorial")
		document.getElementById("id_EditorialClass").className = "active";
	else
		document.getElementById("id_UserClass").className = "active";

	fnShowInfoLoadingImage("id_NewsFeedTab");
	
	ajaxObjects[2] = new sack();
	ajaxObjects[2].requestFile = sitename+"/index.php?mode=ajax&ajax_action=togglenewsfeed&feedtype="+strFeedType;
	ajaxObjects[2].onCompletion = function(){
												if (document.getElementById("id_UserLink").href == "javascript:;")
													document.getElementById("id_UserLink").href = "javascript:fnToggleNewsFeed('user');";
													
												document.getElementById("id_CommunityLink").href = "javascript:fnToggleNewsFeed('community');";
												document.getElementById("id_MediaLink").href = "javascript:fnToggleNewsFeed('media');";
												document.getElementById("id_EditorialLink").href = "javascript:fnToggleNewsFeed('editorial');";
												document.getElementById("id_NewsFeedTab").innerHTML = ajaxObjects[2].response;
												document.getElementById("id_txtWhatAreUWorking").focus();
												
											};
	ajaxObjects[2].runAJAX();
}

function fnSetPreviousValue(objText)
{
	if (objText.value == "")
	{
		objText.value = strEnterText;
		objText.className = "bigTextArea";
		objText.style.height = "30px";
	}
}

function fnAddGoodWork(strUpdateId, strUpdateType, strGotoLink, strSessionUserId, strProfileUserId, strParentId, strOutputDivId)
{
	strLoadingDivId = "id_Loading_"+Base64.decode(strUpdateType)+"_"+Base64.decode(strUpdateId)+"_"+Base64.decode(strParentId);
	fnShowLoadingCircle(strLoadingDivId);
	
	strDivId = "id_"+Base64.decode(strUpdateType)+"_"+Base64.decode(strUpdateId)+"_"+Base64.decode(strParentId);
	document.getElementById(strDivId).style.display = "none";
	
	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);
													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)
{
	strLoadingDivId = "id_Loading_"+Base64.decode(strUpdateType)+"_"+Base64.decode(strUpdateId)+"_"+Base64.decode(strParentId);
	fnShowLoadingCircle(strLoadingDivId);
	
	strDivId = "id_"+Base64.decode(strUpdateType)+"_"+Base64.decode(strUpdateId)+"_"+Base64.decode(strParentId);
	document.getElementById(strDivId).style.display = "none";
	
	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);
													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 fnShowAddUpdateBox()
{
	fnToggleMenu(1,4);
	document.getElementById("id_txtWhatAreUWorking").focus();
}

function fnIncreaseHieghtofTA(elementid)
{
	elementid.style.height = elementid.scrollHeight + 'px';
}

function fnCheckConversationCharCnt(statusid)
	{ 
		var strText;
		var strTextLen;
		strDivId="id_txtWhatAreUWorking_"+statusid; 
		strCharDivId="id_charConvtextCnt_"+statusid; 
		strEnterButton = "submit_"+statusid;
		strText = document.getElementById(strDivId).value;
 		
			if(1000 - strText.length >= 20)
			{
				document.getElementById(strCharDivId).className = "charcount";
			}
			else if((1000 - strText.length < 20) &&  (1000 - strText.length > 10) )
			{					
				document.getElementById(strCharDivId).className = "charcount20";
			}
			else
			{
				document.getElementById(strCharDivId).className = "charcountnegative";
			}
			
			if(1000 - strText.length  < 0)
			{
				document.getElementById(strEnterButton).src = "images/btn_submit_disable.gif";
			}
			else
			{
				document.getElementById(strEnterButton).src = "images/btn_comment.gif";
			}
			if((1000 - strText.length <= 999) && (1000 - strText.length > -1)){ 
				try{
			  		ajax_hideTooltip();
				}
				catch(e){}
			}

			document.getElementById(strCharDivId).innerHTML = (1000 - strText.length); 
	}
	

	function fnViewAllComment(commentcnt,statusid)
	{
		for(i=2;i<=commentcnt;i++)
		{
			document.getElementById("id_tr_" + i + "_" + statusid).style.display="";
		}
		
		document.getElementById("id_maintr_" + statusid).style.display="none";
		document.getElementById("id_after_" + statusid).style.display="";
	}


	function fnHideAllComment(commentcnt,statusid)
	{
		if(document.getElementById("id_after_" + statusid).style.display == "")
		{
			document.getElementById("id_after_" + statusid).style.display="none";
			document.getElementById("id_maintr_" + statusid).style.display="";
		}
		for(i=2;i<=commentcnt;i++)
		{
			document.getElementById("id_tr_" + i + "_" + statusid).style.display="none";
			
		}
		
		//document.getElementById("id_maintr_" + statusid).style.display="none";
		//document.getElementById("id_after_" + statusid).style.display="";
		
	}
	
function fnAddGoodWorkText(strUpdateId, goodworkId, strUpdateType, strGotoLink, strSessionUserId, strProfileUserId)
{ 
	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].runAJAX();
	
	if (strSessionUserId == "")
	{
		Lightbox.showBoxByID("divRegisterLogin", intLoginPopupWidth, intLoginPopupHeight);
		return false;
	}
	//document.getElementById("id_goodworkcomment").style.display="";
	
	// 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(){
												document.getElementById("id_goodworkcomment_"+ goodworkId).style.display="";
												document.getElementById("retract_good_"+ goodworkId).style.display="";
												document.getElementById("good_"+ goodworkId).style.display="none";
												}
	ajaxObjects[6].runAJAX();
}

function fnRemoveGoodWorkText(strUpdateId, goodworkId, strUpdateType, strGotoLink, strSessionUserId,strProfileUserId)
{ 
	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].runAJAX();
	
	if (parseInt(Base64.decode(strSessionUserId)) == 0 || strSessionUserId == "")
	{
		Lightbox.showBoxByID("divRegisterLogin", intLoginPopupWidth, intLoginPopupHeight);
		return false;
	}
	
	//document.getElementById("id_goodworkcomment").style.display="none";
	
	ajaxObjects[6] = new sack();
	ajaxObjects[6].requestFile = sitename+"/index.php?action=addremovegoodwork&mode=ajax&ajax_action=addremovegoodwork&byajax=1";
	ajaxObjects[6].onCompletion = function(){
													document.getElementById("id_goodworkcomment_"+ goodworkId).style.display="none";
													document.getElementById("retract_good_"+ goodworkId).style.display="none";
													document.getElementById("good_"+ goodworkId).style.display="";
											}
	ajaxObjects[6].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(){
												strLoadingDivId = "id_Loading_"+Base64.decode(strUpdateType)+"_"+Base64.decode(strUpdateId)+"_"+Base64.decode(strParentId);
												document.getElementById(strLoadingDivId).innerHTML = "";
												document.getElementById(strLoadingDivId).style.display = "none";
												
												strDivId = "id_"+Base64.decode(strUpdateType)+"_"+Base64.decode(strUpdateId)+"_"+Base64.decode(strParentId);
												document.getElementById(strDivId).style.display = "";
												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 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);
													}
													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)
	{
		intDecreasepos = 200;
		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);
		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;
	}
	
	if (strCommentText.length > 240)
	{
		ajax_showTooltip("id_Error_"+strNewsType+"_"+intNewsId+"_"+intParentId,document.getElementById("id_Enter_"+strNewsType+"_"+intNewsId+"_"+intParentId),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_"+strNewsType+"_"+intNewsId+"_"+intParentId),200,48);
				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 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 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 was your last chance to add 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)
{
	fnShowLoadingCircle("id_CommmentHeader_"+strNewsType+"_"+intNewsId+"_"+intParentId);
	
	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)
{
	fnShowLoadingCircle("id_ViewCommentLoading_"+intCommentId);
	document.getElementById("id_ViewCommentLink_"+intCommentId).style.display = "none";
	
	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_ViewCommentLoading_"+intCommentId).innerHTML = "";
													document.getElementById("id_ViewCommentLoading_"+intCommentId).style.display = "none";
													document.getElementById("id_ViewLessCommentLink_"+intCommentId).style.display = "";
													
													document.getElementById("id_Comment_"+intCommentId).innerHTML = ajaxObjects[17].response;
											 };
	ajaxObjects[17].runAJAX();
}

function fnShowLessComment(intProfileUserId, intCommentId)
{
	fnShowLoadingCircle("id_ViewCommentLoading_"+intCommentId);
	document.getElementById("id_ViewLessCommentLink_"+intCommentId).style.display = "none";
	
	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_ViewCommentLoading_"+intCommentId).innerHTML = "";
													document.getElementById("id_ViewCommentLink_"+intCommentId).style.display = "";
													document.getElementById("id_ViewCommentLoading_"+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);
	}
}

////// by prachi for conversation
function fnCancelConversationComment(strElementId)
{ 
	try{ 
		document.getElementById("id_txtNewsFeedDiv_Goodwork_"+strElementId+"").style.display = "";
		document.getElementById("id_CommentBoxTd_"+strElementId+"").style.display = "none";		
	}
	catch(e)
	{}	
	document.getElementById("id_txtWhatAreUWorking_"+strElementId+"").value= "";
	document.getElementById("id_charConvtextCnt_"+strElementId+"").innerHTML = 1000; 
}
////////////////////

function fnShowCommentBoxer(statusid)
	{
		if(document.getElementById("id_txtWhatAreUWorking_"+statusid).value == "" || document.getElementById("id_txtWhatAreUWorking_"+statusid).value == "Write a Comment...")
		{
			document.getElementById("id_txtWhatAreUWorking_"+statusid).style.height = "85px";
			document.getElementById("id_txtWhatAreUWorking_"+statusid).value = "";
			document.getElementById("submit_"+statusid).style.display = "";
			document.getElementById("id_txtWhatAreUWorking_"+statusid).focus();
		}
	}

function fnDisplayReplyCommentBox(intStatusId)
	{		
		document.getElementById("id_CommentBoxTd_"+ intStatusId).style.display="";
		document.getElementById("id_txtWhatAreUWorking_"+ intStatusId).focus();
		document.getElementById("id_txtNewsFeedDiv_Goodwork_"+ intStatusId).style.display="none";
	}

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 = "350px";
											 };
	ajaxObjects[18].runAJAX();
}

function fnAddGoodworkComment(intSessionUser, intGoodworkId, intProfileUserId, intGoodWorkUser)
{
	strCommentText = document.getElementById("id_txtNewsFeedComment_Goodwork_"+intGoodworkId).value;
	var strExtraParam = "";
	
	if (strCommentText == "")
	{
		ajax_showTooltip("id_Div_EmptyCommentError_Goodwork_"+intGoodworkId,document.getElementById("id_Enter_Goodwork_"+intGoodworkId),160,38);
		return false;
	}
	
	if (strCommentText.length > 1000)
	{
		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_"+intGoodworkId,document.getElementById("id_txtNewsFeedComment_Goodwork_"+intGoodworkId),200,45);
				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);
		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)
{
	//id_CommmentHeader_Goodwork_
	//document.getElementById().innerHTML = ""
	fnShowLoadingCircle("id_CommmentHeader_Goodwork_"+intGoodworkId);
	
	ajaxObjects[21] = new sack();
	ajaxObjects[21].requestFile = sitename+"/index.php?action=myprofile&mode=ajax&ajax_action=showgoodworkcommentbox&user="+intProfileUserId+"&goodwork="+intGoodworkId+"&comment="+strCommentType;
	//ajaxObjects[21].PostParam = "&goodwork="+intGoodworkId+"&comment="+strCommentType;
	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)
{
	document.getElementById("id_ViewGCommentLink_"+intCommentId).style.display = "none";
	fnShowLoadingCircle("id_ViewGCommentLoading_"+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_ViewGCommentLoading_"+intCommentId).innerHTML = "";
													document.getElementById("id_ViewGCommentLoading_"+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)
{
	document.getElementById("id_ViewLessGCommentLink_"+intCommentId).style.display = "none";
	fnShowLoadingCircle("id_ViewGCommentLoading_"+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_ViewGCommentLoading_"+intCommentId).innerHTML = "";
													document.getElementById("id_ViewGCommentLoading_"+intCommentId).style.display = "none";
													document.getElementById("id_ViewGCommentLink_"+intCommentId).style.display = "";
													
													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);
													}
													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 > 1000)
	{
		ajax_showTooltip("id_Error_"+strMediaType+"_"+intMediaId,document.getElementById("id_Enter_"+strMediaType+"_"+intMediaId),250,55);
		return false;
	}
	//// to check word character count
	var myarry = new Array();
	var tab= RegExp( "\\n", "g" )
	strText = strCommentText.replace(tab, " ")
	//myarry = strCommentText.split(' '); 
	myarry = strText.split(' ');  
	for (i=0;i<myarry.length;i++)
	{	
		if((myarry[i].length) >= 25)
		{	
			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,48);
				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);
		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 intCommentId = ajaxObjects[32].response;
														fnAddExternalCommentBox(intMediaId, strMediaType, intProfileUserId)
														fnShowExternalCommentBox(intMediaId, strMediaType, intProfileUserId, 'last', intCommentId)
														*/
														
														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 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 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 was your last chance to add 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)
{ 
	fnShowLoadingCircle("id_ExtCommmentHeader_"+strMediaType+"_"+intMediaId);
	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;
	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)
{
	fnShowLoadingCircle("id_ViewECommentLoading_"+intCommentId);
	document.getElementById("id_ViewECommentLink_"+intCommentId).style.display = "none";
	
	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_ViewECommentLoading_"+intCommentId).innerHTML = "";
													document.getElementById("id_ViewECommentLoading_"+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)
{
	fnShowLoadingCircle("id_ViewECommentLoading_"+intCommentId);
	document.getElementById("id_ViewLessECommentLink_"+intCommentId).style.display = "none";
	
	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_ViewECommentLoading_"+intCommentId).innerHTML = "";
													document.getElementById("id_ViewECommentLoading_"+intCommentId).style.display = "none";
													document.getElementById("id_ViewECommentLink_"+intCommentId).style.display = "";
													
													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_VideoPlayer_"+intUpdateId).style.display = "";
}

function fnScrollOverWindow(strStartObjectId, strObjectId)
{
	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 fnShowLoginToHomePageFeed()
{
	document.getElementById("id_LoginFrame").src = securedsitename + "/index.php?action=logmein&frame=1&goto=" + Base64.encode("action=userhomepageV6&newsfeed=1");
	Lightbox.showBoxByID("divRegisterLogin", intLoginPopupWidth, intLoginPopupHeight);
}

$(document).ready(function() {
	$("#editoArro2").click(function(event) {
			event.preventDefault();
			$("#editoBox2").slideToggle();
			$("#editoArro2").addClass("active");
	});
	
	$("#btn_close2").click(function(event) {
		event.preventDefault();
		$("#editoBox2").slideToggle();
		$("#editoArro2").removeClass("active");
		editoState = false;
	});
	$("#editoLnk2").mouseover(function(event) {
			$("#editoArro2").addClass("active");
	});
	$("#editoLnk2").mouseout(function(event) {
			if($("#editoBox2").css("display")== "none"){				 
			$("#editoArro2").removeClass("active");
	}
});
 });								


function fnShowLoadingCircle(DivId)
{
	strLodingHTML = "<img src='images/ajax-loader-small-bar.gif' align='absmiddle'>";
	
	try{
		document.getElementById(DivId).style.display = "";
		document.getElementById(DivId).innerHTML = strLodingHTML;
	}
	catch(e)
	{}
}

function fnAjaxPaginationLoader(strContentId)
{
	document.getElementById(strContentId).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 fnToggleWebClip(strToggleType)
{
	var options = {};
	
	if (strToggleType == "prev")
		intShowClip = parseInt(intWebClip-1);
	else
		intShowClip = parseInt(intWebClip+1);
		
	if (intShowClip == 0 || intShowClip > intTotalClip)
		return;
		
	for (intCount = 1; intCount <= intTotalClip; intCount++)
	{
		if (intCount == intShowClip)
		{
			$("#id_WebClipDiv_"+intCount).toggle();
			document.getElementById("id_WebClipDiv_"+intCount).style.display = "";
		}
		else
		{
			document.getElementById("id_WebClipDiv_"+intCount).style.display = "none";
		}
	}
	
	document.getElementById("id_WebClipPrevDiv").style.color = "#FF0000";
	document.getElementById("id_WebClipNextDiv").style.color = "#FF0000";
	
	if (intShowClip == 1)
		document.getElementById("id_WebClipPrevDiv").style.color = "#000000";
	
	if (intShowClip == intTotalClip)
		document.getElementById("id_WebClipNextDiv").style.color = "#000000";
	
	intWebClip = intShowClip;
}

function fnCheckCharCnt()
{ 
	var strText;
	var strTextLen;		
	strText = document.getElementById("id_txtWhatAreUWorking").value;
	if(strText == "Enter update here...")
		strText = "";
		
	if(140 - strText.length >= 20)
	{
		document.getElementById('id_chartextcnt').className = "charcount";
	}
	else if((140 - strText.length < 20) &&  (140 - strText.length > 10) )
	{					
		document.getElementById('id_chartextcnt').className = "charcount20";
	}
	else
	{
		document.getElementById('id_chartextcnt').className = "charcountnegative";
	}
	
	if(140 - strText.length  < 0)
	{
		document.getElementById('btnEnter').src = "images/btn_gwUpdateDisable.gif";
	}
	else
	{
		document.getElementById('btnEnter').src = "images/btn_gwUpdate.gif";
	}

	if((140 - strText.length <= 139) && (140 - strText.length > -1)){ 
		try{
			ajax_hideTooltip();
		}
		catch(e){}
	}
	document.getElementById('id_chartextcnt').innerHTML =140 - strText.length;
}

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)
{
	fnShowInfoLoadingImage("id_SimilarPost_"+intGoodWorkId);
	ajaxObjects[43] = new sack();
	ajaxObjects[43].requestFile = sitename+"/index.php?mode=ajax&ajax_action=showsimilarpost&intLimit="+intLimit+"&similarpost=similarpost&intGoodWorkId="+intGoodWorkId;
	ajaxObjects[43].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[43].response;
												fnSetFadeEffects("id_Show_SimilarPost_"+intGoodWorkId);
											};
	ajaxObjects[43].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);
}

// 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