function limitChar(p_form_element, p_limitCount, p_info)
{
	var text = $('#'+p_form_element).val();	
	var textlength = text.length;
	if(textlength > p_limitCount) {
		$('#' + p_info).html('<strong>Limit reached.</strong>');
		$('#'+p_form_element).val(text.substr(0,p_limitCount));
		return false;
	} else{
		$('#' + p_info).html('<strong>' + (p_limitCount - textlength) +'</strong> chars remaining');
		return true;
	}
}

function toggleManufacturer() { 
	if ($('#manufacturerNotListed').is(':checked')) { 
		$('#MANUFACTURER').val(0);
		$('#newManufacturer').show();
	} else { 
		$('#newManufacturer').hide();
		$('#NEW_MANUFACTURER').val('');
	}
}

function toggleIndustry() {
	var industryType = $('#TYPE option:selected').text().substr(0,3).toUpperCase();
	$('#INDUSTRY').val(industryType);
	if (industryType == 'COM')
	{
		$('#commercialData').show();
		$('#residentialData').hide();
		$('#residentialAssociation').hide();
	}
	else
	{
		$('#commercialData').hide();
		$('#residentialData').show();
		$('#residentialAssociation').show();
	}
}

function showStateProvinceTerritory(p_countryCode) { 

	switch (p_countryCode) { 

		case 'US':
			$('#state').show();
			$('#province').hide();
			$('#PROVINCE_CODE').val(0);
			$('#territory').hide();
			$('#TERRITORY').val('');
			break;
		case 'CA':
			$('#state').hide();
			$('#STATE_CODE').val(0);
			$('#province').show();
			$('#territory').hide();
			$('#TERRITORY').val('');
			break;
		default:
			$('#state').hide();
			$('#STATE_CODE').val(0);
			$('#province').hide();
			$('#PROVINCE_CODE').val(0);
			$('#territory').show();
			break;
	}

}

$(function(){
	$('#QUICK_DETAIL').keyup(function(){
		limitChar('QUICK_DETAIL', 250, 'charCount');
})
});
