function GetFieldString(theField) {
	//to retrieve value of the simple field - do not use it to other types of fields i.e. checkbox, radiobutton etc.
	return eval ("document.forms[0]." + theField +".value"); 
}

function GetFieldVal(theField) {
	//to retrieve value of the simple field - do not use it to other types of fields i.e. checkbox, radiobutton etc.
	return eval ("document.forms[0]." + theField +".value"); }	
	
function GetFieldSel(theField) {
	//to retrieve index of selection field.
	return eval ("document.forms[0]." + theField +".selectedIndex"); }
	
function GetFieldSelVal(theField, type) {
	//to retrieve value or text of selection field.
	return eval ("document.forms[0]."+ theField + "[document.forms[0]."+ theField + ".selectedIndex]."+type); }

function GetFieldRadioVal(theField) {	
	radio = eval ("document.forms[0]."+theField);
	for (i=0; i<radio.length; i++) {
		if (radio[i].checked=="1") return radio[i].value;		
	}
}
	
function GetFieldType(theField) {
	//to retrieve type of field.
	return eval ("document.forms[0]." + theField +".type"); }	
	
function SetFieldVal(theField, theVal) {
	//to retrieve value of the simple field - do not use it to other types of fields i.e. checkbox, radiobutton etc.
	eval ("document.forms[0]." + theField +".value="+theVal); }
	
function putFocus(theField) {
	eval ("document.forms[0]." + theField +".focus()"); }	

//************************************************************
//this is for WWW Forms database only

function field_validate ( obj , validType , imgID ) { 
	x = imgID;
	switch ( validType ) {
		case "text" :
			a = obj.value ;
			if (  a.replace(/^\s+|\s+$/g, '') != '' ) 
				updateVal ( imgID , true ) ;
			else 
				updateVal ( imgID , false );
			break;
		case "number" :
			
			break;
		case "email" :
			a = obj.value ;
			if ( a != "" && a.length > 5 && a.indexOf ("@") !=-1 && a.indexOf (".") !=- 1 ) 
				updateVal ( imgID , true ) ;
			else 
				updateVal ( imgID , false );
			break;
		case "select" :
			fld  = eval ("document.forms[0]." + obj.name );
			idx = eval ("document.forms[0]." + obj.name +".selectedIndex");
			a = fld[idx].text;	
			if (  a != '' ) 
				updateVal ( imgID , true ) ;
			else 
				updateVal ( imgID , false );		
			break;
		default :
			alert ("Nieznany typ walidacji") ;
	}
	//window.status = mandatoryCount;
}

function updateVal ( imgID , isOK )  {
	img = document.getElementById ( imgID );
	if ( isOK ) {		
			if (  !mandatoryFieldsCompleted.exists ( imgID ) ) {
				mandatoryCount -= 1 ; 			
				mandatoryFieldsCompleted.add ( imgID );	
				img.src = www_img_ok ;
			}
		}
	else {
			if ( mandatoryFieldsCompleted.exists ( imgID ) ) {
				mandatoryCount += 1 ; 		
				mandatoryFieldsCompleted.remove ( imgID );	
				img.src = www_img_not; 
			}
		}
}
