

   //'
   //'NAVIGATION INDEX BIG TILES (Hover over and they grow larger
   //'
   var commonBigTileSaveWidth;
   var commonBigTileSaveHeight;
   function commonBigTile(commonBigTileItem,commonBigTileEnable) {
      if (commonBigTileEnable) {
         commonBigTileSaveWidth=commonBigTileItem.style.width;
         commonBigTileSaveHeight=commonBigTileItem.style.height;
         commonBigTileItem.style.width="50px";
         commonBigTileItem.style.height="50px";
         }
      else {
         commonBigTileItem.style.width=commonBigTileSaveWidth;
         commonBigTileItem.style.height=commonBigTileSaveHeight;
         }
      }
   //'
   //'QUICK SEARCH
   //'
   var CommonSearchPrompt = '';
   var timer;
   function commonSearchAJAX() {
      if (document.getElementById('commonSearch').value != '') {
         //'Submit the AJAX request
         document.getElementById('commonSearchTip').innerHTML="";
         commonLibraryAJAXPostHTML('/Common/CommonSearchAJAX.htm', 'CommonSearchAJAX.Search=' + escape(document.getElementById('commonSearch').value) + '&CommmonSearchAJAX.SearchType=' + escape(document.getElementById('commonProductType').value), 'commonSearchResults', '', true);
         }
      }
   function commonSearchUpdate() {
      if (document.getElementById('commonSearch').value != '') {
         clearTimeout(timer);
         timer=setTimeout('commonSearchAJAX();',500);
         document.getElementById('commonSearchButton').style.visibility = 'visible';
         document.getElementById('commonSearchTip').innerHTML="&uarr; Type&hellip;Pause&hellip;Preview";
         if (document.getElementById('commonQuickSearchTeaser')) {document.getElementById('commonQuickSearchTeaser').style.visibility='hidden';}
         if (document.getElementById('commonSearchListTip')) {document.getElementById('commonSearchListTip').style.visibility='hidden';}
         if (document.getElementById('commonSearchDropDown')) {document.getElementById('commonSearchDropDown').style.visibility='hidden';}
         }
      else {
         document.getElementById('commonSearchResults').style.visibility = 'hidden';
         document.getElementById('commonSearchResults').innerHTML='';
         document.getElementById('commonSearchButton').style.visibility = 'hidden';
         document.getElementById('commonSearchTip').innerHTML="";
         }
      }

   //'
   //' DIV TOGGLE ON/OFF
   //'
   function toggleDiv(element, showDiv)
   {
      var e = document.getElementById(element); 
      var s;

      if (showDiv == null || showDiv == 'undefined') // if showDiv is not specified, toggle the div from it's current state.
         s = (e.style.display == 'block') ? 'none' : 'block';
      else if (Boolean(showDiv))
         s = 'block';
      else
         s = 'none';

      e.style.display = s;
   }
   //'
   //' PANEL CHANGE
   //'
   //' Set a panel on a form to the value of another panel
   //' The target is called "panel" by default.
   //' panelChange("FooBar"); sets the <Div ID=FooBar> to an empty area
   //' panelChange("Somewhere","FooBar"); sets <Div ID=Somewhere> to the value of <Div ID=FooBar>
   //'
   function panelChange(panelChangeDestination,panelChangeSource) {
      if (panelChangeSource != null && panelChangeSource != undefined) {
         document.getElementById(panelChangeDestination).innerHTML=document.getElementById(panelChangeSource).innerHTML;
         }
      else {
         //' If no source specified, then empty the destination
         document.getElementById(panelChangeDestination).innerHTML="";
         }
      }

   //'
   //' AJAX: POST HTML (Returns HTML into a DIV or SPAN)
   //'
   //' POST type transactions have the distinct advantage that they are not limited by the number of characters sent to server.
   //' POST transactions are not cached within the browser, while GET transactions are.
   //' However, POST transactions are ever so slightly less efficient and are larger.
   //'
   var http_request = false;
   function commonLibraryAJAXPostHTML(url, parameters, divId, waitMessage, visibilityAuto, onDoneFunction) {
      //PARAMETERS EXAMPLES:
      //   url:        'Debugger/DebuggerAjax.htm' // The URL to make the Ajax Request to
      //   parameters: 'Debugger.Command=' + encodeURI( document.getElementById('TextAreaID').value ) // data to send to the Ajax page handler
      //   divID:      'The section that the result is to be stuffed into
      //   visivilityAuto: 'If true, the divId is made visible when the result comes in.
      //Use encodeURI() anything that could contain special characters
      var element = document.getElementById(divId);
      http_request = false;
      if (window.XMLHttpRequest) {
         // Mozilla, Safari,...
         http_request = new XMLHttpRequest();
         if (http_request.overrideMimeType) {
            // set type accordingly to anticipated content type
            //http_request.overrideMimeType('text/xml');
            http_request.overrideMimeType('text/html');
            }
         }
      else if (window.ActiveXObject) {
         // IE versions prior to 7
         try {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
            }
         catch (e) {
            try {
               http_request = new ActiveXObject("Microsoft.XMLHTTP");
               }
            catch (e) {
               }
            }
         }
      if (!http_request) {
         element.innerHTML= 'Cannot create XMLHTTP instance';
         if (visibilityAuto) {
            element.style.visibility = 'visible';
            }
         }

      http_request.onreadystatechange = function() {
         if (http_request.readyState == 4) {
            element = document.getElementById(divId);
            if (http_request.status == 200) {
               try {
                  element.innerHTML = http_request.responseText;
                  } 
               catch (e) {
                  var tn = element.tagName;
                  if(tn=='TBODY' || tn=='TR' || tn=='TD') {
                     var tempDiv = document.createElement("div");
                     tempDiv.innerHTML = '<table id="tempTable" style="display: none">' + http_request.responseText + '</table>';
                     element.parentNode.replaceChild(tempDiv.getElementsByTagName(tn).item(0), element);
                     }
                  else throw e;
                  }

               if (onDoneFunction != null && onDoneFunction != 'undefined' && onDoneFunction != '') {
                  eval(onDoneFunction);
                  }
               }
            else {
               element.innerHTML= 'There was a problem with the AJAX request. ' + http_request.status;
               }
            if (visibilityAuto) {
               element.style.visibility = 'visible';
               }
            }
         };
      http_request.open('POST', url, true);
      if (waitMessage != '') {
         try {
            element.innerHTML = waitMessage;
            } 
         catch (e) {
            var tn = element.tagName;
            if(tn=='TBODY' || tn=='TR' || tn=='TD') {
               var tempDiv = document.createElement("div");
               tempDiv.innerHTML = '<table id="tempTable" style="display:none;">' + waitMessage + '</table>';
               element.parentNode.replaceChild(tempDiv.getElementsByTagName(tn).item(0), element);
               }
            else throw e;
            }
         }
      http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
      http_request.setRequestHeader("Content-length", parameters.length);
      http_request.setRequestHeader("Connection", "close");
      http_request.send(parameters);
      }
   //'
   //' AJAX: POST EVALUATE (Execute the AJAX Returned Results
   //'
   function commonLibraryAJAXPostEval(url, parameters) {
      //PARAMETERS EXAMPLES:
      //   url:        'Debugger/DebuggerAjax.htm' // The URL to make the Ajax Request to
      //   parameters: 'Debugger.Command=' + encodeURI( document.getElementById('TextAreaID').value ) // data to send to the Ajax page handler
      //Use encodeURI() anything that could contain special characters
      http_request = false;
      if (window.XMLHttpRequest) {
         // Mozilla, Safari,...
         http_request = new XMLHttpRequest();
         if (http_request.overrideMimeType) {
            // set type accordingly to anticipated content type
            //http_request.overrideMimeType('text/xml');
            http_request.overrideMimeType('text/html');
            }
         }
      else if (window.ActiveXObject) {
         // IE versions prior to 7
         try {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
            }
         catch (e) {
            try {
               http_request = new ActiveXObject("Microsoft.XMLHTTP");
               }
            catch (e) {
               }
            }
         }
      if (!http_request) {
         alert('Cannot create XMLHTTP instance');
         }

      http_request.onreadystatechange = function() {
         if (http_request.readyState == 4) {
            if (http_request.status == 200) {
               eval(http_request.responseText);
               }
            else {
               alert('There was a problem with the AJAX request.');
               }
            }
         };
      http_request.open('POST', url, true);
      http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
      http_request.setRequestHeader("Content-length", parameters.length);
      http_request.setRequestHeader("Connection", "close");
      http_request.send(parameters);
      }

   // serializes all the Input fields of a Form into a parameters string that can be added to a URL, or passed as parameters to a javascript function (especially AJAX).
   // There is no way to directly perform AJAX with form fields.  The fields must be serialized into a string and passed as the Params value to the AJAX call.
   function commonLibraryFormSerialize(formName) {
      var returnValue = '';

      // Getting ALL elements inside of form element
      form = document.getElementById(formName);
      var elements = form.getElementsByTagName('*');

      // Looping through all elements inside of form and checking to see if they're "form elements"
      for( var index = 0; index < elements.length; index++ ) {
         var element = elements[index];

         if(!element.disabled && ((element.name && element.name.length > 0) || (element.id && element.id.length > 0)) ) {
            elementName = '';
            if (element.name && element.name.length > 0)
               elementName = element.name;
            else
               elementName = element.id;
               
            switch(element.tagName.toLowerCase()) {
               case 'input':
                  switch(element.type) {
                    case 'checkbox':
                    case 'radio':
                      if(element.checked) {
                        returnValue += '&' + elementName + '=' + encodeURIComponent(element.value);
                        }
                      break;
                    case 'hidden':
                    case 'password':
                    case 'text':
                      returnValue += '&' + elementName + '=' + encodeURIComponent(element.value);
                      break;
                    }
                  break;
               case 'select':
               case 'textarea':
                  returnValue += '&' + elementName + '=' + encodeURIComponent(element.value);
                  break;
               }
            }
         }
      if(returnValue.length > 1)
         return returnValue.substr(1);
      else
         return returnValue;
      }

