function getUrlParameter(url, param) {
	var url_parameters = url.search.substring(1);
    var url_param_array = url_parameters.split('&');

    for (var i = 0; i < url_param_array.length; i++) {
        var parameterName = url_param_array[i].split('=');

        if (parameterName[0] == param)
            return parameterName[1];
    }

	return null;
}

function adInfoOnLoad() {
    var url_string = window.location;

	var dataTypeTechName = getUrlParameter(url_string, "dataTypeTechName");
	var dictionaryEntryName = getUrlParameter(url_string, "dictionaryEntryName");
	var pattern = getUrlParameter(url_string, "pattern");
	var minLength = getUrlParameter(url_string, "minLength");
	var maxLength = getUrlParameter(url_string, "maxLength");
	var minInclusive = getUrlParameter(url_string, "minInclusive");
	var maxInclusive = getUrlParameter(url_string, "maxInclusive");
	
	var table = document.getElementById("AdInfoTable");
	if ( dataTypeTechName != null ) {
		var row = addRowToTable("Data type technical name:", dataTypeTechName);
		table.appendChild(row);
	}

	if ( dictionaryEntryName != null ) {
		var row = addRowToTable("Dictionary entry name:", dictionaryEntryName);
		table.appendChild(row);
	}

	if ( pattern != null ) {
		var row = addRowToTable("Pattern:", pattern);
		table.appendChild(row);
	}

	if ( minLength != null ) {
		var row = addRowToTable("Min length:", minLength);
		table.appendChild(row);
	}

	if ( maxLength != null ) {
		var row = addRowToTable("Max length:", maxLength);
		table.appendChild(row);
	}

	if ( minInclusive != null ) {
		var row = addRowToTable("Min inclusive:", minInclusive);
		table.appendChild(row);
	}

	if ( maxInclusive != null ) {
		var row = addRowToTable("Max inclusive:", maxInclusive);
		table.appendChild(row);
	}
}

function addRowToTable(name, value) {
	var row = document.createElement("div");
	row.setAttribute("class", "Row");

	var cellName = document.createElement("div");
	cellName.setAttribute("class", "CellName");
	var Name = document.createTextNode(name);
	cellName.appendChild(Name);
	
	var cellValue = document.createElement("div");
	cellValue.setAttribute("class", "CellValue");
	var Value = document.createTextNode(value);
	cellValue.appendChild(Value);
	
	row.appendChild(cellName);
	row.appendChild(cellValue);

	return row;
}
