// ********** FormOnFly Class                            *************
// ********** By this class you can create a form on fly *************
// ********** and add elements to it and finally submit  *************
FormOnFly = function()
{
    this.form = document.getElementById("onFlyForm");
    this.form.innerHTML = "";
}
FormOnFly.prototype.setPrimaryAttribute = function(formMethod, formAction)
{
    this.form.setAttribute("method",formMethod);
    this.form.setAttribute("action",formAction);    
}
FormOnFly.prototype.setAttribute = function(attribName, attribValue)
{
    this.form.setAttribute(attribName, attribValue);
}
FormOnFly.prototype.addElement = function(elementName, elementValue)
{
    var newElement = document.createElement("input");
    newElement.setAttribute("name",elementName);
    newElement.setAttribute("type","hidden");
    newElement.setAttribute("value",elementValue);
    this.form.appendChild(newElement);
}
FormOnFly.prototype.addFileElement = function(elementName, elementValue)
{
    var newElement = document.createElement("input");
    newElement.setAttribute("name",elementName);
    newElement.setAttribute("type","file");
    newElement.setAttribute("value",elementValue);
    this.form.appendChild(newElement);
}
FormOnFly.prototype.submit = function()
{   
	var browser=navigator.appName;
	var b_version=navigator.appVersion;
	var version=parseFloat(b_version);
	if ((browser=="Microsoft Internet Explorer") && (version<7))
	{
		setTimeout('document.getElementById("onFlyForm").submit();', 500);
	}
	else
	{
		this.form.submit();
	}
}

function CreateFormOnFly(formMethod, formAction)
{
    var theForm = new FormOnFly;
    theForm.setPrimaryAttribute(formMethod, formAction);
    return theForm
}
