Index: /schedule/function/SplitDelete.php
===================================================================
--- /schedule/function/SplitDelete.php	(revision 16815)
+++ /schedule/function/SplitDelete.php	(revision 16816)
@@ -1,9 +1,11 @@
 <script type="text/javascript">
  $(document).ready(function(){
- 
+ var name='';
+var value='';
  var timeValue;
 var meas;
 var meas2;
 var getTableId;
+var is=0;
  window.cnt=0;
  
@@ -79,12 +81,13 @@
 			button.setAttribute('value','[+]'),
 			button.setAttribute('id','btnAddTime'),
-			button.onclick=function(){
-			
-			
-			
-			if($('#Time1').val() != ""){  var splitting = $('#Time1').val().split(':'); var add = 01;   
+			button.setAttribute('name','table'+cnt),
+			button.onclick=function(){
+			
+			
+			
+			if($('#Time'+cnt).val() != ""){  var splitting = $('#Time'+cnt).val().split(':'); var add = 01;   
 
 			timeValue = pad((Number(splitting[0]) + Number(add)),2)+':'+splitting[1]; 
-
+		
 						function pad(number, length) {
 				   
@@ -97,6 +100,27 @@
 
 						}
-
-			 meas = "name"; meas2 = "time";   getTableId = '#table'+cnt;  split1();    }else{   alert("please enter value for time to add measurement");   }
+						var s = 0; var	get;
+						var nn;
+						nn = $(this).attr('name');
+				$("table").each(function() {
+				if($(this).attr("name")==nn){
+					
+					get = "#"+$(this).attr("id"); 
+					//get = $(this).attr("name");
+						s =1;
+				}else{
+				if(s==0){
+				get = '#table'+cnt;
+				}
+				}
+				});
+
+	
+					
+				getTableId =get;
+
+
+			name="name"; value=""; meas = "name"; meas2 = "time";   //getTableId = $(this).attr('name'); 
+			split1();    }else{   alert("please enter value for time to add measurement");   }
 
 				
@@ -157,7 +181,8 @@
 			button.setAttribute('type','button'),
 			button.setAttribute('value','[+]'),
-			button.setAttribute('id','btnAddTime'),
-			button.onclick=function(){
-			if($('#Time1').val() != ""){ timeValue = $('#Time1').val();  meas = "hidden"; meas2 = true; getTableId = '#table'+cnt; split1();    }else{   alert("please enter value for time to add measurement");   }
+			button.setAttribute('id','btnAddTime'+cnt),
+			button.setAttribute('name','table'+cnt),
+			button.onclick=function(){
+			if($('#Time'+cnt).val() != ""){ timeValue = $('#Time'+cnt).val(); name="name"; value=$(this).attr('name'); meas = "hidden"; meas2 = true; is=1; getTableId = $(this).attr('name'); split1();    }else{   alert("please enter value for time to add measurement");   }
 
 				
@@ -181,12 +206,22 @@
 			button.setAttribute('id','btnSplit'),
 			button.setAttribute('value','Split'),
+			button.setAttribute('name','#table'+cnt),
 			button.onclick= function()
 			{
 
-			if($('#Time1').val() != ""){  var splitting = $('#Time1').val().split(':'); var add = 30;   
-
-
+			if($('#Time'+cnt).val() != ""){  var splitting = $('#Time'+cnt).val().split(':'); var add = 30;   
+
+						
+		var limit = 60;
+				var adds =0;
+				adds =  (Number(splitting[1]) + Number(add));
+				 if(adds >= limit){
+				 adds = Number(adds) - Number(limit);
+				 timeValue =pad(Number(splitting[0])+1,2)+':'+ pad(adds,2);
+				 
+				 }else{
+				 
 			timeValue =pad(splitting[0],2)+':'+ pad((Number(splitting[1]) + Number(add)),2); 
-
+					}
 						function pad(number, length) {
 				   
@@ -199,6 +234,11 @@
 
 						};
-
-			 meas = "name"; meas2 = "time";  getTableId = '#table'+cnt;  split1();    }else{   alert("please enter value for time to add measurement");   }
+						
+						
+			 name="name"; value=""; 
+			 meas = "name"; meas2 = "time";  
+			 getTableId = $(this).attr('name'); 
+			 split1(); 
+			 }else{ alert("please enter value for time to add measurement"); }
 
 				 
@@ -253,6 +293,7 @@
 			button.setAttribute('value','[+]'),
 			button.setAttribute('id','btnAddTime'),
-			button.onclick=function(){
-			if($('#Time2').val() != ""){ var splitting = $('#Time2').val().split(':'); var add = 01;   
+			button.setAttribute('name','#table2'),
+			button.onclick=function(){
+			if($('#Time1').val() != ""){ var splitting = $('#Time1').val().split(':'); var add = 01;   
 
 			timeValue = pad((Number(splitting[0]) + Number(add)),2)+':'+splitting[1]; 
@@ -267,5 +308,23 @@
 						return str;
 
-						};  meas = "name"; meas2 = "time";  getTableId = '#table1';  split();    }else{   alert("please enter value for time to add measurement");   }
+						}; 
+						
+						var s = 0; var	get;
+						
+$("table").each(function() {
+				if($(this).attr("name")=='table2'){
+				get = "#"+$(this).attr("id"); 
+				
+						s =1;
+				}else{
+				if(s==0){
+				get = '#table'+cnt;
+				}
+				}
+    });
+getTableId =get;
+name="name"; value="";
+						name="name"; value="";  meas = "class"; meas2 = "time";  //getTableId = $(this).attr('name'); 
+						split2();    }else{   alert("please enter value for time to add measurement");   }
 
 				
@@ -321,6 +380,7 @@
 			button.setAttribute('value','[+]'),
 			button.setAttribute('id','btnAddTime'),
-			button.onclick=function(){
-			if($('#Time2').val() != ""){ timeValue = $('#Time2').val();  meas = "hidden"; meas2 = true;  getTableId = '#table1';  split();    }else{   alert("please enter value for time to add measurement");   }
+			button.setAttribute('name','#table2'),
+			button.onclick=function(){
+			if($('#Time1').val() != ""){ timeValue = $('#Time1').val(); name="name"; value="table2";  meas = "hidden"; meas2 = true;  getTableId = $(this).attr('name');  split2();    }else{   alert("please enter value for time to add measurement");   }
 
 				
@@ -342,10 +402,18 @@
 			button.setAttribute('id','btnSplit'),
 			button.setAttribute('value','Split'),
+			button.setAttribute('name','#table2'),
 			button.onclick= function()
 			{
-				 if($('#Time2').val() != ""){  var splitting = $('#Time2').val().split(':'); var add = 30;   
-
+				 if($('#Time1').val() != ""){  var splitting = $('#Time1').val().split(':'); var add = 30; var limit = 60;
+				var adds =0;
+				adds =  (Number(splitting[1]) + Number(add));
+				 if(adds >= limit){
+				 adds = Number(adds) - Number(limit);
+				 timeValue =pad(Number(splitting[0])+1,2)+':'+ pad(adds,2);
+				 
+				 }else{
+				 
 			timeValue =pad(splitting[0],2)+':'+ pad((Number(splitting[1]) + Number(add)),2); 
-
+					}
 						function pad(number, length) {
 				   
@@ -358,6 +426,7 @@
 
 						}
-
-			 meas = "name"; meas2 = "time"; getTableId = '#table1';   split();    }else{   alert("please enter value for time to add measurement");   }
+			
+			 meas = "name"; meas2 = "time"; getTableId = $(this).attr('name');  
+			 split2();    }else{   alert("please enter value for time to add measurement");   }
 				 
 			}
@@ -405,4 +474,5 @@
 			button.setAttribute('value','[+]'),
 			button.setAttribute('id','btnAddTime'),
+			button.setAttribute('name','#table1'),
 			button.onclick=function(){
 			if($('#Time2').val() != ""){ var splitting = $('#Time2').val().split(':'); var add = 01;   
@@ -419,5 +489,25 @@
 						return str;
 
-						};  meas = "name"; meas2 = "time";  getTableId = '#table1';  split();    }else{   alert("please enter value for time to add measurement");   }
+						}; 
+						
+						
+						var s = 0; var	get;
+						
+$("table").each(function() {
+				if($(this).attr("name")=='table1'){
+				get = "#"+$(this).attr("id"); 
+				
+						s =1;
+				}else{
+				if(s==0){
+				get = '#table'+cnt;
+				}
+				}
+    });
+getTableId =get;
+
+						
+						name="name"; value="";  meas = "class"; meas2 = "time";  //getTableId = $(this).attr('name'); 
+						split2();    }else{   alert("please enter value for time to add measurement");   }
 
 				
@@ -473,6 +563,7 @@
 			button.setAttribute('value','[+]'),
 			button.setAttribute('id','btnAddTime'),
-			button.onclick=function(){
-			if($('#Time2').val() != ""){ timeValue = $('#Time2').val();  meas = "hidden"; meas2 = true;  getTableId = '#table1';  split();    }else{   alert("please enter value for time to add measurement");   }
+			button.setAttribute('name','#table1'),
+			button.onclick=function(){
+			if($('#Time2').val() != ""){ timeValue = $('#Time2').val(); name="name"; value="table1"; meas = "hidden"; meas2 = true;  getTableId = $(this).attr('name'); split2();    }else{   alert("please enter value for time to add measurement");   }
 
 				
@@ -494,10 +585,20 @@
 			button.setAttribute('id','btnSplit'),
 			button.setAttribute('value','Split'),
+			button.setAttribute('name','#table1'),
 			button.onclick= function()
 			{
 				 if($('#Time2').val() != ""){  var splitting = $('#Time2').val().split(':'); var add = 30;   
 
+			var limit = 60;
+				var adds =0;
+				adds =  (Number(splitting[1]) + Number(add));
+				 if(adds >= limit){
+				 adds = Number(adds) - Number(limit);
+				 timeValue =pad(Number(splitting[0])+1,2)+':'+ pad(adds,2);
+				 
+				 }else{
+				 
 			timeValue =pad(splitting[0],2)+':'+ pad((Number(splitting[1]) + Number(add)),2); 
-
+					}
 						function pad(number, length) {
 				   
@@ -511,5 +612,11 @@
 						}
 
-			 meas = "name"; meas2 = "time"; getTableId = '#table1';   split();    }else{   alert("please enter value for time to add measurement");   }
+
+						name="name"; value="";	
+						
+meas = "class"; meas2 = "time";
+
+		getTableId = $(this).attr('name');  
+		split2();    }else{   alert("please enter value for time to add measurement");   }
 				 
 			}
@@ -539,8 +646,8 @@
 	}
 	var meas;
-		var timeValue;
-		var pad;
+	var timeValue;
+	var pad;
 	if(cnt==0){  cnt=2; }	
-	function split()
+	function split2()
 	{
 	
@@ -549,4 +656,5 @@
 			table.setAttribute('id',"table"+cnt);
 			table.setAttribute('width','100%');
+			table.setAttribute(name,value);
 		var tr = document.createElement('tr');
 			tr.setAttribute('id','');
@@ -566,4 +674,5 @@
 						input.setAttribute(meas,meas2),
 						input.setAttribute("value",timeValue)
+					
 						
 			);
@@ -574,4 +683,6 @@
 			button.setAttribute('id','btnAddTime'),
 			button.setAttribute(meas,meas2),
+			button.setAttribute('name','table'+cnt),
+			
 			button.onclick=function(){
 			if($('#Time'+cnt).val() != ""){var splitting = $('#Time'+cnt).val().split(':'); var add = 01;   
@@ -588,5 +699,24 @@
 						return str;
 
-						}   meas = "name"; meas2 = "time";  getTableId = '#table'+cnt;   split1();    }else{   alert("please enter value for time to add measurement");   }
+						}  
+
+					var s = 0; var	get;
+						var nn;
+						nn = $(this).attr('name');
+				$("table").each(function() {
+				if($(this).attr("name")==nn){
+					
+					get = "#"+$(this).attr("id"); 
+					//get = $(this).attr("name");
+						s =1;
+				}else{
+				if(s==0){
+				get = '#table'+cnt;
+				}
+				}
+				});
+
+name="name"; value=$(this).attr('name');
+						meas = "class"; meas2 = "time";  getTableId = get;   split1();    }else{   alert("please enter value for time to add measurement");   }
 
 				
@@ -643,12 +773,15 @@
 			button.setAttribute('value','[+]'),
 			button.setAttribute('id','btnAddTime'),
-			button.onclick=function(){
-			
+			button.setAttribute('name','#table'+cnt),
+			button.onclick=function(){
+		
 			if($('#Time'+cnt).val() != "")
 			{ 
+				name = "name";
+				value = "table"+cnt;
 				timeValue = $('#Time'+cnt).val();
 				meas = "hidden"; 
 				meas2 = true;
-				getTableId = '#table'+cnt; 
+				getTableId = $(this).attr('name'); 
 				split1();    
 			}
@@ -677,9 +810,19 @@
 				button.setAttribute('id','btnSplit'),
 				button.setAttribute('value','Split'),
+				button.setAttribute('name','#table'+cnt),
 				button.onclick=function(){
 				 if($('#Time'+cnt).val() != ""){  var splitting = $('#Time'+cnt).val().split(':'); var add = 30;   
 
+			var limit = 60;
+				var adds =0;
+				adds =  (Number(splitting[1]) + Number(add));
+				 if(adds >= limit){
+				 adds = Number(adds) - Number(limit);
+				 timeValue =pad(Number(splitting[0])+1,2)+':'+ pad(adds,2);
+				 
+				 }else{
+				 
 			timeValue =pad(splitting[0],2)+':'+ pad((Number(splitting[1]) + Number(add)),2); 
-
+					}
 						function pad(number, length) {
 				   
@@ -693,5 +836,9 @@
 						}
 
-			 meas = "name"; meas2 = "time";  getTableId = '#table'+cnt;  split();    }else{   alert("please enter value for time to add measurement");   }
+						meas = "class"; meas2 = "time"; 
+						
+
+			 getTableId = $(this).attr('name'); 
+			 split2();    }else{   alert("please enter value for time to add measurement");   }
 				}
 			);
@@ -727,4 +874,5 @@
 			table.setAttribute('id',"table"+cnt);
 			table.setAttribute('width','100%');
+			table.setAttribute(name,value);
 		var tr = document.createElement('tr');
 			tr.setAttribute('id','');
@@ -750,4 +898,6 @@
 			button.setAttribute('id','btnAddTime'),
 			button.setAttribute(meas,meas2),
+			button.setAttribute('name','table'+cnt),
+			
 			button.onclick=function(){
 			if($('#Time'+cnt).val() != ""){ var splitting = $('#Time'+cnt).val().split(':'); var add = 01;   
@@ -764,5 +914,22 @@
 						return str;
 
-						}  meas = "name"; meas2 = "time";   getTableId = '#table'+cnt; split1();    }else{   alert("please enter value for time to add measurement");   }
+						}
+						var s = 0; var	get;
+						var nn;
+						nn = $(this).attr('name');
+				$("table").each(function() {
+				if($(this).attr("name")==nn){
+					
+					get = "#"+$(this).attr("id"); 
+					//get = $(this).attr("name");
+						s =1;
+				}else{
+				if(s==0){
+				get = '#table'+cnt;
+				}
+				}
+				});
+
+				name="name"; value="";		meas = "class"; meas2 = "time";   getTableId = get; split1();    }else{   alert("please enter value for time to add measurement");   }
 
 				
@@ -820,7 +987,9 @@
 			button.setAttribute('value','[+]'),
 			button.setAttribute('id','btnAddTime'),
-			button.onclick=function(){
-		
-			if($('#Time'+cnt).val() != ""){ timeValue = $('#Time'+cnt).val();  meas = "hidden"; meas2 = true; getTableId = '#table'+cnt;   split1();    }else{   alert("please enter value for time to add measurement");   }
+			button.setAttribute('name','#table'+cnt),
+			button.onclick=function(){
+		
+			if($('#Time'+cnt).val() != ""){ timeValue = $('#Time'+cnt).val(); 				
+			name = "name"; value = $(this).attr('name');  meas = "hidden"; meas2 = true; getTableId = $(this).attr('name');   split1();    }else{   alert("please enter value for time to add measurement");   }
 
 				
@@ -843,9 +1012,19 @@
 				button.setAttribute('id','btnSplit'),
 				button.setAttribute('value','Split'),
+				button.setAttribute('name','#table'+cnt),
 				button.onclick=function(){
 				 if($('#Time'+cnt).val() != ""){  var splitting = $('#Time'+cnt).val().split(':'); var add = 30;   
 
+		var limit = 60;
+				var adds =0;
+				adds =  (Number(splitting[1]) + Number(add));
+				 if(adds >= limit){
+				 adds = Number(adds) - Number(limit);
+				 timeValue =pad(Number(splitting[0])+1,2)+':'+ pad(adds,2);
+				 
+				 }else{
+				 
 			timeValue =pad(splitting[0],2)+':'+ pad((Number(splitting[1]) + Number(add)),2); 
-
+					}
 						function pad(number, length) {
 				   
@@ -859,5 +1038,5 @@
 						}
 				
-			 meas = "name"; meas2 = "time"; getTableId = '#table'+cnt;    split();    }else{   alert("please enter value for time to add measurement");   }
+			 meas = "name"; meas2 = "time"; getTableId = $(this).attr('name');    split2();    }else{   alert("please enter value for time to add measurement");   }
 				}
 			);
