var S_NONE=0;
var S_LABEL=1;
var S_TR=2;
var S_TD=4;
var S_ALL=7;
var S_ALLNOTR=5;
var S_NOWIDTH=8;
var S_ALLNW = 15;
var S_INFOLABEL=16;

function formBegin()
{
	var html = "<table border=0 cellpadding=5 cellspacing=0>";
	return html;
}

function formEnd()
{
	var html = "</table>";
	return html;
}

function formPre(label, style)
{
	var html = "";
	if (style & S_TR)
		html += "<tr>";

	html += formLabel(label, style);
	
	if (style & S_TD)
	{	
		if (style & S_NOWIDTH)
			html += "<td>";
		else
			html += "<td width=100%>";
	}
	return html;
}

function formPost(style)
{
	var html = "";
	
	if (style & S_TD)
		html += "</td>";
	
	if (style & S_TR)
		html += "</tr>";
	
	return html;
}

function formLabel(label, style)
{
	var html = "";
	if (style & S_LABEL)
	{
		var cls = "lbl";
		
		if (style & S_INFOLABEL)
			cls = "lblinfo";
			
		html += "<td class='" + cls + "' nowrap valign=top>";
		if (label != "")
			html += label + ":";
		html += "</td>";
	}
	return html;
}

function formHelp(help)
{
	var html = "";
	if (help)
		html += "<br><span class='eg'>" + help + "</span>";
	return html;
}



function formInfo(label, value, style)
{
	var html = formPre(label, style | S_INFOLABEL);
	html += "<span class='fld'>" + value + "</span>";
	html += formPost(style);
	return html;
}

function formText(label, name, value, size, maxsize, help, style)
{
	var html = formPre(label, style);
	html += "<input class='editfld' type='text' size=" + size + " maxlength=" + maxsize + " name='" + name + "' id='" + name + "' value='" + value + "'>";
	html += formHelp(help);
	html += formPost(style);
	return html;
}

function formPass(label, name, value, size, maxsize, help, style)
{
	var html = formPre(label, style);
	html += "<input class='editfld' type='password' size=" + size + " maxlength=" + maxsize + " name='" + name + "' id='" + name + "' value='" + value + "'>";
	html += formHelp(help);
	html += formPost(style);
	return html;
}

function formMemo(label, name, value, cols, rows, maxsize, help, style)
{
	var html = formPre(label, style);
	html += "<textarea class='editfld' cols=" + cols + " rows=" + rows + " maxlength=" + maxsize + " name='" + name + "' id='" + name + "'>" + value + "</textarea>";
	html += formHelp(help);
	html += formPost(style);
	return html;
}

function formFile(label, name, value, size, maxsize, help, style)
{
	var html = formPre(label, style);
	html += "<input class='editfld' type='file' size=" + size + " maxlength=" + maxsize + " name='" + name + "' id='" + name + "' value='" + value + "'>";
	html += formHelp(help);
	html += formPost(style);
	return html;
}

function formSelect(label, name, value, items, help, style)
{
	var html = formPre(label, style);
	html += "<select size=1 id='" + name + "' name='" + name + "' class='editfld'>";

	for (var i = 0; i < items.length; i++)
	{
		if (items[i].id == value)
			html += "<option value='" + items[i].id + "' selected>" + items[i].name;
		else
			html += "<option value='" + items[i].id + "'>" + items[i].name;
	}
	
	html += "</select>";
	html += formHelp(help);
	html += formPost(style);
	return html;
}

