	/*
	  * Convenient Functions
	  */
function openwin(page, width, height)
{
  window.open(page, "", "scrollbars=yes, menubar=no, toolbar=no, resizable=no, width=" + width + ", height=" + height + ", top=100, left=100");
}
function show(element)
{
  document.getElementById(element).style.display = 'block';
}
function close(element)
{
  document.getElementById(element).style.display="none";
}
function openOrClose(element)
{
	if(document.getElementById(element).style.display == "none")
		show(element)
	else
		close(element)
}
function profileInfo(txt)
{
  document.getElementById("contact").innerHTML = txt;
  show("contact");
}

  // drawPercentBar()
  // Written by Matthew Harvey (matt AT unlikelywords DOT com)
  // (http://www.unlikelywords.com/html-morsels/)
  // Mod by Yvonne
  // (http://www.cogknition.org/knitblogging/percentagebar/)
  // Distributed under the Creative Commons
  // "Attribution-NonCommercial-ShareAlike 2.0" License
  // (http://creativecommons.org/licenses/by-nc-sa/2.0/)
  function drawPercentBar(percent)
  {

	var width = 180;

	var color = "#99B0BE";
	var background = "#FFFFFF";
	var border = "#4C0039";

    if (!color) { color = "#B0B0B0"; }
    if (!background) { background = "none"; }
    if (!border) { border = "#000000"; }

    var pixels = width * (percent / 100);

    document.write("<div style=\"position: relative; line-height: 1em; background-color: "
                   + background + "; border: 1px solid " + border + "; width: "
                   + width + "px\">");
    document.write("<div style=\"height: 1.5em; width: " + pixels + "px; background-color: "
                   + color + ";\"><\/div>");
    document.write("<div style=\"position: absolute; text-align: center; padding-top: .25em; width: "
                   + width + "px; top: 0; left: 0\">" + percent + "%<\/div>");
    document.write("<\/div>");
  }

