{include file='form_ajax_list_input.inc.tpl'}

<script language="javascript" type="text/javascript">
{literal}


var ccounter = 1;

// ZUSATZ ZUM NORMALEM JS FORMCHECK
function validate_form_addon(dom){
	var alert_str = '';
	// WENN DOCUMENT_PRESENT DANN MUSS VALUE_OF_GOODS > 0 SEIN
	if(dom.elements['documents_present'].value == 1){
		value = dom.elements['value_of_goods'].value;
		vog = parseFloat(value);
		if(value == '' || vog == NaN){
			alert_str += YES_JS_ERROR_DOCUMENTS_PRESENT;
		}
		if(vog == 0){
			alert_str += YES_JS_ERROR_DOCUMENTS_PRESENT;
		}
	}
	// WENN TRANSPORTART LUFTFRACHT, DANN PRUEFEN OB TRANSPORTCODE ALPHANUMERISCH
	// IM FORMAT AAA-
	if(dom.elements['transport_types_id'].value == 0){
		code = dom.elements['transport_types_code'].value;
		code_valid = true;
		if(code.length<4){
			code_valid = false;
		}
		if(code_valid){
			var illegalChars = /[^A-Za-z0-9\-]/;
			// allow only letters, numbers, and underscores
			if (illegalChars.test(code)) {
				code_valid = false;
			}
		}
		if(code_valid){
			var separator = '-';
			if (code.indexOf(separator)!=3){
			   code_valid = false;
			}
		}
		if(!code_valid){
			if(alert_str.length > 0) alert_str += '<br /><br />';
			alert_str += YES_JS_ERROR_TRANSPORT_TYPE_AIRLINE;
		}
	}
	if(alert_str.length > 0)
		return "<br /><br />"+alert_str;
	else
		return '';
}

var scolcounter = 1;
function moreFieldsShipCollies() {
	scolcounter++;
	var newFields = document.getElementById('ship_collies_readroot').cloneNode(true);
	newFields.id = '';
	newFields.style.display = 'block';
	var newField = newFields.childNodes;
	var insertHere = document.getElementById('ship_collies_writeroot');
	insertHere.parentNode.insertBefore(newFields,insertHere);
}

var scostscolcounter = 1;
function moreFieldsShipCosts() {
	scostscolcounter++;
	var newFields = document.getElementById('ship_costs_readroot').cloneNode(true);
	newFields.id = '';
	newFields.style.display = 'block';
	var newField = newFields.childNodes;
	var insertHere = document.getElementById('ship_costs_writeroot');
	insertHere.parentNode.insertBefore(newFields,insertHere);
}

function _page_load(){
	{/literal}
{if $MODE == 'add'}
	// AKTIVIEREN WENN SCHIFFSKOSTEN WIEDER AKTIV
	moreFieldsShipCosts();
	moreFieldsShipCollies();
{/if}
	
	{literal}
}

window.onload = _page_load;

{/literal}
</script>

{if $MODE != 'view'}

{include file='form_validator_view.inc.tpl'}

{/if}



{if $PAGE_MENU}
<div style="padding:8px;padding-left:0px;">{$PAGE_MENU}</div>
{/if}

{if $PAGE_TITLE}
<div id="page_title">{$PAGE_TITLE}</div>
{/if}

{if $MODE != 'view'}


{if $FORM_INPUT_ERRORS}<span class="dbFormError">{$FORM_INPUT_ERRORS}</span>{/if}

<div id="dbform_div">
{$FORM}{$action}
	<div id="dbform_head">{$REQUIRED_INTRO}</div>
{foreach from=$fields item=field}
	{if $field.index and $MODE != 'add'}
		{$field.input}
	{/if}

	{if $field.group_id == 'main'}
	
		{include file='form_field.inc.tpl'}
	
	{/if}
	{if $field.type == 'hidden' and !$field.view_hidden_field}
		{$field.input}
	{/if}
	
{/foreach}

{* ERWEITERBARE SCHIFF-KOLLIES - NUR IM ADD MODE *}
{if $MODE == 'add'}
	<div id="dbform_row_subgroup">
	{$SUBGROUP_COLLIES}
	</div>

<span id="ship_collies_writeroot"></span>
<input class="dbforminput" type="button" id="more_fields_ship_collies" value="{$TEXT_ADD_ENTRY}" onclick="moreFieldsShipCollies();" />
{/if}

{* ERWEITERBARE SCHIFF-KOSTEN - NUR IM ADD MODE *}
{if $MODE == 'add'}
	<div id="dbform_row_subgroup">
	{$SUBGROUP_COSTS}
	</div>

<span id="ship_costs_writeroot"></span>
<input class="dbforminput" type="button" id="more_fields_ship_costs" value="{$TEXT_ADD_ENTRY}" onclick="moreFieldsShipCosts();" />
{/if}


	<div id="dbform_row_save">{$SAVE_BUTTON}</div>
	<div id="dbform_head" style="width:1000px;">{$REQUIRED_INTRO}</div>
</form>
</div>

{* ERWEITERBARE SCHIFF-KOLLIES - NUR IM ADD MODE *}
{if $MODE == 'add'}

<div id="ship_collies_readroot" style="display:none;">

{foreach from=$fields item=field}
		{if $field.group_id == 'sub4'}

			{include file='form_field.inc.tpl'}

		{/if}

{/foreach}
	<input class="dbforminput" type="button" id="remove_field" value="{$TEXT_REMOVE_ENTRY}" onclick="this.parentNode.parentNode.removeChild(this.parentNode);" />
</div>

{/if}

{* ENDE ERWEITERBARE SCHIFF-KOLLIES *}

{* ERWEITERBARE SCHIFF-KOSTEN - NUR IM ADD MODE *}
{if $MODE == 'add'}

<div id="ship_costs_readroot" style="display:none;">

{foreach from=$fields item=field}
		{if $field.group_id == 'sub3'}

			{include file='form_field.inc.tpl'}

		{/if}

{/foreach}
	<input class="dbforminput" type="button" id="remove_field" value="{$TEXT_REMOVE_ENTRY}" onclick="this.parentNode.parentNode.removeChild(this.parentNode);" />
</div>

{/if}

{* ENDE ERWEITERBARE SCHIFF-KOSTEN *}






<script language="javascript" type="text/javascript">
{literal}
processDBF_DISPLAY();
{/literal}
</script>




{*
/*---------------------------------------------------------------------------
END IF NOT VIEW MODE
---------------------------------------------------------------------------*/
*}

{else}

{*
/*---------------------------------------------------------------------------
START VIEW MODE
---------------------------------------------------------------------------*/
*}
<table class="dbFormTable" cellspacing="0">

{foreach from=$fields item=field key=k}
	{if $field.type != 'hidden' and !$field.index}
<tr class="dbFormRow">
	<td class="dbFormContentTitle" valign="top"><b>{if $field.title != ''}{$field.title}{else}{$field.name}{/if}</b></td>
	<td class="dbFormContentValue" valign="top">
		{if $field.type == 'datetime'}
			{$field.value|date_format:"$date_format"}
		{else}
			{$field.value}
		{/if}
		&nbsp;
	</td>
</tr>
	{/if}
	
{/foreach}
</table>

{*
/*---------------------------------------------------------------------------
END VIEW MODE
---------------------------------------------------------------------------*/
*}
{/if}

