/**
 * Social Media Tool Module JS Files
 * @author Praxis Solutions India
 * @link http://www.praxissolutions.biz
 * @version 1.0
 * @package justmeans
 * @subpackage Social Media Tool
 */
 /*
$(document).ready(function(){
		setTimeout("FnGetlatest();", 10000);
});*/





/*----------------------------- COMMON FUNCTIONS ----------------------------------*/
var strLoadingHtml = "<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>";
var strSmallLoadingHtml = "<div style='text-align:center; padding: 22px;'><span style='font-size: 15px; font-weight: bold; color: #AAAAAA;'>Loading...</span>&nbsp;<img src='images/ajax-loader-small-bar.gif' align='absmiddle'></div>";
var ajaxObjects = new Array();
var ajaxObjects = new Array();
var arrSubtabOnclick = new Array();
var strFacebookAccountOption = "";
Lightbox.enmStopResetSession = 0;

var dragsort = ToolMan.dragsort();
var junkdrawer = ToolMan.junkdrawer();
// FOR ALL TAB SCROLL
var enmExtraPos = false;
var strScrollDir = "left";
var intElementOrgLeft = 0;
var intExtraLeft = 0;

var strOperation = "";
var strOperationTest = "";
var boolLogginUserId = 0;

var arrMediaAccounts = new Array();
arrMediaAccounts[0] = new Array();
arrMediaAccounts[0]['type'] = "tw";
arrMediaAccounts[0]['display'] = "none";
arrMediaAccounts[1] = new Array();
arrMediaAccounts[1]['type'] = "fb";
arrMediaAccounts[1]['display'] = "none";
arrMediaAccounts[2] = new Array();
arrMediaAccounts[2]['type'] = "ln";
arrMediaAccounts[2]['display'] = "none";

var objAutoRefresh = new Array();

function fnBuildMediaArray(strMediaAccounts) {
	var arrTempArray = new Array();
	if(strMediaAccounts != "") {
		arrTempArray  = strMediaAccounts.split(",");
	}
	for(var i=0 ; i< arrMediaAccounts.length; i++) {
		var strTabs = arrMediaAccounts[i]["type"];
		for(var j=0; j<arrTempArray.length; j++) {
			var strSelectedTab = arrTempArray[j];
			if(strTabs == strSelectedTab) {
				arrMediaAccounts[i]["display"] = "";
			}
		}	
	}
}

function fnLoadDyanamicJs(strjs,intflag,strModule)
{
	if(intflag)
	{
		document.getElementById('external_script').src = sitename+'/js/'+strjs;
	}
	else if(strModule!='')
	{
		document.getElementById('external_script').src = sitename+'/'+strModule+'/js/'+strjs;
	}
}

function fnResetMediaArray(strSelectedTabName) {
	var intParentTabCount = arrParentTabs.length;
	for(var i=0; i<intParentTabCount; i++) {
		strTabType = arrParentTabs[i]['type'];
		if(strTabType == strSelectedTabName) {
			switch(strOperation) {
				case "view":
				case "add":
					arrParentTabs[i]["display"] = "";
				break;
				case "remove":
					arrParentTabs[i]["display"] = "none";
					strSelectedTabName = "list";
				break;
				default:
					strSelectedTabName = "list";
				break;
			}
			break;
		}
	}
	strOperation = "";
	return strSelectedTabName;
}

function fnSetParentTabs(strSelectedTabName) {
	strSelectedTabName = fnResetMediaArray(strSelectedTabName);
	var intParentTabCount = arrParentTabs.length;
	for(var i=0; i<intParentTabCount; i++) {
		strTabType = arrParentTabs[i]['type'];
		if(strSelectedTabName != "") {
			if(strSelectedTabName == strTabType) {
				if(strTabType == "stat" || strTabType == "rss" || strTabType == "schlist") arrParentTabs[i]["class"] = "lightBlueButton lightBlueButtonActive";	
				else arrParentTabs[i]["class"]= "active";	
			} else {
				if(strTabType == "stat" || strTabType == "rss" || strTabType == "schlist") arrParentTabs[i]["class"] = "lightBlueButton";	
				else arrParentTabs[i]["class"] = "";
			}
		}	
	}
	 
	for(var i=0; i<intParentTabCount; i++) {
		var strTabType = arrParentTabs[i]['type'];
		var strTabId = arrParentTabs[i]['id'];
		var strTabDispalay =  arrParentTabs[i]['display'];
		var strTabClassName = arrParentTabs[i]['class'];
		document.getElementById(strTabId).style.display = strTabDispalay;
		document.getElementById(strTabId).className = strTabClassName;
	}
}

function fnResetAutoRefreshObject() {
	objAutoRefresh = null;
	objAutoRefresh = new Array();
	return;
}

function fnShowTabAccount(strAccountType, objTab, boolLogin) {
	  
	fnLoadDyanamicJs("jquery.js",0,'metrics');
	if(!boolLogin) { 
		fnNewRegisterLogin(0,0);
		return false;
	}
	if(strAccountType == null) return false;
	if(objTab == null) return false;
	
	/* Reset auto refresh object */
	fnResetAutoRefreshObject();
	strOperation = 'view'; 
	fnSetParentTabs(strAccountType);
	switch(strAccountType){
		case "all":
			fnShowAllAccounts('id_SocialMediaSite_Container','');
		break;
		case "jm":
			 fnShowJustmeansAccount(objTab);
		break;
		case "tw":
			fnShowTwitterAccounts(objTab);
		break;
		case "fb":
			fnShowFacebookAccount(objTab);
		break;
		case "ln":
			fnShowLinkedinAccount(objTab);
		break;
		case "list":
			fnShowAddAccount(objTab);
		break;
		case "stat":
			fnShowUrlStatDetails();
		break;
		case "schlist":
			fnShowUrlScheduleDetails();
		break;		
		case "rss":
			fnShowRssDetails();
		break;
		default:
			return false;
		break;
	}	
}
var arrAccounts = new Array( "justmeans", "fb", "tw", "ln", "network");

function HideScheduleDeleteMessage()
{
	document.getElementById("id_schdeletemsg").style.display="none";
}

function fnDeleteScheduleStatusMessageConfirm(intId)
{
	ajax_hideTooltip();
	ajaxObjects[255] = new sack();
	ajaxObjects[255].requestFile = sitename+"/managesocialmedianetwork&mode=ajax&ajax_action=viewschedulelist&deleteid="+intId;
	ajaxObjects[255].onCompletion = function(){
												//alert(ajaxObjects[255].response);
												/* CHANGE TAB CLASS */
												document.getElementById("id_SocialMediaSite_Container").innerHTML = ajaxObjects[255].response;
												fnScrollWindow('id_schdeletemsg');
												setTimeout("HideScheduleDeleteMessage();", 10000);
											};
	ajaxObjects[255].runAJAX();
}
function fnDeleteScheduleStatusMessage(intId)
{
	ajax_showTooltip('id_remove_update_'+intId,document.getElementById('id_'+intId),220,55);
	return false;
}

function fnShowUrlScheduleDetails()
{
	document.getElementById("id_SocialMediaSite_Container").innerHTML = strLoadingHtml;
	var objTabs = document.getElementsByName("alltabs[]");
	for(var i=0; i<objTabs.length; i++) 
	{
		objTabs[i].className = "";
	}
	ajaxObjects[155] = new sack();
	ajaxObjects[155].requestFile = sitename+"/managesocialmedianetwork&mode=ajax&ajax_action=viewschedulelist";
	ajaxObjects[155].onCompletion = function(){
												//alert(ajaxObjects[155].response);
												/* CHANGE TAB CLASS */
												document.getElementById("id_SocialMediaSite_Container").innerHTML = ajaxObjects[155].response;
											};
	ajaxObjects[155].runAJAX();
}



function fnInitMediaAccount()
{
	arrMenuTabs = document.getElementById("id_Account_Tab").getElementsByTagName("LI");
	fnShowJustmeansAccount(arrMenuTabs[0], "", "");
}

function fnViewMainNavigationTabs(strTabType)
{
	ajaxObjects[3] = new sack();
	ajaxObjects[3].PostParam = "&tabtype="+strTabType;
	ajaxObjects[3].requestFile = sitename+"/managesocialmedianetwork&mode=ajax&ajax_action=viewallaccounttabs";
	ajaxObjects[3].onCompletion = function(){
												strResponse = ajaxObjects[3].response;
												document.getElementById("id_SocialMediaSite_Tab").innerHTML = strResponse;
												var objTwitterTab = null;
												arrAccountTabs = document.getElementById("id_Account_Tab").getElementsByTagName("LI");
												
												for (intI = 0; intI < arrAccountTabs.length; intI++)
												{
													if (arrAccountTabs[intI].getAttribute("tabname") == "tw" && strTabType == "tw")
													{
														objTwitterTab = arrAccountTabs[intI];
														fnShowTwitterAccount(objTwitterTab);
														break;
													}
													if (arrAccountTabs[intI].getAttribute("tabname") == "fb" && strTabType == "fb")
													{
														objTwitterTab = arrAccountTabs[intI];
														fnShowFacebookAccount(objTwitterTab);
														break;
													}
													if (arrAccountTabs[intI].getAttribute("tabname") == "ln" && strTabType == "ln")
													{
														objTwitterTab = arrAccountTabs[intI];
														fnShowLinkedinAccount(objTwitterTab);
														break;
													}
												}
											};
	ajaxObjects[3].runAJAX();
}

function fnProcessManageAccounts()
{
	ajaxObjects[3] = new sack();
	ajaxObjects[3].requestFile = sitename+"/addsocialnetwork&mode=ajax&ajax_action=viewmanageaccount";
	ajaxObjects[3].onCompletion = function(){
												strResponse = ajaxObjects[3].response;
												document.getElementById("id_ManageAccountForm").innerHTML = strResponse;
											};
	ajaxObjects[3].runAJAX();
}

function fnEditAccount(strAccoutId,strAccountType)
{
	document.getElementById("id_Edit_"+strAccoutId).style.display = "none";
	document.getElementById("id_Edit_Loading_"+strAccoutId).style.display = "";
	
	ajaxObjects[5] = new sack();
	ajaxObjects[5].PostParam = "&account="+strAccoutId+"&type="+strAccountType;
	ajaxObjects[5].requestFile = sitename+"/addsocialnetwork&mode=ajax&ajax_action=editaccount";
	ajaxObjects[5].onCompletion = function(){
												document.getElementById("id_Edit_"+strAccoutId).style.display = "";
												document.getElementById("id_Edit_Loading_"+strAccoutId).style.display = "none";
												strResponse = ajaxObjects[5].response;
												arrResponse = strResponse.split("|");
												
												if (arrResponse[0] == "error")
												{
													//document.getElementById("id_ErrorMessage").style.display = "";
													document.getElementById("id_ErrorMessage").innerHTML = arrResponse[1];
													if (document.getElementById("id_ErrorMessage").style.display == "none")
														$("#id_ErrorMessage").slideToggle();
												}
												else
												{
													document.getElementById("id_ErrorMessage").style.display = "none";
													document.getElementById("id_ErrorMessage").innerHTML = "";
													
													document.getElementById("id_EditAccount").innerHTML = arrResponse[1];
													Lightbox.enmStopResetSession = 0;
													Lightbox.showBoxByID("id_EditAccount");
												}
											};
	ajaxObjects[5].runAJAX();
}

function fnRemoveAccount(strAccoutId, strAccountType, verified)
{
	if(verified) {
		var isAccountExists = 0;
		try { ajax_hideTooltip(); } catch(e) { }
		var strDecodedAccountType = Base64.decode(strAccountType);
		switch(strDecodedAccountType) {
			case "fb":
			case "fbp":
				try { 
					fnUnsetFacebookAccount(strAccoutId, strAccountType)
				} catch(e) { }
			break;
			default:
				ajax_hideTooltip();	
				ajaxObjects[7] = new sack();
				ajaxObjects[7].PostParam = "&account="+strAccoutId;
				ajaxObjects[7].requestFile = sitename+"/addsocialnetwork&mode=ajax&ajax_action=removeaccount";
				ajaxObjects[7].onCompletion = function(){
															var strResponse = ajaxObjects[7].response;
															arrResponse = strResponse.split("|");
															if(arrResponse[0] == "success") {
																isAccountExists = parseInt(arrResponse[2], 10);
																if(!isAccountExists) strOperation = "remove";
																else strOperation = "";
																fnSetParentTabs(Base64.decode(strAccountType));
																fnSetSocialNetworkAccounts(0);
																fnShowAddAccount(document.getElementById('id_list'));
															} else {
																ajax_showTooltip('id_remove_error',document.getElementById('id_Remove_'+strAccoutId),220,55);
															}
														};
				ajaxObjects[7].runAJAX();			
			break;
		}
		return true;
	} else {
		document.getElementById('id_remove_confirm').setAttribute('onClick', "fnRemoveAccount('" + strAccoutId + "' , '" + strAccountType + "', 1); void(0);" );
		ajax_showTooltip('id_remove_account',document.getElementById('id_Remove_'+strAccoutId),220,60);
		return false;
	}
}

