function jforms(id) {
	alert(yes);
	if (!document.getElementById || !document.getElementsByTagName) return false;
	
	if(id==""||id=="parse"){return;}
	
	switch(typeof(id))
	{
		case "object":
		this.form = id;
		break;
		
		case "string":	
		this.form = document.getElementById(id);		
		break;
		
		default:
		return;
	}

	this.elements=this.form.elements;
	this.name=this.form.name;
	
	if(typeof(this.form.action)=="object") {
	  this.action="error.html";
	  alert("You cannot use a form element named 'action'");
	} else {
	   this.action=this.form.action;
    }
	
	this.bustcache=true;
	this.init();
	return 0;
}


jforms.prototype.init = function() {
 var jf=this;
	for(var i=0;i<this.elements.length;i++) {
	if(this.elements[i].name!='') {eval("jf."+this.elements[i].name+"=jf.elements["+i+"];");};
	}

//lock height
  try {
  this.form.parentNode.style.height=this.form.parentNode.offsetHeight;
  this.form.parentNode.style.overflow="hidden";
  } catch(exception) {
  this.parentScrHeight=this.form;
  }
	
//create disable screen
  var element=document.createElement('div')
  //this.form.parentNode.appendChild(element);
  document.body.appendChild(element);
  this.screen=element;		
  
  this.err={text:'Message',icon:'information',title:'Default',callback:"msgbox.close();alert('todo: you failed to specify code!');"};

}



jforms.prototype.buildQuery = function() {
var p = new Array();

var count=-1;
	for(var i=0;i<this.elements.length;i++) {count++;
	this.element=this.elements[i];
	switch(this.element.tagName) {
	case "TEXTAREA":
	p[count]=this.element.name+"="+escape(this.element.value);
	break;
	case "SELECT":
	p[count]=this.element.name+"="+escape(this.element.options[this.element.selectedIndex].value);
	break;
	case "INPUT":
	  switch(this.element.type) {
	  case "text":
	  p[count]=this.element.name+"="+escape(this.element.value);
	  break;
	  case "password":
	  p[count]=this.element.name+"="+escape(this.element.value);
	  break;
	  case "radio":
	  if(this.element.checked) {p[count]=this.element.name+"="+escape(this.element.value);} else {count--;}
	  break;
	  case "checkbox":
	  if(this.element.checked) {p[count]=this.element.name+"="+escape(this.element.value);} else {count--;}
	  break;
	  case "hidden":
	  p[count]=this.element.name+"="+escape(this.element.value);
	  break;
	  default:
	  count--;
	  break;
	  }
	 break;	
	default:
	count--;
	break;
	}	
}


this.query=this.form.action;

this.query+="?"+p.join("&");

if(this.bustcache) this.query+="&cache="+new Date().getTime();

return this.query;
}


jforms.prototype.dumpQuery = function() {

var q=this.buildQuery();  

	var out="<title>Query | "+this.form.name+" | "+this.action.value+"</title>"+q+"<hr>";

var s = q.split("?")[1].split("&");
  for(var i=0;i<s.length;i++) {
	out+="<li>"+s[i]+"\n";
  }

d=window.open("","");
d.document.write(out);
d.document.close();
d.focus();

}

jforms.prototype.trim = function(str) {return str.replace(/^\s+|\s+$/g, ''); }

jforms.prototype.urldecode = function(str) {re=/\+/g;str = str.replace(re, " ");str=unescape(str);return str;}

jforms.prototype.submit = function() {
this.form.submit();  //submit form
}

jforms.prototype.reset = function() {
this.form.reset();  //submit form
}


jforms.prototype.selectItem = function(select,sval) {  //this.selectItem(this.country,"AF");
for(i=0;i<select.length;i++) {if(select.options[i].value==sval) {select.selectedIndex=i;break;}}
}


jforms.prototype.dump = function() {
	var out="<title>Raw | "+this.name+" | "+this.action.value+"</title>";
	for(var i=0;i<this.elements.length;i++) {
	out+="<li>"+this.elements[i].name+" = "+this.elements[i].value+"\n";
	}

d=window.open("","");
d.document.write(out);
d.document.close();
d.focus();
}

