﻿// JScript File
 //===================BLOGS============================
//==========Server side controls ids===================
var ddlcatid="";
var txtblogid="";
var txtkeywordid="";
var lblmsgcatid="";
var lblmsgblogid="";
var txttitleid="";
var lbltitlemsgid="";
var lblmsgid="";
function SendClientIds(ddlcat,txtblog,txtkeyword,lblmsgcat,lblmsgblog,txttitle,lbltitlemsg,lblmsg)
 {
   ddlcatid=ddlcat;
   txtblogid=txtblog;
   txtkeywordid=txtkeyword;
   lblmsgcatid=lblmsgcat;
   lblmsgblogid=lblmsgblog;
   txttitleid=txttitle;
   lbltitlemsgid=lbltitlemsg;
   lblmsgid=lblmsg;
 }
 function validateBlogPost()
 {
   ClearAllMsg();
   var txtblog=trimAll(document.getElementById(txtblogid).value);
   var ddlcat=trimAll(document.getElementById(ddlcatid).value);
   var titletxt=trimAll(document.getElementById(txttitleid).value);
   document.getElementById(lblmsgid).innerHTML="";
   document.getElementById(lblmsgblogid).innerHTML="";
   document.getElementById(lblmsgcatid).innerHTML="";
   document.getElementById(lbltitlemsgid).innerHTML="";
    document.getElementById(lblmsgid).innerHTML="";
   var flag="0";
   if(ddlcat=="0")
   {
     flag="1";
     document.getElementById(ddlcatid).focus();
     document.getElementById(lblmsgcatid).innerHTML="Please select category.";
   }
   if(titletxt=="")
   {
    
     if(flag=="0")
     {
      document.getElementById(txttitleid).focus();
     }
      flag="1";
     document.getElementById(lbltitlemsgid).innerHTML="Please enter title.";
   }
   if(txtblog=="")
   {
     
     if(flag=="0")
     {
     document.getElementById(txtblogid).focus();
     }
     flag="1";
     document.getElementById(lblmsgblogid).innerHTML="Please enter blog text.";
   }
   if(flag=="1")
   {
    return false;
   }
   else
   {
    return true;
   }
 }
 
 function expandblog(divcolid,divexpid)
 {
  document.getElementById(divcolid).style.display='none';
  document.getElementById(divexpid).style.display='block';
  return false;
 }
 function collpasblog(divcolid,divexpid)
 {
  document.getElementById(divcolid).style.display='block';
  document.getElementById(divexpid).style.display='none';
   return false;
 }
 
 function ViewProfile(userid)
 {
  window.location.href='myprofile.aspx?uid='+userid;
  return false;
 }
 
function OpenCommentPage(blogid)
 {
  window.location.href='blogcomment.aspx?blogid='+blogid;
  return false;
 }
  //===================END BLOGS===========================
  
  
  
 //===================Comment==============================
 //================Server Side Ids=====================
var LblCommentDateid="";
var Lnkcommentbyid="";
var Lnkcommentbyid="";
var Lblcommentid="";
var LblMsgComentid="";
var txtcommtid="";
function GetServerSideIds(LblMsgComent,txtcommt)
{
  LblMsgComentid=LblMsgComent;
  txtcommtid=txtcommt;
}
//====================================================

//==============Comment validator=====================
function ValidateComment()
 {
  var cmt=trimAll(document.getElementById(txtcommtid).value);
   document.getElementById(LblMsgComentid).innerHTML="";
   var flag="0";
   if(cmt=="")
    {
     flag="1";
     document.getElementById(txtcommtid).focus();
     document.getElementById(LblMsgComentid).innerHTML="Please enter comment."
    }
    if(flag=="1")
    {
    return false;
    }
    else
    {
     return true;
    }
 }

 //===================End Comment=====================
 
 
 
 
 
 
 //===================BLOG SEARCH=========================
 //***Global variable******
 var catids=new Array();
 var txtkeywordsearchid="";
 var chklistid="";
 var lblsearchmsgid="";
 var lblKeywordSearchid="";
 var txtlocsearchid="";
 var lbllocsearchid="";
 //************************
 function Sendcatids(catid)//Get blog cat ids
 {
  catids=catid.split('~');
 }

function GetSearchControlsIds(txtkeywordsearch,chklist,lblsearchmsg,lblKeywordSearch,txtlocsearch,lbllocsearch)//Get Server control ids
 {
  txtkeywordsearchid=txtkeywordsearch;
  chklistid=chklist;
  lblsearchmsgid=lblsearchmsg;
  lblKeywordSearchid=lblKeywordSearch;
  txtlocsearchid=txtlocsearch;
  lbllocsearchid=lbllocsearch;
 }