function fnToggleAccountMenu(intTabId)
{
	var arrAccountTabs=null;
	try{
		if(document.getElementById("id_AccountTabContainer"))
		arrAccountTabs = document.getElementById("id_AccountTabContainer").getElementsByTagName("A");
		
		for (intI = 0; intI < arrAccountTabs.length; intI++)
		{
			if (intTabId == arrAccountTabs[intI].getAttribute("value"))
				//arrAccountTabs[intI].parentNode.className = "active";
				AddClassName(arrAccountTabs[intI].parentNode,"active");
			else
				//arrAccountTabs[intI].parentNode.className = "";
				RemoveClassName(arrAccountTabs[intI].parentNode,"active");
		}
	}
	catch(e)
	{
		
	}

	document.getElementById("id_JustmeansForm").style.display = "none";
	document.getElementById("id_JustmeansForm").innerHTML = "";
	
	document.getElementById("id_TwitterForm").style.display = "none";
	document.getElementById("id_TwitterForm").innerHTML = "";
	
	document.getElementById("id_FacebookForm").style.display = "none";
	document.getElementById("id_FacebookForm").innerHTML = "";
	
	document.getElementById("id_FacebookPagesForm").style.display = "none";
	document.getElementById("id_FacebookPagesForm").innerHTML = "";
	
	document.getElementById("id_LinkedinForm").style.display = "none";
	document.getElementById("id_LinkedinForm").innerHTML = "";
	
	document.getElementById("id_DeliciousForm").style.display = "none";
	document.getElementById("id_DeliciousForm").innerHTML = "";
	
	document.getElementById("id_TumblerForm").style.display = "none";
	document.getElementById("id_TumblerForm").innerHTML = "";
	
	document.getElementById("id_ManageAccountForm").style.display = "none";
	document.getElementById("id_ManageAccountForm").innerHTML = "";
	
	strFacebookAccountOption = "";
	
	switch (intTabId)
	{
		case 1:
		
			document.getElementById("id_TwitterForm").style.display = "";
			document.getElementById("id_TwitterForm").innerHTML = strLoadingHtml;
			fnProcessToggleMenu("id_TwitterForm","tw");
		break;
		case 2:
			document.getElementById("id_FacebookForm").style.display = "";
			document.getElementById("id_FacebookForm").innerHTML = strLoadingHtml;
			strFacebookAccountOption = "account";
			fnConnectToFacebook("id_FacebookForm","fb")
			//fnProcessToggleMenu("id_FacebookForm","fb");
		break;
		case 3:
			document.getElementById("id_LinkedinForm").style.display = "";
			document.getElementById("id_LinkedinForm").innerHTML = strLoadingHtml;
			fnProcessToggleMenu("id_LinkedinForm","ln");
		break;
		case 4:
			document.getElementById("id_ManageAccountForm").style.display = "";
			document.getElementById("id_ManageAccountForm").innerHTML = strLoadingHtml;
			fnProcessManageAccounts();
		break;
		case 5:
			document.getElementById("id_DeliciousForm").style.display = "";
			document.getElementById("id_DeliciousForm").innerHTML = strLoadingHtml;
			fnProcessToggleMenu("id_DeliciousForm","del");
		break;
		
		case 6:
			document.getElementById("id_TumblerForm").style.display = "";
			document.getElementById("id_TumblerForm").innerHTML = strLoadingHtml;
			fnProcessToggleMenu("id_TumblerForm","tumb");
		break;
		
		case 7:
			document.getElementById("id_FacebookPagesForm").style.display = "";
			document.getElementById("id_FacebookPagesForm").innerHTML = strLoadingHtml;
			strFacebookAccountOption = "page";
			fnProcessToggleMenu("id_FacebookPagesForm","fbp");
		break;
		case 8:
			document.getElementById("id_JustmeansForm").style.display = "";
			document.getElementById("id_JustmeansForm").innerHTML = strLoadingHtml;
			fnProcessToggleMenu("id_JustmeansForm","jm");
		break;
	}
}

function fnProcessToggleMenu(strContainer,strAccountType)
{
	ajaxObjects[6] = new sack();
	ajaxObjects[6].PostParam = "&type="+Base64.encode(strAccountType);
	ajaxObjects[6].requestFile = sitename+"/managesocialmedianetwork&mode=ajax&ajax_action=togglemenu";
	ajaxObjects[6].onCompletion = function(){
													document.getElementById(strContainer).innerHTML = ajaxObjects[6].response;
											};
	ajaxObjects[6].runAJAX();
}

function fnShowAddAccount(objAccountTab)
{
	fnSetParentTabs("list");
	document.getElementById("id_SocialMediaSite_Container").innerHTML = strLoadingHtml;
	
	ajaxObjects[12] = new sack();
	ajaxObjects[12].requestFile = sitename+"/managesocialmedianetwork&mode=ajax&ajax_action=viewaddaccount";
	ajaxObjects[12].onCompletion = function(){
												document.getElementById("id_SocialMediaSite_Container").innerHTML = ajaxObjects[12].response;
												fnShowNetworkOptions();
												try	{
														jQuery('#id_Sub_Account_Tab').jcarousel();
													} catch(e) { }
											};
	ajaxObjects[12].runAJAX();
}

function fnDisableSubAccountTabs()
{
	arrMenuTabs = document.getElementById("id_Sub_Account_Tab").getElementsByTagName("LI");
	intLastItem = (arrMenuTabs.length - 1);
	for (intTab = 0; intTab < arrMenuTabs.length; intTab++)
	{
		arrSubtabOnclick[intTab] = arrMenuTabs[intTab].onclick;
		arrMenuTabs[intTab].onclick = "";
	}
}

function fnEnableSubAccountTabs()
{
	arrMenuTabs = document.getElementById("id_Sub_Account_Tab").getElementsByTagName("LI");
	intLastItem = (arrMenuTabs.length - 1);
	for (intTab = 0; intTab < arrMenuTabs.length; intTab++)
	{
		arrMenuTabs[intTab].onclick = arrSubtabOnclick[intTab];
	}
}

function fnGetContainerDiv(strParentDivId, strChildDivId)
{
	objParentDiv = document.getElementById(strParentDivId);
	arrChildDiv = objParentDiv.getElementsByTagName("DIV");
	
	for (intI = 0; intI < arrChildDiv.length; intI++)
	{
		if (arrChildDiv[intI].id == strChildDivId)
			return arrChildDiv[intI];
	}
}

/******************************** ALL TABS FUNCTION *****************************************/
function fnGetMoreTwits(intPageid,intMax_id,strSearchq)
{
	document.getElementById("id_twitmoreupdates_"+intPageid).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>";	
	ajaxObjects[110] = new sack();
	ajaxObjects[110].requestFile = sitename+"/allaccountstab?mode=ajax&ajax_action=getmoretwitupdate&pageid="+intPageid+"&maxid="+intMax_id+"&search='"+strSearchq+"'";
	//alert(ajaxObjects[110].requestFile);
	ajaxObjects[110].onCompletion = function(){ 
					// SET RESPONSE AS INNER HTML
					if(ajaxObjects[110].response != "Bad Request" || ajaxObjects[110].response !='INVALID REQUEST!')
					{
						document.getElementById('id_twitmoreupdates_'+intPageid).innerHTML = ajaxObjects[110].response;
					}
					else
					{
						return false;
					}
			};
	ajaxObjects[110].runAJAX();	
}

function fnHideShowRetweet(intFlag,intId)
{
	if(intFlag)
	{
		document.getElementById('id_retweet_'+intId).style.display="";
	}
	else
	{
		document.getElementById('id_retweet_'+intId).style.display="none";
	}	
}

function FnGetlatest()
{
	var ajaxIndex = ajaxObjects.length;	
	ajaxObjects[ajaxIndex] = new sack();
	ajaxObjects[ajaxIndex].requestFile = sitename+"/allaccountstab?mode=ajax&ajax_action=latesttweet";
	
	//alert(ajaxObjects[ajaxIndex].requestFile);
	ajaxObjects[ajaxIndex].onCompletion = function(){ 
					// SET RESPONSE AS INNER HTML
					//alert(ajaxObjects[ajaxIndex].response);
					if(ajaxObjects[ajaxIndex].response != "Bad Request" || ajaxObjects[ajaxIndex].response !='INVALID REQUEST!')
					{
						$("div#twitupdates").prepend(ajaxObjects[ajaxIndex].response);
						$("#twitupdate").slideDown("40");
					}
					else
					{
						return false;
					}
			};
	ajaxObjects[ajaxIndex].runAJAX();	
	setTimeout("FnGetlatest();", 10000);
}


function fnSetAutoRefresh(strLoad_jm,distid,intjmuserid,strtwoption,strUpdateName) {
	switch(strUpdateName)
	{
		case "tw":
			var strTwitterAccountType = "";
			switch(strtwoption) {
				case "homefeed":
					strTwitterAccountType = "homefeed";
				break;
				case "mentions":
					strTwitterAccountType = "mentionfeed";
				break;
				case "directmsg":
					strTwitterAccountType = "directfeed";
				break;
			}
			var strLatestUpdateId = 'id_feed_' + strTwitterAccountType + '_' + Base64.encode(distid);
			var strAutoRefreshTimeId = 'id_refreshtime_' + strTwitterAccountType + '_' + Base64.encode(distid);
			var strUpdateValue = document.getElementById(strLatestUpdateId).value;
			var intAutoRefreshTime = document.getElementById(strAutoRefreshTimeId).value;
			if(parseInt(intAutoRefreshTime, 10) > 0) {
				strRequestActionLink = sitename + "/twitterupdates?mode=ajax&ajax_action=latesttwitterupdate";
				
				strRequestPostParameter = "&type=" + strTwitterAccountType + "&account=" + Base64.encode(distid) + "&lastestvalue=" + strUpdateValue + "&jmuserid=" +intjmuserid;
				fnAutoRefreshTab(intAutoRefreshTime, "id_latest_update_" + strTwitterAccountType + "_" + Base64.encode(distid), "searchfeedlist_" + Base64.encode(distid), strRequestActionLink, strRequestPostParameter, objTwitterAutoRefreshCallBack, "", "", strLatestUpdateId, "hd_" + strLoad_jm + "_last_updated");
			}						
		break;
		case "twsearch":
			var strTwitterAccountType = "search";
			var strLatestUpdateId = 'id_feed_' + strTwitterAccountType + '_' + Base64.encode(intjmuserid);
			var strAutoRefreshTimeId = 'id_refreshtime_' + strTwitterAccountType + '_' + Base64.encode(intjmuserid);
			var strUpdateValue = document.getElementById(strLatestUpdateId).value;
			var intAutoRefreshTime = document.getElementById(strAutoRefreshTimeId).value;
			if(parseInt(intAutoRefreshTime, 10) > 0) {
				strRequestActionLink = sitename + "/twitterupdates?mode=ajax&ajax_action=latesttwitterupdate";
				
				strRequestPostParameter = "&type=searchfeed&account=" + Base64.encode(intjmuserid) + "&lastestvalue=" + strUpdateValue + "&jmuserid=" +intjmuserid;
				fnAutoRefreshTab(intAutoRefreshTime, "id_latest_update_" + strTwitterAccountType + "_" + Base64.encode(intjmuserid), "searchfeedlist_" + Base64.encode(distid), strRequestActionLink, strRequestPostParameter, objTwitterAutoRefreshCallBack, "", "", strLatestUpdateId, "hd_" + strLoad_jm + "_last_updated");
			}						
		break;
		case "ln":
			var strLatestUpdateId = 'id_linkedin_feed_' + Base64.encode(distid);
			var strAutoRefreshTimeId = 'id_refreshtime_feed_' + Base64.encode(distid);
			var strUpdateValue = document.getElementById(strLatestUpdateId).value;
			var intAutoRefreshTime = document.getElementById(strAutoRefreshTimeId).value;
			//if(document.getElementById('id_refreshdate_feed_' + Base64.encode(distid)).value != "")
			//document.getElementById('id_update_time').innerHTML = "Last Updated: " + document.getElementById('id_refreshdate_feed_' + Base64.encode(distid)).value;
			//document.getElementById("id_linkedin_refresh").style.display = "";
			if(parseInt(intAutoRefreshTime, 10) > 0) {
				strRequestActionLink = sitename + "/managelinkedin?mode=ajax&ajax_action=latestlinkedinupdate";
				strRequestPostParameter = "&account=" + Base64.encode(distid) + "&lastestvalue=" + strUpdateValue+"&backendhtml=1";
				fnAutoRefreshTab(intAutoRefreshTime, "id_latest_update_feed_" + Base64.encode(distid), "lnupdatelist_" + Base64.encode(distid), strRequestActionLink, strRequestPostParameter, objLinkedinAutoRefreshCallBack, "", "", strLatestUpdateId, "hd_" + strLoad_jm + "_last_updated");
			}
		break;
		case "fbp":
		case "fb":
			var strLatestUpdateId = 'id_last_update_' + Base64.encode(distid);
			var strUpdateValue = document.getElementById(strLatestUpdateId).value;
			
			var strAutoRefreshTimeId = 'id_refreshtime_' + Base64.encode(distid);
			var intAutoRefreshTime = document.getElementById(strAutoRefreshTimeId).value;
			
			if(parseInt(intAutoRefreshTime, 10) > 0) {
				strRequestActionLink = sitename + "/ajaxfacebookconnect?mode=ajax&ajax_action=getfblatestupdate";
				strRequestPostParameter = "&updatetime=" + strUpdateValue + "&account=" + Base64.encode(distid);
				fnAutoRefreshTab(intAutoRefreshTime, "fb_latest_updates_" + Base64.encode(distid), "fbupdates_" + Base64.encode(distid), strRequestActionLink, strRequestPostParameter, objFacebookAutoRefreshCallBack, "", "", strLatestUpdateId, "hd_" + strLoad_jm + "_last_updated");
			}
		break;
	}	
}


