function analyse_metadata()
{
    // get metadata from form
	metadataIn = metadata_in.value;
	
	// warn user if metadata in box is empty
	if(metadataIn.length == 0)
	{
		window.alert("Paste the metadata you want to analyse into the 'Metadata to analyse' box.");
		return;
	}	
	// remove whitespace between column from metadata
	metadataIn = metadataIn.replace(/ +;/g, ";");
	
	// remove trailing whitespace from metadata
	metadataIn = metadataIn.replace(/ +\r\n/g, "\r\n");
	
	// split into array
	metadataIn = metadataIn.split("\r\n");
	 
	metadataOut = [];
	metadataOutIndex = 0;
	section="Error;";
	
	// for each line in metadata file
	for(metadataInIndex in metadataIn)
	{
		LineIn = metadataIn[metadataInIndex];
		isLineOutput = true
		
		// if line is blank do not output
		if(LineIn == "")
		{
			isLineOutput = false;
		}
		// if line starts with an ! do not output
		if(LineIn.substr(0, 1) == "!")
		{
			isLineOutput = false;
			if(LineIn.substr(0, 13) != "!FILE_FORMAT=" && LineIn.substr(0, 9) != "!VERSION=")
			{
				section = LineIn + ";";
			}
		}
		// if line is comment replace commas with semicolons
		if((LineIn.substr(0, 1) == "'"))
		{
			LineIn = LineIn.replace(/,/g, ";");
		}
		if(isLineOutput)
		{
			metadataOut[metadataOutIndex] = section + LineIn;
			metadataOutIndex++;
		}
	}
	//metadataOut.sort()
	metadataOut = metadataOut.join("\r\n")
	metadataOut = "Section;1;2;3;4;5;6;7;8;9;10;11;12;13;14;15;16;17;18;19;20;21;22;23;24\r\n" + metadataOut;
	
	metadata_out.innerText = metadataOut;
}