//accept either text object or text
jforms.prototype.isMail = function(email) {var cmail=email;
if(typeof(email)=="object") {var email=email.value;}

	window.jform_cache=this;  //reference self
	//var callback="msgbox.hide();jform_cache.enable();";
	var callback="";
	
	if(typeof(cmail)=="object") {
	callback+="window.jform_cache."+cmail.name+".focus();";
	}
	
	
	this.err={text:'Incorrect',icon:'critical',title:'Incomplete Entry',callback:""};
	this.err.callback=callback;

	

	this.errorText="";  //default	
	if(this.trim(email)==""||this.trim(email)=="Email...") {
		this.errorText="Please enter your email address.";
	} else if (email.indexOf("@") < 0) {
		this.errorText="Incorrect email address. Please re-enter.";
	}	else if (email.indexOf(".") < 0) {
		this.errorText="Incorrect email address. Please re-enter.";
	} else if (email.indexOf(" ") >= 0) {
		this.errorText="Incorrect email address. Please re-enter.";
	}	
	
	//check result
	if(this.errorText=="") {return true;}
	
	this.err.text=this.errorText;
	return false;
}


jforms.prototype.verPass = function(pwd,pwd2) {
	window.jform_cache=this;  //reference self
	//var callback="msgbox.hide();jform_cache.enable();";
	var callback="";
	var callback2="window.jform_cache."+pwd.name+".focus();";

	this.errorText="";  //default	


	if (this.trim(pwd.value) =="") {
		this.errorText="Please enter a password (min 6 characters).";
	} else if (pwd.value.length < 6) {
		this.errorText="Password must have at least 6 characters. Please Re-enter.";
	} else if (pwd2.value.length < 6) {
		this.errorText="Confirmatory password must have at least 6 characters. Please Re-enter.";
		callback2="window.jform_cache."+pwd2.name+".focus();";
	} else if (pwd.value != pwd2.value) {
		this.errorText="Passwords do not match. Please re-enter.";
	}

	//check result
	if(this.errorText=="") {return true;}

	callback+=callback2;

	
	this.err={text:'Incorrect',icon:'critical',title:'Invalid password',callback:""};
	this.err.text=this.errorText;
	this.err.callback=callback;
	return false;
}

jforms.prototype.isChecked = function(opt) {
	window.jform_cache=this;  //reference self
	//var callback="msgbox.hide();jform_cache.enable();";
	var callback="document.getElementByName('"+opt.name+"').focus();";	
	this.err={text:'No selection made!',icon:'critical',title:'Incomplete Entry',callback:""};
	this.err.text=this.errorText;
	this.err.callback=callback;
	
	//alert(opt.name);
	//return false;
	
		

var elements=document.getElementsByName(opt.name);
var _cb=null;
for(i=0;i<this.elements.length;i++) {
  try {
  var cb=elements[i];
  if(cb.checked) {return true;};
  if(_cb==null) {_cb=cb;}   
  } catch(exception) {
  void(0);
  }
}


return false;
}



jforms.prototype.check = function(cname,cindex) {
var elements=document.getElementsByName(cname.name);

try {
elements[cindex].checked=true;
return true;
} catch(exception) {
return false;
}
return;
}



jforms.prototype.isEmpty = function(element) {
//declare errors first
	window.jform_cache=this;  //reference self
	this.err={text:'You cannot submit this field blank!',icon:'critical',title:'Incomplete Entry',callback:""};
	this.err.text=this.errorText;
	//var callback="msgbox.hide();jform_cache.enable();";	
	callback="window.jform_cache."+element.name+".focus();";	
	this.err.callback=callback;

if(typeof(element)!="object") {alert("'"+element+"' is not a valid object");return true;}
if(element.tagName=="SELECT") {
	if(element.selectedIndex==0) {return true;} else {return false;}	
} else {
	if(this.trim(element.value)=="") {return true;} else {return false;}	
}	
}


jforms.prototype.getElementLeftPosition = function(e){
var x=0;
while(e){
x+=e.offsetLeft+e.clientLeft;
e=e.offsetParent;
}
return x;
}

jforms.prototype.getElementTopPosition = function(e){
var y=0;
while(e){
y+=e.offsetTop+e.clientTop;
e=e.offsetParent;
}
return y;
}
	
jforms.prototype.disable = function() {
var element=this.screen;

  element.style.cssText=";position:absolute;background:#ffffff;text-align:center;";  
  element.style.cssText+=";filter:alpha(opacity=50);-moz-opacity:.50;opacity:.50;";

  element.style.left=this.getElementLeftPosition(this.form);
  element.style.top=this.getElementTopPosition(this.form);
  element.style.width=this.form.offsetWidth+"px";
  element.style.height=this.form.offsetHeight+"px";  
  


  element.style.paddingTop=(parseInt(element.style.height)*(10/100));  
  
  coll = this.form.getElementsByTagName("SELECT");  
  for(i=0;i<coll.length;i++) {
   coll[i].style.visibility="hidden";
  }
 
  element.style.display="block";
 // element.style.position="absolute";
return;
}