function fnGetUpdateList_jm(strLoad_jm,distid,intjmuserid,strtwoption)
{
	var updatename=strLoad_jm.split("_");
	var strUpdateName = updatename[0];
	
	var ajaxIndex = ajaxObjects.length;	
	ajaxObjects[ajaxIndex] = new sack();
	if(strUpdateName=="jm")
	{
		ajaxObjects[ajaxIndex].requestFile = sitename+"/allaccountstab&mode=ajax&ajax_action=jm_getupdates&jmuserid="+intjmuserid+"&distid="+distid;
	}
	else if(strUpdateName=="jmsearch")
	{
		searchval = Base64.decode(document.getElementById(strLoad_jm).getAttribute('title'));
		ajaxObjects[ajaxIndex].requestFile = sitename+"/allaccountstab&mode=ajax&ajax_action=jmsearch_getupdates&jmuserid="+intjmuserid+"&distid="+distid+"&searchval="+Base64.encode(searchval);
	}

	else
	{
		
		var sendUpdateName = strUpdateName+"_getupdates";
		ajaxObjects[ajaxIndex].requestFile = sitename+"/allaccountstab&mode=ajax&ajax_action="+sendUpdateName+"&distid="+distid+"&tweetopt="+strtwoption+"&jmuserid="+intjmuserid;
	}
	ajaxObjects[ajaxIndex].onCompletion = function(){
						document.getElementById(strLoad_jm).innerHTML = ajaxObjects[ajaxIndex].response;
						try {
							document.getElementById("hd_" + strLoad_jm + "_last_updated").innerHTML = "Last Updated: " + fnGetCurrentTime(); 
						} catch(e) { }
						fnSetAutoRefresh(strLoad_jm,distid,intjmuserid,strtwoption,strUpdateName);	
						fnDisableNewsFeedLink(strLoad_jm);
						try{ objFacebookButton.Share.renderAll(); }	catch (e) {  }
						try{ fnInitTwitterButtons(strLoad_jm); }	catch (e) {  }
					};
					
	ajaxObjects[ajaxIndex].runAJAX();
}


function fnSeArrayUpdates()
{
	var allC = document.getElementById('id_SocialMediaSite_Container').getElementsByTagName('input');
	//return false;
    for(var i=0;i<allC.length;i++)
	{
        if(allC[i].type=='hidden')
		{
			var rowid= allC[i].id;
			var my_array=rowid.split("_");
			var strUpdate = my_array[1];
			var distid = my_array[2];
			var intjmuserid = my_array[3];
			var strtwoption = my_array[4];
			switch(strUpdate)
			{
				case "tw":
					var strUpdatesdiv = "tw_"+distid+"_"+intjmuserid+"_"+strtwoption;
					document.getElementById(strUpdatesdiv).innerHTML = strLoadingHtml;
					fnGetUpdateList_jm(strUpdatesdiv,distid,intjmuserid,strtwoption);
				break;
				case "twsearch":
					var strUpdatesdiv = "twsearch_"+distid+"_"+intjmuserid+"_"+strtwoption;
					document.getElementById(strUpdatesdiv).innerHTML = strLoadingHtml;
					fnGetUpdateList_jm(strUpdatesdiv,distid,intjmuserid,strtwoption);
				break;
				case "ln":
					var strUpdatesdiv = "ln_"+distid+"_"+intjmuserid;
					document.getElementById(strUpdatesdiv).innerHTML = strLoadingHtml;
					fnGetUpdateList_jm(strUpdatesdiv,distid,intjmuserid,'');
				break;
				case "fb":
					var strUpdatesdiv = "fb_"+distid+"_"+intjmuserid;
					document.getElementById(strUpdatesdiv).innerHTML = strLoadingHtml;
					fnGetUpdateList_jm(strUpdatesdiv,distid,intjmuserid,'');
				break;
				case "fbp":
					var strUpdatesdiv = "fbp_"+distid+"_"+intjmuserid;
					document.getElementById(strUpdatesdiv).innerHTML = strLoadingHtml;
					fnGetUpdateList_jm(strUpdatesdiv,distid,intjmuserid,'');
				break;
				case "jm":
					var strUpdatesdiv = "jm_"+distid+"_"+intjmuserid;
					document.getElementById(strUpdatesdiv).innerHTML = strLoadingHtml;
					fnGetUpdateList_jm(strUpdatesdiv,distid,intjmuserid,'');
				break;
				case "jmsearch":
					var strUpdatesdiv = "jmsearch_"+distid+"_"+intjmuserid;
					document.getElementById(strUpdatesdiv).innerHTML = strLoadingHtml;
					fnGetUpdateList_jm(strUpdatesdiv,distid,intjmuserid,'');
				break;
			}
        }
    }
}

/******************************** ALL TABS FUNCTION *****************************************/
function fnShowAllAccounts(strContainerId,tabupdatetype) 
{
	fnLoadDyanamicJs("jquery_alltab.js",1,'');
	//fnSetParentTabs("all");
	//document.getElementById("id_SocialMediaSite_Container").innerHTML = strLoadingHtml;
	document.getElementById(strContainerId).innerHTML = strLoadingHtml;
	var newTabFlag = "";
	var strSetResponse;
	ajaxObjects[9] = new sack();
	ajaxObjects[9].requestFile = sitename+"/allaccountstab?tabupdatetype="+tabupdatetype;
	ajaxObjects[9].onCompletion = function(){
													strResponse = ajaxObjects[9].response;
													document.getElementById(strContainerId).innerHTML = strResponse;
													try	{
														jQuery('#id_Sub_Account_Tab').jcarousel();
													} catch(e) { }
													dragsort.makeListSortable(document.getElementById("id_allupdatesbox_backend"));
													fnSeArrayUpdates();
													fnInitiateSlider();
													try{ objFacebookButton.Share.renderAll(); }	catch (e) {  }
													try{ fnInitTwitterButtons(strContainerId); }	catch (e) {  }
											};
	ajaxObjects[9].runAJAX();
}
/********************************************************************************************/


/*----------------------------- FUNCTIONS FOR JUSTMEANS TAB ----------------------------------*/
var intJustmeansUpdatePage;
var strJustmeansUpdateDiv;
//var strJustMeansNewTab = "id_Justmeans_Tab_3";
var strJustMeansNewTab = "";
 
function fnShowJustmeansAccount(objJusmeansTab, newaddedflag, newaccount) {
	
	document.getElementById("id_SocialMediaSite_Container").innerHTML = strLoadingHtml;
	var newTabFlag = "";
	if(newaddedflag) newTabFlag = "&stab=1";
	ajaxObjects[9] = new sack();
	ajaxObjects[9].requestFile = sitename+"/listjustmeansupdates&mode=ajax&ajax_action=viewjustmeansallaccounts" + newTabFlag;
	ajaxObjects[9].onCompletion = function(){
													strResponse = ajaxObjects[9].response;
													arrResponse = strResponse.split(" | ");
													//document.getElementById("id_SocialMediaSite_Container").innerHTML = Base64.decode(arrResponse[0]);
													document.getElementById("id_SocialMediaSite_Container").innerHTML = arrResponse[0];
													dragsort.makeListSortable(document.getElementById("id_Sub_Account_Tab"));
													
													intJustmeansUpdatePage = 1;
													strJustmeansUpdateDiv = "id_Justmeans_Container";
													arrMenuTabs = document.getElementById("id_Sub_Account_Tab").getElementsByTagName("LI");
													//objFirstTab = document.getElementById("id_Justmeans_Tab_1");
													objFirstTab = arrMenuTabs[0];
													if(newaddedflag) {
														arrMenuTabs = document.getElementById("id_Sub_Account_Tab").getElementsByTagName("LI");
														var newTab = "";
														for(var i = 0; i<arrMenuTabs.length;i++) {
															if(arrMenuTabs[i].getAttribute('tabid') == Base64.encode(newaddedflag)) { 
																objFirstTab = arrMenuTabs[i];
																//arrMenuTabs[i].className = "active"; 
																AddClassName(arrMenuTabs[i],"active");
																break;
															} else {
																 //arrMenuTabs[i].className = "";
																 RemoveClassName(arrMenuTabs[i],"active");
															}
														}
													} else if(newaccount) {
														
														arrMenuTabs = document.getElementById("id_Sub_Account_Tab").getElementsByTagName("LI");
														var newTab = "";
														for(var i = 0; i<arrMenuTabs.length;i++) {
															if(arrMenuTabs[i].getAttribute('jmid') == Base64.decode(newaccount)) { 
																objFirstTab = arrMenuTabs[i];
																//arrMenuTabs[i].className = "active"; 
																AddClassName(arrMenuTabs[i],"active");
																break;
															} else {
																 //arrMenuTabs[i].className = "";
																 RemoveClassName(arrMenuTabs[i],"active");
															}
														}
													}
													if(objFirstTab.getAttribute("networktabtype")!='all')
													{
														document.getElementById('id_Justmeans_Container_backend').style.display='none';
														document.getElementById('id_Justmeans_Container_backend').innerHTML='';
														fnViewJustmeansUpdates(arrResponse[1],objFirstTab);
														
													}
													else
													{
														document.getElementById('id_Justmeans_Container_backend').style.display='';
														document.getElementById('id_Justmeans_Container_main').style.display='none';
														fnShowAllAccounts('id_Justmeans_Container_backend','jm');
														//alert(document.getElementById("id_SocialMediaSite_Container").innerHTML);
													}
													fnShowSlider();
													//setTimeout("fnShowSlider();",5000);
											};
	ajaxObjects[9].runAJAX();
	
}

function fnToggleJustmeansAccount(strJustmeansTab)
{
	objJustmeansTab = document.getElementById(strJustmeansTab);
	try{
		document.getElementById('id_subtab_operation').style.display="none";
	}
	catch(e)
	{
		
	}	
	fnToggleSubAccountTabs(objJustmeansTab.id);
	intJustmeansUpdatePage = 1;
	strJustmeansUpdateDiv = "id_Justmeans_Container";	

	if(objJustmeansTab.getAttribute("networktabtype")!='all')
	{
		document.getElementById('id_Justmeans_Container_backend').style.display='none';
		document.getElementById('id_Justmeans_Container_backend').innerHTML='';
		document.getElementById('id_Justmeans_Container_main').style.display='';
		fnViewJustmeansUpdates(objJustmeansTab.getAttribute("account"), objJustmeansTab);
	}
	else
	{
		document.getElementById('id_Justmeans_Container_backend').style.display='';
		document.getElementById('id_Justmeans_Container_main').style.display='none';
		fnShowAllAccounts('id_Justmeans_Container_backend','jm');
		//alert(document.getElementById("id_SocialMediaSite_Container").innerHTML);
	}
}

function fnViewJustmeansAccountFeed(strAccountId, strDivId, intPage, intRequest)
{
	if (intPage == 1) document.getElementById(strDivId).innerHTML = strLoadingHtml;
	ajaxObjects[intRequest] = new sack();
	ajaxObjects[intRequest].PostParam = "&account="+strAccountId+"&page="+intPage;
	ajaxObjects[intRequest].requestFile = sitename+"/listjustmeansupdates&mode=ajax&ajax_action=getjustmeansinnerhtml";
	ajaxObjects[intRequest].onCompletion = function(){
														if (intPage == 1) {
															document.getElementById(strDivId).innerHTML = ajaxObjects[intRequest].response;
														} else	{
															document.getElementById(strDivId).removeChild(document.getElementById(strDivId).lastChild);
															document.getElementById(strDivId).innerHTML = document.getElementById(strDivId).innerHTML + ajaxObjects[intRequest].response;
														}
													};
	ajaxObjects[intRequest].runAJAX();
}


