function recount() 
	{ 
	price=0; 
	var cprice = order.price.value
	var tprice=0;
	if (order.duration.value==1) tprice=cprice ; 
	else if (order.duration.value==5) tprice=cprice * 2.8; 
	tprice=order.quantity.value * tprice;
	tprice= Math.round(tprice);
	totalprice.innerHTML=tprice;
	} 
function validation()
	{
	with (order)
		{
		if (customer['0'].checked)
			{
			if (legal_bit['0'].checked)
				{
				if (!firstname.value)
				return showmsg('firstname')
				else if (!lastname.value)
				return showmsg('lastname')
				}
			else
				{
				if (!legal_name.value)
				return showmsg('legal_name')	
				}
			if (!email.value)
			showmsg('email')						
			else if (!password1.value)
			showmsg('password1')
			else if (!password2.value)
			showmsg('password2')
			else if (!city.value)
			showmsg('city')
			else if (!phone.value)
			showmsg('phone')	
			else if (!state.value)
			showmsg('state')
			else if (!postcode.value)
			showmsg('postcode')
			else if (!address.value)
			showmsg('address')		
			else if (!secret_question.value)
			showmsg('secret_question')		
			else if (!secret_answer.value)
			showmsg('secret_answer')	
			else if (!captcha.value)
			showmsg('captcha')	
			else if (password2.value != password1.value)
				{
				alert("Passwords do not match");
				order[password1].focus();
				//return false;
				}
			else if (password2.value.length < 8 )
				{
				alert("Password's length is less than 8 characters!");
				order[password1].focus();
				//return false;
				}								
			else
				{
				cnfOrder.href="#";
				submit();
				}
			}
		else
			{
			if (!loginhandle.value)
			showmsg('loginhandle')	
			else if (!loginpass.value)
			showmsg('loginpass')
			else
				{
				cnfOrder.href="#";
				submit();
				}		
			}
		}	
									
	}

function showmsg(field)
	{	
	alert("Please fill out form completely!");
	order[field].focus();
	//return false;
	}
function check_order_form()
	{
	if (order.customer['1'].checked)
	showform('old')
	if (order.legal_bit['1'].checked)
	showform('legal')	
	}
function showform(type)
	{	
	if (type=='old')
		{
		tblregister.style.display='none';
		tbllogin.style.display='';
		}
	else if (type=='new')
		{
		tbllogin.style.display='none';
		tblregister.style.display='';
		}
	else if (type=='person')
		{
		tbl_legal.style.display='none';
		tbl_person.style.display='';
		}
	else if (type=='legal')
		{
		tbl_person.style.display='none';
		tbl_legal.style.display='';
		}
	else if (type=='cc')
		{
		tblcc.style.display='';
		tblbank.style.display='none';
		}	
	else if (type=='bank')
		{
		tblcc.style.display='none';
		tblbank.style.display='';
		}							
	}
function formatCurrency(num) 
	{
	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)?'':'-') + num);
}
