{extends file=$element.methods->getTemplatePath('generalClone')}

{*** NOTE: values should always be set to 0 or to default values. The actual element values are handled by JS  ***}
{block name=input append}
	<div>
		<input type="text"
			{if $element.style.CSSClass}
				class="{$element.style.CSSClass}"
			{/if}
			name="{$element.name}[.:id:.][code]"
			id="{$element.id}_.:id:.__code_"
			value=""

			{if $element.disabled}
				disabled="disabled"
			{/if}

			{if $element.methods->getCodeMaxlength()}
				maxlength="{$element.methods->getCodeMaxlength()}"
			{/if}

			style="{if $element.style.width} width:{$element.style.width*0.3}px;{/if}"
		/>

		<input type="text"
			{if $element.style.CSSClass}
				class="{$element.style.CSSClass}"
			{/if}
			name="{$element.name}[.:id:.][value]"
			id="{$element.id}_.:id:.__value_"
			value=""

			{if $element.disabled}
				disabled="disabled"
			{/if}

			style="{if $element.style.width} width:{$element.style.width*0.7-10}px;{/if}"
		/>

	</div>

{/block}

<script type="text/javascript">
	{*** NOTE: dont use single quotes(') in the script as there are some replacements automatically made on the main template ***}

	{block name=script prepend}

		{function name=onChange_clonedKeyValue}
		{/function}

		{function name=onClone_clonedKeyValue}
			{*** only initialize the js stuff if the element is not disabled ***}
			{*if !$element.disabled}
				_inputValidator.createOnLoad("{$element.id}_.:id:.__code_", "string", { "maxLength":"1" });
			{/if*}

			{*** this is used by the generalClone.tpl to initialize and set field values ***}
			{*** NOTE: item is set when we're creating an element with predefined values (ex: on page load, when filling pre-existent elements) ***}
			if(item){
				$("{$element.id}_.:id:.__code_").value = item.code;
				$("{$element.id}_.:id:.__value_").value = item.value;
			}
		{/function}

		{call name='onChange_clonedKeyValue' assign=onChange_output}
		{call name='onClone_clonedKeyValue' assign=onClone_output}
	{/block}
</script>