function fnViewAllJustmeansAccount(strJustmeansId, objJustmeansTab) {
	strTabType  = objJustmeansTab.getAttribute("tabtype");
	strTabValue = objJustmeansTab.getAttribute("tabvalue");
	document.getElementById(strJustmeansUpdateDiv).innerHTML = strLoadingHtml;
	ajaxObjects[32] = new sack();
	ajaxObjects[32].PostParam = "&account="+strJustmeansId+"&action="+strTabType+"&actionvalue="+strTabValue+"&page="+intJustmeansUpdatePage;
	ajaxObjects[32].requestFile = sitename+"/listjustmeansupdates&mode=ajax&ajax_action=viewallaccounts";
	ajaxObjects[32].onCompletion = function(){
												strResponse = ajaxObjects[32].response;
												arrResponse = strResponse.split(" | ");
												document.getElementById(strJustmeansUpdateDiv).innerHTML = Base64.decode(arrResponse[0]);
												strAccountIds = Base64.decode(arrResponse[1]);
												arrAccountIds = strAccountIds.split(",");
												for (intI = 0; intI < arrAccountIds.length; intI++) {
													strAccountId = arrAccountIds[intI].toString();
													strDivId = "id_JustmeansHome_"+(intI + 1);
													intRequest = 10000 + intI;
													fnViewJustmeansAccountFeed(Base64.encode(strAccountId),strDivId,1,intRequest);
												}
											};
	ajaxObjects[32].runAJAX();
}




/*
	VIEW ALL JUSTMEANS ACCOUNT IN ALL TAB [TAB ALL] [JUSTMEANS]
*/
function fnViewAllJustmeansAc(objJustmeansTab) {
	document.getElementById('id_subtab_operation').style.display="none";
	fnToggleSubAccountTabs(objJustmeansTab.id);
	intJustmeansUpdatePage = 1;
	strJustmeansUpdateDiv = "id_Justmeans_Container";	
	//document.getElementById(strJustmeansUpdateDiv).className = "";
	//document.getElementById(strJustmeansUpdateDiv).style.height = "";
	fnViewAllJustmeansAccount(objJustmeansTab.getAttribute("account"), objJustmeansTab);
	fnEnableSubAccountTabs();
}



function fnViewJustmeansUpdates(strJustmeansId,objJustmeansTab)
{
	strTabType  = objJustmeansTab.getAttribute("tabtype");
	strTabValue = objJustmeansTab.getAttribute("tabvalue");
	intJMUserId = objJustmeansTab.getAttribute("jmid");
	
	fnDisableTwitterSubAccountTabs();
	
	document.getElementById(strJustmeansUpdateDiv).innerHTML = strLoadingHtml;
	ajaxObjects[16] = new sack();
	ajaxObjects[16].PostParam = "&account="+strJustmeansId+"&action="+strTabType+"&actionvalue="+strTabValue+"&page="+intJustmeansUpdatePage+"&jmac=" + intJMUserId;
	ajaxObjects[16].requestFile = sitename+"/listjustmeansupdates&mode=ajax&ajax_action=getjustmeansupdates";
	ajaxObjects[16].onCompletion = function(){
													fnEnableTwitterSubAccountTabs();
													document.getElementById(strJustmeansUpdateDiv).innerHTML = ajaxObjects[16].response;
													fnDisableNewsFeedLink(strJustmeansUpdateDiv);
													if(strTabValue != "")
														document.getElementById('id_subtab_operation').style.display="";
													try {
														document.getElementById("id_update_time").innerHTML = "Last Updated: " + fnGetCurrentTime();
													} catch(e) { }		
													try{ objFacebookButton.Share.renderAll(); }	catch (e) {  }
													try{ fnInitTwitterButtons(strJustmeansUpdateDiv); }	catch (e) {  }
											 };
	ajaxObjects[16].runAJAX();
}


function fnListJustmeansUpdates(strAccountId)
{
	intJustmeansFeedPage = 1;
	intJustmeansDirectMessagePage = 1;
	intJustmeansMentionsPage = 1;

	strJustmeansFeedDiv = "id_JustmeansHome";
	strJustmeansDirectMessageDiv = "id_JustmeansMessages";
	strJustmeansMentionsDiv = "id_JustmeansMentions";
	
	document.getElementById(strJustmeansFeedDiv).innerHTML = strLoadingHtml;
	document.getElementById(strJustmeansDirectMessageDiv).innerHTML = strLoadingHtml;
	document.getElementById(strJustmeansMentionsDiv).innerHTML = strLoadingHtml;

	fnListJustmeansFeedMessages(strAccountId);
	//fnListTwitterMentionMessages(strAccountId);
	//fnListTwitterDirectMessages(strAccountId);
	//intTwitterResponse = 2;
}

function fnListJustmeansFeedMessages(strAccountId)
{
	objFeedContainer = fnGetContainerDiv(document.getElementById(strJustmeansFeedDiv).parentNode.id, strJustmeansFeedDiv);
	if (intJustmeansFeedPage == 1)
		objFeedContainer.innerHTML = strLoadingHtml;
	ajaxObjects[13] = new sack();
	ajaxObjects[13].PostParam = "&account="+strAccountId+"&type=feed&page="+intJustmeansFeedPage+"&all="+0;
	ajaxObjects[13].requestFile = sitename+"/listjustmeansupdates&mode=ajax&ajax_action=getjustmeansupdates";
	ajaxObjects[13].onCompletion = function(){
													if (intTwitterFeedPage == 1)
													{
														objFeedContainer.innerHTML = ajaxObjects[13].response;
														fnListTwitterMentionMessages(strAccountId)
													}
													else
													{
														arrChildElement = objFeedContainer.getElementsByTagName("DIV");
														intLastElementIndex = (arrChildElement.length - 1);
														objLastChild = arrChildElement[intLastElementIndex];
														objFeedContainer.removeChild(objLastChild.parentNode);
														objFeedContainer.innerHTML = objFeedContainer.innerHTML + ajaxObjects[13].response;
													}
													intTwitterResponse = intTwitterResponse + 1;
													fnAfterTwitterResponse();
													return true;
											};
	ajaxObjects[13].runAJAX();
}


function fnAddJustmeansTab(objJustmeansTab)
{
	document.getElementById('id_subtab_operation').style.display="none";
	document.getElementById('id_Justmeans_Container_main').style.display="";
	document.getElementById('id_Justmeans_Container_backend').style.display="none";
	fnToggleSubAccountTabs(objJustmeansTab.id);
	document.getElementById("id_Justmeans_Container").innerHTML = strLoadingHtml;
	
	ajaxObjects[21] = new sack();
	ajaxObjects[21].requestFile = sitename+"/listjustmeansupdates&mode=ajax&ajax_action=addjustmeanstab";
	ajaxObjects[21].onCompletion = function(){
													document.getElementById("id_Justmeans_Container").innerHTML = ajaxObjects[21].response;
													fnEnableSubAccountTabs();
											 };
	ajaxObjects[21].runAJAX();
}

function fnEditJustmeansTab()
{
	var intTabId = 0;
	var objJustmeansTab = "";
	var boolObjFound = false;
	do{
		try {
			objJustmeansTab = document.getElementById("id_Justmeans_Tab_" + intTabId);
			//if(objJustmeansTab.className == "active") boolObjFound = true;
			if(HasClassName(objJustmeansTab,"active")) boolObjFound = true;
		} catch(e) { }
		intTabId++;
	} while(boolObjFound == false)
	objJustmeansTab.className = "";
	var strTabId = objJustmeansTab.getAttribute("tabid");
	
	fnToggleSubAccountTabs(objJustmeansTab.id);
	document.getElementById("id_Justmeans_Container").innerHTML = strLoadingHtml;
	ajaxObjects[21] = new sack();
	ajaxObjects[21].requestFile = sitename+"/listjustmeansupdates&mode=ajax&ajax_action=editjustmeanstab&tabvalue=" + strTabId;
	ajaxObjects[21].onCompletion = function(){
													document.getElementById("id_Justmeans_Container").innerHTML = ajaxObjects[21].response;
													fnEnableSubAccountTabs();
											 };
	ajaxObjects[21].runAJAX();
}

function fnRemoveJustmeansTab(removetab)
{
	
	var intTabId = 0;
	var objJustmeansTab = "";
	var boolObjFound = false;
	do{
		try {
			objJustmeansTab = document.getElementById("id_Justmeans_Tab_" + intTabId);
			//if(objJustmeansTab.className == "active") boolObjFound = true;
			if(HasClassName(objJustmeansTab,"active")) boolObjFound = true;
		} catch(e) { }
		intTabId++;
	} while(boolObjFound == false)
	
	
	
	if(removetab) {
		ajax_hideTooltip();
		objJustmeansTab.className = "";
		var strTabId = objJustmeansTab.getAttribute("tabid");
		fnToggleSubAccountTabs(objJustmeansTab.id);
		ajaxObjects[21] = new sack();
		ajaxObjects[21].requestFile = sitename+"/listjustmeansupdates&mode=ajax&ajax_action=removejustmeanstab&tabid=" + strTabId;
		ajaxObjects[21].onCompletion = function(){
													arrMenuTabs = document.getElementById("id_Account_Tab").getElementsByTagName("LI");
													fnShowJustmeansAccount(arrMenuTabs[0], "", "");													
												 };
		ajaxObjects[21].runAJAX();
	} else {
		ajax_showTooltip('id_remove_sub_tab',objJustmeansTab,220,40);
		return false;
	}
}


function fnAddJustmeansNewTabData(intAccountId, intSubTabId)
{
	lightbox = 0;
	errordiv = "";
	showerrorinlable = 1;
	
	if (fnValidateForm(document.getElementById("id_frmAddJustmeansTab")) == false)
		return false;
		
	document.getElementById("id_EnterButton").style.display = "none";
	document.getElementById("id_LoadingButton").style.display = "";

	strTabName = Base64.encode(document.getElementById("id_TabName").value);
	strTabKeyword = Base64.encode(document.getElementById("id_TabKeyword").value);
	strTabIdParam = "";
	var intTabId = 0;
	var strActionName = "addjustmeanstabdata";
	if(document.getElementById('id_edit_justmeans_tab').value != "") { 
		intTabId = document.getElementById('id_edit_justmeans_tab').value;
		strActionName = "editjustmeanstabdata";
	}

	ajaxObjects[22] = new sack();
	ajaxObjects[22].PostParam = "&tabname="+strTabName+"&tabvalue="+strTabKeyword+"&tabid="+intTabId;
	ajaxObjects[22].requestFile = sitename+"/listjustmeansupdates&mode=ajax&ajax_action="+strActionName;
	ajaxObjects[22].onCompletion = function(){
													strResponse = ajaxObjects[22].response;
													arrResponse = strResponse.split("|");
													
													if(arrResponse[0] == "error") {
														document.getElementById("id_ErrorMessage").style.display = "";
														document.getElementById("id_ErrorMessage").innerHTML = arrResponse[1];
														
													} else {
														
														document.getElementById("id_ErrorMessage").style.display = "none";
														
														
														if(strActionName == "editjustmeanstabdata") {
															var arrSubMenuTabs = document.getElementById("id_Sub_Account_Tab").getElementsByTagName("LI");
															var objTab = "";
															for(var i=0; i<arrMenuTabs.length; i++) {
																objTab = arrMenuTabs[i];
																//var intSelected = document.getElementById('selected_parent_account').value;
																if(objTab.getAttribute("tabid") == intTabId) {
																	objTab.setAttribute("tabvalue", strTabKeyword);
																	break;
																}
															}
															fnToggleJustmeansAccount(objTab.id);
															strTabAccountId = objTab.getAttribute("tabid");
															document.getElementById("id_Sub_Account_"+strTabAccountId).innerHTML = Base64.decode(strTabName);
														} else {
															arrMenuTabs = document.getElementById("id_Account_Tab").getElementsByTagName("LI");
															fnShowJustmeansAccount(arrMenuTabs[0], arrResponse[1], "");														
														}
													}
											 };
	ajaxObjects[22].runAJAX();
	
	return false;
}



function fnViewMoreJustmeansUpdates(objViewMoreDiv)
{
	strJustmeansUpdateDiv = "id_ViewMore_"+intJustmeansUpdatePage;
	intJustmeansUpdatePage = intJustmeansUpdatePage + 1;
	objViewMoreDiv.style.display = "none";
	fnViewJustmeansUpdates(objViewMoreDiv.getAttribute("account"),objViewMoreDiv);
}

function fnSendUpdateToOtherNetwork(intUpdate) {
	if (isBoxDisplay)fnToggleSendMessageBox();
	var optiondiv = document.getElementById('id_update_option_' + intUpdate);
	var strUpdate = document.getElementById('id_update_content_' + intUpdate).innerHTML;
	var plainText = strUpdate.replace(/<\/?[^>]+(>|$)/g, ""); 
	document.getElementById('id_txtWhatAreUWorking').value = plainText;
	document.getElementById('id_txtWhatAreUWorking').style.color = "#000000";
	fnSetCharacterCount();
	optiondiv.style.display = "none";
	fnScrollWindow('bblTabsBlue');
}


function fnGetTop(inputObj)
 {  
   var returnValue = inputObj.offsetTop;
   while((inputObj = inputObj.offsetParent) != null){
    if(inputObj.tagName!='HTML'){
     returnValue += inputObj.offsetTop;
     if(document.all)returnValue+=inputObj.clientTop;
    }
   } 
   return returnValue;
 }
 
