function focuschamp (champ)
{
document.forms[0].elements[champ].focus();
}

function testformaction(){
// checking if the required parameters where introduced
var required=false;
var i=0, m=0, conf="no", vld="yes";
var lastFormElement=document.forms[0].elements.length, lastArgument=testformaction.arguments.length;

while((i<lastFormElement)&&(vld=="yes")){
	var conf2=false, j=1, theType=document.forms[0].elements[i].type;
	//alert(document.forms[0].elements[i].type)
	while(j<lastArgument){
	if(testformaction.arguments[j]==document.forms[0].elements[i].name){
	conf="yes"; conf2=true;
}
	else
	conf="no"; j++;
}	
if(conf2==true){
	if(theType=="textarea" || theType=="text" || theType=="password"){
		if(document.forms[0].elements[i].value!="")
		vld="yes" 
		else 
		vld="no";m=i;
	}
	if(theType=="radio" || theType=="checkbox"){
		if(document.forms[0].elements[i].checked)
		vld="yes"
		else 
		vld="no";m=i;
	}
		if(theType.indexOf("select")!=-1 &&document.forms[0].elements[i].options[document.forms[0].elements[i].selectedIndex].value=="bar")
	{
		vld="no";m=i;

	}
}
	i++;	
}
if(vld=="no"){
alert("Please fill the following field in order to validate your form.");
document.forms[0].elements[m].focus();
return false;
}
else if(vld=="yes"){
document.forms[0].act.value = testformaction.arguments[0];
return true;
}
}


