﻿ 
 var is_Safari = navigator.userAgent.indexOf('Safari');
 function searchForum()
 {
        var temp = document.getElementById("txtSearch");
        temp.value = trim(temp.value);
       
        if(temp.value.length != 0 && temp.value != null && temp.value != "")
        {
            var _path1 = "../../WebPages/Community/ViewForums.aspx?searchtext=" + temp.value;
            SubmitQueryString(_path1);
            return false;        
        }
        else
        {
            //alert("Please enter some text to search !");
             ShowInformationMessageBox("Please enter some text to search !");
            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 false;
}
function AddTopic_onClick()
{
    var loginStatus=IsLoginedUser();
    if(loginStatus)
    {
     // alert("in");
//    if(IsUserMemberOfCommunity())
//    {
         var registrationErrorsDiv = document.getElementById("WarningMsgs_RegistrationErrors");
        // alert("registrationErrorsDiv="+registrationErrorsDiv);
         //Clear the error messages
         registrationErrorsDiv.innerHTML = "";
         registrationErrorsDiv.style.display = "none";
         
          var WarningDiv = document.getElementById("WarningMsgs_divWarningInfo");
         WarningDiv.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 = "";
         
         
         document.getElementById("ddlForumsCatagory").value = -1;
    
         ShowModalPopup('divpnlAddTopic','Add Topic');
        
        document.getElementById("trCategortRow").style.display="block";
        //alert(document.getElementById("ddlForumsCatagory"));
         document.getElementById("ddlForumsCatagory").style.display="block";
         
         return false;
        
//    }
//    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 OffensiveTopicConfirmation(RecordId,btnId)
{
    var loginStatus=IsLoginedUser();
    
    if(loginStatus)
    {
        //return confirm('Would you like to report this forum topic as offensive?');
        document.getElementById("confirmBox_hidButtonId").value=btnId;
        document.getElementById("hidRecordId").value=RecordId;
        ShowConfirmBox('Would you like to report this forum topic as offensive?');
        return false;
    }
    else
    {
       return false;
    }
}

function reply_onClick(TopicId,TopicName,UserId)
{
   var loginStatus=IsLoginedUser();
    
    if(loginStatus)
    {
       // alert("in");
        
        
        if(document.getElementById("divReplyLoading")!=null)
        {
            document.getElementById("divReplyLoading").style.display="block";
        }
       var registrationErrorsDiv = document.getElementById("WarningMsgs_RegistrationErrors");
       registrationErrorsDiv.innerHTML = "";
       registrationErrorsDiv.style.display = "none";
    
        var WarningDiv = document.getElementById("WarningMsgs_divWarningInfo");
         WarningDiv.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;
            }  
//       
    var btnObj=document.getElementById("hidBtnAddReply");
        
       if ((document.all)||(is_Safari > 0))
        {
            // IE
            btnObj.click();            
        }
        else
        {
            // FireFox             
            var e = document.createEvent("MouseEvents");
            e.initEvent("click", true, true);
            btnObj.dispatchEvent(e);           
        }  
        
        }
    //    var errordivObj = document.getElementById("errorDiv");
    //    if(IsUserMemberOfCommunity())
    //    {
           // return ShowModalPopup('divpnlAddTopic','Topic Reply');
    //    }
    //    else
    //    {
    //        return false;
    //    }
   }
   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))
        {
            // 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)
{
   
//    var deleteReply = confirm('Deleting this post will delete all posts under it,Would you like to delete this post?');
//    
//      
//      if(deleteReply == true)  
//      {
//        return true;
//      }
//      else
//      {
//        return false;
//      }
    
    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 IsLoginedUser()
{
    //alert(document.getElementById("hidLoginedUser").value);
    if(document.getElementById("hidLoginedUser")!=null)
    {  
      if(document.getElementById("hidLoginedUser").value!="")
       {
             return true;
       }
        else
       {
          // alert("You need to login first to access this feature.");
            ShowInformationMessageBox("You need to login first to access this feature.");
            return false;
       }
    }
    else
    {
        return false;
    }
}

//for Instant messages
//// JScript File


//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;
    // alert("In");
    //alert(toUserID);
     if(toUserID== "test")
    {
       // alert("In if");
        if(document.getElementById("hidUserId")!=null && document.getElementById("hidUserId").value!="")
        toUserID = document.getElementById("hidUserId").value;
         //alert(toUserID);
    }
    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)
 {
    //alert("In");
    //alert(userID);
    var PageName;
    var status=false;
     if(userID== "test")
    {
        //alert("In if");
        if(document.getElementById("hidUserId")!=null && document.getElementById("hidUserId").value!="")
        userID = document.getElementById("hidUserId").value;
         //alert(userID);
    }
    
    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 == userID))
    {
      // alert("You cannot send message to yourself."); 
       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, "General" ,isMandatory , alertName) != true)
     {
         status = false;   
     }  
    if( document.getElementById("trCategortRow")!=null && document.getElementById("ddlForumsCatagory_topic")!= null)
    {
            if( document.getElementById("trCategortRow").style.display== "block") 
            {
               if(document.getElementById("ddlForumsCatagory_topic").style.display=="block")
               {
                    var temp = (document.getElementById("ddlForumsCatagory_topic").value)
                     { 
                         if (temp == "-1")
                         {
                           errors = "Please select the Category.";
                           status = false;
                          
                         }   
                     }
               }
            }   
      }  
      
    if(document.getElementById("trCategortRow")!=null && document.getElementById("ddlForumsCatagory")!= null)
    {
            if( document.getElementById("trCategortRow").style.display== "block") 
            {
               if(document.getElementById("ddlForumsCatagory").style.display=="block")
               {
                    var temp = (document.getElementById("ddlForumsCatagory").value)
                     { 
                         if (temp == "-1")
                         {
                           errors = "Please select the Category.";
                           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 ShowFBForumPublishData()
{
//    var Path = self.location.href;
//    var PageName = Path.substring(Path.lastIndexOf("/")+1 ,Path.length);
//    if (PageName.indexOf("ForumDetails.aspx")>=0)
//    {  
          if(document.getElementById("hidSendFacebook").value=="True")
          {     
                var FBMessage=document.getElementById("hidFBMessage").value;
                //var FBType=document.getElementById("hidFBMessageType").value;
                FBPublishData(FBMessage);
          }
    //}
}


function ShowFBPublish()
{
    setTimeout("ShowFBPublishData()",5000);
}

function ShowFBPublishData()
{
      if(document.getElementById("hidSendFacebook").value=="True")
      {     
            var FBMessage=document.getElementById("hidFBMessage").value;
            FBPublishData(FBMessage); 
      }
}

function ShowFBText()
{
   var objValue=document.getElementById("socialsettingcontrol_hidSocialSettings").value;

   if((objValue=="")||(objValue.indexOf("False$False") >= 0))
   {
      //document.getElementById("divSocialSettingsText").style.display="block";
   }
   else
   {
      //document.getElementById("divSocialSettingsText").style.display="none";
   }
}


function CallFBRequireFeatures()
{
    var currUrl;
    
    var posURL1,posURL2,posURL3,posURL4,posURL5,posURL6;
    
    currUrl = String(self.location);
    
    currUrl = currUrl.toLowerCase();
    	 
    posURL1 = currUrl.indexOf("http://www.go-ultra.com");
    
    posURL2 = currUrl.indexOf("http://go-ultra.com");
    
    posURL3 = currUrl.indexOf("http://www.goultrasports.com");
    
    posURL4 = currUrl.indexOf("http://goultrasports.com");
	
	//posURL5 = currUrl.indexOf("http://goultratest2");
	
	posURL5 = currUrl.indexOf("http://192.168.200.8");
	
	posURL6 = currUrl.indexOf("http://121.241.77.229");
	
	if(posURL1 >= 0)
	{
	    FB_RequireFeatures(
					["XFBML"], 
					function(){ 
						FB.Facebook.init(
							"89fb9a953dc4eb0adf700008bbf22940", 
							"../../xd_receiver.htm"
						); 
					}
				); 
	}
   else if(posURL2 >= 0)
   {
       FB_RequireFeatures(
					["XFBML"], 
					function(){ 
						FB.Facebook.init(
							"89fb9a953dc4eb0adf700008bbf22940", 
							"../../xd_receiver.htm"
						); 
					}
				); 
   }
   else if(posURL3 >= 0)
   {
        FB_RequireFeatures(
					["XFBML"], 
					function(){ 
						FB.Facebook.init(
							"89fb9a953dc4eb0adf700008bbf22940", 
							"../../xd_receiver.htm"
						); 
					}
				); 
   }
   else if(posURL4 >= 0)
   {
        FB_RequireFeatures(
					["XFBML"], 
					function(){ 
						FB.Facebook.init(
							"89fb9a953dc4eb0adf700008bbf22940", 
							"../../xd_receiver.htm"
						); 
					}
				);    
   }
   else if(posURL5 >= 0)
   {
          FB_RequireFeatures(
					["XFBML"], 
					function(){ 
						FB.Facebook.init(
							"21fc39d41c399f7383e75ab4e8d05ae6", 
							"../../xd_receiver.htm"
						); 
					}
				);       
   }
   else if(posURL6 >= 0)
   {
        FB_RequireFeatures(
					["XFBML"], 
					function(){ 
						FB.Facebook.init(
							"9ff0f0c98159ed46f8ed389e890abab7", 
							"../../xd_receiver.htm"
						); 
					}
				);     
   }
   else
   {
       FB_RequireFeatures(
					["XFBML"], 
					function(){ 
						FB.Facebook.init(
							"21fc39d41c399f7383e75ab4e8d05ae6", 
							"../../xd_receiver.htm"
						); 
					}
				);     
   }
}


function ShowFBForumPublish()
{
//    var Path = self.location.href;
//    var PageName = Path.substring(Path.lastIndexOf("/")+1 ,Path.length);
//    if (PageName.indexOf("ForumDetails.aspx")>=0)
//    {  
        setTimeout("ShowFBForumPublishData()",5000);
    //}
}

function AddTopic()
        {
           
            var loginStatus=IsLoginedUser();
            if(loginStatus)
            {
            //var temp =  document.getElementById("hidTopicId1").value;
            //alert( document.getElementById("hidTopicId1"));
             //alert("in");
            document.getElementById("WarningMsgs_divWarningInfo").style.display="none";
            document.getElementById("ddlForumsCatagory_topic").value = -1;
            ShowModalPopup('divpnlAddTopic','Topic','M');
            document.getElementById("trCategortRow").style.display="block";
             document.getElementById("ddlForumsCatagory_topic").style.display="block";
            return  false;
           }
           else
           {
             return false;
           }
            //alert(document.getElementById("ddlForumsCatagory"));
             
         }

function ValidateMainThreadTopic()
{ 
    
    mandatoryFieldsErrorFlag = false;
     //errors = "<ul>";
     errors = "";
     var status = true;
     
//     var varTemp = document.getElementById("TxtThreadName");  
//     var alertName = "Topic Name";
     var isMandatory = 'True';
//    
//     if(bValidate(varTemp, "General" ,isMandatory , alertName) != true)
//     {
//         status = false;   
//     }   
     if (status == true)
     {
         var varTemp = document.getElementById("TxtThreaadDescription");  
         var alertName = "Topic Description";
         
         if(bValidate(varTemp, "" ,isMandatory , alertName) != true)
         {
             status = false;   
         }    
         var len = varTemp.value.length;
         if(len > 1024)
         {
            var banWordMessage = document.getElementById("ValidationWarning1_RegistrationErrors");
            banWordMessage.style.display = "none"; 
            errors += alertName + sDescription_Message +'<br/>'; 
	        status = false;
	     }    
	     if(document.getElementById("divThreadSave")!=null)
        {
            document.getElementById("divThreadSave").style.display="block";
        }
	 }
	 
     if(status == false)
     { 
        var registrationErrorsDiv = document.getElementById("ValidationWarning1_RegistrationErrors");
        var banWordMessage = document.getElementById("ValidationWarning1_RegistrationErrors");
        
        if(document.getElementById("divThreadSave")!=null)
        {
            document.getElementById("divThreadSave").style.display="none";
        }
        
         var divWarningInfo = document.getElementById("ValidationWarning1_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 varTemp = document.getElementById("chkFb"); 
	  if(varTemp!=null  && varTemp.checked==true)
	  {
	   
	    ShowFBPopups();
	  }
        var registrationErrorsDiv = document.getElementById("ValidationWarning1_RegistrationErrors");
        registrationErrorsDiv.style.display = "none";
         var divWarningInfo = document.getElementById("ValidationWarning1_divWarningInfo");
        divWarningInfo.style.display = "none";
    
        errors ='';
       // status = CheckBanWord(document.getElementById("txtTopicName"),document.getElementById("txtTopicDescription"),document.getElementById("WarningMsgs_RegistrationErrors"));
    }   
    
   
    //return status;
}

         