function fnGetLeft(inputObj)
 {   
   var returnValue = inputObj.offsetLeft;
   while((inputObj = inputObj.offsetParent) != null){
    if(inputObj.tagName!='HTML'){
     returnValue += inputObj.offsetLeft;
     if(document.all)returnValue+=inputObj.clientLeft;
    }
   }
   return returnValue;
 }
 

function fnShowOperationDiv(intUpdate, obj, intExtraLeft, intExtraTop) {
	var optiondiv = document.getElementById('id_update_option_' + intUpdate);
	if(optiondiv.style.display == "none") {
		optiondiv.style.display = "";
		
		if(intExtraLeft) intExtraLeft = parseInt(intExtraLeft, 10); else intExtraLeft = 0;
		if(intExtraTop) intExtraTop = parseInt(intExtraTop, 10); else intExtraTop = 0;	
		
		optiondiv.style.left = (parseInt(fnGetLeft(obj),10) + intExtraLeft) + "px";
		optiondiv.style.top =  (parseInt(fnGetTop(obj),10) + intExtraTop) + "px";		
	} else {
		optiondiv.style.display = "none";
	}
}


/*----------------------------- FUNCTIONS FOR TWITTER TAB ----------------------------------*/
var intTwitterFeedPage;
var strTwitterFeedParentDiv;
var intTwitterDirectMessagePage;
var intTwitterMentionsPage;
var strTwitterFeedDiv;
var strTwitterDirectMessageDiv;
var strTwitterMentionsDiv;
var strTwitterTabDiv;
var intTwitterTabPage;
var intTwitterResponse = 0;


function fnSetSocialNetworkAccounts(networklist) {
	
	if(document.getElementById("id_ManageAccountForm") && networklist) {
		document.getElementById("id_ManageAccountForm").innerHTML = strLoadingHtml;
	}
	
	document.getElementById('id_social_sites_account_block').innerHTML = strSmallLoadingHtml;
	
	ajaxObjects[32] = new sack();
	ajaxObjects[32].requestFile = sitename+"/addsocialnetwork&mode=ajax&ajax_action=getsocialnetworkaccounts";
	ajaxObjects[32].onCompletion = function(){
												strResponse = ajaxObjects[32].response;
												try {
													document.body.removeChild(document.getElementById('id_SeeMore'));
												} catch(e) { }
												//document.getElementById('id_social_sites_account_block').innerHTML = strResponse;
												document.getElementById('id_all_account_list').innerHTML = strResponse;
												if(networklist) fnToggleAccountMenu(4);
										    };
	ajaxObjects[32].runAJAX();	
}

function fnValidateAddJustmeans()
{
	// VALIDE FORM INPUTS
	lightbox = 0;
	errordiv = "";
	showerrorinlable = 1;
	
	if (fnValidateForm(document.getElementById("id_fnJustmeansAction")) == false)
		return false;
		
	document.getElementById("id_EnterButton").style.display = "none";
	document.getElementById("id_LoadingButton").style.display = "";
	
	strJustmeansAccountName = Base64.encode(document.getElementById("id_txtJustmeansAcName").value);
	strJustmeansLogin 		= Base64.encode(document.getElementById("id_txtJustmeansLogin").value);
	strJustmeansPassword 	= Base64.encode(document.getElementById("id_txtJustmeansPassword").value);
	
	ajaxObjects[0] = new sack();
	ajaxObjects[0].PostParam = "&login="+strJustmeansLogin+"&password="+strJustmeansPassword+"&accountname="+strJustmeansAccountName;
	ajaxObjects[0].requestFile = sitename+"/addsocialnetwork&mode=ajax&ajax_action=addjustmeansaccount";
	ajaxObjects[0].onCompletion = function(){
												strResponse = ajaxObjects[0].response;
												arrResponse = strResponse.split("|");
												document.getElementById("id_EnterButton").style.display = "";
												document.getElementById("id_LoadingButton").style.display = "none";
												
												if (arrResponse[0] == "success")
												{
													try { Lightbox.hideBox(); } catch(e) { }	
													if(arrResponse[1] == "Account updated successfully.") {
														fnSetSocialNetworkAccounts(1);
													} else {
														strOperation = "add";
														fnSetParentTabs("jm");
														fnSetSocialNetworkAccounts(1);
														document.getElementById("id_JustmeansErrorMessage").innerHTML = "";
														document.getElementById("id_JustmeansErrorMessage").style.display = "none";
														try{ Lightbox.hideBox(); } catch(e) { } 
														if(arrResponse[2]) {
															arrMenuTabs = document.getElementById("id_Account_Tab").getElementsByTagName("LI");
															fnShowJustmeansAccount(arrMenuTabs[0], "", arrResponse[2]);	
														}
													}
												}
												else
												{
													document.getElementById("id_JustmeansErrorMessage").innerHTML = arrResponse[1];
													document.getElementById("id_JustmeansErrorMessage").style.display = "";
												}
										    };
	ajaxObjects[0].runAJAX();
}

function fnGetMainAccountId(mainaccounttype) {
	var arrMenuTabs = document.getElementById("id_Account_Tab").getElementsByTagName("LI");
	for(var i=0; i<arrMenuTabs.length; i++) {
		if(arrMenuTabs[i].getAttribute("tabname") == mainaccounttype) {
			return  arrMenuTabs[i];
		}
	}
	return arrMenuTabs[0];
}


function fnValidateDelicious()
{
	// VALIDE FORM INPUTS
	lightbox = 0;
	errordiv = "";
	showerrorinlable = 1;
	
	if (fnValidateForm(document.getElementById("id_fnDeliciousAction")) == false)
		return false;
		
	document.getElementById("id_EnterButton").style.display = "none";
	document.getElementById("id_LoadingButton").style.display = "";
		
	strDeliciousLogin 		= Base64.encode(document.getElementById("id_txtDeliciousLogin").value);
	strDeliciousPassword 	= Base64.encode(document.getElementById("id_txtDeliciousPassword").value);
	strDeliciousAccountName = Base64.encode(document.getElementById("id_txtDeliciousAcName").value);
		
	ajaxObjects[0] = new sack();
	ajaxObjects[0].PostParam = "&login="+strDeliciousLogin+"&password="+strDeliciousPassword+"&accountname="+strDeliciousAccountName;
	ajaxObjects[0].requestFile = sitename+"/addsocialnetwork&mode=ajax&ajax_action=adddeliciousaccount";
	ajaxObjects[0].onCompletion = function(){
												try { Lightbox.hideBox(); } catch(e) {}	
												strResponse = ajaxObjects[0].response;
												arrResponse = strResponse.split("|");
												
												document.getElementById("id_EnterButton").style.display = "";
												document.getElementById("id_LoadingButton").style.display = "none";
												
												if (arrResponse[0] == "success")
												{
													document.getElementById("id_DeliciousErrorMessage").innerHTML = "";
													document.getElementById("id_DeliciousErrorMessage").style.display = "none";
													try{ Lightbox.hideBox(); } catch(e) { } 
													strOperation = "Add";
													fnSetParentTabs("list");
													fnSetSocialNetworkAccounts(1);
												}
												else
												{
													document.getElementById("id_DeliciousErrorMessage").innerHTML = arrResponse[1];
													document.getElementById("id_DeliciousErrorMessage").style.display = "";
												}
										    };
	ajaxObjects[0].runAJAX();
}

function fnValidateTumbler()
{
	// VALIDE FORM INPUTS
	lightbox = 0;
	errordiv = "";
	showerrorinlable = 1;
	
	if (fnValidateForm(document.getElementById("id_fnTumblerAction")) == false)
		return false;
		
	document.getElementById("id_EnterButton").style.display = "none";
	document.getElementById("id_LoadingButton").style.display = "";
		
	strTumblerLogin 	  = Base64.encode(document.getElementById("id_txtTumblerLogin").value);
	strTumblerPassword 	  = Base64.encode(document.getElementById("id_txtTumblerPassword").value);
	strTumblerAccountName = Base64.encode(document.getElementById("id_txtTumblerAcName").value);
		
	ajaxObjects[0] = new sack();
	ajaxObjects[0].PostParam = "&login="+strTumblerLogin+"&password="+strTumblerPassword+"&accountname="+strTumblerAccountName;
	ajaxObjects[0].requestFile = sitename+"/addsocialnetwork&mode=ajax&ajax_action=addtumbleraccount";
	ajaxObjects[0].onCompletion = function(){
												try { Lightbox.hideBox(); } catch(e) { }		
												strResponse = ajaxObjects[0].response;
												arrResponse = strResponse.split("|");
												
												document.getElementById("id_EnterButton").style.display = "";
												document.getElementById("id_LoadingButton").style.display = "none";
												
												if (arrResponse[0] == "success")
												{
													
													document.getElementById("id_TumblerErrorMessage").innerHTML = "";
													document.getElementById("id_TumblerErrorMessage").style.display = "none";
													try{ Lightbox.hideBox(); } catch(e) { } 
													fnSetSocialNetworkAccounts(1);
													
												}
												else
												{
													document.getElementById("id_TumblerErrorMessage").innerHTML = arrResponse[1];
													document.getElementById("id_TumblerErrorMessage").style.display = "";
												}
										    };
	ajaxObjects[0].runAJAX();
}

function fnShowSelectedTwitterAccount()
{
	var objTwitterTab = null;
	arrAccountTabs = document.getElementById("id_Account_Tab").getElementsByTagName("LI");
	
	for (intI = 0; intI < arrAccountTabs.length; intI++)
	{
		if (arrAccountTabs[intI].getAttribute("tabname") == "tw")
		{
			objTwitterTab = arrAccountTabs[intI];
			objTwitterTab.style.display = "";
			break;
		}
	}
	
	if (objTwitterTab == null)
	{
		fnViewMainNavigationTabs("tw");
	}
	else
	{
		fnShowTwitterAccount(objTwitterTab);
	}
}
 
function fnShowSelectedLinkedInAccount()
{
	var objLinkedInTab = null;
	/*arrAccountTabs = document.getElementById("id_Account_Tab").getElementsByTagName("LI");
	
	for (intI = 0; intI < arrAccountTabs.length; intI++)
	{
		if (arrAccountTabs[intI].getAttribute("tabname") == "ln")
		{
			objLinkedInTab = arrAccountTabs[intI];
			objTwitterTab.style.display = "";
			break;
		}
	}
	if (objLinkedInTab == null)
	{*/
		//fnViewMainNavigationTabs("ln");
	/*}
	else
	{*/
		fnShowLinkedinAccount(document.getElementById('id_ln'));
	//}
}

/*twitter changed by sagar*/


/***************************************************************/
/* ADD NEW TWITTER SUB TAB */
/***************************************************************/

/***********************************************/
/* INITIAT OBJECTS */
/***********************************************/

var objTwitterSubTabContainer = "";
var objTwitterHtmlContainer = "";
var objSocialMediaListContainer= "";

function fnInitObject() {
	if(!objSocialMediaListContainer) {
		try {
			objSocialMediaListContainer = document.getElementById("id_SocialMediaSite_Container");
		} catch(e) { }
	}
	if(!objTwitterSubTabContainer) {
		try {
			objTwitterSubTabContainer = document.getElementById('id_Sub_Account_Tab');
		} catch(e) { }
	}
	if(!objTwitterHtmlContainer) {
		try {
			objTwitterHtmlContainer = document.getElementById("id_Twitter_Tab_Container");
		} catch(e) { }
	}
}


/***********************************************/
/* SET TWITTER ACCOUNT SUB TABS */
/***********************************************/
function fnHideOptionDiv(strUpdateId) {
	var optiondiv = document.getElementById('id_update_option_' + strUpdateId);
	optiondiv.style.display = "none";
	try {
		fnScrollWindow('bblTabsBlue');
	} catch(e) { }
}


function fnRetweetOtherNetwork(strUpdateDivId, strTweetId, strAccountId) {
	if(!strUpdateDivId || !strTweetId || !strAccountId) return false;
	objUpdateInfo = document.getElementById("id_Update_Info_" + strUpdateDivId);
	strUpdateText = objUpdateInfo.getAttribute("text");
	strAccountId  = objUpdateInfo.getAttribute("account");
	fnConfirmRetweetRequest(strUpdateDivId, strTweetId, strAccountId, 0);
}

