function checkEnter(e){ //e is event object passed from function invocation
    var characterCode; //literal character code will be stored in this variable

    if(e && e.which){ //if which property of event object is supported (NN4)
        e = e;
        characterCode = e.which; //character code is contained in NN4's which property
    }
    else{
        e = event;
        characterCode = e.keyCode; //character code is contained in IE's keyCode property
    }

    if(characterCode == 13){ //if generated character code is equal to ascii 13 (if enter key)
        checkSearchBox(); //submit the form
        return false; 
    }
}

/* Added for IE6 display issue. Toggle the display of the windowed controls.
 This would help in having the Menu displayed properly. */
function toggleWindowedControls(theVisibility) 
{
    // Pipe separated Select control ID's which need to be hidden. 
    // Please add pipe separated control ID(for dropdowns) here which needs to be hidden for IE6
    var strSelectIDToHide = 'ddlCategory|ddlProduct|ddlSolutions'
    // Pipe separated Embed control ID's which need to be hidden.
    // Please add pipe separated control ID(for EMBED tags) here which needs to be hidden for all browsers
    var strEmbedIDToHide = ''
    var strSelectIDArray = new Array();
    strSelectIDArray = strSelectIDToHide.split('|');
    var strEmbedIDArray = new Array();
    strEmbedIDArray = strEmbedIDToHide.split('|');
    
    // Check for the browser and see if it is IE6 or below
    if(!window.XMLHttpRequest)
    {
        for (e=0;e<strSelectIDArray.length;e++)
        {
            // Check for the SELECT tag and hide the control
            if (document.getElementById(strSelectIDArray[e])!= null) 
            {
                document.getElementById(strSelectIDArray[e]).style.visibility=theVisibility;
            }
        }
    }
    
    // Do the same for the EMBED objects. But do for all the browsers.
    for (e=0;e<strEmbedIDArray.length;e++)
    {
        // Check for the EMBED tag and hide the control
        if (document.getElementById(strEmbedIDArray[e])!= null) 
        {
            document.getElementById(strEmbedIDArray[e]).style.visibility=theVisibility;
        }
    }
}

function ChangeSearchImage( id ) {
    var but = document.getElementById("imgSearchBtn");
    var img = document.getElementById(id);
       
    but.src =pt_1854.transformURL( img.src);
    return false;
}

function SearchButtons( show, hide ) {
    document.getElementById(show).style.display = '';
    document.getElementById(hide).style.display = 'none';
    return false;
}

	function searchBoxText() {
		var mainNavSearch = document.getElementById('mainNavSearchBox');
		if (mainNavSearch && typeof mainNavSearch.value) {
			mainNavSearch.onclick = function() {
				if (this.value == 'search') {
					this.value = '';
				}
			};
			mainNavSearch.onblur = function() {
				if (this.value == '') {
					this.value = 'search';
				}
			}
		}
	}
	
function checkSearchBox(){
  var sId = document.getElementById('SearchPageId').value;
  var valid = false;
  var reg = new RegExp("[a-zA-Z0-9&_/+@.,-][a-zA-Z0-9&_/+@.,-][a-zA-Z0-9&_/+@.,-]+");
  var txt = document.getElementById('mainNavSearchBox');
  
  //check for length of search term
  if ( txt.value.match(reg) ) {
      valid = true;   
  } else {
      alert("Search term must have at least 3 characters"); 
      valid = false;
      return false;
  }
  
  //check for "and"
  if ( txt.value == "and" || txt.value == "*and" || txt.value == "and*" ) {
      alert("Search terms can not contain keywords such as 'and', 'or'"); 
      valid = false;
      return false;
  } else {
      
       valid = true; 
  }
  
  //check for "and" or "or" in the search phrase
  var arr = txt.value.split(" ");
  for(var i=0; i<arr.length; i++) {
      if ( arr[i] == "and" || arr[i] == "or" || arr[i] == "and*" || arr[i] == "or*" || arr[i] == "*and" || arr[i] == "*or" ) {
         if ( arr.length < 3 ) {
              alert("Search terms can not contain keywords such as 'and', 'or'"); 
              valid = false;
              return false;
          }
      }
  }
  
  if ( valid ) {
      //__doPostBack('','');
      // Keywords entered, submit...
	PTPortlet.setSessionPref("SearchQuery", txt.value); 
	PTCommonOpener.openInSameWindow(PTCommonOpener.getOpenerURLOpenObjID(514, sId, 'null', 2));
      return false;
  }
      
  return false;
}