	var  url;
	var destDivId;
	var destDivWidth;
	var searchOver;
	var searchNormal;
	String.prototype.ReplaceAll = function(stringToFind,stringToReplace){
	    var temp = this;
	    var index = temp.indexOf(stringToFind);
	        while(index != -1){
	            temp = temp.replace(stringToFind,stringToReplace);
	            index = temp.indexOf(stringToFind);
	        }
	        return temp;
	}

	function LoadSearchBox(u,ddId,ddWidth)  {
		url = u;destDivId=ddId;destDivWidth=ddWidth;
		var destDiv = document.getElementById(destDivId);
		if(!destDiv){
			alert("The Div Id that you are provided may be wrong.  Please change the variable destDivId");
		}else if(!destDivWidth || destDivWidth.length < 0 ){
			alert("The Div Width that you are provided may be wrong. Please change the variable destDivWidth");
		}else if(!url || url.length < 0 ){
			alert("The URL that you are provided may be wrong.  Please change the variable url");
		}else{
			var contentString = "<div id='SearchDiv' style='"+destDivWidth+"px;'><table id='SearchTable' cellpadding='0' cellspacing='0' border='0'><tr><td  id='textBoxTd'><input  name='search' id='searchAll' type='text' name='searchAll' onKeyPress='onKeyEnterPress(event)'  onfocus='onTextBoxFocus(this);' onblur='onTextBoxBlur(this);'  value= 'Enter customer name, city or state' class='searchText' />	</td><td class='searchButtonTd'><input type='button' id='butSearch' class='searchButton' onclick='search()' onmouseover='changeImage(this,searchOver);' onmouseout='changeImage(this,searchNormal);' onfocus='changeImage(this,searchOver);' onblur='changeImage(this,searchNormal);'/></td></tr>        <tr><td colspan='2'><div id='searchErrorDiv' style='display:none' class='errorSpan'></div></td></tr></table></div>";
			destDiv.style.width=destDivWidth+"px";
			destDiv.innerHTML =contentString;

			var headID = document.getElementsByTagName("head")[0];        
			var cssNode = document.createElement('link');
			cssNode.type = 'text/css';
			cssNode.rel = 'stylesheet';
			cssNode.href ='../scripts/adminDash.css';
			cssNode.media = 'screen';
			headID.appendChild(cssNode);

			 searchOver = new Image(83,35);
			 searchOver.src = "../images/search_visited2.gif";
			 searchNormal = new Image(83,35);
			 searchNormal.src = "../images/search2.gif";

			//if(document.getElementById('searchAll')){
			//	document.getElementById('searchAll').blur();
			//	document.getElementById('searchAll').focus();
		//	}
		}
	}
	function changeImage(obj,imgsrc){obj.style.background="url('"+imgsrc.src+"')";}
	function search(){
		if(strip(document.getElementById("searchAll").value) == '' || strip(document.getElementById("searchAll").value) == " " || document.getElementById("searchAll").value == "Enter customer name, city or state"){
			//var t = "<style>#pushed {margin-top:20px;margin-bottom:20px;}</style><p>er 4a</p>"
            //document.getElementById('pushed').innerHTML = t;
			document.getElementById('searchErrorDiv').innerHTML = 'Please enter search term(s)';
			document.getElementById('searchErrorDiv').style.display = 'block';
			document.getElementById('searchErrorDiv').style.marginBottom = '21px';
			document.getElementById('searchErrorDiv').style.marginTop = '7px';
			
			
			}else{
			var searchVal = strip(document.getElementById("searchAll").value);
				if(searchVal.match('&')){
					searchVal = searchVal.ReplaceAll("&", "%26");
				}
			var newUrl = url+"/indexSearch.jsp?searchType=KEYWORD_SEARCH&search="+searchVal;
			window.open(newUrl);
		}
	}
	function onKeyEnterPress(e){var key;if(window.event){key = window.event.keyCode;} else {key = e.which;}if(key == 13){search();}}
	function onTextBoxFocus(obj){
		if(strip(obj.value)  == "" || strip(obj.value) == " " || obj.value == 'Enter customer name, city or state'){
			obj.value='';
		}	
		obj.style.color="#666666";
		obj.style.fontStyle="normal";
		document.getElementById('searchErrorDiv').style.display = 'none';
		document.getElementById('searchErrorDiv').style.marginBottom = '0px';
		document.getElementById('searchErrorDiv').style.marginTop = '7px';
		
	}

	function onTextBoxBlur(obj){
		if(	strip(obj.value)  == "" || strip(obj.value) == 'Enter customer name, city or state'){
				obj.style.color="#C5C5C5";
				obj.style.fontStyle="italic";
				obj.value="Enter customer name, city or state";
				
		}
	}

 function strip(elementValue) {
	return elementValue.replace(/^\s+/, '').replace(/\s+$/, '');
 };