function fnConfirmRetweetRequest(strUpdateDivId, strTweetId, strAccountId, verified) {
	if(!strUpdateDivId || !strTweetId || !strAccountId) return false;
	if(parseInt(verified, 10)) {
		fnHideOptionDiv(strUpdateDivId);
		try { ajax_hideTooltip(); } catch(e) { }
		ajaxObjects[25] = new sack();
		ajaxObjects[25].PostParam = "&account="+strAccountId+"&tweet=" + strTweetId;
		ajaxObjects[25].requestFile = sitename+"/listtwitterupdates&mode=ajax&ajax_action=retweetupdate";
		ajaxObjects[25].onCompletion = function(){
													
													strResponse = ajaxObjects[25].response;
													arrResponse = strResponse.split("|");
													fnCheckAccounts("none");
													if (arrResponse[0] == "error") {
														var strErrorMessage = "Error while sending update";
														if(arrResponse[1]) strErrorMessage = arrResponse[1];
														fnShowMsgDiv(strErrorMessage, "");
													} else {
														fnShowMsgDiv("Message sent", "");
														fnLoadAddUpdateBacisSetting();
														fnCheckAccounts("none");
													}
										};
		ajaxObjects[25].runAJAX();
	} else {
		verified = 1;
		document.getElementById('id_retweet_confirm_ok').setAttribute('onClick', "fnConfirmRetweetRequest('" + strUpdateDivId + "', '" + strTweetId + "', '" + strAccountId + "', '" + verified + "');" );
		ajax_showTooltip("id_confirm_retweet", document.getElementById('id_re_tweet_' + strUpdateDivId), 200, 38);
	}
}

function fnPublishToOtherNetwork(strUpdateDivId)
{
	fnHideOptionDiv(strUpdateDivId);
	objUpdateInfo = document.getElementById("id_Update_Info_"+strUpdateDivId);
	strUpdateText = objUpdateInfo.getAttribute("text");
	strAccountId  = objUpdateInfo.getAttribute("account");
	fnUpdateSendMessageBox(Base64.decode(strUpdateText), strAccountId);
}

function fnReplyTweet(strUpdateDivId)
{
	fnHideOptionDiv(strUpdateDivId);
	objUpdateInfo = document.getElementById("id_Update_Info_"+strUpdateDivId);
	
	strUpdateText = "@"+Base64.decode(objUpdateInfo.getAttribute("username"))+" ";
	strAccountId  = objUpdateInfo.getAttribute("account");
	strReplyMsgId = objUpdateInfo.getAttribute("update");

	document.getElementById("id_hdnReplyToId").value = Base64.decode(strReplyMsgId);
	
	var objTextBox = document.getElementById("id_txtWhatAreUWorking");
	objTextBox.style.color='#000000';

	fnUpdateReplyMessageBox(strUpdateText, strAccountId);
}

function fnViewAddUserToList(strUpdateDivId)
{
	fnHideOptionDiv(strUpdateDivId);
	objUpdateInfo = document.getElementById("id_Update_Info_"+strUpdateDivId);
	
	strAccountId  = objUpdateInfo.getAttribute("account");
	strUpdateUser = objUpdateInfo.getAttribute("userid");
	
	Lightbox.enmStopResetSession = 0;
	Lightbox.showBoxByID('id_Twitter_LightBox',400,200);
	document.getElementById("id_Twitter_LightBox").innerHTML = strLoadingHtml;
	
	ajaxObjects[25] = new sack();
	ajaxObjects[25].PostParam = "&account="+strAccountId+"&user="+strUpdateUser;
	ajaxObjects[25].requestFile = sitename+"/listtwitterupdates&mode=ajax&ajax_action=viewtwitterlistbox";
	ajaxObjects[25].onCompletion = function(){
													document.getElementById("id_Twitter_LightBox").innerHTML = ajaxObjects[25].response;
										    };
	ajaxObjects[25].runAJAX();
}

function fnAddUserToList(strUpdateDivId)
{
	try{ fnHideOptionDiv(strUpdateDivId); } catch(e) { }
	document.getElementById("id_Loading_Button").style.display = "";
	document.getElementById("id_Submit_Button").style.display = "none";
	
	strListName 	= document.getElementById("id_optTwitterList").value;
	strUserId 		= document.getElementById("id_hdnUserId").value;
	strAccountId 	= document.getElementById("id_hdnAccountId").value;
	
	ajaxObjects[26] = new sack();
	ajaxObjects[26].PostParam = "&account="+strAccountId+"&user="+strUserId+"&list="+Base64.encode(strListName);
	ajaxObjects[26].requestFile = sitename+"/listtwitterupdates&mode=ajax&ajax_action=addtwitterusertolist";
	ajaxObjects[26].onCompletion = function(){
													Lightbox.hideBox()
													strResponse = ajaxObjects[26].response;
													arrResponse = strResponse.split("|");
													document.getElementById("id_TwitterSuccess").style.display = "";
													document.getElementById("id_TwitterSuccess").innerHTML = arrResponse[1];
													if (arrResponse[0] == "error")
													{
														document.getElementById("id_TwitterSuccess").className = "errormessage";
														
														document.getElementById("id_Loading_Button").style.display = "none";
														document.getElementById("id_Submit_Button").style.display = "";
													}
													else
													{
														document.getElementById("id_TwitterSuccess").className = "success";
													}
													
													setTimeout("fnHideTwitterSuccess();", 1000);
										    };
	ajaxObjects[26].runAJAX();
}

function fnHideTwitterSuccess() {
	document.getElementById('id_TwitterSuccess').innerHTML='';
}

function fnSendTwitterMessage(strUpdateDivId)
{
	fnHideOptionDiv(strUpdateDivId);
	objUpdateInfo = document.getElementById("id_Update_Info_"+strUpdateDivId);
	
	strUpdateText = "d "+Base64.decode(objUpdateInfo.getAttribute("username"));
	strAccountId  = objUpdateInfo.getAttribute("account");
	strTwitterUserId = objUpdateInfo.getAttribute("userid");

	fnUpdateReplyMessageBox(strUpdateText, strAccountId);
}


	function fnScrollWindow(strObjectId, intPosition)
	{	
		arrDivPosition = fnFindPos(document.getElementById(strObjectId));
		if(intPosition)
		{
			window.scroll(0, ( intPosition + arrDivPosition[1] ) );
		}
		else
		{
			window.scroll(0, arrDivPosition[1]);
		}
		//parent.window.scroll(0,900);
	}
	
	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 fnViewProfile(intUserId, intUpdate) {
		ajaxObjects[11] = new sack();
		ajaxObjects[11].PostParam = "&user="+intUserId;
		ajaxObjects[11].requestFile = sitename+"/listjustmeansupdates&mode=ajax&ajax_action=getuserprofile";
		ajaxObjects[11].onCompletion = function(){
													try {
														document.getElementById("id_update_option_" + intUpdate).style.display = "none";
													} catch(e) {
													}
													document.getElementById('id_profile_html_div').innerHTML = "";
													document.getElementById('id_profile_html_div').innerHTML = Base64.decode(ajaxObjects[11].response);
													Lightbox.enmStopResetSession = 0;
													Lightbox.showBoxByID('id_profile_html_div',400,300);
												};
		ajaxObjects[11].runAJAX();
	}

function fnSendJustmeansMessage(intUpdate, strsendmessagetext)
{
	try {
		document.getElementById("id_update_option_" + intUpdate).style.display = "none";
	} catch(e) {}
			
	strUpdateText = "d "+ strsendmessagetext;
	strAccountId  = 0;
	fnUpdateReplyMessageBox(strUpdateText, strAccountId);
}

function fnValidateRss()
{
	lightbox = 0;
	errordiv = "";
	showerrorinlable = 1;
	document.getElementById('id_txt_feedUrlErr').innerHTML = "";
	//alert(document.getElementById('id_includetxt').checked);return false;
	/*if(document.getElementById('id_includetxt').checked==false && document.getElementById('id_includetxt').value=="")
		document.getElementById('id_includetxt').alt="M-";*/
	
	if(fnValidateForm(document.getElementById('id_frm_addBlog')) == false)
			return false;
	
		
	 document.getElementById('id_frm_addBlog').submit();
}

function fnSetDistributedValue(accno,accval)
{
	if(document.getElementById('id_distribution_'+accno).value)	
		document.getElementById('id_distribution_'+accno).value='';
	else
		document.getElementById('id_distribution_'+accno).value=accval;
	
}

function fnSelectAllccounts(strType,distvalue)
{
	document.getElementById("id_CheckAll").className = "";
	document.getElementById("id_CheckNone").className = "";
	if (strType == "all")
		{
			document.getElementById("id_CheckAll").className = "selected";
			document.getElementById("id_alldistribution").value =distvalue;
		}
	else
		{
			document.getElementById("id_CheckNone").className = "selected";
			document.getElementById("id_alldistribution").value ='';
		}

	for (intI = 1; intI < document.getElementById("id_hdnTotalAccounts").value; intI++)
	{
		if (strType == "all")
		{
			document.getElementById("id_AccountBtn_"+intI).className = "selected";
		}
		else if (strType == "none")
		{
			document.getElementById("id_AccountBtn_"+intI).className = "";
		}
	}
}

function fnShowMsgDiv(strMessage,strDivClass) { 
	if(strDivClass == "") strDivClass = "spamsuccessmessage";
	if(strMessage != "") {   
	   try {
			document.getElementById("searchoptions").style.display='none';   
	   } catch(e) {} 
	   
	   document.getElementById("spam").innerHTML = "<img src='images/ico_delete.gif' align='right' style='vertical-align:top;cursor:pointer;margin-left=900px;' alt='close' title='close' onclick='javascript:fnCloseMsgDiv();' /><br>" + strMessage;
	   document.getElementById("spam").className = strDivClass; //spamerrormessage , spamsuccessmessage
	   $("#spam").slideToggle();
	   setTimeout("fnHideMsgDiv();",5000);    
	}  
 }
 
var intFlag = 0;
 
function fnHideMsgDiv() {  
	if(intFlag == 0) {  
		$("#spam").slideToggle();
		try {
			document.getElementById("searchoptions").style.display="block";
		} catch(e){} 
		document.getElementById("spam").style.display='none';
	}
}
 
function fnCloseMsgDiv() {   
	$("#spam").slideToggle();
	try {
		document.getElementById("searchoptions").style.display="block";
	} catch(e) {} 
	document.getElementById("spam").style.display='none';
	intFlag = 1;    
}




function fnToggleSubAccountTabs(intAccountId)
{
	//fnDisableSubAccountTabs();
	arrMenuTabs = document.getElementById("id_Sub_Account_Tab").getElementsByTagName("LI");
	intLastItem = (arrMenuTabs.length - 1);
	for (intTab = 0; intTab < arrMenuTabs.length; intTab++)
	{
		if (intTab == intLastItem)
		{
			
			RemoveClassName(arrMenuTabs[intTab],"active");
			//alert("tab="+intTab+"class="+arrMenuTabs[intTab].className);
			//arrMenuTabs[intTab].className = "";
		}
		else
		{
			RemoveClassName(arrMenuTabs[intTab],"active");
			//alert("tab="+intTab+"class="+arrMenuTabs[intTab].className);
			//arrMenuTabs[intTab].className = "";			
		}	
			
		if (arrMenuTabs[intTab].id.replace(/[^0-9]/g,'') == intAccountId.replace(/[^0-9]/g,''))
		{
			if (arrMenuTabs[intTab].className == "")
			{
				//arrMenuTabs[intTab].className = "active";
				AddClassName(arrMenuTabs[intTab],"active");
			}			
			else
			{
				//arrMenuTabs[intTab].className = arrMenuTabs[intTab].className + " active";
				AddClassName(arrMenuTabs[intTab],"active");
			}
		}
	}
}



// ----------------------------------------------------------------------------
// RemoveClassName
//
// Description : removes a class from the class attribute of a DOM element
//    built with the understanding that there may be multiple classes
//
// Arguments:
//    objElement              - element to manipulate
//    strClass                - class name to remove
//
function RemoveClassName(objElement, strClass)
   {

   // if there is a class
   if ( objElement.className )
      {

      // the classes are just a space separated list, so first get the list
      var arrList = objElement.className.split(' ');

      // get uppercase class for comparison purposes
      var strClassUpper = strClass.toUpperCase();

      // find all instances and remove them
      for ( var i = 0; i < arrList.length; i++ )
         {

         // if class found
         if ( arrList[i].toUpperCase() == strClassUpper )
            {

            // remove array item
            arrList.splice(i, 1);

            // decrement loop counter as we have adjusted the array's contents
            i--;

            }

         }

      // assign modified class name attribute
      objElement.className = arrList.join(' ');

      }
   // if there was no class
   // there is nothing to remove

   }
// 
// RemoveClassName
//


// AddClassName
//
// Description : adds a class to the class attribute of a DOM element
//    built with the understanding that there may be multiple classes
//
// Arguments:
//    objElement              - element to manipulate
//    strClass                - class name to add
//
function AddClassName(objElement, strClass, blnMayAlreadyExist)
   {

   // if there is a class
   if ( objElement.className )
      {

      // the classes are just a space separated list, so first get the list
      var arrList = objElement.className.split(' ');

      // if the new class name may already exist in list
      if ( blnMayAlreadyExist )
         {

         // get uppercase class for comparison purposes
         var strClassUpper = strClass.toUpperCase();

         // find all instances and remove them
         for ( var i = 0; i < arrList.length; i++ )
            {

            // if class found
            if ( arrList[i].toUpperCase() == strClassUpper )
               {

               // remove array item
               arrList.splice(i, 1);

               // decrement loop counter as we have adjusted the array's contents
               i--;

               }

            }

         }

      // add the new class to end of list
      arrList[arrList.length] = strClass;

      // add the new class to beginning of list
      //arrList.splice(0, 0, strClass);
      
      // assign modified class name attribute
      objElement.className = arrList.join(' ');

      }
   // if there was no class
   else
      {

      // assign modified class name attribute      
      objElement.className = strClass;
   
      }

   }
