dojo.addOnLoad(function(){
    
	var firstName = 
		dojo.byId("atg_b2cblueprint_paymentInfoAddNewCardFirstName") || 
		dojo.byId("atg_b2cblueprint_profileMyInfoEditFirstName") ||
		dojo.byId("atg_b2cblueprint_registerFirstName") || 
		dojo.byId("atg_b2cblueprint_firstNameInput");
	
	
	var lastName = 
		dojo.byId("atg_b2cblueprint_paymentInfoAddNewCardLastName") ||
		dojo.byId("atg_b2cblueprint_profileMyInfoEditLastName") ||
		dojo.byId("atg_b2cblueprint_lastNameInput") ||
		dojo.byId("atg_b2cblueprint_registerLastName");
	
	if (firstName) {
		countChar(firstName);
		dojo.event.connect(firstName, "onkeyup", function(){
			countChar(firstName);
		});
	}
	
	if (lastName) {
		countChar(lastName);
		dojo.event.connect(lastName, "onkeyup", function(){
			countChar(lastName);
		});
	}
	
	function countChar(inputObj){
		var maxCount = 30;
		var first = firstName.value.length;
		var last = lastName.value.length;
		var total = first + last;
		var numCharRemain = maxCount - total;
		var counter = dojo.byId("nameGrp_count");
		
		if (numCharRemain >= 0) 
			counter.value = numCharRemain;
		else {
			inputObj.value=inputObj.value.substr(0,(inputObj.value.length-1));
			counter.value = 0;
		}
	}
	
  	if (company=dojo.byId("atg_b2cblueprint_companyNameInput")) {
     	company.setAttribute("size", "30");
		company.setAttribute("maxLength", "30");
	}
	
	if (address1=dojo.byId("lineone")) {
     	address1.setAttribute("size", "30");
		address1.setAttribute("maxLength", "50");
	}
	
	if (address2=dojo.byId("linetwo")) {
     	address2.setAttribute("size", "30");
		address2.setAttribute("maxLength", "50");
	}
	
	if (city=dojo.byId("city")) {
     	city.setAttribute("size", "30");
		city.setAttribute("maxLength", "30");
	}
	
	if (zip=dojo.byId("zip")) {
     	zip.setAttribute("size", "10");
		zip.setAttribute("maxLength", "20");
	}
	
	if (tel=dojo.byId("atg_b2cblueprint_telephoneInput")) {
     	tel.setAttribute("size", "20");
		tel.setAttribute("maxLength", "20");
	}
	
	if (mediaCode=dojo.byId("mediaCode")) {
     	mediaCode.setAttribute("size", "10");
		mediaCode.setAttribute("maxLength", "10");
	}
	
	if (po=dojo.byId("po_number")) {
     	po.setAttribute("size", "20");
		po.setAttribute("maxLength", "20");
	}
	
	if (customerCode=dojo.byId("customerCode")) {
     	customerCode.setAttribute("size", "20");
		customerCode.setAttribute("maxLength", "20");
	}
	
	if (customerNotes=dojo.byId("customerNotes")) {
		customerNotes.setAttribute("maxLength", "500");
	}
});