<!--//
// horizontal nav over images

  over_services = new Image;
  over_services.src = "images/nav/services_on.gif";
  over_projects = new Image;
  over_projects.src = "images/nav/projects_on.gif";
  over_employment = new Image;
  over_employment.src = "images/nav/employment_on.gif";
  over_hsq = new Image;
  over_hsq.src = "images/nav/hsq_on.gif";
  over_qanda = new Image;
  over_qanda.src = "images/nav/qa_on.gif";
  over_partnering = new Image;
  over_partnering.src = "images/nav/partnering_on.gif";
  over_clientarea = new Image;
  over_clientarea.src = "images/nav/clientarea_on.gif";

   
  
  
// horizontal nav off images

  off_services = new Image;
  off_services.src = "images/nav/services_off.gif";
  off_projects = new Image;
  off_projects.src = "images/nav/projects_off.gif";
  off_employment = new Image;
  off_employment.src = "images/nav/employment_off.gif";
  off_hsq = new Image;
  off_hsq.src = "images/nav/hsq_off.gif";
  off_qanda = new Image;
  off_qanda.src = "images/nav/qa_off.gif";
  off_partnering = new Image;
  off_partnering.src = "images/nav/partnering_off.gif";
  off_clientarea = new Image;
  off_clientarea.src = "images/nav/clientarea_off.gif";


  

// primary nav on images

  on_services = new Image;
  on_services.src = "images/nav/services_on.gif";
  on_projects = new Image;
  on_projects.src = "images/nav/projects_on.gif";
  on_employment = new Image;
  on_employment.src = "images/nav/employment_on.gif";
  on_hsq = new Image;
  on_hsq.src = "images/nav/hsq_on.gif";
  on_qanda = new Image;
  on_qanda.src = "images/nav/qa_on.gif";
  on_partnering = new Image;
  on_partnering.src = "images/nav/partnering_on.gif";
  on_clientarea = new Image;
  on_clientarea.src = "images/nav/clientarea_on.gif";
 

  

// function for the rollovers
  function ImgFunc(imgDocID, imgObjName) {
      document.images[imgDocID].src = eval(imgObjName + ".src")
}
function imgOn(imgName) {
        if (document.images) {
            document[imgName].src = eval(imgName + "on.src");
        }
}

function imgOff(imgName) {
        if (document.images) {
            document[imgName].src = eval(imgName + "off.src");
        }
}

function setRowClass(src, style) {
	src.className = style;
}

function validateLoginForm() {
	var err = 0;
	var errors = 'Sorry, the following error(s) exist on the form:\n';

	if (!document.login_form.username.value) {
		err++;
		errors += ' - please enter your username\n';
	}

	if (!document.login_form.password.value) {
		err++;
		errors += ' - please enter your password\n';
	}

	if (err > 0) {
		alert(errors);	
	}

	return (err == 0);
}
	

/* search the dom for the object */
function findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document;
  if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);
  }
  if(!(x=d[n])&&d.all) {
    x=d.all[n];
  }
  for (i=0;!x&&i<d.forms.length;i++) {
    x=d.forms[i][n];
  }
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) {
    x=findObj(n,d.layers[i].document);
  }
  if(!x && d.getElementById) {
    x=d.getElementById(n);
  }
  // alert('object ' + n + ' is ' + x);
  return x;
}


/* find then set a layers visibility */
function showHideLayers() { //v6.0
  var i,p,v,obj,args=showHideLayers.arguments;

  for (i=0; i<(args.length-2); i+=3) {

        if ((obj=findObj(args[i]))!=null) {
            v=args[i+2];
            if (obj.style) {
                obj=obj.style;
                v=(v=='show')? 'visible' : (v=='hide')? 'hidden':v;
            }
            obj.visibility=v;
    }
  }
}

/* takes the highlighting of a field */
function blurField(field) {
	try {
		var classes = field.className.split(" fieldOn");
		if (classes.length > 0) {
			field.className = classes[0];
		}
	} catch (error) {

	}
}

/* puts highlighting focus on a field */
function focusField(field) {
	
	try {
	  field.className = field.className + ' fieldOn';
	  field.focus();
	} catch (error) {

	}
}

/* sets the background colour of a field */
function setColour(src, colour) {
  src.style.backgroundColor=colour;
}

/**
 * Set the css class of an object
 */
