//-----( Global functions )------------------------------------
var hideBgHandle;

function ajaxExceptionHandler(transport, e){
  try {
    if ( Ajax.getTransport()== false ) {
      //let the global handler deal with this.
      //todo need a better way to interact with global handler?
      return;
    }
  } catch(e) {
  }
  
  try {
    var hdr = 'Ajax Handler\n' 
            + 'An exception occurred. Provide this information to support.\n\n'
    var transportPart = 'State: ' + transport.readyState + "\n"
                      + 'Status: ' + transport.status + "\n\n";
    var exception = 'Exception Info\n     ' + e + '\n\n';
    try {
      var parts = 
          'Description:         ' + e.description + '\n' 
        + 'FileName:            ' + e.fileName + '\n' 
        + 'LineNumber:          ' + e.lineNumber + '\n' 
        + 'Message:             ' + e.message + '\n'
        + 'Name:                ' + e.name + '\n'
        + 'Number:              ' + e.number + '\n'
        + 'Prototype:           ' + e.prototype + '\n'
        + 'Stack:               ' + e.stack + '\n';
        
      var responseText = transport.responseText;      
    }  catch(e) {
    }
  
    var message = hdr + transportPart + exception + parts + '\n\n\n' + responseText;
    alert(message);
  } catch (e) {
  }
}


// go to a location
function gotoUrl(url) {
	window.location.href = url;
}

// open a popup window with params
function popupUrl(url, name, features) {
	var newWindow = window.open(url, name, features);
	newWindow.focus();
}

// element toggler
function toggle(id) {
	var element = document.getElementById(id);
	if (element.style.display == "block") {
		element.style.display = "none";
	} else {
		element.style.display = "block";
	}
} // toggle

// toggle the visibility property -- combine with toggle function
function toggleVisibility(id) {
	var el = document.getElementById(id);
	if (el.style.visibility == "visible" 
	|| el.style.visibility == "") {
		el.style.visibility = "hidden";
	} else {
		el.style.visibility = "visible";
	}
	
}

// toggle the display property -- combine with toggle function
function toggleDisplay(id) {
	var el = document.getElementById(id);
	if (el.style.display == "block" 
	|| el.style.display == "") {
		el.style.display = "none";
	} else {
		el.style.display = "block";
	}
}

// encode urls
function urlEncode(str){
	str = escape(str);
	str = str.replace(new RegExp('\\+','g'),'%2B');
	return str.replace(new RegExp('%20','g'),'+');
} // urlEncode

// decode urls
function urlDecode(str){
	str = str.replace(new RegExp('\\+','g'),' ');
	return unescape(str);
} // urlDecode

// get the left n characters from a string
function left(str, n){
  if (n <= 0) {
	  return "";
	} else if (n > String(str).length) {
    return str;
	} else {
	  return String(str).substring(0, n);
  }
} // left

// get the right n characters from a string
function right(str, n){
  if (n <= 0) { 
    return "";
  } else if (n > String(str).length) {
    return str;
  } else {
    var iLen = String(str).length;
    return String(str).substring(iLen, iLen - n);
  }
} // right

// trim the leading and trailing spaces from a string
function trim(str) {
	str = str.replace(/^\s*|\s*$/g,"");
	return str;
} // trim

// looks in array for a specified value
function inArray(array, value) {
	for (var i=0; i<array.length; i++) {
		if (array[i] == value) {
			return true;
		}
	}
	return false;
}

// remove an element
function removeElement(el) {       
	if (el.parentNode) {
		el.parentNode.removeChild(el);
	}
} // removeElement

// insert content after an existing element
function insertAfter(newElement, existingElement) {
	var parentElement = existingElement.parentNode;
	if (parentElement.lastChild == existingElement) {
		return parentElement.appendChild(newElement);
	} else {
		return parentElement.insertBefore(newElement, existingElement.nextSibling);
	}
} // insertAfter

// this function is needed to work around 
// a bug in IE related to element attributes
function hasClass(obj) {
	var result = false;
	var classAttr = obj.getAttribute("class");
	if (classAttr != null) {
		result = classAttr.value;
	}
	return result;
}



