function orderform_toggle(value) {
	formNumberPorationDiv = document.getElementById('form_number_portation');
	formNewNumberSeries = document.getElementById('form_new_number_series');

	formNumberPorationDiv.style.display = 'none';
	formNewNumberSeries.style.display = 'none';

	switch(value) {
		case 'portation':
			formNumberPorationDiv.style.display = 'block';
			break;

		case 'new_series':
			formNewNumberSeries.style.display = 'block';
			break;

	}
}

var portationLine = 1;
function addNumberPortationLine() {

	insertPoint = document.getElementById('form_number_portation_numbers');

	divPortationLine = document.createElement('div');
	divPortationLine.setAttribute('id', 'portation_line_' + portationLine);
	divPortationLine.setAttribute('class', 'clearfix');

	portationLineAnchor = document.createElement('a');
	portationLineAnchor.setAttribute('name', 'anchor_port_number_' + portationLine);

	pInputLine = document.createElement('p');

	label = document.createElement('label');
	label.setAttribute('for', 'port_number_ ' + portationLine);

	input = document.createElement('input');
	input.setAttribute('id', 'port_number_ ' + portationLine);
	input.setAttribute('name', 'port_number[]');
	input.setAttribute('type', 'text');
	input.setAttribute('size', '8');
	input.setAttribute('maxlength', '8');

	newLineLink = document.createElement('a');
	newLineLink.setAttribute('style', 'float: right');
	newLineLink.setAttribute('href', '#anchor_port_number_' + (portationLine));
	newLineLink.setAttribute('onclick', 'addNumberPortationLine();');
	newLineLink.setAttribute('class', 'icon_add');
	newLineLink.setAttribute('onmouseover', 'return overlib(\'Legg til flere telefonnummer\');')
	newLineLink.setAttribute('onmouseout', 'nd();');
	newLineLinkSpan = document.createElement('span');
	newLineLinkSpan.setAttribute('class', 'nodisplay');
	newLineLinkSpan.appendChild(document.createTextNode('Legg til enda et nummer'));
	newLineLink.appendChild(newLineLinkSpan);

	removeLineLink = document.createElement('a');
	removeLineLink.setAttribute('style', 'float: right');
	removeLineLink.setAttribute('href', '#anchor_port_number_' + (portationLine - 1));
	removeLineLink.setAttribute('onclick', 'removeNumberPortationLine(' + portationLine + ');');
	removeLineLink.setAttribute('class', 'icon_subtract');
	removeLineLink.setAttribute('onmouseover', 'return overlib(\'Fjern denne linjen\');')
	removeLineLink.setAttribute('onmouseout', 'nd();');
	removeLineLinkSpan = document.createElement('span');
	removeLineLinkSpan.setAttribute('class', 'nodisplay');
	removeLineLinkSpan.appendChild(document.createTextNode('Fjern denne linjen'));
	removeLineLink.appendChild(removeLineLinkSpan);

	label.appendChild(document.createTextNode('Nummer ' + (portationLine + 1) + ': '));
	label.appendChild(input);

	pInputLine.appendChild(label);
	pInputLine.appendChild(newLineLink);
	pInputLine.appendChild(removeLineLink);

	divPortationLine.appendChild(portationLineAnchor);
	divPortationLine.appendChild(pInputLine);

	insertPoint.appendChild(divPortationLine);

	input.focus();

	portationLine++;
}

function removeNumberPortationLine(lineNumber) {
	nd();
	insertPoint = document.getElementById('form_number_portation_numbers');
	divPortationLine = document.getElementById('portation_line_' + lineNumber);
	insertPoint.removeChild(divPortationLine);

	input = document.getElementById('port_number_ ' + (lineNumber - 1));
	input.focus();
}

