﻿ 
 var imgInProcess = "<div><img src='UI/img/ajax-loader.gif' alt='Loading data'></div>"
 
// function BindData(Data,context)
//      {
//       
//           
//           if (context.BindControl)
//           { 
//               var objTemp  =   $(context.BindControl).setTemplateURL(context.Template,null,{runnable_functions: context.runnable_functions});  
//               objTemp.processTemplate(Data);
//           }
//         
//                ShowProgressBar(false);
//           
//           
//           if (context.CommandControl)
//                jQuery.each(context.CommandControl, function(i,val)
//                {
//                    
//                                $(val).click(OnCmdClick).hover(  
//                                                                     function() {  
//                                                                        $(this).addClass('hover');  
//                                                                     },  
//                                                                     function() {  
//                                                                        $(this).removeClass('hover');  
//                                                                     }  
//                                                                ); 
//                                
//                }) ;                 
//           if (context.CallBack)
//                    eval(context.CallBack);
//                    
//                    
//            ParentDock();
//                    
//                    
//           
//      }
      
      
     function ShowProgressBar(obj)
     {
        try
        {             
            var CurrentWindow = window; 
            if (CurrentWindow)
            { 
               
                var objParent = $(CurrentWindow).parent(); 
                var objParentDocument =objParent.get(0); 
                var innerDoc = (objParentDocument.contentDocument) ? objParentDocument.contentDocument : objParentDocument.ownerDocument;            
                
                var objWindow =  innerDoc.parentWindow? innerDoc.parentWindow :innerDoc.defaultView ; 
                
                if (objWindow) 
                    if (objWindow.ShowProgressBar)
                          objWindow.ShowProgressBar(obj);  
            } 
            else
            {
                if (ShowProgressBar)
                    ShowProgressBar(obj);
            }
                 
                 
        }catch(err)
        {
            var obj = err.description;
        }
            
     } 
      
      
      
      
      $.fn.getIndex = function(){
  var parentSet=$(this).parent().children();
  return $(parentSet).index(this);
}

  
  
function ParentDock()
{

        
        var CurrentWindow = window.frameElement; 
        if (CurrentWindow)
        {
        
        
          // get reference of document object
           var innerDoc = (CurrentWindow.contentDocument) ? CurrentWindow.contentDocument : CurrentWindow.contentWindow.document;
         
           //set height and width of iframe
           $(CurrentWindow).height(innerDoc.body.scrollHeight + 10);
           
           if ($(CurrentWindow).attr("AutoWidth"))
                $(CurrentWindow).width(innerDoc.body.scrollWidth);
           
            if ($(CurrentWindow).attr("MinimumHeight"))
                if ($(CurrentWindow).height() < $(CurrentWindow).attr("MinimumHeight"))
                        $(CurrentWindow).height($(CurrentWindow).attr("MinimumHeight"));
                
          
           
            var objParent = $(CurrentWindow).parent(); 
            
             
            var objParentDocument =objParent.get(0); 
              
            
            innerDoc = (objParentDocument.contentDocument) ? objParentDocument.contentDocument : objParentDocument.ownerDocument;            
            
            var objWindow =  innerDoc.parentWindow? innerDoc.parentWindow :innerDoc.defaultView ; 
            
            if (objWindow) 
                objWindow.ParentDock();
        } 
}


 function OnFailed(error, userContext, methodName)  
      {  
            if(error !== null)  
            {  
              alert(error.get_message());  
              ShowProgressBar(false); 
            }  
      }   
      
  
    
    
      
