﻿    /* <![CDATA[ */
       
        var _ifrPhoto;

      

        function initPhotoUpload()
        {
           
            _ifrPhoto = document.getElementById('ifrPhoto');

            var btnUpload = _ifrPhoto.contentWindow.document.getElementById('btnUpload');

            btnUpload.onclick = function(event)
            {
                var filPhoto = _ifrPhoto.contentWindow.document.getElementById('filPhoto');

                
                
                if (filPhoto.value.length == 0)
                {
                    ShowMessage("Please specify the file.");
                    filPhoto.focus();
                    return;
                }

                
                beginPhotoUploadProgress();
                _ifrPhoto.contentWindow.document.getElementById('photoUpload').submit();
               
            }
        }

        function beginPhotoUploadProgress()
        {
           onUpdating();
        }

        function clearPhotoUploadProgress()
        {
            
        }

        function updatePhotoUploadProgress()
        {
           
        }

        function photoUploadComplete(message, isError)
        {
          
           if(isError == true)
           {
             ShowMessage("Please specify a valid file. Valid formats are Word,Excel,Text,PDF and JPG Image");
             onUpdated();
             return false;
           }
           var extender=$find("YuiGrid1_GridProperties");
            //get the ExtJs Grid
            var grid=extender.get_Grid();
            //get the store
            var store=grid.getStore();
            
            var symbol=message;
            //get the options used to load the grid
            var pageParams=store.lastOptions.params;
            //add the custom parameter
            
            pageParams.deleteparam = undefined;
            pageParams.symbol=symbol;
            //reload the grid     
           
            
            
            store.load({params:pageParams});  
            onUpdated();
            
        }
  
      
      
    
 
 
   
        
            
             
            function onUpdating(){
            
                
                // get the update progress div
                var pnlPopup = document.getElementById("pnlPopup");

                //  get the gridview element        
                var gridView = document.getElementById("divFrame");
                
                // make it visible
                pnlPopup.style.display = '';
                   
                
                // get the bounds of both the gridview and the progress div
                var gridViewBounds = Sys.UI.DomElement.getBounds(gridView);
                var pnlPopupBounds = Sys.UI.DomElement.getBounds(pnlPopup);
                
                //  center of gridview
                var x = gridViewBounds.x + Math.round(gridViewBounds.width / 2) - Math.round(pnlPopupBounds.width / 2);
                var y = gridViewBounds.y + Math.round(gridViewBounds.height / 2) - Math.round(pnlPopupBounds.height / 2);	    

                //	set the progress element to this position
                Sys.UI.DomElement.setLocation(pnlPopup, x, y);   
                gridView.style.display='none';	        
            }

            function onUpdated() {
                // get the update progress div
                var pnlPopup = document.getElementById("pnlPopup");
                 var gridView = document.getElementById("divFrame");
                 
                // make it invisible
                pnlPopup.style.display = 'none';  
                gridView.style.display = '';              
               
            }    
            
              
       function deleteFile(val)
             {
               return '<a href="Javascript:RemoveRow()" style="color:red;overflow:auto;">'+val+'</a>'      
             }
             
       function RemoveRow(){
         var extender=$find("YuiGrid1_GridProperties");
         /*
           removeRow-Removes the selected row(s) and fires the 
           RowRemoved event passing the row(s) selected 
            
         */
          var extender=$find("YuiGrid1_GridProperties");
            //get the ExtJs Grid
            var grid=extender.get_Grid();
            //get the store
            var store=grid.getStore();
            var no = store.getCount();
            
         var pageParams=store.lastOptions.params;
            //add the custom parameter
            pageParams.symbol=undefined;
            
            pageParams.deleteparam = "Delete";
         if(confirm("Are you sure you want to delete?"))
                extender.removeRow();
        }             
