function validatefield(type) {

    var blnError;

    validity=true;

    switch (type){

    case 1:

        if (document.fpost1.BuildingNo.value=="")
	    {validity=false;alert("building/block/house no. must not be empty");
	     document.fpost1.BuildingNo.focus();
	    }
        else if (document.fpost1.StreetName.value=="")
	    {validity=false;alert("street name must not be empty");
	     document.fpost1.StreetName.focus();
	    }

        if (validity==true)
           {document.fpost1.submit();}    
	
	break;

    case 2:

        if (document.fpost2.BuildingName.value=="")
	    {validity=false;alert("major building/estate name must not be empty");
	     document.fpost2.BuildingName.focus();
		}

        if (validity==true)
           {document.fpost2.submit();}    

	break;

    case 3:

        if (document.fpost3.POBox.value=="")
	    {validity=false;alert("PO Box/window delivery/locked bag no. must not be empty");
	     document.fpost3.POBox.focus();
	}

        else if (document.fpost3.PostOffice.value=="")
	    {validity=false;alert("post office must not be empty");
	     document.fpost3.PostOffice.focus();

 	    }

        if (validity==true)
           {document.fpost3.submit();}    

	break;

    case 4:

        if (document.fpost4.PCode.value=="")
	    {validity=false;alert("6-digit postal code must not be empty");
	     document.fpost4.PCode.focus();
	    }


        if (validity==true)
           {document.fpost4.submit();}    

	break;

    }    

}

function clearfields(type){

    switch (type){

    case 1:

        document.fpost1.BuildingNo.value="";
	document.fpost1.StreetName.value="";

    case 2:

        document.fpost2.BuildingName.value="";

    case 3:

        document.fpost3.POBox.value="";
	document.fpost3.PostOffice.value="";

    case 4:

        document.fpost4.PCode.value="";
        document.fpost4.CheckCode.value="";

    }    


}
