var cAccount = new function () {
	var newPassword = false;
	var seperateDelivery;
	var seperateDeliveryRows;
	
	this.init = function() {
		cAccount.initSeperateDeliveryAddress();
	};
	
	this.orderListBehaviour = function(e) {
		if (e.type = "mouseover") {
			$(this).parent().find("td").addClass("active");
		}
		else if (e.type = "mouseout") {
			$(this).parent().find("td").removeClass("active");
		}
	};
	
	this.initSeperateDeliveryAddress = function() {
		cAccount.seperateDeliveryRows = $("form.update_customer tr.delivery_address");
		cAccount.seperateDelivery = ($("input#separate_delivery_address").is(":checked"));

		if (cAccount.seperateDelivery) {
			cAccount.seperateDeliveryRows.show();
			cAccount.seperateDeliveryRows.find(":text").addClass("required");
		}
		else {
			cAccount.seperateDeliveryRows.hide();
			cAccount.seperateDeliveryRows.find(":text").removeClass("required");
		}
	}

	this.toggleSeperateDeliveryAddress = function() {
		if (!cAccount.seperateDelivery) {
			$(this).attr("checked", "checked");
			cAccount.seperateDeliveryRows.show();
			cAccount.seperateDeliveryRows.find(":text:first").focus();
			cAccount.seperateDeliveryRows.find(":text").addClass("required");
		}
		else {
			$(this).removeAttr("checked");
			cAccount.seperateDeliveryRows.hide();
			cAccount.seperateDeliveryRows.find(":text").removeClass("required");
		}

		cAccount.seperateDelivery = !cAccount.seperateDelivery;
	};
	
	this.toggleNewPassword = function() {
		var newPasswordRows = $("form.update_customer tr.new_password");

		if (!cAccount.newPassword) {
			$(this).addClass("checked");
			newPasswordRows.show();
			newPasswordRows.find("input#new_password").focus();
			newPasswordRows.find(":password").val("").addClass("required");
		}
		else {
			$(this).removeClass("checked");
			newPasswordRows.hide();
			newPasswordRows.find(":password").val("").removeClass("required");
		}

		cAccount.newPassword = !cAccount.newPassword;
		return false;
	};
	
	this.emailUsernameBehaviour = function() {
        $('input#username').val($(this).val());
	};

}