// determine if the string is alpha numeric only
function isAlphaNumeric(string) {
  var matcher = string.match(/^\w+$/);
  if (matcher != null) { return true; } else { return false; }
} // isAlphaNumeric

// determines if the year is a leap year
function isLeapYear(year) {
  if (year%4 == 0 && year%100 != 0 || year%400 == 0) { return true; } else { return false; }
} // isLeapYear

// enable/disable elements
function enable(el) { document.getElementById(el.id).disabled = false; }
function disable(el) { document.getElementById(el.id).disabled = true; }
function enableThis(el) { el.disabled = false; }
function disableThis(el) { el.disabled = true; }

//-----( END )-------------------------------------------------


//-----( @Prototypes )-----------------------------------------
// Summary: prototype implementations of existing javascript functions

// prototype implementation of the trim function
String.prototype.trim = function() {
  var x = this;
  return trim(x);
}

// prototype implementation of the left function
String.prototype.left = function(n) {
	var x = this;
	return left(x, n);
};

// prototype implementation of the right function
String.prototype.right = function(n) {
	var x = this;
	return right(x, n);
};

Array.prototype.inArray = function(n) {
	var x = this;
	return inArray(x, n);
};

Array.prototype.shuffle = function() {
  var len = this.length;
  var rand, temp, i;
  for (i = 0; i < len; i++){
    rand = Math.floor(Math.random() * len);
    temp = this[i];
    this[i] = this[rand];
    this[rand] = temp;
  }
};

Array.prototype.copy = function() {
  return this.slice();
};

Array.prototype.indexOf = function(value) {
  var i = 0;
  while(i < this.length){
    if(this[i] == value) return i;
    i++;
  }
  return -1;
}

Array.prototype.lastIndexOf = function(value) {
  var i = this.length;
  while (--i){
    if (this[i] == value) {
			return i;
		}
  }
  return -1;
}
//-----( END )-------------------------------------------------


// determines if the link has a # in it, then highlights the area
function doHighlight(href) {
  if (href.indexOf('#') != -1) {
    var pos = href.indexOf('#');
    pos = href.length - pos;
    href = right(href, pos -1);
    new Effect.Highlight(href);
  }
}


// sets the value of a select list
function setSelected(el, value) {
  var listObj = document.getElementById(el);
  var length = listObj.length;
  for (var i=0; i<length; i++) {
    if (listObj.options[i].text == value
    || listObj.options[i].value == value) {
      listObj.options[i].selected = true;
    }
  }
} // setSelected


// show MSDS popup window
function viewMsds(url) {
	var name = "fcom_msds_popup";
	var features = "width=785,height=589,";
	features += "directories=no,location=yes,menubar=yes,";
  features += "resizable=yes,scrollbars=yes,status=yes,toolbar=yes";
	popupUrl(url, name, features);
} // viewMsds


// IE6 only, all other browsers will ignore.
// This is used to imitate the css :hover 
// use: applyHover($("NAMEOFCONTAINER"), 'TYPEOFTAG');
// css mod: #NAMEOFCONTAINER TYPEOFTAG:hover {} -> #NAMEOFCONTAINER TYPEOFTAG:hover, #NAMEOFCONTAINER TYPEOFTAG.hover {} 
function applyHover(container, tagType){
  if (document.all&&container.getElementsByTagName&&!window.XMLHttpRequest) {
    var elementsToHover = container.getElementsByTagName(tagType);
    for (i=0; i<elementsToHover.length; i++) {
      node = elementsToHover[i];
      node.onmouseover=function() {
        this.className+=" hover";
      }
      node.onmouseout=function() {
        this.className=this.className.replace(" hover", "");
      }
    }
  }
}// applyHover


function checkTimeOut(errorHTML, redirect) {
	errorHTML = errorHTML.stripTags();
	errorHTML = errorHTML.strip();
	var timeout = false;
	errorHTML.scan(/\w+/, function(match){ if(match[0] == 'timeout') timeout = true; });
	if (timeout == true){
		var sURL = redirect; //'../accounts.ex';
		window.location.href = sURL;
		return false;
	}
	return true;
} //end checkTimeOut

