function isVatReg()
{
 $(document).ready(function(){

  if(($('#vatReg').attr("checked")) == true)
  {
     $("#vatNumber").slideDown("normal");
  }
  else
  {
    $("#vatNumber").slideUp("normal");
  }
  
 });
}

function isVatRegCheckBox()
{
 alert ();
 
 $(document).ready(function(){
  if($('#vatReg').val() == 1)
  {
    $("#vatNumCont").fadeIn("normal");
  }
  else
  {
    $("#vatNumCont").fadeOut("normal");
  }
 });
}

function  hideBox(id)
{
$(".notice").fadeOut(500);
}

function calcInvoice(cont)
{

var jqueryObject = $(cont).parent().next().html("<label class = 'notice' id = 'notice'><b>Costing Breakdown Updated</b></label>");

setTimeout("hideBox('notice')",2000);

/*Calculate Cost variables*/
var cost = $("#quantity").val()*2.20;
var design;

switch($("#design").val())
{
 case "1":
  design = 950;
 break;
 case "2":
  design = 1250;
 break;
 case "3":
  design = 0;
 break;
 case "4":
  design = 0;
 break;
 default:
  design = 0;
 break;
}

var totalExclVat = cost+design+120;

/*Apply values in HTML invoice*/
$("#quantityCost").html(formatCurrency(cost));
$("#quantityStr").html(formatNumber($("#quantity").val())+" @ R 2.20 /Customer");
 
$("#designCost").html(formatCurrency(design));
$("#designStr").html($("#design > :nth-child("+$("#design").val()+")").html())

$("#totalExclVat").html(formatCurrency(totalExclVat));
$("#vat").html(formatCurrency(totalExclVat*0.14));
$("#total").html(formatCurrency(totalExclVat*1.14));
$("#costingBreakdown").effect("highlight", {}, 1000);
}

function formatCurrency(strValue)
{
	strValue = strValue.toString().replace(/\R|\,/g,'');
	dblValue = parseFloat(strValue);

	blnSign = (dblValue == (dblValue = Math.abs(dblValue)));
	dblValue = Math.floor(dblValue*100+0.50000000001);
	intCents = dblValue%100;
	strCents = intCents.toString();
	dblValue = Math.floor(dblValue/100).toString();
	if(intCents<10)
		strCents = "0" + strCents;
	for (var i = 0; i < Math.floor((dblValue.length-(1+i))/3); i++)
		dblValue = dblValue.substring(0,dblValue.length-(4*i+3))+' '+
		dblValue.substring(dblValue.length-(4*i+3));
	return (((blnSign)?'':'-') + 'R ' + dblValue + '.' + strCents);
}

function formatNumber(strValue)
{
	strValue = strValue.toString().replace(/\R|\,/g,'');
	dblValue = parseFloat(strValue);

	blnSign = (dblValue == (dblValue = Math.abs(dblValue)));
	dblValue = Math.floor(dblValue*100+0.50000000001);
	intCents = dblValue%100;
	strCents = intCents.toString();
	dblValue = Math.floor(dblValue/100).toString();
	if(intCents<10)
		strCents = "0" + strCents;
	for (var i = 0; i < Math.floor((dblValue.length-(1+i))/3); i++)
		dblValue = dblValue.substring(0,dblValue.length-(4*i+3))+' '+
		dblValue.substring(dblValue.length-(4*i+3));
	return (((blnSign)?'':'-')  + dblValue);
}