Index: schedule/function/SplitDelete.php
===================================================================
--- schedule/function/SplitDelete.php	(revision 16913)
+++ schedule/function/SplitDelete.php	(revision 16918)
@@ -1,9 +1,11 @@
 <script type="text/javascript">
  $(document).ready(function(){
- var name='';
-var value='';
+ var name;
+var value;
  var timeValue;
 var meas;
 var meas2;
+var x=0;
+var measurement=0;
 var getTableId;
 var is=0;
@@ -282,4 +284,5 @@
 getTableId =get;
 name="name"; value = '#table2';
+measurement = 0;
 						  meas = "class"; meas2 = "time";  //getTableId = $(this).attr('name'); 
 						split2();    }else{   alert("please enter value for time to add measurement");   }
@@ -343,5 +346,5 @@
 					aa = $(this).val();
 					});
-			if(aa != ""){ timeValue =aa; name="name"; value=$(this).attr('name');  meas = "hidden"; meas2 = true;  getTableId = $(this).attr('name');  split2();    }else{   alert("please enter value for time to add measurement");   }
+			if(aa != ""){ timeValue =aa; name="name"; value=$(this).attr('name'); measurement = 1; meas = "hidden"; meas2 = true;  getTableId = $(this).attr('name');  split2();    }else{   alert("please enter value for time to add measurement");   }
 
 				
@@ -462,5 +465,5 @@
 getTableId =get;
 name="name"; value = '#table1';
-						
+						measurement = 0;
   meas = "class"; meas2 = "time";  //getTableId = $(this).attr('name'); 
 split2();    }else{   alert("please enter value for time to add measurement");   }
@@ -525,5 +528,5 @@
 					});
 			
-			if(aa != ""){ timeValue = aa; name="name"; value="#table1"; meas = "hidden"; meas2 = true;  getTableId = $(this).attr('name'); split2();    }else{   alert("please enter value for time to add measurement");   }
+			if(aa != ""){ timeValue = aa; name="name"; value="#table1"; measurement=1; meas = "hidden"; meas2 = true;  getTableId = $(this).attr('name'); split2();    }else{   alert("please enter value for time to add measurement");   }
 
 				
@@ -577,5 +580,5 @@
 			table.setAttribute('id',"table"+cnt);
 			table.setAttribute('width','100%');
-			table.setAttribute(name,value);
+			if(measurement==1){ table.setAttribute(name,value); }
 		var tr = document.createElement('tr');
 			tr.setAttribute('id','');
@@ -604,5 +607,5 @@
 			button.setAttribute('id','btnAddTime'),
 			button.setAttribute(meas,meas2),
-			button.setAttribute('name','#table'+cnt),
+			button.setAttribute('name','table'+cnt),
 			
 			button.onclick=function(){
@@ -611,5 +614,7 @@
 					aa = $(this).val();
 					});
-					bb =  $(this).closest('table').attr('name'); 
+					
+					if(value == 'undefined'){  bb =  $(this).closest('table').attr('name'); }else{
+					 bb = value; }
 			if(aa != ""){var splitting = aa.split(':'); var add = 01;   
 
@@ -630,5 +635,5 @@
 					var s = 0; var	get;
 						var nn;
-						nn = bb;
+						nn = '#'+$(this).attr("name");
 				$("table").each(function() {
 				if($(this).attr("name")==nn){
@@ -645,5 +650,5 @@
 
 name="name"; value = bb;
-meas = "class"; meas2 = "time";  getTableId = get;   split1();    }else{   alert("please enter value for time to add measurement");   }
+meas = "class"; meas2 = "time";  getTableId = get; measurement =0;   split1();    }else{   alert("please enter value for time to add measurement");   }
 
 				
@@ -702,10 +707,24 @@
 			button.setAttribute('name','#table'+cnt),
 			button.onclick=function(){
-		var aa;
-		var bb;
+		var aa,cc=0;
+		var bb,dd;
 			$('div#TableHolder #table'+cnt+' #Time').each(function(){
 					aa = $(this).val();
+					
+					
+					
 					});
-		bb =  $(this).closest('table').attr('name'); 
+					 dd= $(this).attr('name');
+					//alert(dd);
+					if($('div#TableHolder '+dd+' #Time').is(':visible')){
+					cc=0;
+					//alert(cc);
+					}else{
+					cc=1;
+					}
+					//alert(value);
+					 x = 1;
+					if(meas2 == 'time' && measurement == 0 && cc != 1){  bb =  '#'+$(this).closest('table').attr('id'); }else{
+					 bb = value; } 
 			if(aa != "")
 			{ 
@@ -717,4 +736,6 @@
 				meas2 = true;
 				getTableId = $(this).attr('name'); 
+				//alert(getTableId);
+				measurement = 1;
 				split1();    
 			}
@@ -772,5 +793,5 @@
 			table.setAttribute('id',"table"+cnt);
 			table.setAttribute('width','100%');
-			table.setAttribute(name,value);
+				if(measurement==1){ table.setAttribute(name,value); }
 		var tr = document.createElement('tr');
 			tr.setAttribute('id','');
@@ -797,5 +818,5 @@
 			button.setAttribute('id','btnAddTime'),
 			button.setAttribute(meas,meas2),
-			button.setAttribute('name','#table'+cnt),
+			button.setAttribute('name','table'+cnt),
 			
 			button.onclick=function(){
@@ -804,5 +825,6 @@
 					aa = $(this).val();
 					});
-					bb =  $(this).closest('table').attr('name'); 
+						if(value == 'undefined'){  bb =  $(this).closest('table').attr('name'); }else{
+					 bb = value; }
 			if(aa != ""){ var splitting = aa.split(':'); var add = 01;   
 
@@ -835,5 +857,5 @@
 				});
 
-				name="name"; value=bb;		meas = "class"; meas2 = "time";   getTableId = get; split1();    }else{   alert("please enter value for time to add measurement");   }
+				name="name"; value=bb;	measurement=0;	meas = "class"; meas2 = "time";   getTableId = get; split1();    }else{   alert("please enter value for time to add measurement");   }
 
 				
@@ -890,15 +912,24 @@
 			button.setAttribute('type','button'),
 			button.setAttribute('value','[+]'),
-			button.setAttribute('id','btnAddTime'),
+			button.setAttribute('id','btnAddTimes'),
 			button.setAttribute('name','#table'+cnt),
 			button.onclick=function(){
 		
-			var aa;
-		var bb;
+			var aa,cc=0;
+		var bb,dd;
 			$('div#TableHolder #table'+cnt+' #Time').each(function(){
 					aa = $(this).val();
+					
 					});
-			
-						bb =  $(this).closest('table').attr('name'); 
+					dd= $(this).attr('name');
+					if($('div#TableHolder '+dd+' #Time').is(':visible')){
+					cc=0;
+					//alert(cc);
+					}else{
+					cc=1;
+					}
+			 x=1;
+						if(meas2 == 'time' && measurement == 0 && cc!=1){  bb =  '#'+$(this).closest('table').attr('id'); }else{
+					 bb = value; }
 					
 			if(aa != "")
@@ -911,4 +942,5 @@
 				meas2 = true;
 				getTableId = $(this).attr('name'); 
+				measurement =1;
 				split1();    
 			}
