function showhide(id1) {
	if(document.getElementById(id1).style.display=='none') {
		document.getElementById(id1).style.display='block';
	} else {
		document.getElementById(id1).style.display='none';
	}
}

function showdiv(id1) {
	if(document.getElementById(id1))
	document.getElementById(id1).style.display='block';
}

function hidediv(id1) {
	if(document.getElementById(id1))
	document.getElementById(id1).style.display='none';
}

function ShowHideSelectDeps(field_id) {
  var elem = "field_"+field_id;
  var show = document.getElementById(elem).options[document.getElementById(elem).options.selectedIndex].value;
  var possible_options = document.getElementById(elem).options.length-1;
  for(x=0; x<possible_options; x++) {
    if(x != show | show == "") {
      hidediv(elem+"_option"+x);
    } else {
      showdiv(elem+"_option"+x);
    }
  }
}

function ShowHideRadioDeps(field_id, show, dep_field, total_options) {
  var elem = "field_"+field_id;
  for(x=0; x<total_options; x++) {
    if(x != show) {
      hidediv(elem+"_radio"+x);
    } else {
      showdiv(elem+"_radio"+x);
      if(document.getElementById(dep_field)) {
        document.getElementById(dep_field).focus()
	document.getElementById(dep_field).value = document.getElementById(dep_field).value;
      }
    }
  }
}


function ShowHideCheckboxDeps(field_id, show, dep_field, total_options) {
  var elem = "field_"+field_id;
  for(x=0; x<total_options; x++) {
    if(x != show) {
      hidediv(elem+"_checkbox"+x);
    } else {
      showdiv(elem+"_checkbox"+x);
      if(document.getElementById(dep_field)) {
        document.getElementById(dep_field).focus()
	document.getElementById(dep_field).value = document.getElementById(dep_field).value;
      }
    }
  }
}

function showBusyLayer() {
		var busyLayer = document.getElementById("busy_layer")
		if (busyLayer != null) {
			busyLayer.style.visibility = "visible";

    var innerWidth,innerHeight;
    if (self.innerHeight) // all except Explorer
    {
    	innerWidth = self.innerWidth;
    	innerHeight = self.innerHeight;
    }
    else if (document.documentElement && document.documentElement.clientHeight)
    	// Explorer 6 Strict Mode
    {
    	innerWidth = document.documentElement.clientWidth;
    	innerHeight = document.documentElement.clientHeight;
    }
    else if (document.body) // other Explorers
    {
    	innerWidth = document.body.clientWidth;
    	innerHeight = document.body.clientHeight;
    }

    var docWidth,docHeight;
    var test1 = document.body.scrollHeight;
    var test2 = document.body.offsetHeight
    if (test1 > test2) // all but Explorer Mac
    {
    	docWidth = document.body.scrollWidth;
    	docHeight = document.body.scrollHeight;
    }
    else // Explorer Mac;
         //would also work in Explorer 6 Strict, Mozilla and Safari
    {
    	docWidth = document.body.offsetWidth;
    	docHeight = document.body.offsetHeight;
    }

    var width = Math.max(1004, Math.max(innerWidth, docWidth));
    var height = Math.max(innerHeight, docHeight);
			busyLayer.style.width = width + "px";
			busyLayer.style.height = height + "px";
		}
	}

	function hideBusyLayer() {
		var busyLayer = document.getElementById("busy_layer")
		if (busyLayer != null) {
			busyLayer.style.visibility = "hidden";
			busyLayer.style.height = "0px";
		}
	}
