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

function countdatediff(str_start,str_end)
{
	var nseconds = str_end - str_start; // Number of seconds between the two dates
	if(parseInt(nseconds) < 0)
	{
	  
	  if(document.getElementById('blowoutpage').value == "home")
	   		var str= 'Blowout Sale Ended';
  	   else
	   		var str= 'Blowout Sale Ended';
	   
	   document.getElementById('CountDownPanel').innerHTML=str; 
  	   return;
	}
	
	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(document.getElementById('blowoutpage').value == "home")
		var str= ' Blowout Sale Ends In ';
  	else
		var str= ' Blowout Sale Ends In ';

	
	
	if((''+nhours).length==1)
		{ str=str+'0'+nhours+'H ';	}
	else
		{ str=str+nhours+'H ';	}
	
	if((''+nminutes).length==1)
		{ str=str+'0'+nminutes+'Min '; }
	else
		{ str=str+nminutes+'Min '; }
		
	if((''+nseconds).length==1)
		{ str=str+'0'+nminutes_m+'Sec ';	}
	else
		 { str=str+nseconds_m+'Sec ';}
		
	document.getElementById('CountDownPanel').innerHTML = str ;
		
}

if(document.getElementById('CountDownPanel') && document.getElementById('jnowtime') && document.getElementById('jendtime'))
{
	
	setInterval("datediff()",1000);
}