function setClass(src, name) {
  src.className = name;
}

/* selects an array element */
function selectRadio(groupName, newval) {
   var buttonGroup;

   // get the button group element from its name
   eval("buttonGroup = " + groupName);

   for (var i=0; i<buttonGroup.length; i++) {

         if (buttonGroup[i].value == newval) {
            buttonGroup[i].checked = true;
         }
      }
   }

function getSelectedRadio(buttonGroup) {
   // returns the array number of the selected radio button or -1 if no button is selected
   if (buttonGroup[0]) { // if the button group is an array (one button is not an array)
      for (var i=0; i<buttonGroup.length; i++) {
         if (buttonGroup[i].checked) {
            return i
         }
      }
   } else {
      if (buttonGroup.checked) { return 0; } // if the one button is checked, return zero
   }
   // if we get to this point, no radio button is selected
   return -1;
} // Ends the "getSelectedRadio" function

function getSelectedRadioValue(buttonGroup) {
   // returns the value of the selected radio button or "" if no button is selected
   var i = getSelectedRadio(buttonGroup);
   if (i == -1) {
      return "";
   } else {
      if (buttonGroup[i]) { // Make sure the button group is an array (not just one button)
         return buttonGroup[i].value;
      } else { // The button group is just the one button, and it is checked
         return buttonGroup.value;
      }
   }
} // Ends the "getSelectedRadioValue" function

/**
 * Set a layers display value
 */
function displayLayer(name, value) {

	element = findObj(name);

	if (element != null) {

		//
		if (value == 'none') {
			element.style.display = 'none';
		} else {
			element.style.display = '';
		}
	}
}

/**
 * Check if the value of a field is i digit
 */
function isDigit(textfield) {

	var numeric = /^[0-9]+$/.test(textfield.value);
	if (!numeric) {
		alert('Please enter a numeric value');
		return false;
	}
	return true;

}

/**
 * Sets the inner html for a label
 */
function setLabel(lbl, value) {
	var obj;
	if ((obj = findObj(lbl)) != null) {
		obj.innerHTML = value;
	}
}

/**
 * The general page submissiong script, calls the validation
 * which can in turn show any errors
 */
function submitForm() {

	if (validateForm()) {
		document.form.submit();
		return true; // never gets to here
	}

	return false;
}

/**
 * Sets the selected option on a select
 */
function selectOption(field, value) {
	options = field.options;

	for(i=0;i<options.length;i++) {

		if (options[i].value == value) {
			field.options.selectedIndex = i;
		}
	}
}

function confirmDelete(item) {
  	return confirm('Are you sure you want to delete this ' + item + '?\n\tTo continue click \'OK\'\n');
}

function openPopup(height, width) {
	var left = 0;
	var top = 0;

	try {
	    left = (screen.width) ? (screen.width-width)/2 : 0;
    	top  = (screen.height) ? (screen.height-height)/2 : 0;
	} catch (error) {
		// 
	}

	window.open("","x",'toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=1,width=' + width + ',height=' + height + ',left=' + left + ',top=' + top + ',resizable=1');
}

//
function onOffElements(show,elList,toggleBy) {
   	HM_DOM = document.getElementById ? true : false;
    HM_IE  = document.all ? true : false;
	HM_NS4 = document.layers ? true : false;

	if(!(HM_DOM||HM_IE||HM_NS4)) {
		return true;
	}

	if(HM_NS4&&(toggleBy=="tag")) { 
		return true;
	}

	for(var i=0; i<elList.length; i++) {
		var ElementsToToggle = [];
		switch(toggleBy) {
			case "tag":
				ElementsToToggle = (HM_DOM) ? document.getElementsByTagName(elList[i]) : document.all.tags(elList[i]);
				break;
			case "id":
				ElementsToToggle[0] = (HM_DOM) ? document.getElementById(elList[i]) : (HM_IE) ? document.all(elList[i]) : document.layers[elList[i]];
				break;
		}
	}
		
	for(var j=0; j<ElementsToToggle.length; j++) {
		var theElement = ElementsToToggle[j];
		if(!theElement) { 
			continue; 
		}
		if(HM_DOM||HM_IE) {
			theElement.style.visibility = show ? "inherit" : "hidden";
		} else if (HM_NS4) {
			theElement.visibility = show ? "inherit" : "hide";
		}
	}
	return true;
}
//-->