// 
// AddClassName
//


// ----------------------------------------------------------------------------
// HasClassName
//
// Description : returns boolean indicating whether the object has the class name
//    built with the understanding that there may be multiple classes
//
// Arguments:
//    objElement              - element to manipulate
//    strClass                - class name to add
//
function HasClassName(objElement, strClass)
   {

   // if there is a class
   if ( objElement.className )
      {

      // the classes are just a space separated list, so first get the list
      var arrList = objElement.className.split(' ');

      // get uppercase class for comparison purposes
      var strClassUpper = strClass.toUpperCase();

      // find all instances and remove them
      for ( var i = 0; i < arrList.length; i++ )
         {

         // if class found
         if ( arrList[i].toUpperCase() == strClassUpper )
            {

            // we found it
            return true;

            }

         }

      }

   // if we got here then the class name is not there
   return false;

   }
// 
// HasClassName
//

	function fnShowRegistrationLoginForm()
	{ 
		if(document.getElementById("divRegisterLogin").style.display == "none")
		{
			fnNewRegisterLogin(0,0);
		}
		return false;
	}
	
	
	function SocialMediaUpdate() {
		var intObjId = null;
		var objAjax = null;
		var intRefreshTime = 120000;
		var strRefreshDivName = "";
		var strAppendDivId = "";
		var strRequestActionLink = "";
		var strRequestPostParamsLink = "";
		var strOnCompletionCallBack = "";
		var strOnLoadingCallBack = "";
		var strOnFailCallBack = "";
		var strLatestUpdateInputId = "";
		var strLastRefreshTimeDivId = "";
		var arrPostParameters = new Array();
	}
	
	SocialMediaUpdate.prototype.fnSetPostParamsArray = function() {
		var strBuildPostParamsLink = this.fnGetRequestPostParameter();
		if(trim(strBuildPostParamsLink) != "") {
			var arrPostParamsTemp =  strBuildPostParamsLink.split("&");
			for(var i=0; i< arrPostParamsTemp.length; i++) {
				if(trim(arrPostParamsTemp[i]) != "") {
					var arrParams = arrPostParamsTemp[i].split("=");
					var intArrayPostParameters = this.arrPostParameters.length;
					this.arrPostParameters[intArrayPostParameters]['name'] =  arrParams[0];
					this.arrPostParameters[intArrayPostParameters]['value'] =  arrParams[1];
				}
			}
		}
	}
	
	SocialMediaUpdate.prototype.fnGetLastRefreshTimeDivId = function() {
		return this.strLastRefreshTimeDivId;
	}
	
	SocialMediaUpdate.prototype.fnSetLastRefreshTimeDivId = function(strGetLastRefreshTimeDivId) {
		if(!strGetLastRefreshTimeDivId || strGetLastRefreshTimeDivId == "") this.strLastRefreshTimeDivId = "";
		else this.strLastRefreshTimeDivId = strGetLastRefreshTimeDivId;
	}
		
	
	SocialMediaUpdate.prototype.fnGetArrayPostParameter = function() {
		return this.arrPostParams;
	}
	
	SocialMediaUpdate.prototype.fnSetLatestUpdateInputId = function(strUpdateValueInputId) {
		this.strLatestUpdateInputId = strUpdateValueInputId;
	}
	
	SocialMediaUpdate.prototype.fnGetLatestUpdateInputId = function() {
		return this.strLatestUpdateInputId;
	}
	
	SocialMediaUpdate.prototype.fnSetOnCompletionCallBack = function(strFunctionName) {
		if(!strFunctionName || strFunctionName == "") strFunctionName = "";
		this.strOnCompletionCallBack = strFunctionName;
	}
	
	SocialMediaUpdate.prototype.fnGetOnCompletionCallBack = function() {
		return this.strOnCompletionCallBack;
	}

	SocialMediaUpdate.prototype.fnSetOnLoadingCallBack = function(strFunctionName) {
		if(!strFunctionName || strFunctionName == "") strFunctionName = "";
		this.strOnLoadingCallBack = strFunctionName;
	}
	
	SocialMediaUpdate.prototype.fnGetOnLoadingCallBack = function() {
		return this.strOnLoadingCallBack;
	}

	SocialMediaUpdate.prototype.fnSetOnFailCallBack = function(strFunctionName) {
		if(!strFunctionName || strFunctionName == "") strFunctionName = "";
		this.strOnFailCallBack = strFunctionName;
	}
	
	SocialMediaUpdate.prototype.fnGetOnFailCallBack = function() {
		return this.strOnFailCallBack;
	}

	SocialMediaUpdate.prototype.fnGetRequestActionLink = function() {
		return this.strRequestActionLink;
	}
	
	SocialMediaUpdate.prototype.fnSetRequestActionLink = function(strRequestActionName) {
		this.strRequestActionLink = strRequestActionName;
	}
	
	SocialMediaUpdate.prototype.fnGetPostParamValue = function(strGetName) {
		var arrTemp =  this.arrPostParameters;
		var intPostParameterCount = arrTemp.length;
		var strValue = "";
		for(var i=0; i < intPostParameterCount; i++) {
			var strName = this.arrPostParameters[i]['name'];
			if(this.arrPostParameters[i]['name'] == strGetName) strValue = this.arrPostParameters[i]['value'];
		}
		return strValue;
	}
	
	SocialMediaUpdate.prototype.fnSetPostParamValue = function(strGetName, strGetValue) {
		var arrTemp =  this.arrPostParameters;
		//var arrTemp =  this.fnGetArrayPostParameter();
		var intPostParameterCount = arrTemp.length;
		for(var i=0; i < intPostParameterCount; i++) {
			var strName = this.arrPostParameters[i]['name'];
			if(this.arrPostParameters[i]['name'] == strGetName) this.arrPostParameters[i]['value'] = strGetValue;
		}
	}
	
	SocialMediaUpdate.prototype.fnGetRequestPostParameter = function() {
		var arrTempParams = this.arrPostParameters;
		var strRequestPostParamsLink = "";
		for(var i=0; i < arrTempParams.length; i++) {
			var strName = arrTempParams[i]['name'];
			var strValue =arrTempParams[i]['value'];
			strRequestPostParamsLink = strRequestPostParamsLink + "&" + strName + "=" + strValue;
		}
		this.strRequestPostParamsLink = strRequestPostParamsLink;
		return this.strRequestPostParamsLink;
	}
	
	
	SocialMediaUpdate.prototype.fnSetRequestPostParameter = function(strBuildPostParamsLink) {
		var arrPostParameters = new Array();
		if(trim(strBuildPostParamsLink) != "") {
			var arrPostParamsTemp =  strBuildPostParamsLink.split('&');
			for(var i=0; i < arrPostParamsTemp.length; i++) {
				if(trim(arrPostParamsTemp[i]) != "") {
					var arrParams = arrPostParamsTemp[i].split('=');
					var intArrayPostParameters = arrPostParameters.length;
					arrPostParameters[intArrayPostParameters] = new Array();
					arrPostParameters[intArrayPostParameters]['name'] =  arrParams[0];
					arrPostParameters[intArrayPostParameters]['value'] =  arrParams[1];
				}
			}
		}
		this.arrPostParameters = arrPostParameters;
	}
		
	SocialMediaUpdate.prototype.fnSetAjaxObject = function() {
		this.objAjax = new sack();
	}

	SocialMediaUpdate.prototype.fnGetAjaxObject = function() {
		return this.objAjax;
	}

	SocialMediaUpdate.prototype.fnSetIntRefreshTime = function(intUserRefreshTime) {
		this.intRefreshTime = parseInt(intUserRefreshTime, 10);
	}
	
	SocialMediaUpdate.prototype.fnGetIntRefreshTime = function() {
		return this.intRefreshTime;
	}
	
	SocialMediaUpdate.prototype.fnSetRefreshDivName = function(strRefreshDivName) {
		this.strRefreshDivName = strRefreshDivName;
	}
	
	SocialMediaUpdate.prototype.fnGetRefreshDivName = function() {
		return this.strRefreshDivName;
	}
	
	SocialMediaUpdate.prototype.fnSetAppendDivId = function(strAppendDivName) {
		this.strAppendDivId = strAppendDivName;
	}
	
	SocialMediaUpdate.prototype.fnGetAppendDivId = function() {
		return this.strAppendDivId;
	}

	SocialMediaUpdate.prototype.fnRefreshUpdate = function() {
	    var self = this;
		setTimeout( "fnLatestUpdate(" + self.fnGetObjectId() + ")", self.fnGetIntRefreshTime());
	}
	
	SocialMediaUpdate.prototype.fnSetObjectId = function(intObjectId) {
		this.intObjId = intObjectId;
	}

	SocialMediaUpdate.prototype.fnGetObjectId = function() {
		return this.intObjId;
	}

	
	SocialMediaUpdate.prototype.fnGetLatestUpdate = function() {
		var self = this;
		var objTempAjax = self.fnGetAjaxObject();
		var selfObjId = self.fnGetObjectId();
		var strOnCompletionCallBack = self.fnGetOnCompletionCallBack();
		var strRequestPostParamLink = self.fnGetRequestPostParameter();
		var strLatestUpdateInputId = self.fnGetLatestUpdateInputId();
		if(strRequestPostParamLink != "") objTempAjax.PostParam = strRequestPostParamLink;
		objTempAjax.requestFile = self.fnGetRequestActionLink();
		//alert(objTempAjax.requestFile + "" + objTempAjax.PostParam + ", \n" + fnGetCurrentTime());
		if(strOnCompletionCallBack != "") {
			objTempAjax.onCompletion =  function(){ strOnCompletionCallBack(self, objTempAjax.response, self.fnGetRefreshDivName(), self.fnGetAppendDivId(), strLatestUpdateInputId ); };
		}
		else {
			objTempAjax.onCompletion = function(){ 
				var strResponse = objTempAjax.response;
					// SET RESPONSE AS INNER HTML
					if(strResponse != "Bad Request" || strResponse !='INVALID REQUEST!') {
						//arrTempArray  = strResponse.split("|");
						//$("div#" + self.fnGetRefreshDivName()).prepend(Base64.decode(arrTempArray[0]));
						$("div#" + self.fnGetRefreshDivName()).prepend(objTempAjax.response);
						$("#" + self.fnGetAppendDivId()).slideDown("40");
						self.fnRefreshUpdate();
					} else {
						self.fnRefreshUpdate();
						return false;
					}
			};	
		}
		objTempAjax.runAJAX();
	}
	
	function fnLatestUpdate(intObjId) {
		try {
			var intRefreshTime = objAutoRefresh[intObjId].fnGetIntRefreshTime();
			var strRefreshDivName = objAutoRefresh[intObjId].fnGetRefreshDivName();
			var strAppendDivId = objAutoRefresh[intObjId].fnGetAppendDivId();
			var strRequestActionLink = objAutoRefresh[intObjId].fnGetRequestActionLink();
			var strRequestPostParams = objAutoRefresh[intObjId].fnGetRequestPostParameter();
			var strOnCompletionFunction = objAutoRefresh[intObjId].fnGetOnCompletionCallBack();
			var strOnLoadingFunction = objAutoRefresh[intObjId].fnGetOnLoadingCallBack();
			var strOnFailFunction = objAutoRefresh[intObjId].fnGetOnFailCallBack();
			var strLatestUpdateInputId = objAutoRefresh[intObjId].fnGetLatestUpdateInputId();
			var strGetLastRefreshTimeDivId = objAutoRefresh[intObjId].fnGetLastRefreshTimeDivId();
			
			objAutoRefresh[intObjId] = new SocialMediaUpdate();
			objAutoRefresh[intObjId].fnSetObjectId(intObjId);
			objAutoRefresh[intObjId].fnSetAjaxObject();
			objAutoRefresh[intObjId].fnSetIntRefreshTime(parseInt(intRefreshTime, 10));
			objAutoRefresh[intObjId].fnSetRefreshDivName(strRefreshDivName);
			objAutoRefresh[intObjId].fnSetAppendDivId(strAppendDivId);
			objAutoRefresh[intObjId].fnSetRequestActionLink(strRequestActionLink);
			objAutoRefresh[intObjId].fnSetRequestPostParameter(strRequestPostParams);
			objAutoRefresh[intObjId].fnSetOnCompletionCallBack(strOnCompletionFunction);
			objAutoRefresh[intObjId].fnSetOnLoadingCallBack(strOnLoadingFunction);
			objAutoRefresh[intObjId].fnSetOnFailCallBack(strOnFailFunction);
			objAutoRefresh[intObjId].fnSetLatestUpdateInputId(strLatestUpdateInputId);
			objAutoRefresh[intObjId].fnSetLastRefreshTimeDivId(strGetLastRefreshTimeDivId);
			objAutoRefresh[intObjId].fnGetLatestUpdate();
		} catch(e) { }
	}

	function fnAutoRefreshTab(intRefreshTime, strRefreshDivName, strAppendDivId, strRequestActionLink, strRequestPostParams, strOnCompletionFunction, strOnLoadingFunction, strOnFailFunction, strLatestUpdateInputId, strGetLastRefreshTimeDivId) {
		//$(document).ready(function(){
			try {	
				var intObjCount = objAutoRefresh.length;	
				objAutoRefresh[intObjCount] = new SocialMediaUpdate();
				objAutoRefresh[intObjCount].fnSetObjectId(intObjCount);
				objAutoRefresh[intObjCount].fnSetAjaxObject();
				objAutoRefresh[intObjCount].fnSetIntRefreshTime(parseInt(intRefreshTime, 10));
				objAutoRefresh[intObjCount].fnSetRefreshDivName(strRefreshDivName);
				objAutoRefresh[intObjCount].fnSetAppendDivId(strAppendDivId);
				objAutoRefresh[intObjCount].fnSetRequestActionLink(strRequestActionLink);
				objAutoRefresh[intObjCount].fnSetRequestPostParameter(strRequestPostParams);
				objAutoRefresh[intObjCount].fnSetOnCompletionCallBack(strOnCompletionFunction);
				objAutoRefresh[intObjCount].fnSetOnLoadingCallBack(strOnLoadingFunction);
				objAutoRefresh[intObjCount].fnSetOnFailCallBack(strOnFailFunction);
				objAutoRefresh[intObjCount].fnSetLatestUpdateInputId(strLatestUpdateInputId);
				objAutoRefresh[intObjCount].fnSetLastRefreshTimeDivId(strGetLastRefreshTimeDivId);
				objAutoRefresh[intObjCount].fnRefreshUpdate();
			} catch(e) { }
		//});
	}

	/*-**************************************************************************************************************************************************************/

