var is_Safari=navigator.userAgent.indexOf('Safari');
function DisplayMessage(status,facebookMessage,SendTweet,SendFacebook,logStatus)
{
var msg="";
if(status=="submit")
{
if(SendTweet=="False")
{
msg="Congratulations, Community details are saved successfully.";
}
else
{
msg="Congratulations, Community details are saved successfully and shared with twitter.";
}
}
else
if(status=="update")
{
if(SendTweet=="False")
{
msg="Congratulations, Community details are updated successfully.";
}
else
{
msg="Congratulations, Community details are updated successfully and shared with twitter.";
}
}
else
if(status=="error")
{
msg="Error occured while saving the community details. Please try again.";
}
else
if(status=="Exists")
{
msg="Community already exists in the same category.";
}
if(SendFacebook=="True")
{
ShowMessagewithData(msg,facebookMessage,logStatus);
}
else
{
document.getElementById("msgData").value="";
ShowMessageBox(msg);
}
return true;
}
function DisplayJoinCommunityMessage(status)
{
if(status==0)
{
alert("Error occured while joining the community, please try again.");
}
else if(status==1)
{
var msg="Congratulations, You have joined the community successfully.";
ShowMessageBox(msg);
}
else
{
ShowMessageBox("You are already member of this community.");
}
}
function DisplayUsers()
{
document.getElementById("GridView1").visible=true;
}
function SetAction(action)
{
if(action=="ViewUsers")
{
var temp=document.getElementById("hidAction");
if(temp!=null&&temp!="")
{
temp.value="ViewUsers";
}
}
}
function IsUserMemberOfCommunity()
{
var temp=document.getElementById("hidUserMemberOfCommunity");
if(temp!=null&&temp!="")
{
if(temp.value!=null&&temp.value!=""&&temp.value=="1")
{
return true;
}
else
{
ShowMessageBox("You are not a member of this community, please join the community first.");
return false;
}
}
else
{
ShowMessageBox("You are not a member of this community, please join the community first.");
return false;
}
}
function ShowPanel(controlId)
{
var temp="div"+controlId;
var tempObj=document.getElementById(temp);
tempObj.style.display="block";
}
function DeleteCommunityUserConfirmation(RecordId,btnId)
{
document.getElementById("confirmBox_hidButtonId").value=btnId;
document.getElementById("hidRecordId").value=RecordId;
ShowConfirmBox('Would you like to remove this user from the community?');
return false;
}
function RemoveFriendConfirmation(RecordId,btnId)
{
document.getElementById("confirmBox_hidButtonId").value=btnId;
document.getElementById("hidRecordId").value=RecordId;
ShowConfirmBox('Would you like to remove this user from the Friend list?');
return false;
}
function DeleteCommunityConfirm(RecordId,btnId)
{
document.getElementById("confirmBox_hidButtonId").value=btnId;
document.getElementById("hidRecordId").value=RecordId;
ShowConfirmBox('Deleting this community will delete all topics under this community. Would you like to delete this community?');
return false;
}
function DeleteCommunitySuccess()
{
NotifyCommunityConfirm('JSOperation','NotifyCommunitySuccess');
return false;
}
function NotifyCommunityConfirm(RecordId,btnId)
{
document.getElementById("confirmBox_hidButtonId").value=btnId;
document.getElementById("hidRecordId").value=RecordId;
ShowConfirmBox('Would you like to notify the community deletion to all the members of this community?');
return false;
}
function NotifyCommunitySuccess()
{
var temp=document.getElementById("notifyUsers_CommunityDeleted");
if(temp!=null)
{
temp.value="1";
}
var btnObj=document.getElementById('btnHidDeleteCommunity');
if(btnObj!=null)
{
if((document.all)||(is_Safari>0))
{
btnObj.click();
}
else
{
var e=document.createEvent("MouseEvents");
e.initEvent("click",true,true);
btnObj.dispatchEvent(e);
}
}
return false;
}
function NotifyCommunityFail()
{
var temp=document.getElementById("notifyUsers_CommunityDeleted");
if(temp!=null)
{
temp.value="";
}
var btnObj=document.getElementById('btnHidDeleteCommunity');
if(btnObj!=null)
{
if((document.all)||(is_Safari>0))
{
btnObj.click();
}
else
{
var e=document.createEvent("MouseEvents");
e.initEvent("click",true,true);
btnObj.dispatchEvent(e);
}
}
}
function DeleteCommunityConfirmation()
{
var loginStatus=IsLoginedUser();
if(loginStatus)
{
DeleteCommunityConfirm('JSOperation','DeleteCommunitySuccess');
return false;
}
else
{
return false;
}
}
function DeleteTopicConfirmation(RecordId,btnId)
{
document.getElementById("confirmBox_hidButtonId").value=btnId;
document.getElementById("hidRecordId").value=RecordId;
ShowConfirmBox('Would you like to delete this topic and all its posts?');
return false;
}
function OffensiveCommunityConfirmation(RecordId,btnId)
{
if(IsLoginedUser()==false)
{
return false;
}
document.getElementById("confirmBox_hidButtonId").value=btnId;
document.getElementById("hidRecordId").value=RecordId;
ShowConfirmBox('Would you like to report this community as offensive?');
return false;
}
function OffensiveTopicConfirmation(RecordId,btnId)
{
if(IsLoginedUser()==false)
{
return false;
}
document.getElementById("confirmBox_hidButtonId").value=btnId;
document.getElementById("hidRecordId").value=RecordId;
ShowConfirmBox('Would you like to report this topic of community as offensive?');
return false;
}
function SetCommunityId(communityId)
{
var temp=document.getElementById("hidCommunityId");
if(temp!=null&&temp!="")
{
temp.value=communityId;
}
var btnObj=document.getElementById("btnHidden");
if((document.all)||(is_Safari>0))
{
btnObj.click();
}
else
{
var e=document.createEvent("MouseEvents");
e.initEvent("click",true,true);
btnObj.dispatchEvent(e);
}
return true;
}
function GoTo_TopicDetails_Load(TopicId)
{
var temp=document.getElementById("hidTopicId");
if(temp!=null&&temp!="")
{
temp.value=TopicId;
}
var btnObj=document.getElementById("btnHiddenTopicPage");
if((document.all)||(is_Safari>0))
{
btnObj.click();
}
else
{
var e=document.createEvent("MouseEvents");
e.initEvent("click",true,true);
btnObj.dispatchEvent(e);
}
return true;
}
function reply_onClick(TopicId,TopicName,UserId)
{
var status;
if(IsLoginedUser()==false)
{
return false;
}
if(document.getElementById("hidOpenToAllUser")!=null)
{
var temp=document.getElementById("hidOpenToAllUser").value;
if(temp=="True")
{
status=true;
}
else
{
status=IsUserMemberOfCommunity();
}
}
if(status==true)
{
var valBanWord=document.getElementById("WarningMsgs_RegistrationErrors");
valBanWord.innerHTML="";
valBanWord.style.display="none";
document.getElementById("WarningMsgs_divWarningInfo").style.display="none";
if(TopicId!=null&&TopicId!=""&&TopicName!=null&&TopicName!="")
{
var topicIdObj=document.getElementById("hid_TopicId");
if(topicIdObj!=null&&topicIdObj!="")
{
topicIdObj.value=TopicId;
}
var topicNameObj=document.getElementById("hid_TopicName");
if(topicNameObj!=null&&topicNameObj!="")
{
topicNameObj.value=TopicName;
}
var txtTopicName=document.getElementById("txtTopicName");
if(txtTopicName!=null&&txtTopicName!="")
{
var temp=TopicName.substring(0,3);
if(temp!="Re:")
{
txtTopicName.value="Re:"+TopicName;
}
else
{
txtTopicName.value=TopicName;
}
}
var UserIdObj=document.getElementById("hid_UserId");
if(UserId!=null&&UserId!="")
{
UserIdObj.value=UserId;
}
}
return ShowModalPopup('divpnlAddTopic','Topic Reply');
}
else
{
return false;
}
}
function edit_onClick(TopicId)
{
if(TopicId!=null&&TopicId!="")
{
var topicIdObj=document.getElementById("hid_TopicId");
if(topicIdObj!=null&&topicIdObj!="")
{
topicIdObj.value=TopicId;
}
var tempObj=document.getElementById("hid_ReplyEdit");
if(tempObj!=null&&tempObj!="")
{
tempObj.value="1";
}
var btnObj=document.getElementById("btnHiddenEditTopic");
if((document.all)||(is_Safari>0))
{
btnObj.click();
}
else
{
var e=document.createEvent("MouseEvents");
e.initEvent("click",true,true);
btnObj.dispatchEvent(e);
}
}
else
return false;
}
function delete_onClick(RecordId,btnId)
{
document.getElementById("confirmBox_hidButtonId").value=btnId;
document.getElementById("hidRecordId").value=RecordId;
ShowConfirmBox('Deleting this post will delete all posts under it. Would you like to delete this post?');
return false;
}
function AcceptFriendConfirmation(RecordId,btnId)
{
document.getElementById("confirmBox_hidButtonId").value=btnId;
document.getElementById("hidRecordId").value=RecordId;
ShowConfirmBox('Would you like to also add this user in your friend list?');
return false;
}
function AcceptFriendSuccess()
{
var hidObj=document.getElementById("hidFriendRequestViceVersa");
if(hidObj!=null&&hidObj!="")
{
hidObj.value="1";
}
var btnObj=document.getElementById('btnHidAcceptFriend');
if(btnObj!=null)
{
if((document.all)||(is_Safari>0))
{
btnObj.click();
}
else
{
var e=document.createEvent("MouseEvents");
e.initEvent("click",true,true);
btnObj.dispatchEvent(e);
}
}
return false;
}
function AcceptFriendRequest(FriendId,btnId)
{
document.getElementById("hidFriendId").value=FriendId;
AcceptFriendConfirmation('JSOperation','AcceptFriendSuccess')
return false;
}
function DenyFriendRequest()
{
return true;
}
function searchCommunity()
{
var temp=document.getElementById("txtSearch");
temp.value=trim(temp.value);
if(temp.value.length!=0&&temp.value!=null&&temp.value!="")
{
var _path1="../../WebPages/Community/ViewCommunities.aspx?searchtext="+temp.value;
SubmitQueryString(_path1);
return false;
}
else
{
ShowMessageBox("Please enter some text to search.");
return false;
}
}
function lnkInviteFriends_onClick()
{
var loginStatus=IsLoginedUser();
if(loginStatus)
{
var registrationErrorsDiv=document.getElementById("WarningMsgs_RegistrationErrors");
registrationErrorsDiv.innerHTML="";
registrationErrorsDiv.style.display="none";
var divWarningInfo=document.getElementById("WarningMsgs_divWarningInfo");
divWarningInfo.style.display="none";
var txtObj=document.getElementById("txtEmailId");
txtObj.value="";
txtObj=document.getElementById("txtMessage");
txtObj.value="";
var status=ShowModalPopup('divpnlSendInvitation','Send Invitation');
return status;
}
else
{
return false;
}
}
function AddTopic_onClick()
{
var status;
if(document.getElementById("hidLoginedUser").value=="")
{
ShowMessageBox("You need to login to the system to add new topic.");
status=false;
}
else if(document.getElementById("hidOpenToAllUser")!=null)
{
var temp=document.getElementById("hidOpenToAllUser").value;
if(temp=="True")
{
status=true;
}
else
{
status=IsUserMemberOfCommunity();
}
}
if(status==true)
{
var registrationErrorsDiv=document.getElementById("WarningMsgs_RegistrationErrors");
registrationErrorsDiv.innerHTML="";
registrationErrorsDiv.style.display="none";
var divWarningInfo=document.getElementById("WarningMsgs_divWarningInfo");
divWarningInfo.style.display="none";
var valBanWord=document.getElementById("WarningMsgs_RegistrationErrors");
valBanWord.innerHTML="";
valBanWord.style.display="none";
document.getElementById("WarningMsgs_divWarningInfo").style.display="none";
var txtObj=document.getElementById("txtTopicName");
txtObj.value="";
txtObj=document.getElementById("txtTopicDescription");
txtObj.value="";
return ShowModalPopup('divpnlAddTopic','Add Topic');
}
else
{
return false;
}
}
function PostTopic(ForumId)
{
var status=IsLoginedUser();
if(status==true)
{
var PostNewTopic;
PostNewTopic=document.getElementById("PostNewTopic");
PostNewTopic.href="ForumDetails.aspx?ForumId="+ForumId;
return true;
}
else
{
return false;
}
}
function ValidateCommunityForm()
{
errors="";
mandatoryFieldsErrorFlag=false;
var status=ValidateCommunityFormRoutines();
if(status==false)
{
var registrationErrorsDiv=document.getElementById("WarningMsgs_RegistrationErrors");
registrationErrorsDiv.style.display="block";
var divWarningInfo=document.getElementById("WarningMsgs_divWarningInfo");
divWarningInfo.style.display="block";
registrationErrorsDiv.innerHTML="";
registrationErrorsDiv.innerHTML=errors;
return false;
}
else
{
return true;
}
}
function ValidateCommunityFormRoutines()
{
var status=true;
var varTemp=document.getElementById("txtCommunityName");
var alertName=" Community Name ";
var isMandatory='True';
if(bValidate(varTemp,"General",isMandatory,alertName)!=true)
{
varTemp.focus();
status=false;
return false;
}
varTemp=document.getElementById("txtDescription");
alertName=" Description ";
isMandatory='True';
if(bValidate(varTemp,"",isMandatory,alertName)!=true)
{
varTemp.focus();
status=false;
return false;
}
var len=varTemp.value.length;
if(len>1024)
{
errors+=alertName+sDescription_Message+'<br/>';
varTemp.focus();
status=false;
return false;
}
varTemp=document.getElementById("PhotoUpload");
alertName=" Picture";
var isMandatory='false';
if(varTemp!=null&&varTemp!="")
{
varTemp=varTemp.value;
if(varTemp!=null&&varTemp!="")
{
var ValidImage=CheckImageFileType(varTemp);
if(!ValidImage)
{
errors+=" for "+alertName+'.<br/>'
status=false;
return false;
}
}
}
if(status==false)
{
return false;
}
else
{
errors='';
status=CheckBanWord(document.getElementById("txtCommunityName"),document.getElementById("txtDescription"),document.getElementById("WarningMsgs_RegistrationErrors"));
if(status==false)
{
errors=''+document.getElementById("WarningMsgs_RegistrationErrors").innerHTML;
document.getElementById("WarningMsgs_divWarningInfo").style.display="block";
document.getElementById("WarningMsgs_RegistrationErrors").style.display="block"
}
}
return status;
}
function lnkSubscribe_onClick()
{
var loginStatus=IsLoginedUser();
if(loginStatus)
{
return true;
}
else
{
return false;
}
}
function lnkShowUsers_onClick()
{
var loginStatus=IsLoginedUser();
if(loginStatus)
{return true;
}
else
{
return false;
}
}
function IsLoginedUser()
{
if(document.getElementById("hidLoginedUser")!=null)
{if(document.getElementById("hidLoginedUser").value!="")
{
return true;
}
else
{
ShowMessageBox("You need to login first to access this feature.");
return false;
}
}
else
{
return false;
}
}
function CreateFormCommunity(FileName)
{
var form=document.createElement("form");
form.method='post';
form.enctype='multipart/form-data';
form.setAttribute('accept-charset','utf-8');
var urlValue=FileName;
var imageextension=FileName.substring(FileName.length-3);
var snipshotoutputoptions="{ 'size': {'max': {'width':"+100+", 'height': "+100+" } },"+
" 'filetype': '"+imageextension+"' }";
var currUrl=String(self.location);
var startPos=currUrl.indexOf("WebPages");
currUrl=currUrl.substring(0,startPos);
urlValue=currUrl+"CommunityImages/"+urlValue;
addInputElement(document,form,"snipshot_input",urlValue);
urlValue=currUrl+"WebPages/Community/CommunitySnapsCallback.aspx";
addInputElement(document,form,"snipshot_callback",urlValue);
addInputElement(document,form,"snipshot_callback_agent","user");
addInputElement(document,form,"snipshot_output_options",snipshotoutputoptions);
addInputElement(document,form,"snipshot_output","file");
document.body.appendChild(form);
form.action="http://services.snipshot.com/";
form.submit();
document.body.removeChild(form);
return false;
}
function addInputElement(doc,form,name,value)
{
var e=doc.createElement('input');
e.name=name;
e.value=value;
form.appendChild(e);
}
function ShowInstantMessage(toUserID)
{
var _winHandler;
var objTimer;
var _queryString;
var width=screen.width;
var height=screen.height;
var top=height/2-200;
var left=width/2-200;
var Path;
var PageName;
var fromUserID="";
var status=false;
if(document.getElementById("hidLoginedUser")!=null&&document.getElementById("hidLoginedUser").value!="")
{
status=true;
}
if(status==false)
{
ShowMessageBox("You need to login first to access this feature.");
return false;
}
if((status)&&(document.getElementById("hidLoginedUser").value==toUserID))
{
ShowMessageBox("You cannot send message to yourself.");
return;
}
if(document.getElementById("hidLoginedUser")!=null&&document.getElementById("hidLoginedUser")!=""&&toUserID!=null&&toUserID!="")
{
fromUserID=document.getElementById("hidLoginedUser").value;
Path=self.location.href;
PageName=Path.substring(Path.lastIndexOf("/")+1,Path.length);
if((PageName=="MyHomePage.aspx")||((PageName=="HomePage.aspx")))
{
_queryString="Webpages/IM/InstantMessage.aspx?FromUserID="+fromUserID+"&ToUserID="+toUserID;
}
else
{
_queryString="../IM/InstantMessage.aspx?FromUserID="+fromUserID+"&ToUserID="+toUserID;
}
_winHandler=window.open(_queryString,"InstantMessage_"+fromUserID+"_"+toUserID,"height=375,width=525,toolbars=0,scrollbars=0,resizable=0");
}
}
var xmlHttpFetchObject;
var xmlHttpFetchChatObject;
function GetXmlHttpObject()
{
var objXMLHttp;
if(window.XMLHttpRequest)
{
objXMLHttp=new XMLHttpRequest();
}
else if(window.ActiveXObject)
{
objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
return objXMLHttp;
}
function CheckSendMessage(userID)
{
var PageName;
var status=false;
if(document.getElementById("hidLoginedUser")!=null&&document.getElementById("hidLoginedUser").value!="")
{
status=true;
}
if(status==false)
{
ShowMessageBox("You need to login first to access this feature.");
return false;
}
if((status)&&(document.getElementById("hidLoginedUser").value==userID))
{
ShowMessageBox("You cannot send message to yourself.");
return;
}
var _queryString;
_queryString="../Community/CreateMessage.aspx?userId="+userID;
SubmitQueryString(_queryString);
}
function HandleException()
{
if(!document.all)
{
window.onbeforeunload=function()
{
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(endRequest);
}
}
}
function endRequest(sender,e)
{
var err=e.get_error();
if(err)
{
if(err.name=="Sys.WebForms.PageRequestManagerServerErrorException")
{
e.set_errorHandled(true);
}
if(err.name=="Sys.WebForms.PageRequestManagerParserErrorException")
{
e.set_errorHandled(true);
}
}
}
function ValidateAddTopic()
{
mandatoryFieldsErrorFlag=false;
errors="";
var status=true;
var varTemp=document.getElementById("txtTopicName");
var alertName="Topic Name";
var isMandatory='True';
if(bValidate(varTemp,"AlphaNumWithSpaceApostropheCommaColon",isMandatory,alertName)!=true)
{
status=false;
}
if(status==true)
{
var varTemp=document.getElementById("txtTopicDescription");
var alertName="Topic Description";
if(bValidate(varTemp,"",isMandatory,alertName)!=true)
{
status=false;
}
var len=varTemp.value.length;
if(len>1024)
{
var banWordMessage=document.getElementById("WarningMsgs_RegistrationErrors");
banWordMessage.style.display="none";
errors+=alertName+sDescription_Message+'<br/>';
status=false;
}
}
if(status==false)
{
var registrationErrorsDiv=document.getElementById("WarningMsgs_RegistrationErrors");
var banWordMessage=document.getElementById("WarningMsgs_RegistrationErrors");
var divWarningInfo=document.getElementById("WarningMsgs_divWarningInfo");
banWordMessage.style.display="none";
registrationErrorsDiv.style.display="block";
divWarningInfo.style.display="block";
registrationErrorsDiv.innerHTML="";
registrationErrorsDiv.innerHTML=errors;
return false;
}
else
{
var registrationErrorsDiv=document.getElementById("WarningMsgs_RegistrationErrors");
registrationErrorsDiv.style.display="none";
var divWarningInfo=document.getElementById("WarningMsgs_divWarningInfo");
divWarningInfo.style.display="none";
errors='';
status=CheckBanWord(document.getElementById("txtTopicName"),document.getElementById("txtTopicDescription"),document.getElementById("WarningMsgs_RegistrationErrors"));
}
return status;
}
function CheckEmailIds()
{
var status=CheckEmailId();
if(status==false)
{
if(document.getElementById("WarningMsgs_divWarningInfo")!=null)
{
var registrationErrorsDiv=document.getElementById("WarningMsgs_RegistrationErrors");
registrationErrorsDiv.style.display="block";
var divWarningInfo=document.getElementById("WarningMsgs_divWarningInfo");
divWarningInfo.style.display="block";
registrationErrorsDiv.innerHTML="";
registrationErrorsDiv.innerHTML=errors;
}
if(document.getElementById("WarningMsgs2_divWarningInfo")!=null)
{
var registrationErrorsDiv=document.getElementById("WarningMsgs2_RegistrationErrors");
registrationErrorsDiv.style.display="block";
var divWarningInfo=document.getElementById("WarningMsgs2_divWarningInfo");
divWarningInfo.style.display="block";
registrationErrorsDiv.innerHTML="";
registrationErrorsDiv.innerHTML=errors;
}
return false;
}
else
{
return true;
}
}
function CheckEmailId()
{
mandatoryFieldsErrorFlag=false;
errors="";
var _location=0;
var _length=0;
var i=0;
var _emailId=null;
var status=true;
var _temp=document.getElementById("txtEmailId");
var _originalText=null;
var flag=false;
if(_temp!=null)
{
_temp=_temp.value;
if(flag==false)
{
_originalText=_temp;
flag=true;
}
var emailidCnt=0;
var i=0;
while(i<5)
{
_length=_temp.length;
_location=_temp.indexOf(";");
if(_location!=-1)
{
_emailId=_temp.substring(0,_location);
_location++;
if(_location<_length)
{
_temp=_temp.substring(_location);
}
else
{
i=5;
}
}
else
{
_emailId=_temp.substring(0,_length);
i=5;
}
if(_emailId!="")
{
emailidCnt++;
i++;
var varTemp=document.getElementById("txtEmailId");
var temp=varTemp.value;
varTemp.value=_emailId;
var alertName=" Email Id ";
var isMandatory='True';
if(bValidate(varTemp,"Email",isMandatory,alertName)!=true)
{
varTemp.focus();
varTemp.value=temp;
status=false;
return false;
}
if(bValidate(varTemp,"EmailName",isMandatory,alertName)!=true)
{
varTemp.focus();
varTemp.value=temp;
status=false;
return false;
}
}
}
if(emailidCnt==0)
{
errors+='Please enter Email address.';
var varTemp=document.getElementById("txtEmailId");
varTemp.focus();
status=false;
return false;
}
if(_location!=-1)
{
if(_location<_length)
{
_length=_temp.length;
_emailId=_temp.substring(0,_length);
if(_emailId!=null||_emailId!="")
{
errors+="Maximum number of recipients is 5 separated with (;)"+'<br/>';
varTemp.value=temp;
varTemp.focus();
status=false;
return false;
}
}
}
var varTemp=document.getElementById("txtEmailId");
varTemp.value=_originalText;
varTemp=document.getElementById("txtMessage");
alertName="Message Text";
isMandatory='True';
if(varTemp.value=="")
{
if(isMandatory=="True")
{
errors+=alertName+" can not be blank."+'<br/>';
mandatoryFieldsErrorFlag=true;
}
varTemp.focus();
status=false;
return false;
}
if(bValidate(varTemp,"",isMandatory,alertName)!=true)
{status=false;
varTemp.focus();
return false;
}
}
else
{
return false;
}
}
function ShowFBPublishData()
{
if(document.getElementById("hidSendFacebook").value=="True")
{
var FBMessage=document.getElementById("hidFBMessage").value;
FBPublishData(FBMessage);
}
}
function ShowFBPublish()
{
setTimeout("ShowFBPublishData()",5000);
}
