// JavaScript Document
var warnPrefix = "You did not enter a value into the "
var warnSuffix = " field. This is a required field. Please enter it now."

function isempty(s)
{
	if((s=="")||(s.length==0))
	return true;
}

function iswhitespace(s)
{   
	var i;
	var whitespace=" \t\n\r";
    if (isempty(s)) 
	return true;
	
    for (i=0; i<s.length; i++)
    {   
        var c=s.charAt(i);
        if (whitespace.indexOf(c)=="-1") return false;
    }
	 return true;
}

function strvalidation(field,str)
{
	var val=field.value;
	if(isempty(val))
	{
		alert(warnPrefix + str + warnSuffix);
		field.focus();
		return false;
	}
	if(iswhitespace(val))
	{
		alert("U have entered whitespace in the field" + str + "entert the correct data");
		field.value="";
		field.focus();
		return false;
	}
	return true;
}

function combovalidation(field, str)
{
	if (field.options(0).selected)
	{
	alert("Please choose the " + str + " field. This is required field. Please select it now");
	field.focus();
	return false;
	}
	else
	return true;
}

function check()
{
	alert("now i am in check function");
	var val=document.formvalidation.c1;
	var txt="";
	for(i=0;i<(val.length);++i)
	{
		if(val[i].checked)
		{
			txt= txt + val[i].value + "  ";
		}
	}
	alert("u have selected" + txt);
}


function formsubmit(){
				
/*			var authority11=document.formvalidation.authority1.value;
			var authority22=document.formvalidation.authority2.value;
			var datedthis1=document.formvalidation.datedthis.value;
			var comboval=document.formvalidation.day.options[document.formvalidation.day.selectedIndex].text;
			var signed1=document.formvalidation.signed.value;*/
			alert("i am in formsubmit");
			var result=check();
/*					 strvalidation(document.formvalidation.elements["connection"],"connection") &&  
				     strvalidation(document.formvalidation.elements["authorized"],"authorized") && 
				     strvalidation(document.formvalidation.elements["authorizedname"],"authorizedname") && 
				     strvalidation(document.formvalidation.elements["authority1"],"authority1")  &&	
					 strvalidation(document.formvalidation.elements["authority2"],"authority2") &&	
					 strvalidation(document.formvalidation.elements["datedthis"],"date") &&	
					 combovalidation(document.formvalidation.elements["day"],"day") &&
					 strvalidation(document.formvalidation.elements["signed"],"signed") 
					 );*/
			
			if(result)
				alert("result is true");
			else
				alert("result is false");
//				formresult(connection1,authorized1,authorizedname1,authority11,authority22,datedthis1,comboval,signed1);
			
	}