/*------------------- FOR DRAG N DROP FUNCTIONALITY --------------------------*/
function fnSaveTabOrder(strTabOrder)
{
	if (strTabOrder == "")
		return;

	ajaxObjects[16] = new sack();
	ajaxObjects[16].PostParam = "&taborder="+Base64.encode(strTabOrder);
	ajaxObjects[16].requestFile = sitename+"/managesocialmedianetwork&mode=ajax&ajax_action=savetaborder";
	ajaxObjects[16].onCompletion = function(){
													//alert(ajaxObjects[16].response);
										     };
	ajaxObjects[16].runAJAX();
}


function fnShowMoveElement(objTwitterTab)
{
	arrMoveElement = objTwitterTab.getElementsByTagName("DIV");
	arrMoveElement[0].style.visibility = "visible";
}

function fnHideMoveElement(objTwitterTab)
{
	arrMoveElement = objTwitterTab.getElementsByTagName("DIV");
	arrMoveElement[0].style.visibility = "hidden";
}

var arrSubtabOnclick;

function fnDisableTwitterSubAccountTabs()
{
	//return;
	arrMenuTabs = document.getElementById("id_Sub_Account_Tab").getElementsByTagName("LI");
	intLastItem = (arrMenuTabs.length - 1);
	for (intTab = 0; intTab < arrMenuTabs.length; intTab++)
	{
		arrClickObject = arrMenuTabs[intTab].getElementsByTagName("A");
		if (arrClickObject.length > 0)
		{
			if (arrClickObject[0].onclick != "")
			{
				arrSubtabOnclick[intTab] = arrClickObject[0].getAttribute("href");
				arrClickObject[0].setAttribute("href","javascript:;");
			}
		}
	}
}

function fnEnableTwitterSubAccountTabs()
{
	arrMenuTabs = document.getElementById("id_Sub_Account_Tab").getElementsByTagName("LI");
	for (intTab = 0; intTab < arrSubtabOnclick.length; intTab++)
	{
		try{
			arrClickObject = arrMenuTabs[intTab].getElementsByTagName("A");
			//arrClickObject[0].onclick = arrSubtabOnclick[intTab];
			if (arrClickObject.length > 0)
			{
				arrClickObject[0].setAttribute("href",arrSubtabOnclick[intTab]);
			}
		}
		catch (e)
		{ }
	}
}
/*------------------- FOR DRAG N DROP FUNCTIONALITY --------------------------*/


function fnShowSlider()
{
   	jQuery('#id_Sub_Account_Tab').jcarousel();
}


function fnManualJustmeansRefresh() {
	var intTabId = 1;
	var objJustmeansTab = "";
	var boolObjFound = false;
	do{
		try {
			objJustmeansTab = document.getElementById("id_Justmeans_Tab_" + intTabId);
			if(HasClassName(objJustmeansTab,"active")) {
				boolObjFound = true;
				break;
			}
		} catch(e) { }
		intTabId++;
	} while(boolObjFound == false)
	var strTabId = objJustmeansTab.getAttribute("tabid");

	var input = document.getElementById('id_Sub_Account_' + strTabId);
	if (input.fireEvent) { // IE way
		var e = document.createEventObject();
		input.fireEvent('onclick', e);
	}
	else { // DOM way
		var e = document.createEvent('MouseEvents');
		e.initEvent('click', true, true);
		input.dispatchEvent(e);
	}
}


function fnGetCurrentTime() {
	var currentTime = new Date()
	  var hours = currentTime.getHours()
	  var minutes = currentTime.getMinutes()
	
	  var suffix = "AM";
	  if (hours >= 12) {
	  suffix = "PM";
	  hours = hours - 12;
	  }
	  if (hours == 0) {
	  hours = 12;
	  }
	
	  if (minutes < 10)
	  minutes = "0" + minutes
	
	 var strCurrentTime = "" + hours + ":" + minutes + " " + suffix + "";
	 return strCurrentTime;
}


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 fnDisableNewsFeedLink(strDivId)
{
	try{
		arrNewsFeedLinks = document.getElementById(strDivId).getElementsByTagName("A");
	}
	catch (e)
	{ arrNewsFeedLinks = new Array(); }

	for (intI = 0; intI < arrNewsFeedLinks.length; intI++)
	{
		if (arrNewsFeedLinks[intI].getAttribute("medialink") == "true")
		{
			arrNewsFeedLinks[intI].removeAttribute("href");
			arrNewsFeedLinks[intI].setAttribute("className","nolinknormal");
			arrNewsFeedLinks[intI].setAttribute("style","color:#006B85; text-decoration:none;");
		}
	}
}

function fnShowNetworkOptions()
{
	arrAccountOptions = document.getElementById("id_SocialMediaSite_Container").getElementsByTagName("DIV");
	for (intI = 0; intI < arrAccountOptions.length; intI++)
	{
		if (arrAccountOptions[intI].getAttribute("type") == "accountoption")
		{
			if (arrAccountOptions[intI].addEventListener && arrAccountOptions[intI].addEventListener!='undefined') 
			{
				arrAccountOptions[intI].addEventListener('mouseover', function() {fnSetActiveOptions(this);}, false);
				arrAccountOptions[intI].addEventListener('mouseout', function() {fnSetDeactiveOptions(this);}, false);
			} else { // IE
				arrAccountOptions[intI].onmouseover = function() {fnSetActiveOptions(this);}; 
				arrAccountOptions[intI].onmouseout = function() {fnSetDeactiveOptions(this);}; 
			}
		}
	}
}

function fnSetActiveOptions(objOptionContainer)
{
	arrAccountOptions = objOptionContainer.getElementsByTagName("IMG");
	for (intI = 0; intI < arrAccountOptions.length; intI++)
	{
		if (arrAccountOptions[intI].getAttribute("name") == "edit")
		{
			arrAccountOptions[intI].src = "images/mdc/account_edit_btn_active.gif";
		}
		if (arrAccountOptions[intI].getAttribute("name") == "delete")
		{
			arrAccountOptions[intI].src = "images/mdc/account_delete_btn_active.gif";
		}
	}
}

function fnSetDeactiveOptions(objOptionContainer)
{
	arrAccountOptions = objOptionContainer.getElementsByTagName("IMG");
	for (intI = 0; intI < arrAccountOptions.length; intI++)
	{
		if (arrAccountOptions[intI].getAttribute("name") == "edit")
		{
			arrAccountOptions[intI].src = "images/mdc/account_edit_btn.gif";
		}
		if (arrAccountOptions[intI].getAttribute("name") == "delete")
		{
			arrAccountOptions[intI].src = "images/mdc/account_delete_btn.gif";
		}
	}
}

function fnListTwitterAccounts()
{
  	document.getElementById('id_twitter_account_listing').style.display = "";
	
	Lightbox.showBoxByID("id_twitter_account_listing",400);
	document.getElementById('id_twitter_account_listing').innerHTML     = strLoadingHtml;
	ajax_hideTooltip();
	ajaxObjects[26] = new sack();
	//ajaxObjects[16].PostParam = "&taborder="+Base64.encode(strTabOrder);
	ajaxObjects[26].requestFile = sitename + "/managesocialmedianetwork&mode=ajax&ajax_action=view_twitter_accounts";
	ajaxObjects[26].onCompletion = function(){
													document.getElementById('id_twitter_account_listing').innerHTML = ajaxObjects[26].response;
										     };
	ajaxObjects[26].runAJAX();
}

function fnSelectAccountTwitter(strAccountCount, intAccountId, intJmId)
{
   	if(document.getElementById('id_tickimage_' + intAccountId).className != "")
	{
		document.getElementById('id_tickimage_' + intAccountId).className = "";
		document.getElementById('id_tickimage_' + intAccountId).setAttribute('twitterAccID',intAccountId);
		
		document.getElementById('id_tickimage_' + intAccountId).style.position = "absolute"; 
		document.getElementById('id_tickimage_' + intAccountId).style.left  = "0px";
		document.getElementById('id_tickimage_' + intAccountId).style.top  = "28px";
	}
	else
	{
		document.getElementById('id_tickimage_' + intAccountId).className = "tick";
		if(document.getElementById('id_tickimage_' + intAccountId).getAttribute('twitterAccID') != null)
		{
		   	document.getElementById('id_tickimage_' + intAccountId).removeAttribute('twitterAccID');
		}
	}
	
}
function fnTweetToSelectedAccounts()
{
	var strRetweetAccounts = document.getElementsByName("txt_twitteraccountinfo");
	var strTwitterAccountIds = "";
	
	for(var i=0; i<strRetweetAccounts.length; ++i)
	{
		if(strRetweetAccounts[i].getAttribute('twitterAccID') != null)
		{
			intTwitterAccId = strRetweetAccounts[i].getAttribute('twitterAccID');
			strTwitterAccountIds += intTwitterAccId + ',';
		}
		
		
	}
	
	if(strTwitterAccountIds == "")
	{
	   document.getElementById('id_noaccount_selected').style.display = "";
	   setTimeout("fnHideErrorSuccessMessage('id_noaccount_selected')", 5000);
	   return;
	}
	document.getElementById('id_submit_to_selected_account').style.display = "none";
	document.getElementById('ajax_loader').style.display = "";
	
    fnRetweetOtherNetwork(null,strTwitterAccountIds);
}

function fnCheckAllTwitterAccounts(strSelectionType)
{
    	var strRetweetAccounts = document.getElementsByName("txt_twitteraccountinfo");
		
		if(strSelectionType == "all")
		{
				strTickImgId = "";
				
				document.getElementById('id_TwitterCheckAll').className = "selected";
				document.getElementById('id_TwitterCheckNone').className = "";
				
				for(var i=0; i<strRetweetAccounts.length; ++i)
				{
				   strRetweetAccounts[i].className = "";
				   if(strRetweetAccounts[i].getAttribute('twitterAccID') == null)
				   {
				       strTickImgId = strRetweetAccounts[i].id;
					   strTickImgId = strTickImgId.replace(/id_tickimage_/i, "");
					   document.getElementById(strRetweetAccounts[i].id).setAttribute('twitterAccID',strTickImgId);
					   document.getElementById(strRetweetAccounts[i].id).style.position = "absolute";
					   document.getElementById(strRetweetAccounts[i].id).style.left     = "0px";
					   document.getElementById(strRetweetAccounts[i].id).style.top      = "28px";
				   }
				}
		}
		else
		{
		      	document.getElementById('id_TwitterCheckAll').className = "";
				document.getElementById('id_TwitterCheckNone').className = "selected";
				for(var i=0; i<strRetweetAccounts.length; ++i)
				{
				   strRetweetAccounts[i].className = "tick";
				   if(strRetweetAccounts[i].getAttribute('twitterAccID') != null)
				   {
				       strTickImgId = strRetweetAccounts[i].id;
					   strTickImgId.replace(/id_tickimage_/i, "");
					   document.getElementById(strRetweetAccounts[i].id).removeAttribute('twitterAccID');
					   document.getElementById(strRetweetAccounts[i].id).removeAttribute('style');
				   }
				}
		}
}
function fnHideErrorSuccessMessage(strDivId)
{
	try
	{
		document.getElementById(strDivId).style.display = "none";
	}
	catch(e){}
}