jforms.prototype.enable = function() {
var element=this.screen;

  element.style.cssText=";display:none;";  

  coll = this.form.getElementsByTagName("SELECT");
  
  for(i=0;i<coll.length;i++) {
   coll[i].style.visibility="visible";
  }

return;
}


jforms.prototype.hide = function() {
this.screen.style.display="none";
this.form.style.visibility="hidden";
}

jforms.prototype.show = function() {
this.screen.style.display="none";
this.form.style.visibility="visible";
}


jforms.prototype.debug = function() {
this.firstname.value="Ayo";
this.selectItem(this.country,"AF");
return;
}


//parser
jforms.prototype.parse = function(url) {
this.url=url;  //parse url

if(url.indexOf("?")!=-1) {
var s = url.split("?")[1].split("&");
} else {
var s = url.split("&");
}
this.queryStr=s;
this.length=this.queryStr.length;

 var jf=this;
	for(var i=0;i<this.queryStr.length;i++) {
	    eval("jf."+this.queryStr[i].split("=")[0]+"='"+this.queryStr[i].split("=")[1]+"'" );
	}
}


jforms.prototype.ajaxRequest = function() {
 var activexmodes=["Msxml2.XMLHTTP", "Microsoft.XMLHTTP"] //activeX versions to check for in IE
 if (window.ActiveXObject){ //Test for support for ActiveXObject in IE first (as XMLHttpRequest in IE7 is broken)
  for (var i=0; i<activexmodes.length; i++){
   try{
    return new ActiveXObject(activexmodes[i])
   }
   catch(e){
    //suppress error
   }
  }
 }
 else if (window.XMLHttpRequest) // if Mozilla, Safari etc
  return new XMLHttpRequest()
 else
  return false
return;
}


jforms.prototype.isReady = function() {
if((this.xmlhttp.readyState == 4) && (this.xmlhttp.status==200)) {
this.responseText=this.xmlhttp.responseText;
try {
 var json=eval("("+this.responseText+")");
 this.json=json;
} catch(exception) {
//alert("json error!");
 var json = new Array('error','error');
 this.json=json;
}

return true;
} else {return false;}

}

jforms.prototype.isNav = function() {
if((this.xmlhttp.readyState == 4) && (this.xmlhttp.status!=200)) {
	switch(this.xmlhttp.status) {
	case 0:
	msg="Requested was cancelled.";
	break;
	case 301:
	msg="Sorry, the requested page has been moved permanently.";
	break;
	case 304:
	msg="Sorry, the requested page was not modified.";
	break;
	case 401:
	msg="Sorry, the requested page was unauthorized.";
	break;
	case 403:
	msg="Access to requested page Was forbidden.";
	break;
	case 404:
	msg="Sorry, the requested page was not found.";
	break;
	case 12029:
	msg="Internet connection is not available. Please try again later.";
	break;
	default:
	msg=this.xmlhttp.status+": error loading requested page.";
	break;
	}
	
	//store info into json array by default
	window.jform_cache=this;  //reference self
	this.json={status:0,msg:"Request failed",icon:'critical',title:'No Connection',callback:"msgbox.hide();jform_cache.enable();"};
	this.json.status=this.xmlhttp.status;
	this.json.msg=msg;
		
	this.errorText=msg;this.responseText=msg;
	this.status=this.xmlhttp.status;	
   return true;
} else {return false;}
}


jforms.prototype.post = function() {
this.json_mode=false;

	switch(this.post.arguments.length) {
	case 0:
	alert("Invalid post request!");
	return false;
	case 1:
	var fx=this.post.arguments[0];
	break;
	case 2:
	var fx=this.post.arguments[0];
	 switch(this.post.arguments[1]) {
	 case "json":
	 this.json_mode=true;
	 break;
	 }
	break;
	}

 var jf=this;
 var xmlhttp=new this.ajaxRequest()
 this.xmlhttp=xmlhttp;
 jf.xmlhttp.onreadystatechange=fx;
 jf.xmlhttp.open("post", this.buildQuery(), true)
 jf.xmlhttp.send(null);
 return true;
}