function checkResponseForErrors(transport) {
	var status = true;
	
	try{
    var urlLocation = transport.getResponseHeader("Content-Location");
    //alert(urlLocation);
    if (urlLocation.indexOf('login') > 0){
      //window.location.href = '/web/products.ex';
      var pageFrom = "?pageFrom=" + document.getElementById('pageFrom').value;
      var sURL = SITE_ROOT + 'login/signin.ex';
      window.location.href = sURL + pageFrom;
      status = false;
    }
  }catch (e){
    
  }finally{
    return status;
  }
  
  
	
} //end checkResponseForErrors


function handleErrorForwarding(urlLocation){
	
	  if (urlLocation.indexOf('products') > 0){
		window.location.href = SITE_ROOT + 'products.ex';
	  }
	
	
	  if (urlLocation.indexOf('pohistory') > 0){
		window.location.href = SITE_ROOT + 'history.ex';
	  }
		
		
	  if (urlLocation.indexOf('login') > 0){
		var pageFrom = "?pageFrom=" + document.getElementById('pageFrom').value;
		var sURL = SITE_ROOT + 'login/signin.ex';
		window.location.href = sURL + pageFrom;
	  }
	
}

  function showPopInBackground(){
    try{
        if(hideBgHandle){
          //clear setInterval for hiding bg see hidePopInBackground()
          clearInterval(hideBgHandle);
          hideBGHanle=null;
        }//end if
    }catch(e){
    }

  document.getElementById("shadeOutBackground").style.visibility = 'visible';
  document.getElementById("loadingBar").style.display = 'block';
  //when the background is made visible, IE6 needs this to make it fill up the whole page
  if (!window.XMLHttpRequest) {//IE6 and other older browsers only
    //var wrapHeight = document.getElementById("wrap").getHeight() + 'px';
    var wrapHeight = 1000;//window.screen.availHeight;
    document.getElementById("shadeOutBackground").style.height = wrapHeight;
    document.getElementById("shadeOutBackground").style.position = "absolute";
    document.getElementById("loadingBar").style.height = wrapHeight;
    document.getElementById("loadingBar").style.position = "absolute";
  }
} //end showPopInBackground


function hidePopInBackground() {
  //alert('hidePopInBackground begin');
  //$("shadeOutBackground").style.visibility = 'hidden';
  //$("loadingBar").style.display = 'none';
  //alert('hidePopInBackground end');
  
  //ensure background is hidden by looping until it is.
  hideBgHandle = setInterval (hidePopInBackgroundInterval,500);
}
//run repeatedly until the background is hidden
//once hidden exectute clearInterval
function hidePopInBackgroundInterval(){
  document.getElementById("shadeOutBackground").style.visibility = 'hidden';
  document.getElementById("loadingBar").style.display = 'none';
  if(isBackgroundHidden() ){
    clearInterval(hideBgHandle);
    hideBgHandle=null;
  };
}
//returns true if pop in bg is hidden
function isBackgroundHidden(){
  if (document.getElementById("shadeOutBackground").style.visibility == 'hidden'
      && document.getElementById("loadingBar").style.display == 'none'){
      return true;
  }else{
    return false;
  }
}

function openPopIn(section, clickedElement) {
  showPopInBackground();    
  document.getElementById(section + "PopIn").centerOn(clickedElement);
  Effect.Appear(section + "PopIn", {duration:.5});
  Effect.Fade("loadingBar", {duration:.5});
  document.getElementById("display" + section + "Errors").innerHTML = "";
  if (document.getElementById(section + "Errors") != null) {
    document.getElementById(section + "Errors").innerHTML = ""; 
  }
}


function popupEdit(section) {
  openPopIn(section, document.getElementById(section));
}


