function limitText(limitField, limitCount, limitNum) {
	if (limitField.value.length > limitNum) {
		limitField.value = limitField.value.substring(0, limitNum);
	} else {
		limitCount.value = limitNum - limitField.value.length;
	}
}

function whywant_keypress() {
	limitText(document.getElementById('whywant'), document.getElementById('whywant_countdown'),1200); 
}

function doglist_keypress() {
    limitText(document.getElementById('doglist'), document.getElementById('doglist_countdown'),360);
}

function otherdogs_keypress() {
    limitText(document.getElementById('otherdogs'), document.getElementById('otherdogs_countdown'),360);
}

function otheranimals_keypress() {
    limitText(document.getElementById('otheranimals'), document.getElementById('otheranimals_countdown'),360);
}

function addinfo_keypress() {
	limitText(document.getElementById('addinfo'), document.getElementById('addinfo_countdown'),1200);
}

function doMain() {
	whywant_keypress();
	doglist_keypress();
	otherdogs_keypress();
    otheranimals_keypress();
    addinfo_keypress();
    
	document.getElementById('whywant').onkeydown = function() { whywant_keypress(); };
	document.getElementById('whywant').onkeyup   = function() { whywant_keypress(); };
	
	document.getElementById('doglist').onkeydown = function() { doglist_keypress(); };
	document.getElementById('doglist').onkeyup   = function() { doglist_keypress(); };

	document.getElementById('otherdogs').onkeydown = function() { otherdogs_keypress(); };
	document.getElementById('otherdogs').onkeyup   = function() { otherdogs_keypress(); };

	document.getElementById('otheranimals').onkeydown = function() { otheranimals_keypress(); };
	document.getElementById('otheranimals').onkeyup   = function() { otheranimals_keypress(); };

	document.getElementById('addinfo').onkeydown = function() { addinfo_keypress(); };
	document.getElementById('addinfo').onkeyup   = function() { addinfo_keypress(); };
}

