function jsshow(id){
	el = document.getElementById(id);
	el.style.display ='block';
}

function jshide(id){
	el = document.getElementById(id);
	el.style.display ='none';
}

var dtimer,_dhour, _dminute,_dsecond;
function dealTimerSetup(dt){
	dtimer 		= dt;
	_dhour 		= document.getElementById('dealhour');
	_dminute 	= document.getElementById('dealminute');
	_dsecond 	= document.getElementById('dealsecond');
	
	dealTimer();
}

function dealTimer(){
	dhour = Math.floor(dtimer / 3600 );
	dminute = Math.floor((dtimer - (3600 * dhour)) / 60 );
	dsecond = dtimer - (dminute * 60 + dhour * 3600);
	
	_dhour.innerHTML = dealStrFormat(dhour);
	_dminute.innerHTML = dealStrFormat(dminute);
	_dsecond.innerHTML = dealStrFormat(dsecond);
	
	dtimer = dtimer - 1;
	if(dtimer >= 0) setTimeout('dealTimer()',1000);
}

function dealStrFormat(str){
	str = str + "";
	if(str.length > 1) return str;
	else return "0"+str;
}

var _punit, _pprice, _psubtotal, _punique, _ptotal;
function purchaseSetup(){
	_punit 		= document.getElementById('punit');
	_pprice 	= document.getElementById('pprice');
	_psubtotal 	= document.getElementById('psubtotal');
	_punique 	= document.getElementById('punique');
	_ptotal 	= document.getElementById('ptotal');
	
	purchaseMonitor();
}

function purchaseMonitor(){
	unit = 1 * _punit.value;
	if(unit == 0){
		unit = 1;
	}
	
	price =  1 * _pprice.value;	
	unique =  1 * _punique.value;
	
	subtotal = unit * price;
	total = subtotal + unique;
	_psubtotal.innerHTML = formatCurrency(subtotal);
	_ptotal.innerHTML = formatCurrency(total);
	
	setTimeout('purchaseMonitor()',100);
}

function formatCurrency(num) {
	currency_rate = 1;
	decimal_right = 2;
	num = num * currency_rate;
	num = num.toString().replace(/\$|\,/g,'');
	if(isNaN(num))
	num = "0";
	sign = (num == (num = Math.abs(num)));
	num = Math.floor(num*100+0.50000000001);
	cents = num%100;
	num = Math.floor(num/100).toString();
	if(cents<10)
	cents = "0" + cents;
	for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
	num = num.substring(0,num.length-(4*i+3))+'.'+
	num.substring(num.length-(4*i+3));
	return (((sign)?'':'-') + 'Rp ' + num + ',-');
}