function sendSavePopIn(section, url, formSubmitted) {
  disable(document.getElementById('submit' + section));
  if ( formSubmitted == null ) {
    formSubmitted = document.getElementById("form" + section);
  }
  
  if ( document.getElementById(section + "PopIn") != null ) {
    Effect.Fade(section + "PopIn", {duration:.2});
  }
  
  Effect.Appear("loadingBar", {duration:.2});
  document.getElementById('temp' + section).innerHTML = '';
  new Ajax.Updater( {success:'temp' + section}
                  , url
                  , { 
                      asynchronous:true
                    , parameters:Form.serialize(formSubmitted)
                    , onComplete:function(transport){savePopIn(transport, section);}
                    , onException:function(transport,e ){failedSendSavePopIn(transport, section,e);} 
                    
                    } );
} //end sendSavePopIn


function savePopIn(transport, section) {
  //alert('save popIn: ' + section);
	var response = transport.responseText;
	//alert("response: " + response);
  //alert('savePopin: ' + transport.status);
  
  if (transport.status>1000){
    //alert('savePopin abort, crazy status code: ' + transport.status);
    failedPopIn(transport, section, 'Status code: ' + transport.status);
    return;
  }
  
  try{
  if (document.getElementById('temp' + section).innerHTML != null && document.getElementById('temp' + section).innerHTML != '') {
		var errorHTML = 'none';
		if (document.getElementById(section + "Errors") != null) { 
			errorHTML = document.getElementById(section + "Errors").innerHTML; 
		}
		errorHTML = errorHTML.stripTags();
		errorHTML = errorHTML.strip();
    //alert('check transport for errors');
		if (checkResponseForErrors(transport)) {
			if (errorHTML == "none") {
				document.getElementById(section).innerHTML = document.getElementById('temp' + section).innerHTML;
				Effect.Fade(section + "PopIn", {duration:.5});
				Effect.Fade("loadingBar", {duration:.5});
				setTimeout("popInCleanup('" + section + "', true)", 500);
			} else {
				Effect.Appear(section + "PopIn", {duration:.5});
				Effect.Fade("loadingBar", {duration:.5});
				document.getElementById("display" + section + "Errors").innerHTML = document.getElementById(section + "Errors").innerHTML;
				document.getElementById("display" + section + "Errors").style.display = "block";
			}
			document.getElementById(section + "Errors").innerHTML = "";
			document.getElementById('temp' + section).innerHTML = "";
		}
		enable(document.getElementById('submit' + section));
	} else { //something failed in the ajax call, clean up the code
		//alert("failedPopIn was called from savePopIn."+ "\n response: " + response); //Error tracking
    failedPopIn(transport, section);
	}
  }catch(e){
    //throw e;
  }finally{
    //alert('finally');
  }
} //end savePopIn

function failedSendSavePopIn(transport, section,e) {
  failedPopIn(transport, section,e);
  if(e){
    //setTimeout("popInCleanup('" + section + "', true)", 500);
    hidePopInBackground();
  }
}


function failedPopIn(transport, section,e) {
  //alert('failed popin');
  enable(document.getElementById('submit' + section));
	ajaxExceptionHandler(transport, e);
  popInCleanup( 'failed', false );
  
  
  
  
  //throw e;
  //todo, reset form?
}


function cancelPopIn(section) {
  Effect.Fade(section + "PopIn", {duration:.5});
  document.getElementById("shadeOutBackground").style.visibility = 'hidden';

  document.getElementById("form" + section).reset();

  setTimeout("popInCleanup('" + section + "', false)", 500);
}


function resetDefaultValues(form) {
  var iMaxElements = form.elements.length;
  for (var i = 0; i < iMaxElements; i++) {
    myType = form.elements[i].type;
    if (myType == 'checkbox' || myType == 'radio') {
      form.elements[i].defaultChecked = form.elements[i].checked;
    }
    
    if (myType == 'hidden' || myType == 'password' || myType == 'text' || myType == 'textarea') {
      form.elements[i].defaultValue = form.elements[i].value;
    }
    
    if (myType == 'select-one' || myType == 'select-multiple') {
      var iMaxElementsOptions = form.elements[i].options.length;
      for (var j = 0; j < iMaxElementsOptions; j++) {
        form.elements[i].options[j].defaultSelected = form.elements[i].options[j].selected;
      }
    }
  }
} //end resetDefaultValues


