	// show / hide an area
	function toggle ( target )
	{
	  if (document.getElementById)
	  {
			target = document.getElementById( target );
			
			if (target.style.display == "none")
			{
				target.style.display 	= "";
			}
			else
			{
				target.style.display 	= "none";
			}
		}
	}

	function checkEmail(email) {
		if (email.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\..{2,2}))$)\b/gi) == false) {
			alert("invalid email");
			return false;
		} else {
			return true;
		}
	}

	function popup(url,w,h)
	{
		window.open(url,"popup_pd","fullscreen=no,toolbar=no,status=no,menubar=no,scrollbars=auto,resizable=yes,directories=no,location=no,width="+w+",height="+h).focus();
		return false;
	}

	function yousure(msg)
	{
		if (!msg) {msg = "Are you sure?";}
		
		var where_to= confirm(msg);

		if (where_to == true) {
			return true;
		} else if (where_to == false) {
			return false;
		}
	}

	function addCommas(nStr) {
		nStr += '';
		x = nStr.split('.');
		x1 = x[0];
		x2 = x.length > 1 ? '.' + x[1] : '';
		var rgx = /(\d+)(\d{3})/;
		while (rgx.test(x1)) {
			x1 = x1.replace(rgx, '$1' + ',' + '$2');
		}
		return x1 + x2;
	}

// AJAX
	var http_request = false;

	function makePOSTRequest(url, parameters) {
      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
         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');
         return false;
      }
      
      http_request.onreadystatechange = alertContents;
      http_request.open('POST', url, true);
//		http_request.open('GET', 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);
   }

   function alertContents() {
      if (http_request.readyState == 4) {
         if (http_request.status == 200) {
//alert(http_request.responseText);
            result = http_request.responseText;
//            document.getElementById('AJAXnotice').innerHTML = http_request.responseText;
//			document.getElementById('AJAXnotice').innerHTML = "doggy";
			document.getElementById('bid_placed').innerHTML = addCommas(document.getElementById('bid').value);
			if (document.getElementById('current_bid')) {document.getElementById('current_bid').innerHTML = addCommas(document.getElementById('bid').value);}
			document.getElementById('bid_placed_author').style.display = '';
			document.getElementById('display_bid_box').style.display = 'none';
         } else {
            alert('There was a problem with the request.');
         }
      }
   }
   
	function AJAXbid(obj) {
		var poststr = 
			"func=place_bid&ajax=1" +
			"&area_id=" + encodeURI( document.getElementById("area_id").value ) +
			"&bid=" + encodeURI( document.getElementById("bid").value );
		
		makePOSTRequest("func-bid.php", poststr);
	}
	function LTrim(str) {
	   var whitespace = new String(" \t\n\r");
	
	   var s = new String(str);
	
	   if (whitespace.indexOf(s.charAt(0)) != -1) {
		  // We have a string with leading blank(s)...
	
		  var j=0, i = s.length;
	
		  // Iterate from the far left of string until we
		  // don't have any more whitespace...
		  while (j < i && whitespace.indexOf(s.charAt(j)) != -1)
			 j++;
	
		  // Get the substring from the first non-whitespace
		  // character to the end of the string...
		  s = s.substring(j, i);
	   }
	   return s;
	}

	function RTrim(str) {
	   // We don't want to trip JUST spaces, but also tabs,
	   // line feeds, etc.  Add anything else you want to
	   // "trim" here in Whitespace
	   var whitespace = new String(" \t\n\r");
	
	   var s = new String(str);
	
	   if (whitespace.indexOf(s.charAt(s.length-1)) != -1) {
		  // We have a string with trailing blank(s)...
	
		  var i = s.length - 1;       // Get length of string
	
		  // Iterate from the far right of string until we
		  // don't have any more whitespace...
		  while (i >= 0 && whitespace.indexOf(s.charAt(i)) != -1)
			 i--;
	
	
		  // Get the substring from the front of the string to
		  // where the last non-whitespace character is...
		  s = s.substring(0, i+1);
	   }
	
	   return s;
	}
	
	function trim(str) {
	   return RTrim(LTrim(str));
	}