﻿// JScript File

var is_Safari = navigator.userAgent.indexOf('Safari');
function DisplayMessage(status,facebookMessage,SendTweet,SendFacebook,logStatus)
{      
//        var registrationErrorsDiv = document.getElementById("RegistrationErrors");
//        if(registrationErrorsDiv!=null && registrationErrorsDiv != "")
//        {
//            registrationErrorsDiv.style.display = "block";
         
            var msg ="";
            if(status == "submit") 
            {
                if(SendTweet=="False")
                {
                   msg = "Congratulations! Community details are saved successfully.";
                   
                   
                   if(SendFacebook=="True")
                  {  
                     ShowMessagewithData(msg,facebookMessage,logStatus);
                  }
                  else
                  { 
                     document.getElementById("msgData").value="";
                     ShowMessageBox(msg);     
                  }
                  ShowFBText();
                  CallFBRequireFeatures();
                   ShowFBPublish();
                 } 
                 else
                 {
                    msg = "Congratulations! Community details are saved successfully and shared with twitter.";
                    if(SendFacebook=="True")
                  {  
                     ShowMessagewithData(msg,facebookMessage,logStatus);
                  }
                  else
                  { 
                     document.getElementById("msgData").value="";
                     ShowMessageBox(msg);     
                  }
                 } 
              
            }
            else 
            if(status=="update")
            {
                if(SendTweet=="False")
                {
                    msg = "Congratulations, Community details are updated successfully.";
                    if(SendFacebook=="True")
                  {  
                     ShowMessagewithData(msg,facebookMessage,logStatus);
                  }
                  else
                  { 
                     document.getElementById("msgData").value="";
                     ShowMessageBox(msg);     
                  }
                 }
                 else
                 {
                    msg = "Congratulations, Community details are updated successfully and shared with twitter.";
                    if(SendFacebook=="True")
                  {  
                     ShowMessagewithData(msg,facebookMessage,logStatus);
                  }
                  else
                  { 
                     document.getElementById("msgData").value="";
                     ShowMessageBox(msg);     
                  }
                 }
               
               //ShowMessageBox(msg);
            }
            else 
            if(status=="error")
            {
               msg = "Error occured while saving the community details. Please try again.";
               if(SendFacebook=="True")
                  {  
                     ShowMessagewithData(msg,facebookMessage,logStatus);
                  }
                  else
                  { 
                     document.getElementById("msgData").value="";
                     ShowInformationMessageBox(msg);     
                  }
               
              // alert(msg);
            }
            else 
            if(status=="Exists")
            {
               msg = "Community already exists in the same category."; 
               if(SendFacebook=="True")
                  {  
                     ShowMessagewithData(msg,facebookMessage,logStatus);
                  }
                  else
                  { 
                     document.getElementById("msgData").value="";
                     ShowInformationMessageBox(msg);     
                  }
                
               //ShowMessageBox(msg);
            }
           else
           {
           if(SendFacebook=="True")
          {  
             ShowMessagewithData(msg,facebookMessage,logStatus);
          }
          else
          { 
             document.getElementById("msgData").value="";
             ShowInformationMessageBox(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
//    {
//         ShowInformationMessageBox("You are already member of this community.");
//    }
//}



    //-----------------------------------------------------------------
    // function:checkCommunityName
    // 
    // Synopsis:
    //      This Function is used to check whether 
    //      community name entered by User is already exist
//    
//function checkCommunityName()
//{ 
//    //var xmlHttpCommunity; 
//    var _communityName = document.getElementById("txtCommunityName").value;
//    xmlHttpCommunity = null;
//    xmlHttpCommunity=GetxmlHttpCommunityObject();
//   
//    if (xmlHttpCommunity==null)
//    {
//        alert("Browser does not support HTTP Request");
//        return;
//    } 
//    var url="../CheckCommunityName.aspx";
//    url=url+"?CommunityName="+_communityName; 
//    
//    xmlHttpCommunity.onreadystatechange=stateChangedcheckCommunityName;
//    xmlHttpCommunity.open("GET",url,true);
//    //xmlHttp.send(null);
//    
//}
//    // end of function checkCommunityName
//    //---------------------------------------------------------------------


//    //---------------------------------------------------------------------
//    // function:stateChanged
//    // 
//    // Synopsis:
//    //      This Function is used to display  message depending 
//    //      upon result of checkCommunityName function 


//function stateChangedcheckCommunityName() 
//{ 
//    var loadstatustext="<img src='../../Images/Registration/warning.gif' /> A community with name you specified already exists.\n Please enter some another community name.";
//    
//    if (xmlHttpCommunity.readyState==4 )
//    { 
//       
//       if((xmlHttpCommunity.responseText).search(/exists/i) > 0)
//       {
//          var registrationErrorsDiv = document.getElementById("RegistrationErrors");
//          var CommunityNameTextbox = document.getElementById("txtCommunityName");
//          CommunityNameTextbox.value = "";
//          CommunityNameTextbox.focus();
//          registrationErrorsDiv.style.display = "block";
//          registrationErrorsDiv.innerHTML = loadstatustext;
//    
//       }
//       else
//       {
//            var registrationErrorsDiv = document.getElementById("RegistrationErrors");
//            registrationErrorsDiv.style.display = "none";
//            registrationErrorsDiv.innerHTML="";
//            
//        }
//     } 
//} 
//    // end of function checkCommunityName
//    //---------------------------------------------------------------------
//function GetxmlHttpCommunityObject()
//{ 
//    var objXMLHttp=null;
//    if (window.XMLHttpRequest)
//    {
//        objXMLHttp=new XMLHttpRequest();
//    }
//    else if (window.ActiveXObject)
//    {
//        objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP");
//    }
//    return objXMLHttp;
//}

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
        {
//            document.getElementById("hidUserMessage").value= "UserNotMemberOfCommunity";
             ShowInformationMessageBox("You are not a member of this community, please join the community first.");
            return false;
        }
    }
    else 
    {
        //document.getElementById("hidUserMessage").value= "UserNotMemberOfCommunity";
             ShowInformationMessageBox("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 RemoveUserConfirmation()
//{
//    return confirm('Would you like to remove this user from the community?');
//}
function RemoveFriendConfirmation(RecordId,btnId)
{
    //return confirm('Would you like to remove this user from the Friend list?');   
    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)
{
    //return confirm('Would you like to delete this record?');
    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');
//    var temp = document.getElementById("notifyUsers_CommunityDeleted");
//    
//    //set hid var
//     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);
//        }
//     } 
     
     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");
    
    //set hid var
     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");
      
    //set hid var
     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');
        
        //var result = confirm('Deleting this community will delete all topics under this community. Would you like to delete this community?');
//        if( result == true)
//        {
//           // var notify = confirm('Would you like to notify the community deletion to all the members of this community?');
//            var temp = document.getElementById("notifyUsers_CommunityDeleted");
//      
//            if(notify == true)  
//            {
//                //set hid var
//        
//                 if(temp != null)
//                 {
//                     temp.value = "1";
//                 }
//      
//            }
//            else
//            {
//                 temp.value = "";
//            }
//            return true;
//        }
//        else
        return false;
    }
    else
    {
       return false;
    }
   
}
function DeleteTopicConfirmation(RecordId,btnId)
{
    //return confirm('Would you like to delete this topic & all its posts?');
    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)
{
    //return confirm('Would you like to report this community as offensive?');
    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)
{
    //return confirm('Would you like to report this topic of community as offensive?');
    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 loginStatus=IsLoginedUser(); 
    //    if(loginStatus)
   //    {
   
        var temp = document.getElementById("hidCommunityId");
        if(temp != null && temp!= "")
        {
            temp.value = communityId;
        }
        //   alert(document.getElementById("hidCommunityId").value);
    
         var btnObj=document.getElementById("btnHidden");
         if ((document.all)||(is_Safari > 0))
         {
             // IE
            btnObj.click();
         }
         else
         {
            // FireFox 
        
           var e = document.createEvent("MouseEvents");
           e.initEvent("click", true, true);
           btnObj.dispatchEvent(e);
        }
        return true;
     //  }
    //  else
    // {
    //     return false;
    //}
}
function GoTo_TopicDetails_Load(TopicId)
{
    var temp = document.getElementById("hidTopicId");
    if(temp != null && temp!= "")
    {
        temp.value = TopicId;
    }
 //   alert(document.getElementById("hidCommunityId").value);
    
    var btnObj=document.getElementById("btnHiddenTopicPage");
    //btnObj.click();
    if ((document.all)||(is_Safari > 0))
    {
        // IE
        btnObj.click();
    }
    else
    {
        // FireFox 
        
        var e = document.createEvent("MouseEvents");
        e.initEvent("click", true, true);
        btnObj.dispatchEvent(e);
    }
    return true;
}
//function reply_onClick(TopicId,TopicName,UserId)
//{
//    //alert("in");
//    var ddlForumsCatagory = document.getElementById("ddlForumsCatagory").style.display="block";
//    
//     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 registrationErrorsDiv = document.getElementById("errorDivAddTopic");
////        registrationErrorsDiv.innerHTML = "";
////        registrationErrorsDiv.style.display = "none";
//        
//        ///Added By Amit To Clear the BanWord Message.
//            var valBanWord = document.getElementById("WarningMsgs_RegistrationErrors");
//            valBanWord.innerHTML = "";
//            valBanWord.style.display = "none";   
//             document.getElementById("WarningMsgs_divWarningInfo").style.display = "none";
//  
//         //End of changes
//        
//        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;
//            }  
//            
//        }
//        
//        //document.getElementById("ddlForumsCatagory").style.display = "block";
//        
//         return ShowModalPopup('divpnlAddTopic','Topic Reply');
//         
//        
//   }
//   else
//   {
//        return false;
//   }
////    var errordivObj = document.getElementById("errorDiv");
////    if(IsUserMemberOfCommunity())
////    {
////        return ShowModalPopup('divpnlAddTopic','Topic Reply');
////    }
////    else
////    {
////        return false;
////    }
//    
//}

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 registrationErrorsDiv = document.getElementById("errorDivAddTopic");
//        registrationErrorsDiv.innerHTML = "";
//        registrationErrorsDiv.style.display = "none";
        
        ///Added By Amit To Clear the BanWord Message.
            var valBanWord = document.getElementById("WarningMsgs_RegistrationErrors");
            valBanWord.innerHTML = "";
            valBanWord.style.display = "none";   
             document.getElementById("WarningMsgs_divWarningInfo").style.display = "none";
  
         //End of changes
        
        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;
   }
//    var errordivObj = document.getElementById("errorDiv");
//    if(IsUserMemberOfCommunity())
//    {
//        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 topicNameObj = document.getElementById("hid_TopicName");
//        if(topicNameObj!= null && topicNameObj!= "")
//        {
//           topicNameObj.value = TopicName;    
//        }
//        
//        var txtTopicName = document.getElementById("txtTopicName");
//        if(txtTopicName != null && txtTopicName != "")
//        {
//            txtTopicName.value = TopicName;
//        }
//        
//        
//        var topicDescObj = document.getElementById("hid_TopicDescription");
//        if(topicDescObj!= null && topicDescObj!= "")
//        {
//           topicDescObj.value = TopicDescription;    
//        }
//    //    alert("desc="+TopicDescription);
//        var txtTopicDesc = document.getElementById("txtTopicDescription");
//        if(txtTopicDesc != null && txtTopicDesc != "")
//        {
//            txtTopicDesc.value = TopicDescription;
//        }
      
      var tempObj = document.getElementById("hid_ReplyEdit");
        if(tempObj != null && tempObj!= "")
        {
            tempObj.value = "1";
        }
        
        
        
         var btnObj=document.getElementById("btnHiddenEditTopic");
    //btnObj.click();
    if ((document.all)||(is_Safari > 0))
    {
        // IE
        btnObj.click();
        
    }
    else
    {
        // FireFox 
        
        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;
    
    //var deleteReply = confirm('Deleting this post will delete all posts under it,Would you like to delete this post?');
     
      
      //if(deleteReply == true)  
     // {
////        var temp = document.getElementById("hidTopicId");
////        if(temp != null && temp!= "")
////        {
////            temp.value = TopicId;
////        }
//            if(TopicId!=null && TopicId!= "")
//            {
//                var topicIdObj = document.getElementById("hid_TopicId");
//                if(topicIdObj != null && topicIdObj!= "")
//                {
//                    topicIdObj.value = TopicId;
//                }
//                return true;
//            }
//            else
//                return false;
       // return true;
     // }
     // else
      //  return false;

}

//function delete_onClick(TopicId)
//{
//    alert("delete");
//    return true;
//}

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;
    
    //    var flag;
    //    flag = confirm('Would you like to also add this user in your friend list?');
    //    if(flag == true)
    //    {
    //        var hidObj = document.getElementById("hidFriendRequestViceVersa");
    //        if(hidObj != null && hidObj != "")
    //        {
    //            hidObj.value = "1";   
    //        }
    //    }
    //    return true;

}
function DenyFriendRequest()
{
    return true;
}
//function CheckSearchText()
//{
//    var temp = document.getElementById("txtSearch");
//    temp.value = trim(temp.value);
//   // alert(temp.value);
//    if(temp.value.length == 0 || temp.value == null || temp.value == "")
//    {
//        alert("Please enter some text to search !");
//        return false;
//    }
//    else
//    {
//       return true;
//    }
//}
function searchCommunity()
{
    var temp = document.getElementById("txtSearch");
    temp.value = trim(temp.value);
   // alert(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
    {
        ShowInformationMessageBox("Please enter some text to search.");
        return false;
    }
    
}

function lnkInviteFriends_onClick()
{
    var loginStatus=IsLoginedUser();
    
    if(loginStatus)
    {
        var registrationErrorsDiv = document.getElementById("WarningMsgs_RegistrationErrors");
      
        //Clear the error messages
        registrationErrorsDiv.innerHTML = "";
        registrationErrorsDiv.style.display = "none";
         var divWarningInfo = document.getElementById("WarningMsgs_divWarningInfo");
             
        divWarningInfo.style.display = "none";
    
        //Clear the text box values
         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=="")
    {
         ShowInformationMessageBox("You need to login first 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(IsUserMemberOfCommunity())
    if(status==true)
    {
         var registrationErrorsDiv = document.getElementById("WarningMsgs_RegistrationErrors");
         //Clear the error messages
         registrationErrorsDiv.innerHTML = "";
         registrationErrorsDiv.style.display = "none";
         
         
         
                var divWarningInfo = document.getElementById("WarningMsgs_divWarningInfo");
                divWarningInfo.style.display = "none";
        //Added By Amit To Clear the BanWord Message.
        var valBanWord = document.getElementById("WarningMsgs_RegistrationErrors");
        valBanWord.innerHTML = "";
        valBanWord.style.display = "none";     
        document.getElementById("WarningMsgs_divWarningInfo").style.display = "none";


        //End of changes
    
         
         //Clear the text box values
         var txtObj = document.getElementById("txtTopicName");
         txtObj.value = "";
    
         txtObj = document.getElementById("txtTopicDescription");
         txtObj.value = "";
    
        return ShowModalPopup('divpnlAddTopic','Add Topic','m');
    }
    else
    {
        return false;
    }
}

function PostTopic(ForumId)
{    
    var status = IsLoginedUser();   
      
        if(status == true)
        {  
            var PostNewTopic; 
            PostNewTopic = document.getElementById("PostNewTopic");             
            PostNewTopic.href = "ForumDetails.aspx?ForumId=" + ForumId;
           
           //PostTopic.href="ForumDetails.aspx?ForumId=" + ForumId;
           return true;
        }         
        else
        {
            return false;  
        }           
 }    

function ValidateCommunityForm()
{
    //errors = "<ul>";
      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";
        
        //errors +='</ul>';
        registrationErrorsDiv.innerHTML = "";
        registrationErrorsDiv.innerHTML = errors; 
        return false;   
      }
      else 
      {
        return true;
      }
}

//------------------------------------------------------------------------------------------
 function ValidateCommunityFormRoutines()
 {
    
    var status = true;
        // validating CommunityName
   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; 
   }   
   
   var varTemp = document.getElementById("ddlCategory");  
   if(varTemp != null)
   {
       if(varTemp.selectedIndex == 0)
       {
            varTemp.focus();
		    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 = "Select category for community."; 
		    errors = "Select category for community."; 
		    return false; 
       }
   }
   
   
   var varTemp = document.getElementById("txtWebsite");  
   var alertName = " Community Website ";
   var isMandatory = 'false';
   if(bValidate(varTemp, "WebUrl" ,isMandatory , alertName) != true)
   { 
        varTemp.focus();
		status = false;
		return false; 
   }  
   
        //Description
    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; 
     }
  
   //Photo
   varTemp = document.getElementById("PhotoUpload");
   alertName = " Picture";
   var isMandatory = 'false'; 
   if(varTemp!= null && varTemp!= "")
   {
      //Get the filename
      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)
    {  var btnObj=document.getElementById("btnViewUsers");
		if ((document.all)||(is_Safari>0))
        {
	        // IE
	        btnObj.click();
        }
        else
        {
	        // FireFox 		
	        var e = document.createEvent("MouseEvents");
	        e.initEvent("click", true, true);
	        btnObj.dispatchEvent(e);
		}
        return true;
    }
    else
    {
       return false;
    }
 }
 
 function IsLoginedUser()
{
    if(document.getElementById("hidLoginedUser")!=null)
    {  if(document.getElementById("hidLoginedUser").value!="")
       {
             return true;
       }
        else
       {
           ShowInformationMessageBox("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);
 }
            
//for Instant messages

//This function will open the Instant Message window
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)
    {
      //alert("You need to login first to access this feature.");
      ShowInformationMessageBox("You need to login first to access this feature.");
      return false;
    }
	if((status) &&(document.getElementById("hidLoginedUser").value == toUserID))
   {
     //alert("You cannot send message to yourself."); 
     ShowInformationMessageBox("You cannot send message to yourself.");
     return;
   }
	
	if(document.getElementById("hidLoginedUser") != null && document.getElementById("hidLoginedUser") != "" && toUserID!=null && toUserID!= "")
    {
    
        //get the FromUserID
        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;
}




//active private message link according to login user 
 function CheckSendMessage(userID)
 {
    var PageName;
    var status=false;
    if(document.getElementById("hidLoginedUser")!=null && document.getElementById("hidLoginedUser").value!="")
    {  
        status=true;
    }
    
    if(status == false)
    {
         ShowInformationMessageBox("You need to login first to access this feature.");
        return false;
    }
    
    if((status) &&(document.getElementById("hidLoginedUser").value == userID))
    {
        ShowInformationMessageBox("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 = "<ul>";
     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";
        //alert(errors);
        //errors +='</ul>';
        registrationErrorsDiv.innerHTML = "";
        registrationErrorsDiv.innerHTML = errors; 
        //errors = "<center>Some errors were encountered while processing your submission.</center><br /><ul>";
        
        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";
                    //alert(errors);
                    //errors +='</ul>';
                    registrationErrorsDiv.innerHTML = "";
                    registrationErrorsDiv.innerHTML = errors; 
                   // errors = "<center>Some errors were encountered while processing your submission.</center><br /><ul>";
                }
                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";
                    //alert(errors);
                    //errors +='</ul>';
                    registrationErrorsDiv.innerHTML = "";
                    registrationErrorsDiv.innerHTML = errors; 
                   // errors = "<center>Some errors were encountered while processing your submission.</center><br /><ul>";
                }
                return false;
            }
            else
            {
                return true;
            }
}
 function CheckEmailId()
 {
    
  //  var EmailIdsMoreThanFive = false;
  
    mandatoryFieldsErrorFlag = false;
    //errors = "<ul>";
    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;
        }
        //for (i = 0; i < 5; i++)
       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
                {   // break;
                    i=5;
                }
            }
            else
            {
                _emailId = _temp.substring(0, _length);
                //break;
                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)
                {
                  //  _temp = _temp.substring(_location);
                    _length = _temp.length;
                  //  _location = _temp.indexOf(";");
                    _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);
}