function validateSearch()///validate search
 {
    ClearAllMsg();
    document.getElementById(lblsearchmsgid).innerHTML="";
    var chkList= document.getElementById(chklistid);
    var arrayOfCheckBoxes= chkList.getElementsByTagName("input");
    var arrayOfCheckBoxLabels= chkList.getElementsByTagName("label");
    var listcount = arrayOfCheckBoxes.length;
    var cattext="";
    for(var i=0;i<arrayOfCheckBoxes.length;i++)
      {
       if(arrayOfCheckBoxes[i].checked)
         {
         if(cattext=="")
           {
           cattext=catids[i];
           // cattext= trimAll(arrayOfCheckBoxLabels[i].innerText.substring(0, arrayOfCheckBoxLabels[i].innerText.indexOf('(')));
           }
           else
           {
           cattext= cattext+","+catids[i];
           //cattext= cattext+","+trimAll(arrayOfCheckBoxLabels[i].innerText.substring(0, arrayOfCheckBoxLabels[i].innerText.indexOf('(')));
           }
        }
     }
     if(cattext=="")
      {
       document.getElementById(lblsearchmsgid).innerHTML="Please select category";
       return false;
      }
}
function validateKeySearch()
 {
  ClearAllMsg();
   var keyword= trimAll(document.getElementById(txtkeywordsearchid).value);
   var flag="0";
   if(keyword=="")
   {
    flag="1";
    document.getElementById(lblKeywordSearchid).innerHTML="Please enter keyword.";
    document.getElementById(txtkeywordsearchid).focus();
    
   }
  if(flag=="1")
  {
  return false;
  }
  else
  {
  return true;
  }
 }
 function validateLocSearch()
 {
  ClearAllMsg();
   var loc= trimAll(document.getElementById(txtlocsearchid).value);
   var flag="0";
   if(loc=="")
   {
    flag="1";
    document.getElementById(lbllocsearchid).innerHTML="Please enter location.";
    document.getElementById(txtlocsearchid).focus();
    
   }
  if(flag=="1")
  {
  return false;
  }
  else
  {
  return true;
  }
 }
 //===================END BLOG SEARCH=====================
 
 //===================XTRA=====================
 function redirecttopage(pageurl)
 {
 window.location.href=pageurl;
 return false;
 }
 function OpenBlogReply(blogid)
  {
   var url="viewblogreply.aspx?blogid="+blogid;
   //window.open(url,'PROPIMG','left=20,top=20,width=700,height=600,scrollbars=yes,menubar=no,toolbar=no,resizable=1');
   // window.open(url);
   window.location.href=url;
   return false;
  }
  function signup()
    {
     try
     {
     window.location.href="register.aspx";
    // self.close();
     }
     catch(e)
     {
     }
    }
function refreshMasterPage()
    {
    // alert(window.opener.location);
      try
       {
       window.opener.location.replace(window.opener.location);
       }
       catch(e)
        {
        }
     //window.opener.location.reload();
    }
function ValidateLogin(lblid,txtuserid,txtpwdid)
    {
     var txtlbl=document.getElementById(lblid);
     var txtuser=document.getElementById(txtuserid);
     var txtpwd=document.getElementById(txtpwdid);
     if(trimAll(txtuser.value)=="")
     {
     txtlbl.innerHTML="<span style='color:Red'>Please enter email.</span>";
     document.getElementById(txtuserid).focus();
     return false;
     }
     else if(ValidEmail(trimAll(txtuser.value))==false)
     {
     txtlbl.innerHTML="<span style='color:Red'>Please enter valid email.</span>";
     document.getElementById(txtuserid).focus();
     return false;
     }
     if(trimAll(txtpwd.value)=="")
     {
     txtlbl.innerHTML="<span style='color:Red'>Please enter password.</span>";
     return false;
     }
     return true;
    }
 function ClearAllMsg()
 {
   document.getElementById(lblmsgid).innerHTML="";
   document.getElementById(lblmsgblogid).innerHTML="";
   document.getElementById(lblmsgcatid).innerHTML="";
   document.getElementById(lbltitlemsgid).innerHTML="";
   document.getElementById(lblmsgid).innerHTML="";
   document.getElementById(lblsearchmsgid).innerHTML="";
   document.getElementById(lbllocsearchid).innerHTML="";
   document.getElementById(lblKeywordSearchid).innerHTML="";
 }
 //============================================