function clear_all(){
  for(i=0; i<document.theForm.elements.length-2; i++){
    switch(document.theForm.elements[i].type){
      case "checkbox" : document.theForm.elements[i].checked=false;
      break;
      case "text" : document.theForm.elements[i].value="";
      break;
      case "radio" : document.theForm.elements[i].checked=false;
      break;
      case "select-one" : document.theForm.elements[i].selectedIndex=0;
      break;
      default : ;
      break;
    }
  }
}
function disableRequiredFields() {
    for(j=0; j<document.productListForm.elements.length; j++){
        name = document.productListForm.elements[j].name;
        //alert('name = '+name);
        if (name.indexOf("checkBox")>-1) {
            recordNo = name.substring(9, name.length);
            //alert('document.productListForm.elements[j].checked = '+document.productListForm.elements[j].checked);
            if (document.productListForm.elements[j].checked!=true) {
                for(i=0; i<document.productListForm.elements.length; i++){
                    name = document.productListForm.elements[i].name;
                    //alert('name = '+name);
                    if (name=="deliverEmail"+recordNo) {
                        //alert('disable the deliverEmail for recordNo '+recordNo);
                        document.productListForm.elements[i].disabled='true';
                    }
                    if (name=="coordsys"+recordNo) {
                        //alert('disable the coordsys for recordNo '+recordNo);
                        document.productListForm.elements[i].disabled='true';
                    }
                    if (name=="format"+recordNo) {
                        //alert('disable the format for recordNo '+recordNo);
                        document.productListForm.elements[i].disabled='true';
                    }
                }
            }
        }
    }
}
function toggleDeliverEmail(recordNo, checked) {
    for(i=0; i<document.productListForm.elements.length; i++){
        switch(document.productListForm.elements[i].type) {
          case "checkbox" :
            name = document.productListForm.elements[i].name;
            if (name=="deliverEmail"+recordNo) {
                if (checked==true) {
                    document.productListForm.elements[i].disabled='';
                } else {
                    document.productListForm.elements[i].disabled='true';
                    document.productListForm.elements[i].checked='';
                    toggleSelectFields(recordNo, checked);
                }
                break;
            }
        }
    }
}
function toggleSelectFields(recordNo, checked) {
    if (checked==true) {
        for(j=0; j<document.productListForm.elements.length; j++){
            name = document.productListForm.elements[j].name;
            if (name=="coordsys"+recordNo) {
                document.productListForm.elements[j].disabled='';
            }
            if (name=="format"+recordNo) {
                document.productListForm.elements[j].disabled='';
            }
        }
    } else {
        for(j=0; j<document.productListForm.elements.length; j++){
            name = document.productListForm.elements[j].name;
            if (name=="coordsys"+recordNo) {
                document.productListForm.elements[j].selectedIndex=0;
                document.productListForm.elements[j].disabled='true';
            }
            if (name=="format"+recordNo) {
                document.productListForm.elements[j].selectedIndex=0;
                document.productListForm.elements[j].disabled='true';
            }
        }
    }
}
function proceedToCart(){
  document.productListForm.handler.value='addToMyFolder';
  document.productListForm.actionField.value='goToMyFolder';
  document.productListForm.submit();
}
function gotoPage(pageNum){

  var n;
  for (n = 0; n < document.forms.length; n ++)
  {
		if (typeof (document.forms[n].actionField) != "undefined")	
		{		 
			var theAction = document.forms[n].action;
			document.forms[n].action = theAction + '#results';
			document.forms[n].actionField.value='gotoPage';
			document.forms[n].pageNumber.value=pageNum;
			document.forms[n].submit();
			break;
		}
  }	
}

function lot_plan_clear_all(){
    document.lotPlanSearch.LOT.value="";
    document.lotPlanSearch.PLAN.value="";

}
function directory_clear_all(){
    document.directorySearch.REFERENCE.value="";
    document.directorySearch.PAGE.value="";

}
function address_clear_all(){
    document.reportSearch.UNIT_NUMBER.value="";
    document.reportSearch.STREET_NUMBER.value="";
    document.reportSearch.STREET_NAME.value="";
    document.reportSearch.STREET_TYPE.selectedIndex=0;
    document.reportSearch.STREET_SUFFIX.selectedIndex=0; 
    document.reportSearch.LOCALITY.value="";
    document.reportSearch.POST_CODE.value="";
    }
function crown_clear_all(){
    document.crownSearch.ALLOTMENT.value="";
    document.crownSearch.SECTION.value="";
    document.crownSearch.SUBDIVISION.value="";
    document.crownSearch.PORTION.value="";
    document.crownSearch.BLOCK.value=""; 
    document.crownSearch.parishName.value="";
    makePList (document.crownSearch.parishName,"");
    }
function parcel_pfi_clear_all(){
    document.parcelPFISearch.PARCEL_PFI.value="";
    document.parcelPFISearch.PARCEL_PFI.focus ();
    }
function property_view_pfi_clear_all(){
    document.propertyViewPFISearch.PROPERTY_VIEW_PFI.value="";
    document.propertyViewPFISearch.PROPERTY_VIEW_PFI.focus ();
    }
function parcel_spi_clear_all(){
    document.parcelSPISearch.PARCEL_SPI.value="";
    document.parcelSPISearch.PARCEL_SPI.focus ();
    }
function cpn_clear_all(){
    document.cpnSearch.PROPNUM.value="";
    document.cpnSearch.LGA_CODE.value="";
    document.cpnSearch.LGA_NAME.selectedIndex=0;
    document.cpnSearch.PROPNUM.focus ();
    }
function hermes_clear_all(){
    document.hermesSearch.HERMES_NO.value="";
    document.hermesSearch.HERMES_NO.focus ();
    }
function vhr_clear_all(){
    document.vhrSearch.VHR_NO.value="";
    document.vhrSearch.VHR_NO.focus ();
    }

function removeItems(){
    document.reportListForm.handler.value='myFolder';
    document.reportListForm.actionField.value='removeItems';
    document.reportListForm.submit();
}
function makePayment(URL){
    document.reportListForm.action=URL;
    document.reportListForm.actionField.value='undef';
    document.reportListForm.submit();
}