function copyAllValues(className, newValue) {
  if(confirm('Are you sure you want to update all values to: ' + newValue + '?')){
		var classInputs = getElementsByClassName(className, "input");
		classInputs.each(function(classInput) {
      classInput.value = newValue;
		});
  }
}


//Error tracking
function exceptionInSendSavePopIn() {
  alert("There was an exception in sendSavePopIn.")
}

function getStyle(oElm, strCssRule){
	var strValue = "";
	if(document.defaultView && document.defaultView.getComputedStyle){
		strValue = document.defaultView.getComputedStyle(oElm, "").getPropertyValue(strCssRule);
	}
	else if(oElm.currentStyle){
		strCssRule = strCssRule.replace(/\-(\w)/g, function (strMatch, p1){
			return p1.toUpperCase();
		});
		strValue = oElm.currentStyle[strCssRule];
	}
	return strValue;
}

function findPos(obj) {
  var curleft = 0;
  var curtop = 0;
  
  if (obj.offsetParent) {
    do {
      curleft += obj.offsetLeft;
      curtop += obj.offsetTop;
    } while (obj = obj.offsetParent); /* this line is correct, this will return false when obj.offsetParent == 'HTML' */
    
    return [curleft, curtop];
  }
}

//create function, it expects 2 values.
function insertAfter(newElement,targetElement) {
	//target is what you want it to go after. Look for this elements parent.
	var parent = targetElement.parentNode;
	
	//if the parents lastchild is the targetElement...
	if(parent.lastchild == targetElement) {
		//add the newElement after the target element.
		parent.appendChild(newElement);
		} else {
		// else the target has siblings, insert the new element between the target and it's next sibling.
		parent.insertBefore(newElement, targetElement.nextSibling);
		}
}

function rmWhiteSpace(str) {
    spaceFree = str.replace(/\s+/g,'');
 
    return spaceFree;   
}

// Creates the isContainedIn function
if ( !window.Element ) {
	Element = function() {};
  
  var element = new Element;
  _isContainedIn = element.isContainedIn;
}

// The following code is to support IE...  THIS CODE NEEDS TO STAY
if (!document.getElementsByClassName) { // This check makes sure the default class isn't over written.
    document.getElementsByClassName = function(className) {
        var hasClassName = new RegExp("(?:^|\\s)" + className + "(?:$|\\s)");
        var allElements = document.getElementsByTagName("*");
        var results = [];
        
        var element;
        for (var i = 0; (element = allElements[i]) != null; i++) {
            var elementClass = element.className;
            if (elementClass && elementClass.indexOf(className) != -1 && hasClassName.test(elementClass))
                results.push(element);
        }
        
        return results;
    }
}

function showPopup(ref) {
  var location = ref.getAttribute("href");
  
  if (location != null || location != "") {
    var name = "fcom_help_popup";
    var features = "width=500,height=400,";
    features += "directories=no,location=no,menubar=no,";
    features += "resizable=no,scrollbars=yes,status=yes,toolbar=no";
    popupUrl(location, name, features);
    
  }
    
  return false;
}

function popupUrl(url, name, features) {

	var newWindow = window.open(url, name, features);

	//newWindow.focus();
}

function SetAllCheckboxes(FormName, FieldName, CheckValue) {
    // Required: FormName = The name of the form that will have Checkboxes modified.
    // Required: FieldName = The name of the checkboxes that will be modified.
    // Required: CheckValue = true(selected) or false(deselected)
    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 {
        for(var count=0;count<countCheckBoxes;count++) {
        objCheckBoxes[count].checked = CheckValue;
        }
    }
}

function getScrollXY() {
  var scrOfX = 0, scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
    scrOfX = window.pageXOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    scrOfY = document.body.scrollTop;
    scrOfX = document.body.scrollLeft;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
    scrOfX = document.documentElement.scrollLeft;
  }
  return [ scrOfX, scrOfY ];
}

