/******************************************************************
* Create by Vadim Krasnov - 01/15/2008
* JS client-side functionality
*
*********************************************************************/
  var msg = "Do you want to save your changes?\n\n"
                     +"OK? Click UPDATE before exiting the Checklist.\n\n" 
                     +"Cancel? Uncheck the Checklist items\n (or check the items on the Completed page)";


 var calWin; 
 function openPopup(url, width, height) { 
        
    closePopup();  
    var sOptions ='width='+width+',height='+height+',top=50,left=50,scrollbars=yes,toolbar=no,'+ 
                  'location=no,directories=no,status=no, menubar=no, titlebar=no'; 
  
    calWin = window.open(url,'AddTasks',sOptions);  
    	
 } 


            
 function closePopup() {
      if (calWin && calWin.open && !calWin.closed) calWin.close();
            
 } 
 
 
 function fnRedirect( redirectPage ){ 
                
            var tasksSelected=fnTaskSelecteded();   
        
             if ( initChecked != tasksSelected ) { 
                if ( confirm(msg) ) 
                window.location.href=windows.location.href; 
            //    return false; 
             } 
                  window.location=redirectPage;
                  return false; 
}


function fnRedirect_CurrentTasks( redirectPage ){ 
                
            var tasksSelected=fnTaskSelecteded();           

             if ( initChecked != tasksSelected ) {
                if ( confirm(msg) )
                return false; // instead of ---->>>> windows.location.href=windows.location.href; <<<<----- (THE page will not POST BACK)
             } 
                  window.location=redirectPage;
                  return false; 
}



//The function checks whether at least one check box is selected      
function fnTaskSelecteded(){ 
             
             var iSelected=0; 
             for (var i=0; i< document.all.length; i++) { 
		     
                       var obj = document.all[i]; 
		       if (obj.type == 'checkbox') 
			 if (obj.checked) iSelected++; 
		        
             } 
             return iSelected 
}

 


