function element( elementId )
{
   if ( document.getElementById )
   {
      return document.getElementById( elementId )
   }
   else if ( document.all )
   {
      return document.all[elementId]
   }
   else if ( document.layers ) 
   {
      return document[ elementId ]
   }
   else
   {
      //alert( "no element: " + elementId )
   }
}

function showSearch() {
	element('fuzzysearch').className="visible";
}

function closeSearch() {
	element('fuzzysearch').className="hidden";
}


function ajaxFunction(type, arg1, offset, cid){

	var ajaxRequest = null;  // The variable that makes Ajax possible!

   try {
    netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
   } catch (e) {

   try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("This feature was disabled by your browser.");
				return false;
			}
		}
	}
	}
	// Create a function that will receive data sent from the server
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState==4 || ajaxRequest.readyState=="complete"){
          if (type == 'search')
			var ajaxDisplay = document.getElementById('fuzzysearch');
			
			ajaxDisplay.innerHTML = ajaxRequest.responseText;
	        ajaxDisplay.className="visible";			
            if (ajaxRequest.responseText.length > 500)
			{
			  ajaxDisplay.style.height = '300px';
			  ajaxDisplay.style.overflow = 'auto';			  
			} else
			{
			  ajaxDisplay.style.height = '';
			  ajaxDisplay.style.background = '#FFFFFF';			  
			  ajaxDisplay.style.overflow = "visible";				  
			}			
      }
	}

    if (type == 'search'){
	  var rowsPerPage = 10;
	  if (cid == 'confirmedFriends')
	    rowsPerPage = 25;
	  if ((cid == 'groups')||(cid == 'images'))
	    rowsPerPage = 5;		
      var queryString = "?searchText=" + element('sSearch').value; 
//	  alert(queryString);
	  if (element('sSearch').value.length >= 3)
	  {
        ajaxRequest.open("GET", "http://www.hooplah.com/includes/ajaxFunctions.php" + queryString, true);
	  ajaxRequest.send(null);	
//  	    element('fuzzysearch').className="hidden";	 	  
	  } else
  	    element('fuzzysearch').className="hidden";	  
	}	

/*
    if (type == 'userPage'){
	  var rowsPerPage = 10;
	  if (cid == 'confirmedFriends')
	    rowsPerPage = 25;
	  if ((cid == 'groups')||(cid == 'images'))
	    rowsPerPage = 5;		
      var queryString = "?pageUid=" + vid + "&rowsPerPage=" + rowsPerPage + "&page=" + offset + "&action=" + cid ; 
//	  alert(queryString);
      ajaxRequest.open("GET", root +"/ajaxFunctions.php" + queryString, true);
	  ajaxRequest.send(null);	
	}	*/
	
}