var Module = {
    //div with results
    createResultsDiv: function() {
        var container = document.createElement("div");
        container.setAttribute("id", "results");
        return container;
    },
    //v16 site search container
    v16Module: function() {
		var searchBox = document.getElementById("search-container");
		var container = "<div class=\"ibm-container\">";
		container += "<h2>Buscar</h2>";
		container += "<div class=\"ibm-container-body\">"
		container += "<table>";
		container += "<tr>";
		container += "<td>Buscar: </td>";
		container += "<td><input type=\"text\" id=\"searchField\" size=\"65\" onkeypress=\"Search.keyPress(event);\"/></td>";
		container += "</tr>";
		container += "<tr>";
		container += "<td>Resultados por p&aacute;gina: </td>";
		container += "<td><select id=\"resultsPerPage\"><option value=\"5\" selected=\"\">5</option><option value=\"10\">10</option><option value=\"25\">25</option><option value=\"50\">50</option><option value=\"75\">75</option><option value=\"100\">100</option></select></td>";
		container += "</tr>";
		container += "<td><input id=\"search-button\" class=\"ibm-btn-view-pri\" type=\"button\" value=\"Buscar\" onclick=\"Search.startSearch();\"/><br /><br /></td>";
		container += "</tr>";
		container += "</table>";
		container += "</div>";
		container += "</div>";
		searchBox.innerHTML = container;
		searchBox.innerHTML  += "<div id=\"results\"></div>";
		
    },
    //crate table header method
    createTableHeader: function(color) {
        var headerText = document.createTextNode("Buscar");
        var tableRow = document.createElement("tr");
        var tableHeader = document.createElement("td");
        tableHeader.className = "v14-header-" + color;
        tableHeader.appendChild(headerText);
        tableRow.appendChild(tableHeader);
        return tableRow;
    },
    //create table space
    createTableSpace: function() {
        var tableRow = document.createElement("tr");
        var tableColumn = document.createElement("td");
        var spacer = document.createElement("img");
        spacer.setAttribute("src", "//www.ibm.com/i/c.gif");
        spacer.setAttribute("width", 1);
        spacer.setAttribute("height", 7);
        spacer.setAttribute("alt", "");
        tableColumn.appendChild(spacer);
        tableRow.appendChild(tableColumn);
        return tableRow;
    },
    //creates empty column
    createColumn: function() {
        var column = document.createElement("td");
        var spacer = document.createElement("img");
        spacer.setAttribute("src", "//www.ibm.com/i/c.gif");
        spacer.setAttribute("width", 7);
        spacer.setAttribute("height", 1);
        spacer.setAttribute("alt", "");
        column.appendChild(spacer);
        return column;
    },
    //v14/v15 site search container
    v15Module: function() {
		var searchBox = document.getElementById("search-container");
		var tableRow = "<tr><td><img width=\"1\" height=\"7\" src=\"//www.ibm.com/i/c.gif\" alt=\"\"/></td></tr>";
		var tableColumn = "<td><img width=\"1\" height=\"7\" src=\"//www.ibm.com/i/c.gif\" alt=\"\"/></td>";
		var container = "<table class=\"v14-gray-table-border\" width=\"443\" cellspacing=\"0\" cellpadding=\"0\">";
		container += "<tr>";
		container += "<td class=\"v14-header-1\">Buscar</td>";
		container += "</tr>";
		container += "<tr>";
		container += "<td>";
		container += "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";
		container += tableRow;
		container += "<tr>";
		container += "<td>Buscar: </td>";
		container += tableColumn;
		container += "<input id=\"searchField\" type=\"text\" size=\"45\" onkeypress=\"Search.keyPress(event)\" />";
		container += "</tr>";
		container += tableRow;
		container += "<tr>";
		container += "<td>Resultados por p&aacute;gina: </td>";
		container += tableColumn;
		container += "<td><select id=\"resultsPerPage\"><option value=\"5\" selected=\"\">5</option><option value=\"10\">10</option><option value=\"25\">25</option><option value=\"50\">50</option><option value=\"75\">75</option><option value=\"100\">100</option></select></td>";
		container += "</tr>";
		container += tableRow;
		container += "<tr>";
		container += "<td><input type=\"image\" id=\"search-button\" src=\"//www.ibm.com/i/v14/buttons/us/en/submit.gif\" alt=\"Submit\" value=\"Submit\" onclick=\"Search.startSearch();\" /></td>";
		container += "</tr>";
		container += "</table>";
		container += "<td>";
		container += "</tr>";
		container += tableRow;
		searchBox.innerHTML = container;
		searchBox.innerHTML  += "<div id=\"results\"></div>";
    },
	//v8 box
	v8Module: function () {
		var searchBox = document.getElementById("search-container");
		var container = "<div class=\"callout bg-gray-lightest\">";
		container += "<h2 class=\"bar-blue-med-dark\">Buscar</h2>";
		container += "<table>";
		container += "<tr>";
		container += "<td>Buscar: </td>";
		container += "<td><input type=\"text\" id=\"searchField\" size=\"65\" onkeypress=\"Search.keyPress(event);\"/></td>";
		container += "</tr>";
		container += "<tr>";
		container += "<td>Resultados por p&aacute;gina: </td>";
		container += "<td><select id=\"resultsPerPage\"><option value=\"5\" selected=\"\">5</option><option value=\"10\">10</option><option value=\"25\">25</option><option value=\"50\">50</option><option value=\"75\">75</option><option value=\"100\">100</option></select></td>";
		container += "</tr>";
		container += "<td><span class=\"button-blue\"><input type=\"button\" id=\"search-button\" class=\"ibm-btn-view-pri\" value=\"Buscar\" onclick=\"Search.startSearch();\" /></span></td>";
		container += "</tr>";
		container += "</table>";
		container += "</div>";
		searchBox.innerHTML = container;
		searchBox.innerHTML  += "<div id=\"results\"></div>";

	},
	createModule: function() {
		var headNode = document.getElementsByTagName("head")[0];
		if(headNode.innerHTML.indexOf("v16") != -1) {
			Search.layout = "v16";
			this.v16Module();
		} else if(headNode.innerHTML.indexOf("v14") != -1 || headNode.innerHTML.indexOf("v15") != -1) {
			Search.layout = "v15";
			this.v15Module();
		} else {
			Search.layout = "v8";
			this.v8Module();
		}
	}
};