// JavaScript Document
function Calculate()
{
	var total = 0;
	var w =	document.getElementById('cf2_field_45').value; // LOC_weeky
	if (w == parseFloat(w))
	{
		total += parseFloat(w);
	}
	var f = document.getElementById('cf2_field_46').value; // LOC_fortnightly
	if (f == parseFloat(f))
	{
		total += parseFloat(f);
	}
	var m = document.getElementById('cf2_field_47').value; // LOC_monthly
	if (m == parseFloat(m))
	{
		total += parseFloat(m);
	}
	total = total * 1.2;
    var output = CurrencyFormat(total);
	document.getElementById('result').innerHTML = '<p>Your letter of credit total is $<span class="amount">' + output + '</span></p>';
    document.getElementById('cf2_field_49').value = output;
	return false;
}

function CurrencyFormat(amount)
{
	var i = parseFloat(amount);
	if(isNaN(i)) { i = 0.00; }
	var minus = '';
	if(i < 0) { minus = '-'; }
	i = Math.abs(i);
	i = parseInt((i + .005) * 100);
	i = i / 100;
	s = new String(i);
	if(s.indexOf('.') < 0) { s += '.00'; }
	if(s.indexOf('.') == (s.length - 2)) { s += '0'; }
	s = minus + s;
	return s;
}

/*
function AssignHiddenFields()
{
    var part1 = document.getElementById('phone-1-1').value;
    var part2 = document.getElementById('phone-1-2').value;
    var part3 = document.getElementById('phone-1-3').value;
    var result = part1 + part2 + part3;
    document.getElementById('cf2_field_12').value = result;
    
    part1 = document.getElementById('fax-1-1').value;
    part2 = document.getElementById('fax-1-2').value;
    part3 = document.getElementById('fax-1-3').value;
    result = part1 + part2 + part3;
    document.getElementById('cf2_field_14').value = result;
	
	part1 = document.getElementById('mob-1-1').value;
    part2 = document.getElementById('mob-1-2').value;
    result = part1 + part2;
    document.getElementById('cf2_field_16').value = result;
    
    part1 = document.getElementById('phone-2-1').value;
    part2 = document.getElementById('phone-2-2').value;
    part3 = document.getElementById('phone-2-3').value;
    result = part1 + part2 + part3;
    document.getElementById('cf2_field_22').value = result;
    
    part1 = document.getElementById('fax-2-1').value;
    part2 = document.getElementById('fax-2-2').value;
    part3 = document.getElementById('fax-2-3').value;
    result = part1 + part2 + part3;
    document.getElementById('cf2_field_24').value = result;
	
	part1 = document.getElementById('mob-2-1').value;
    part2 = document.getElementById('mob-2-2').value;
    result = part1 + part2;
    document.getElementById('cf2_field_26').value = result;
    
    part1 = document.getElementById('Bank-Account-Number-1').value;
    part2 = document.getElementById('Bank-Account-Number-2').value;
    part3 = document.getElementById('Bank-Account-Number-3').value;
    var part4 = document.getElementById('Bank-Account-Number-4').value;
    result = part1 + part2 + part3 + part4;
    document.getElementById('cf2_field_38').value = result;
    
    
}

function init()
{
    document.getElementById('cf2_field_64').onclick = AssignHiddenFields;    
    
}

window.onload = init;

*/
// Sign-Up Form jQuery

$(document).ready(function(){
	$(function() {
			   
	// Append html elements to sign-up form
	 
	$('li#li-2-5').append('<span class="form-note">Find my <a href="http://www.nzpost.co.nz/Cultures/en-NZ/OnlineTools/PostCodeFinder" target="_blank">Post Code</a></span>');
	
	$('li#li-2-6').prepend('<span class="reqtxt">Required</span>');
	
	$('li#li-2-6').append('<span class="form-note">Same as Postal Address</span>');
	
	$('li#li-2-32').append('<span class="form-note"><a href="javascript:void(0);" class="small-large-help-show" title="help">Help</a></span>');
	
	$('li#li-2-34').append('<span class="form-note"><a href="javascript:void(0);" class="acc-help-show" title="help">Help</a></span>');
	
	$('li#li-2-64').prepend('<span class="reqtxt">Required</span>');
	
	$('li#li-2-64').append('<span class="form-note"><a href="javascript:void(0);" class="terms-conditions-show" title="Terms and Conditions">Terms and Conditions</a>.</span>');
	
	$('form#cforms2form p.cf-sb').append('<span class="form-note">Your information will be sent to SmartPayroll.<br />Confirmation will be sent to your email.</span>');
	
	// Hide all 
	$('.help-pop-up').hide();

	// Show pop-up on click
	$('a.small-large-help-show').click(function() {
  	$('div#small-large').show('fast');
  	return false;
  	});	
	
	$('a.acc-help-show').click(function() {
  	$('div#acc').show('fast');
  	return false;
  	});	
	
	$('a.terms-conditions-show').click(function() {
  	$('div#terms-conditions').show('fast');
  	return false;
  	});	
	
	// Hide pop-up on click
	$('#small-large a.pop-up-close').click(function() {
  	$('div#small-large').hide('fast');
  	return false;
  	});	
	
	$('#acc a.pop-up-close').click(function() {
  	$('div#acc').hide('fast');
  	return false;
  	});	
	
	$('#terms-conditions a.pop-up-close').click(function() {
  	$('div#terms-conditions').hide('fast');
  	return false;
  	});	
	
    // Add onclick handler to checkbox w/id checkme
    $("#cf2_field_6").click(function(){
    // If checked
    if ($("#cf2_field_6").is(":checked"))
    {
    //hide the hidden div
    $("li#li-2-7").hide("fast");
    }
	// if unchecked
	else
	{     
    //otherwise, hide it
	$("li#li-2-7").show("fast");
    }
    
    });
	
	});
	
});






