<!--- TEMPORARY FUNCTION TO PRE-LOAD IMAGES FOR SLIDESHOW --->

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

<!--- ADD MORE FIELDS DYNAMICALLY FOR CONTRACTORS ADD / UPDATE PROJECT PAGE --->
function addField(options,field,limit) {

   if(!document.getElementById) return; //Prevent older browsers from getting any further.

   var field_area = document.getElementById("uploadfiles");
   var all_inputs = field_area.getElementsByTagName("input"); //Get all the input fields in the given area.

   //  Find the count of the last element of the list. It will be in the format '<field><number>'. If the 
   //  field given in the argument is 'friend_' the last id will be 'friend_4'.
   var last_item = all_inputs.length - 1;
   var last = all_inputs[last_item].id;
   var count = Number(last.split("_")[1]) + 1;

   //  If the maximum number of elements have been reached, exit the function.
   //  If the given limit is lower than 0, infinite number of fields can be created.
   if(count > limit && limit > 0) return;

   if(document.createElement) { //W3C Dom method.

      // Variables for first elements created
      var ul = document.createElement("ul");
      var li = document.createElement("li");
      var newText = document.createTextNode("File "+count);

      // Style those elements created
      li.className = "heading";
      li.style.width = "490px";
      li.style.textAlign = "left";
      li.style.fontWeight = "bold";
      li.style.marginTop = "3px";
      li.style.marginBottom = "3px";

      // Append the elements to each other
      li.appendChild(newText);
      ul.appendChild(li);

      // Create the next element
      var li = document.createElement("li");
      var p1 = document.createElement("p");
      var p2 = document.createElement("p");
      var p3 = document.createElement("p");
      var newText1 = document.createTextNode("Name The Upload File:");
      var newText2 = document.createTextNode("Select File to Upload:");
      var newText3 = document.createTextNode("Select a Category:");

      // Style those elements
      li.style.width = "156px";
      li.style.marginRight = "3px";
      li.className = "heading";
      p1.style.margin = "4px";
      p2.style.margin = "9px";
      p3.style.margin = "4px";

      // Append the elements to each other
      p1.appendChild(newText1);
      p2.appendChild(newText2);
      p3.appendChild(newText3);
      li.appendChild(p1);
      li.appendChild(p2);
      li.appendChild(p3);
      ul.appendChild(li);

      // Create the next element
      var li = document.createElement("li");
      var input = document.createElement("input");

      // Style those elements
      li.style.width = "320px";
      li.style.margin = "0";
      li.id = "title_"+count+"_title";
      input.id = "title_"+count;
      input.name = "title_"+count;
      input.type = "text"; //Type of field - can be any valid input type like text,file,checkbox etc.
      input.size = "49";
      input.style.border = "0";

      // Append the elements to each other
      li.appendChild(input);
      ul.appendChild(li);

      // Create the next element
      var li = document.createElement("li");
      var input = document.createElement("input");

      // Style those elements
      li.style.width = "320px";
      li.style.margin = "1px 0";
      input.id = "stuff_"+count;
      input.name = "stuff_"+count;
      input.type = "file"; //Type of field - can be any valid input type like text,file,checkbox etc.
      input.size = "35";

      // Append the elements to each other
      li.appendChild(input);
      ul.appendChild(li);

      // Create the next element
      var li = document.createElement("li");
      var select = document.createElement("select");

      // Style those elements
      li.style.width = "320px";
      li.style.margin = "0";
      select.id = "pickme_"+count;
      select.name = "pickme_"+count;
      select.style.width = "320px";

      // A loop to make the categories easier
      var my_options = options.split(",");
      for (var i=0; i<my_options.length; i++){
         var option = document.createElement("option");
         option.value = my_options[i++];
         var newText = document.createTextNode(my_options[i]);
         option.appendChild(newText);         
         select.appendChild(option);
      }

      // Append the elements to each other
      li.appendChild(select);
      ul.appendChild(li);

      field_area.appendChild(ul);  
   }
   document.getElementById('title_'+count+'_error').style.height='83px';
   document.getElementById('title_'+count+'_error').style.paddingTop='37px';
   document.getElementById('title_'+count+'_error').innerHTML='&nbsp;';
}

function SetAllCheckBoxes(FormName, FieldName, CheckValue){
	if(!document.forms[FormName])
		return;
	var objCheckBoxes = document.forms[FormName].elements[FieldName];
	if(!objCheckBoxes)
		return;
	var countCheckBoxes = objCheckBoxes.length;
	if(!countCheckBoxes)
		objCheckBoxes.checked = CheckValue;
	else
		// set the check value for all check boxes
		for(var i = 0; i < countCheckBoxes; i++)
			objCheckBoxes[i].checked = CheckValue;

}


<!--- OPENS UP NEW WINDOWS FOR STAFF RESPONSIBLITIES FROM HOME PAGE --->

function dpSmartLink(u,n,w,h,p) { // v1.4 by David Powers
  var a,j,k,x,y,f='';if(!n){n='';}if(w){f+='width='+w+',';}if(h){f+='height='+h+',';}
  if(p){p=p.split(':');if(p[0]!='z'){p[0]=='c'?(x=(screen.width-w)/2):x=p[0];f+='left='+x+',';}
  if(p[1]!='z'){if(p[0]=='c'){y=(screen.height-h-p[1])/2;if(navigator.appName.indexOf('Op')!=-1){
  y-=96;y=y<0?0:y;}}else{y=p[1];}f+='top='+y+',';}}a=arguments.length;if(a>5){for (k=5;k<a;k++){
  switch(arguments[k]){case 'all':f+='toolbar,menubar,location,scrollbars,status,resizable,';break;
  case 't':f+='toolbar,';break; case 'm':f+='menubar,';break;case 'l':f+='location,';break;
  case 'sc':f+='scrollbars,';break;case 's':f+='status,';break;case 'r':f+='resizable,';}}}
  if(f.charAt(f.length-1)==','){f=f.slice(0,-1);}j=window.open(u,n,f);j.focus();
  document.MM_returnValue=false;
}

<!-- SUCKERFISH SCRIPT TO GET :HOVER ON LIS FOR IE -->

sfHover = function() {
	var sfEls = document.getElementById("nav").getElementsByTagName("li");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}

function changeInputs() {
   var els = document.getElementsByTagName('input');
   var elsLen = els.length;
   var i = 0;
   for ( i=0;i<elsLen;i++ ) {
      if ( els[i].getAttribute('type') ) {
         if ( els[i].getAttribute('type') == "text" || els[i].getAttribute('type') == "password" )
            els[i].className = 'text';
      }
   }
}

function confirmDelete(){
   var answer = confirm("\t\t***** WARNING *****\n\tTHIS PROCESS IS PERMINANT AND CANNOT BE UNDONE\n\nDeleting a project will delete all files and reports associated with the project.\nAre you sure you want to delete the selected project(s)?");
   if(answer){
      form.submit();
   }else{
	   return false;
   }
}

window.onload = function() { changeInputs(); }
if (window.attachEvent) window.attachEvent("onload", sfHover);