var seriesLine = 1;
function addNumberseriesLine() {
	insertPoint = document.getElementById('form_new_number_series_numbers');

	fieldsetLine = document.createElement('fieldset');
	fieldsetLine.setAttribute('id', 'series_line_' + seriesLine);

	lineAnchor = document.createElement('a');
	lineAnchor.setAttribute('name', 'anchor_series_' + seriesLine);

	legend = document.createElement('legend');
	legend.appendChild(document.createTextNode((seriesLine + 1) + '. nummerserie'));

	fieldsetLine.appendChild(lineAnchor);
	fieldsetLine.appendChild(legend);

	pInputLineCounty = document.createElement('p');
	label = document.createElement('label');
	label.setAttribute('for', 'county_number_' + seriesLine);
	label.setAttribute('style', 'margin-left: -25px;');
	label.appendChild(document.createTextNode('Fylke: '));
	pInputLineCounty.appendChild(label);
	select = document.getElementById('county_number_0').cloneNode(true);
	select.setAttribute('id', 'county_number_' + seriesLine);
	select.setAttribute('name', 'series[' + seriesLine + '][county]');
	pInputLineCounty.appendChild(select);

	pInputLineQuantity = document.createElement('p');
	label = document.createElement('label');
	label.setAttribute('for', 'quantity_number_' + seriesLine);
	label.setAttribute('style', 'margin-left: -25px;');
	label.appendChild(document.createTextNode('Antall nr: '));
	pInputLineQuantity.appendChild(label);
	select = document.getElementById('quantity_number_0').cloneNode(true);
	select.setAttribute('id', 'quantity_number_' + seriesLine);
	select.setAttribute('name', 'series[' + seriesLine + '][quantity]');
	pInputLineQuantity.appendChild(select);

	linkDiv = document.createElement('div');
	linkDiv.setAttribute('id', 'series_line_buttons_' + seriesLine);
	linkDiv.setAttribute('style', 'position: relative; margin-top: -15px; margin-right: 10px; z-index: 2; float: right');

	newLineLink = document.createElement('a');
	newLineLink.setAttribute('style', 'float: right');
	newLineLink.setAttribute('href', '#anchor_series_' + (seriesLine + 1));
	newLineLink.setAttribute('onclick', 'addNumberseriesLine();');
	newLineLink.setAttribute('class', 'icon_add');
	newLineLink.setAttribute('onmouseover', 'return overlib(\'Legg til flere nummerserier\');')
	newLineLink.setAttribute('onmouseout', 'nd();');
	newLineLinkSpan = document.createElement('span');
	newLineLinkSpan.setAttribute('class', 'nodisplay');
	newLineLinkSpan.appendChild(document.createTextNode('Legg til flere nummerserier'));
	newLineLink.appendChild(newLineLinkSpan);

	removeLineLink = document.createElement('a');
	removeLineLink.setAttribute('style', 'float: right');
	removeLineLink.setAttribute('href', '#anchor_series_' + (seriesLine - 1));
	removeLineLink.setAttribute('onclick', 'removeNumberseriesLine(' + seriesLine + ');');
	removeLineLink.setAttribute('class', 'icon_subtract');
	removeLineLink.setAttribute('onmouseover', 'return overlib(\'Fjern denne nummerserien\');')
	removeLineLink.setAttribute('onmouseout', 'nd();');
	removeLineLinkSpan = document.createElement('span');
	removeLineLinkSpan.setAttribute('class', 'nodisplay');
	removeLineLinkSpan.appendChild(document.createTextNode('Fjern denne nummerserien'));
	removeLineLink.appendChild(removeLineLinkSpan);

	linkDiv.appendChild(newLineLink);
	linkDiv.appendChild(removeLineLink);

	fieldsetLine.appendChild(pInputLineCounty);
	fieldsetLine.appendChild(pInputLineQuantity);

	insertPoint.appendChild(fieldsetLine);
	insertPoint.appendChild(linkDiv);
	seriesLine++;
}

function removeNumberseriesLine(lineNumber) {
	nd();
	insertPoint = document.getElementById('form_new_number_series_numbers');
	divSeriesLine = document.getElementById('series_line_' + lineNumber);
	divSeriesLineButtons = document.getElementById('series_line_buttons_' + lineNumber);
	insertPoint.removeChild(divSeriesLine);
	insertPoint.removeChild(divSeriesLineButtons);
}