/***********************************************
* Dynamic Ajax Content- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

var bustcachevar=1 //bust potential caching of external pages after initial request? (1=yes, 0=no)
var loadedobjects=""
var rootdomain="http://"+window.location.hostname
var bustcacheparameter=""

function ajaxpage(url, containerid)
{

  var page_request = false
  if (window.XMLHttpRequest) // if Mozilla, Safari etc
    page_request = new XMLHttpRequest()
  else if (window.ActiveXObject)
  { // if IE
    try
    {
      page_request = new ActiveXObject("Msxml2.XMLHTTP")
    }

    catch (e)
    {
      try
      {
	page_request = new ActiveXObject("Microsoft.XMLHTTP")
      }

      catch (e){}
    }
  }
  else
    return false

  page_request.onreadystatechange=function()
  {
    loadpage(page_request, containerid)
  }

  if (bustcachevar) //if bust caching of external page
    bustcacheparameter=(url.indexOf("?")!=-1)? "&"+new Date().getTime() : "?"+new Date().getTime()

  page_request.open('GET', url+bustcacheparameter, true)
  page_request.send(null)

	return 1;

}

function loadpage(page_request, containerid)
{

  if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1))
	{
		var obj = document.getElementById(containerid);
    obj.innerHTML = page_request.responseText;
	}

}

function loadobjs()
{
  if (!document.getElementById)
    return

  for (i=0; i<arguments.length; i++)
  {
    var file=arguments[i]
    var fileref=""
    if (loadedobjects.indexOf(file)==-1)
    { //Check to see if this object has not already been added to page before proceeding
      if (file.indexOf(".js")!=-1)
      { //If object is a js file
	fileref=document.createElement('script')
	fileref.setAttribute("type","text/javascript");
	fileref.setAttribute("src", file);
      }
      else if (file.indexOf(".css")!=-1)
      { //If object is a css file
	fileref=document.createElement("link")
	fileref.setAttribute("rel", "stylesheet");
	fileref.setAttribute("type", "text/css");
	fileref.setAttribute("href", file);
       }
    }

    if (fileref!="")
    {
	document.getElementsByTagName("head").item(0).appendChild(fileref)
	loadedobjects+=file+" " //Remember this object as being already added to page
    }
  }
}

	/*
	  * Function for retrieving AJAX pages
	  */
	var xmlhttp = false;

	try {
		// JS > 5 ?
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
		// Older version of ActiveX
		try {
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			alert(2);
		} catch (E) {
			// Not IE as browser
			xmlhttp = false;
		}
	}

	// If not IE...
	if(!xmlhttp && typeof XMLHttpRequest != 'undefined')
	{
		xmlhttp = new XMLHttpRequest();
	}

	function createform(e)
	{
		theObject = document.getElementById("createtask");

		theObject.style.visibility = "visible";
		theObject.style.height = "200px";
		theObject.style.width = "200px";

		var posx = 0;
		var poxy = 0;

		posx = e.clientX + document.body.scrollLeft;
		posy = e.clientY + document.body.scrollTop;

		theObject.style.left = posx + "px";
		theObject.style.top = posy + "px";

		// The location we are loading the page into.
		var objID = "createtask";
		var serverPage = "theform.php";

		var obj = document.getElementById(objID);
		xmlhttp.open("GET", serverPage);
		xmlhttp.onreadystatechange = function() {
			if(xmlhttp.readyState == 4 && xmlhttp.status == 200) {
				obj.innerHTML = xmlhttp.responseText;
			}
		}
		xmlhttp.send(null);
	}

	function closetask()
	{
		theObject = document.getElementById("createtask");

		theObject.style.visibility = "hidden";
		theObject.style.height = "0px";
		theObject.style.width = "0px";

		acObject = document.getElementById("autocompletediv");

		acObject.style.visibility = "hidden";
		acObject.style.height = "0px";
		acObject.style.width = "0px";
	}

	function findPosX (obj)
	{
		var curleft = 0;
		if(obj.offsetParent)
		{
			while (obj.offsetParent)
			{
				curleft += obj.offsetLeft;
				obj = obj.offsetParent;
			}
		}
		else if (obj.x)
		{
			curleft += obj.x;
		}

		return curleft;
	}

	function findPosY (obj)
	{
		var curtop = 0;
		if(obj.offsetParent && document.all)
		{
			while (obj.offsetParent)
			{
				curtop += obj.offsetTop;
				obj = obj.offsetParent;
			}
		}
		else if (obj.y)
		{
			curtop += obj.y;
		}

		return curtop;
	}

	function autocomplete(thevalue, e, isPM1)
	{
		var isPM = (isPM1 == 0) ? 0 : isPM1;

		theObject = document.getElementById("autocompletediv");
		theObject.style.visibility = "visible";
		theObject.style.width = "152px";

		var posx = 0;
		var posy = 0;

		posx = (findPosX (document.getElementById("searchfor")) + 1);
		posy = (findPosY (document.getElementById("searchfor")) + 23);

		theObject.style.left = posx + "px";
		theObject.style.top = posy + "px";

		var theextrachar = e.which;

		if(theextrachar == undefined)
		{
			theextrachar = e.keyCode;
		}

		// The location we are loading the page into.
		var objID = "autocompletediv";

		// Take into account the backspace.
		if(theextrachar == 8)
		{
			if(thevalue.length == 1)
				var serverPage = "../autocomp.php?pm=1";
			else
				var serverPage = "../autocomp.php" + "?sstring=" + thevalue.substr (0, (thevalue.length -1)) + "&pm=1";
		}
		else
		{
			var serverPage = "../autocomp.php" + "?sstring=" + thevalue + String.fromCharCode(theextrachar) + "&pm=1";
		}

		var obj = document.getElementById(objID);
		xmlhttp.open("GET", serverPage);
		xmlhttp.onreadystatechange = function () {
			if(xmlhttp.readyState == 4 && xmlhttp.status == 200)
				obj.innerHTML = xmlhttp.responseText;
		}
		xmlhttp.send(null);

	}

	function setvalue(thevalue)
	{
		//document.getElementById("searchfor").value = thevalue;

		//acObject = document.getElementById("autocompletediv");

		//acObject.style.visibility = "hidden";
		//acObject.style.height = "0px";
		//acObject.style.width = "0px";

		//document.getElementById("showresult").innerHTML = '<b>Click here to see ' + thevalue + '\'s profile</b>';
		//alert(thevalue);
		//window.open('/user/' + (thevalue));
	}