﻿// JScript File

var AuthorXmlHttp;
  j(document).ready(function() {
   
    j('a[href=#top]').click(function(){
        j('html, body').animate({scrollTop:0}, 'slow');
        return false;
    });

});
  function AuthorGetXmlHttpObject()
    {
     return (window.XMLHttpRequest)?(new XMLHttpRequest()):(new ActiveXObject("Microsoft.XMLHTTP"));
    }
         
   function GetRightPanel()
  {

            //xml http
            //
            //
            AuthorXmlHttp = AuthorGetXmlHttpObject();
            AuthorXmlHttp.onreadystatechange = CallRightPanelbyXmlHttp_Callback;
            
            var param='';
           
            //POST method
            //
            //
            AuthorXmlHttp.open ('GET',hRootUrl + "/home/HomeRightPanel.aspx",true);
            AuthorXmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded')
            AuthorXmlHttp.setRequestHeader("Content-length",param.length);
            AuthorXmlHttp.send(param);
        
        
         return false;
   } 
   function CallRightPanelbyXmlHttp_Callback()
  {

             
     if (AuthorXmlHttp.readyState==4 || AuthorXmlHttp.readyState=="complete")
     {
	        //filter
               
          var txt = AuthorXmlHttp.responseText;
  
          try
          { 
              var DivsIndex =  txt.indexOf("<div id='divRightPanel'>");
              var DivlIndex = txt.indexOf("</form>");
  
               if(DivsIndex > -1)
               {
                  
                   
                   // Setting the innerhtml of the teacher div
                     txt = txt.substring(DivsIndex,DivlIndex); 
                     var starttag= '<DivProfile>';
                     var endtag= '</DivProfile>';             
                     var dvStartIndex =  txt.indexOf(starttag)+starttag.length;                                   
                     var dvEndIndex = txt.indexOf(endtag)+endtag.length;                     
                     var innertxt= txt.substring(dvStartIndex,dvEndIndex);                    
                     document.getElementById("contentDvProfile").innerHTML="";
                     document.getElementById("contentDvProfile").innerHTML = innertxt;
                    
                     document.getElementById("contentDvProfile").style.height="";
                    //End the innerhtml of the profile div
                   
                     // Setting the innerhtml of the Action and Todo  and classes divs
                      starttag= '<DivActionToDo>';
                      endtag= '</DivActionToDo>'; 
                      dvStartIndex =  txt.indexOf(starttag)+starttag.length;                                    
                      dvEndIndex =txt.indexOf(endtag)+endtag.length;                                        
                      innertxt= txt.substring(dvStartIndex,dvEndIndex);                        
                      document.getElementById("dvActionTodo").innerHTML="";
                      document.getElementById("dvActionTodo").innerHTML = innertxt;
                     
                      document.getElementById("dvActionTodo").style.height="";
                    // End the innerhtml of the Action and Todo and classes divs
                    
 
               }
               else
               {
                document.getElementById("rightcontent_s").innerHTML="";
               } 
          }
          catch(e)
          {
                document.getElementById("rightcontent_s").innerHTML="";
          }   
     }
} 

    


   function GetMoreUpdates()
{
   document.getElementById("spLoader").style.display = "block";
    j.ajax({
    url: hRootUrl + '/home/action/homeupdates.aspx',
    type: 'POST',
    data: 'lastActID=' +  document.getElementById("hdnLastActID").value , 
    error: function(){
        //alert('Error getting records');
    },
    success: function(msg)
    {
      
       var txt = msg;
      
   
       var DivsIndex =  txt.indexOf("<div1>");
       var DivlIndex = txt.indexOf("</div1>");
        
      
        
       if(DivsIndex > -1)
       {
           // Setting the new value of txtDateFrom
           txt = txt.substring(DivsIndex + 6,DivlIndex);
          if(txt.indexOf("No Updates") != -1)
          {
            document.getElementById("divSeeMore").style.display = "none";
             document.getElementById("divNoMoreUpdates").style.display = "block";
          }
          else
          {
          document.getElementById("spLoader").style.display = "none";
              j('#divMain').append(txt);
           }
       }
       
       // Assigning the value of returned HTML to local txt variable again.
        txt = msg;
       var DivsIndex1 =  txt.indexOf("<div2>");
        var DivlIndex1 = txt.indexOf("</div2>");
        
        if(DivsIndex1 > -1)
       {
       
       // Setting the new value of txtScheduleTime
           txt = txt.substring(DivsIndex1 + 6,DivlIndex1);
           //varLastActID = txt;
          
           document.getElementById("hdnLastActID").value = txt; 
       }
       
     
       
    }
});
}	
    
    function CallParentThickbox(href)
{
var link=document.getElementById("hrefThickBox");
          link.href=href;
         
           try
            {
                HTMLElement.prototype.click = function() {
                var evt = this.ownerDocument.createEvent('MouseEvents');
                evt.initMouseEvent('click', true, true, this.ownerDocument.defaultView, 1, 0, 0, 0, 0, false, false, false, false, 0, null);
                this.dispatchEvent(evt);}
            }
           catch(e)
            {
            }
       document.getElementById('hrefThickBox').click();    
          
}
