function link(address)
{
	window.location = address;
}

function expandImage(e)
{
	if(!e)
	{
		var e = window.event;
	}
	var img = e.target;
	var bgDiv = document.createElement("div");
	bgDiv.setAttribute("style", "width:100%; height:100%; right:0px;position:fixed;z-index:2;text-align:center;");
	bgDiv.setAttribute("id", "zdiv");
	bgDiv.setAttribute("onclick", "closeImage();");
	var newImg = document.createElement("img");
	newImg.setAttribute("style", "margin-top:5%");
	newImg.setAttribute("src", img.src);
	bgDiv.appendChild(newImg);
	document.getElementsByTagName("body")[0].appendChild(bgDiv);
}

function closeImage()
{
	var obj = document.getElementById("zdiv");
	obj.parentNode.removeChild(obj);
}

function postAjax(file,postvar) //takes php file and array of post vars formatted array[0] = VAR_NAME=VAR. Returns response text
{
	var array = postvar;
	var str = '';
	var formattedPostVariables = '';
	var httpObject = getHttpObject();
	if(httpObject == null)
	{
		return "error";
	}
	for(var i=0;i<array.length;i++) //adds the & for multiple post vars
	{
		/*var content = array[i].split("=");
		content[1] = encodeURIComponent(content[1]);
		array[i] = content[0] + "=" + content[1];*/
		
		formattedPostVariables = formattedPostVariables + array[i];
		if(i+1 < array.length)
		{
			formattedPostVariables = formattedPostVariables + '&';
		}
	}
	httpObject.open('POST',file,false);
	httpObject.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    httpObject.setRequestHeader("Content-length", formattedPostVariables.length);
	httpObject.setRequestHeader("Connection","close");
	httpObject.send(formattedPostVariables);

	if(httpObject.status == 200)
	{
		str = httpObject.responseText;
	}
	else
	{
		alert("404 Not Found. There may have been an error in the request");
	}
	return str;
}

function getHttpObject()
{
	var httpObject = null;
	try
	{
	 	httpObject = new XMLHttpRequest();
	}
	catch(e)
	{
		try
		{
			httpObject = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
	    {
			try
			{
				httpObject = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch(e)
			{
				alert("Your browser does not support Ajax");
				return null;
			}
	    }	
	}
	return httpObject;
}