/*
Sub xShowList(label, name, value, items, help, style)

	xPre label, style
	
	GetSelect items, name, value
	xShowHelp help

	xPost style

End Sub

Sub xShowListDelim(label, name, value, items, delim, help, style)

	xPre label, style
	
	GetSelectDelim items, delim, name, value
	xShowHelp help

	xPost style

End Sub

Sub xShowDBList(label, name, value, sql, valfield, idfield, help, style)

	xPre label, style
	
	GetSelectList sql, name, idfield, valfield, value
	xShowHelp help

	xPost style

End Sub

Sub xShowDBListX(label, name, value, sql, valfield, idfield, help, style, url, blank)

	xPre label, style
	
	GetSelectListX sql, name, idfield, valfield, value, url, blank
	xShowHelp help

	xPost style

End Sub

Sub xShowFileList(label, name, value, path, ext, help, style)

	xPre label, style
	
	loadFileList path, ext, name, value
	xShowHelp help

	xPost style

End Sub

Sub xShowMemo(label, name, value, cols, rows, maxsize, help, style)

	xPre label, style
	
	Response.Write "<textarea class=""editfld"" name=""" & name & """ id=""" & name & """ cols=" & cols & " rows=" & rows & " maxlength=" & maxsize & ">" & value & "</textarea>"
	xShowHelp help

	xPost style

End Sub

Sub xShowCheck(label, name, value, style)

	xPre label, style
	
	Response.Write "<input class=""editfld"" type=""checkbox"" name=""" & name & """ id=""" & name & """"
	If CBool(value) Then
		Response.Write " checked"
	End If
	Response.Write ">" & label
	
	xPost style

End Sub

Sub xShowCheckQty(label, name, value, qty, style)

	Response.Write "<input class=""editfld"" type=""checkbox"" name=""" & name & """ id=""" & name & """"
	If value & "" = "1" Then
		Response.Write " checked"
	End If
	Response.Write ">"
	xShowEdit "", name & "qty", qty, 2, 2, "", 0
	Response.Write "&nbsp;" & label

End Sub

Sub xDivide

	Response.Write "<tr><td colspan=10 class=""sep"" style=""padding: 0px""><img src=""images/sp.gif"" height=1></td></tr>"

End Sub

Sub xSpace

	Response.Write "<tr><td colspan=10><img src=""images/sp.gif"" height=1></td></tr>"

End Sub

Sub xSeg(title)
	
	Response.Write "<thead><tr><th colspan=2>" & title & "</th></tr></thead>"
	
End Sub

Sub xHelp(help)

	Response.Write "<tr><td colspan=2 class=""help"">" & help & "</td></tr>"

End Sub

Sub xShowFile(label, name, value, size, maxsize, help, style)

	xPre label, style
	
	Response.Write "<input class=""editfld"" type=""file"" size=" & size & " maxsize=" & maxsize & " name=""" & name & """ id=""" & name & """ value=""" & value & """>"
	xShowHelp help

	xPost style

End Sub

Sub xStat(status)

	Response.Write "<span class=""status"">" & status & "</span><p>"

End Sub

Sub xErr(er)

	Response.Write "<span class=""error"">" & er & "</span><p>"

End Sub

Sub xStatImage(status, image)

	Response.Write "<span class=""status""><img src=""" & image & """ style=""margin-right: 5px;"">" & status & "</span><p>"

End Sub

Sub xCheckStat

	If Session("status") & "" <> "" Then
		xStat Session("status")
		Session("status") = ""
	End If
	
	xCheckErr
	
End Sub

Sub xCheckErr

	If Session("errstatus") & "" <> "" Then
		xErr Session("errstatus")
		Session("errstatus") = ""
	End If
	
End Sub

Sub xShowButtons(buttons, actions)

	Dim btns
	btns = Split(buttons, "|")
	
	Dim actns
	actns = Split(actions, "|")

	Response.Write "<tr><td></td><td colspan=10 align=left style=""padding-top: 10px;"">"
	Response.Write "	<table border=0 cellpadding=0 cellspacing=0><tr>"

	For i = LBound(btns) To UBound(btns)
		If i = LBound(btns) Then
			Response.Write "			<td style=""padding-right: 10px;""><input type=""submit"" class=""btn"" value=""" & btns(i) & """ id=""submit1"" name=""submit1""></td>"
		Else
			'onclick=""javascript:history.go(-1)""
			Response.Write "			<td style=""padding-right: 10px;""><input type=""button"" class=""btn"" value=""" & btns(i) & """ id=""btn" & i & """ name=""btn" & i & """ onclick=""" & actns(i) & """></td>"
		End If		
	Next
	Response.Write "	</tr></table>"
	Response.Write "</td></tr>"			

End Sub
*/