function datediff()
{
	countdatediff(document.getElementById('jnowtime1').value,document.getElementById('jendtime1').value);
	var nowtime=parseInt(document.getElementById('jnowtime1').value)
	document.getElementById('jnowtime1').value=parseInt(nowtime)+1;
}

function countdatediff(str_start,str_end)
{
	var nseconds = str_end - str_start; // Number of seconds between the two dates
	
	
	var prendays = nseconds / 86400; // One day has 86400 seconds

	var ndays=parseInt(prendays);
	var ndays= ndays * 24;

	var nseconds = nseconds % 86400; // The remainder from the operation
	
	var nhours = (nseconds / 3600); // One hour has 3600 seconds
	
	var nhours=parseInt(nhours) + parseInt(ndays);
	
	var nseconds = nseconds % 3600;

	var nminutes = parseInt((nseconds / 60)); // One minute has 60 seconds, duh!
        

	var nseconds_m = nseconds % 60;

	var nminutes_m = parseInt((nseconds_m / 1)); // One minute has 60 seconds, duh!
	
	if ( nminutes == 0 && nhours > 0 )
	{
		nminutes = 59;
		nhours = nhours - 1;
		
	}
	

	if((''+nhours).length==1)
		{ var hrs='0'+nhours;	}
	else
		{ var hrs=nhours;	}
	
	if((''+nminutes).length==1)
		{ var minutes='0'+nminutes; }
	else
		{ var minutes=nminutes; }
		
	if((''+nseconds).length==1)
		{ var sec='0'+nminutes_m;	}
	else
		 { var sec=nseconds_m;}
		
	document.getElementById('hrs').innerHTML = hrs ;
	document.getElementById('min').innerHTML = minutes ;
	document.getElementById('sec').innerHTML = sec ;
	
	
		
}

if(document.getElementById('jnowtime1') && document.getElementById('jendtime1'))
{
	
	setInterval("datediff()",1000);
}