function getWindowSize() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  
  return [ myWidth, myHeight ];
}

function addLoadEvent(func) { 
    var oldonload = window.onload; 
    
    if (typeof window.onload != 'function') { 
      window.onload = func; 
    } else { 
      window.onload = function() { 
        if (oldonload) { 
          oldonload(); 
        }
        
        func(); 
      } 
    } 
} 

function setPath( sExec , sParam ) {
  var fullPath = window.location.toString();
  var endLocation = fullPath.indexOf(SITE_ROOT, SITE_ROOT.length);
  var newPath = SITE_ROOT + sExec + "?" + sParam;
      
  return newPath;
}

function getStyle(elem, name) {
    // J/S Pro Techniques p136
  if (elem) {
    if (elem.style[name]) {
        return elem.style[name];
    } else if (elem.currentStyle) {
        return elem.currentStyle[name];
    }
    else if (document.defaultView && document.defaultView.getComputedStyle) {
        name = name.replace(/([A-Z])/g, "-$1");
        name = name.toLowerCase();
        s = document.defaultView.getComputedStyle(elem, "");
        return s && s.getPropertyValue(name);
    } else {
        return null;
    }
  }
}

function preloadImage(path) {
  pic1= new Image(100,100); 
  pic1.src= path; 
}

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}

function isVisible(e) {
  //returns true is should be visible to user.
  if (typeof e == "string") {
    e = document.getElementById(e);
  }
  while (e.nodeName.toLowerCase() != 'body' && e.style.display.toLowerCase() != 'none' && e.style.visibility.toLowerCase() != 'hidden') {
    e = e.parentNode;
  }
  if (e.nodeName.toLowerCase() == 'body') {
    return true;
  } else{
    return false;
  }
}

function getParameter(name) {
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );
  if( results == null )
    return "";
  else
    return results[1];
}

function popWindow(D,C,E,B) {
  var A=(screen.width-E)/2;
  var H=(screen.height-B)/2;
  var F="height="+B+",width="+E+",screenX="+A+",left="+A+",screenY="+H+",top="+H+",location=no,scrollbars=yes,menubar=no,resizable=no,status=no,toolbar=no";
  var G=window.open(D,C,F);
  G.focus();
}

// Container object for global variables
var FASTENAL = {};

//Cart summary	
FASTENAL.globalCurrent;	// global references to current element
FASTENAL.globalRelated;
FASTENAL.current;	// setTimeout() call for cart summary delay
FASTENAL.related;
FASTENAL.time;

var preventCartState = false;

var fastenal = {
    byId: function(obj) {
        return document.getElementById(obj);
    },
    
    byClass: function(obj) {
        return document.getElementsByClassName(obj);
    },
    
    gotoUrl: function(url) {
        window.location = url;
    },
    
    toggle: function(obj, link) {
        obj = document.getElementById(obj);

        if (obj) {
          if (getStyle(obj,"display") == "block")
              obj.style.display = "none";
          else obj.style.display = "block";

          i = 0;
          
          // toggles max/min child nodes if present
          if (link) {
            for (i=0;i<link.childNodes.length;i++) {
                if (link.childNodes[i].className == "maximize") {
                    link.childNodes[i].className = "minimize";
                } else if (link.childNodes[i].className == "minimize") {
                    link.childNodes[i].className = "maximize";
                }
            }
          }
        }        
    },
    
    setAllCheckboxes: function(FormName, FieldName, CheckValue) {
        SetAllCheckboxes(FormName, FieldName, CheckValue);
    },
    
    enableOn: function(str, obj, target) {
        if (obj.value == str) {
            target.disabled = false;
            target.focus();
        } else {
            target.value = "";
            target.disabled = true;
        }
    },
    
  addLoadEvent: function(func) {
    var oldonload = window.onload;
    if (typeof window.onload != 'function') {
      window.onload = func;
    } else {
      window.onload = function() {
        if (oldonload) oldonload();
        func();
      }
    }
  }
};