var req;

function loadXMLDoc(url, formVars) {
	url = url + "?" + formVars;
	if (window.XMLHttpRequest) {
		// branch for native XMLHttpRequest object
		req = new XMLHttpRequest();
		req.onreadystatechange = processReqChange;
		req.open('GET', url, true);
		req.send(null);
    } else if (window.ActiveXObject) {
		// branch for IE/Windows ActiveX version
		req = new ActiveXObject("Microsoft.XMLHTTP");
		if (req) {
			req.onreadystatechange = processReqChange;
			req.open('GET', url, true);
			req.send(null);
		}
	} else {
		alert("Not supported by your browser.");
	}
}	

function processReqChange() {
	//show loading... [took out - makes page resize too much]
	/*
	if(req.readyState == 2) {
		displayProj('portwork',"<h3>Loading...</h3>");
	}
	*/
	// only if req shows "complete"
	if (req.readyState == 4) {
		// only if "OK"
		if (req.status == 200) {
			// ...processing statements go here...
			var result = req.responseXML.getElementsByTagName('result')[0].firstChild.data.toString();
			/*
			var response = req.responseXML.documentElement;
			var result = response.getElementsByTagName('result')[0].firstChild.data.toString();
			*/
			displayProj('portwork',result);
		} else 	{
			alert("There was a problem retrieving the XML data:\n" + req.statusText);
		}
	}
}

function getWork(urlstring) {
	strFormVals = "getprojname="+urlstring;
	url = "/portfolio/getproject.php";
	loadXMLDoc(url, strFormVals);
	document.getElementById(urlstring).className = 'portthumbviewed';
	hideScreenShots();
	//document.getElementById("screenshots").className = '';
	document.getElementById("ss_"+urlstring).className = '';
}

function hideScreenShots() {
	node = document.getElementById("screenshots");
	if (node.childNodes != null) {
		for (i=0; i < node.childNodes.length; i++) {
			node.childNodes[i].className = 'none';
		}
	}	
}

function displayProj(which,proj) {
	if(document.all) {
		var z=eval("document.all."+ which +"")
        z.innerHTML=proj;
	}else if(document.getElementById) {
		document.getElementById(which).innerHTML=proj;
	}else{
		x=eval("document."+which)
		x.document.open()
		document.write(proj)
		x.close()
	}
}