

	$(document).ready(function() {
  
  
  // accordion functions
//	var accordion = $("#stepForm").accordion(); 
//	var current = 0;
	
/*	$.validator.addMethod("pageRequired", function(value, element) {
		var $element = $(element)
		function match(index) {
			return current == index && $(element).parents("#sf" + (index + 1)).length;
		}
		if (match(0) || match(1) || match(2)) {
			return !this.optional(element);
		}
		return "dependency-mismatch";
	}, $.validator.messages.required)
	
	var v = $("#cmaForm").validate({
		errorClass: "warning",
		onkeyup: false,
		onblur: false,
		submitHandler: function() {
			alert("Submitted, thanks!");
		}
	});
	*/
	// back buttons do not need to run validation
/*	$("#sf2 .prevbutton").click(function(){
		accordion.accordion("activate", 0);
		current = 0;
	}); 
	$("#sf3 .prevbutton").click(function(){
		accordion.accordion("activate", 1);
		current = 1;
	}); 
	// these buttons all run the validation, overridden by specific targets above
	$(".open2").click(function() {
	  if (v.form()) {
	    accordion.accordion("activate", 2);
	    current = 2;
	  }
	});
	$(".open1").click(function() {
	  if (v.form()) {
	    accordion.accordion("activate", 1);
	    current = 1;
	  }
	});
	$(".open0").click(function() {
	  if (v.form()) {
	    accordion.accordion("activate", 0);
	    current = 0;
	  }
	});*/
/* 	  alert('hello');
*/
  
 var value = 'Customer';
 var value2 = '';
 var terms_prefix = 'Agreement\n=========\nI, ';
 var terms_tween = ' ';
 var terms_suffix = ', apply for a Diners Club Card with PIN (if applicable) and confirm that I am at least 18 years of age and that the information provided in this application/agreement is true and correct.\nI have read and agree to be bound by the Terms and Conditions on which the Card is issued and is to be used, which form part of this agreement, and any amendments from time to time.\n\nI will be liable for all charges arising from the use of or relating to the Diners Club Card(s) issued to me. I will also be liable for any charges arising from the use of or relating to any Diners Club Card(s) issued to supplementary applicant(s).\n\nI understand that Diners Club (NZ) Limited may from time to time set credit limits on any Diners Club Card(s) issued to me or at my request and that such limits and any alterations to such limits will be advised to me.\n\nI agree that Diners Club may provide any notices or information related to this agreement in an electronic form including, without limitation, by email.\n\nI agree that this agreement is conditional upon Diners Club being satisfied with the results of identity and credit checks that will be carried out following receipt of this agreement. Diners Club may cancel this agreement by written notice to me if it is not satisfied with those results.\n\nPersonal Information\n====================\nI/We agree that all information (including personal information) obtained in respect of this agreement will be held by Diners Club and may be provided by Diners Club to any related company.\n\nDiners Club and related companies may use any of that information to offer or advise me/us of any of their products and services (including offers or advice by electronic message to me/us at my/our last known email address) or for credit reference or default purposes.\n\nDiners Club may obtain from or disclose to any third party any personal information relating to me/us.\n\nI/We acknowledge that I/We have the right to access and correct any personal information held by Diners Club or a related company.\n\nI/We agree that this agreement or any reproduction of it may be produced as evidence of my/our application for the Diners Club Card, my/our agreement to be bound by the Terms and Conditions and my/our acknowledgement in respect of the use of my/our personal information.';


$("#surname").blur(function () {
      var value2 = $(this).val();
	  var value = $("#first_name").val();
	  var newContent = terms_prefix + value + terms_tween + value2 + terms_suffix;

      $("#formvalue").empty();
	  $("#formvalue").html(newContent);
    }).blur();
/*var newContent = "Agreement\n=========\nI, "+value+" "+value2+", apply for a Diners Club Card with PIN (if applicable) and confirm that I am at least 18 years of age and that the information provided in this application/agreement is true and correct.

I have read and agree to be bound by the Terms and Conditions on which the Card is issued and is to be used, which form part of this agreement, and any amendments from time to time.

I will be liable for all charges arising from the use of or relating to the Diners Club Card(s) issued to me. I will also be liable for any charges arising from the use of or relating to any Diners Club Card(s) issued to supplementary applicant(s).

I understand that Diners Club (NZ) Limited may from time to time set credit limits on any Diners Club Card(s) issued to me or at my request and that such limits and any alterations to such limits will be advised to me.

I agree that Diners Club may provide any notices or information related to this agreement in an electronic form including, without limitation, by email.

I agree that this agreement is conditional upon Diners Club being satisfied with the results of identity and credit checks that will be carried out following receipt of this agreement. Diners Club may cancel this agreement by written notice to me if it is not satisfied with those results.

Personal Information
====================
I/We agree that all information (including personal information) obtained in respect of this agreement will be held by Diners Club and may be provided by Diners Club to any related company.

Diners Club and related companies may use any of that information to offer or advise me/us of any of their products and services (including offers or advice by electronic message to me/us at my/our last known email address) or for credit reference or default purposes.

Diners Club may obtain from or disclose to any third party any personal information relating to me/us.

I/We acknowledge that I/We have the right to access and correct any personal information held by Diners Club or a related company.

I/We agree that this agreement or any reproduction of it may be produced as evidence of my/our application for the Diners Club Card, my/our agreement to be bound by the Terms and Conditions and my/our acknowledgement in respect of the use of my/our personal information.";*/



/*$("#surname").keyup(function () {
      var value = $(this).val();
	  var value2 = $("#first_name").val();
     
  $("#formvalue").html('hello');
*/


//$('#formvalue').replaceWith(newContent);

//    }).keyup();





  
  
   $("#fulltime_box").hide();
    $("#self_employed_box").hide();
	 $("#unemployed_box").hide();
	  $("#other_employment_box").hide();
  
  $.viewEmployment = {
    '0' : $([]),
    'employed_fulltime' : $('#fulltime_box'),
    'employed_parttime' : $('#fulltime_box'),
    'self_employed' : $('#self_employed_box'),
	'unemployed' : $('#unemployed_box'),
	'student' : $('#unemployed_box'),
	'retired' : $('#unemployed_box'),
	'homemaker' : $('#unemployed_box'),
	'other_employment' : $('#other_employment_box')
  };

  $('#employment_select').change(function() {
    // hide all
    $.each($.viewEmployment, function() { this.hide(); });
    // show current
    $.viewEmployment[$(this).val()].show();
  });
	

});
	
	


