var xmlHttp;
var returnElPORT;

function ChangePortfolioItem(command)
{ 
	var script = "";
	//returnEl = returnElment;
	
	returnElPORT = "portfolioItem";
	
	xmlHttp=GetXmlHttpObject();
	
	if (xmlHttp==null)
	 {
		alert ("Browser does not support HTTP Request");
		return;
	 }
	 if (xmlHttp.readyState == 4 || xmlHttp.readyState == 0)
  	 {
		xmlHttp.open("GET", "scripts/PopupContent/Portfolio/scripts/portfolioItem.php?q=" + command, true);
		xmlHttp.onreadystatechange=stateChangedPORT;
		xmlHttp.send(null);
	 }
}

function stateChangedPORT() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 	
		//handle the xml return for the result
		x=xmlHttp.responseXML.documentElement.getElementsByTagName("PortfolioItem");
		for (i=0;i<x.length;i++)
		{
			//set the title
			xx = x[i].getElementsByTagName("Title");//get the element
			document.getElementById("title").innerHTML = xx[0].firstChild.nodeValue; //get the value to use
			
			//See if there is a download link available
			xx = x[i].getElementsByTagName("Download");
			 //get the value to use
			if(xx[0].firstChild.nodeValue == "0")
			{
				//dont show the download link
				document.getElementById("downloadLink").style.display = "none";
			}
			else
			{
				//show download link
				document.getElementById("downloadLink").style.display = "block";
				
				xx = x[i].getElementsByTagName("Downloadlink");
				document.getElementById("downloadLink").innerHTML = "<a href='"+xx[0].firstChild.nodeValue+"' target='_blank' style='color:#000000;'>Download</a>";  //get the value to use
			}
			
			xx = x[i].getElementsByTagName("Description");
			document.getElementById("description").innerHTML = xx[0].firstChild.nodeValue; 
			
			xx = x[i].getElementsByTagName("FlashVideo");
			if(xx[0].firstChild != null)
			{
				//image holds a flash video
				document.getElementById("imageHolder").innerHTML  = '<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" WIDTH="359px" HEIGHT="195" id="'+xx[0].firstChild.nodeValue+'" ALIGN=""> <PARAM NAME=movie VALUE="'+xx[0].firstChild.nodeValue+'"> <PARAM NAME=quality VALUE=high> <PARAM NAME=bgcolor VALUE=#333399> <EMBED src="'+xx[0].firstChild.nodeValue+'" quality=high bgcolor=#333399 WIDTH="359px" HEIGHT="195" NAME="'+xx[0].firstChild.nodeValue+'" ALIGN="" TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></EMBED> </OBJECT>';
			}
			else
			{
				xx = x[i].getElementsByTagName("Image");
				document.getElementById("imageHolder").innerHTML = "<img id='image' src='images/" + xx[0].firstChild.nodeValue + "' width='359' height='195' border='0' title='" + xx[0].firstChild.nodeValue +"'/>";
			}
			
			//handle itemOf
			xx = x[i].getElementsByTagName("itemOf");
			document.getElementById("itemOf").innerHTML = xx[0].firstChild.nodeValue;
			
			//handle the skills list
			xx = x[i].getElementsByTagName("SkillSet");
			
			//split the value by | to create the bullet point list
			skills = xx[0].firstChild.nodeValue.split("|");
			
			var text = "<ul>";
			for(a = 0; a < skills.length;a++)
			{
				text += "<li>"+skills[a]+"</li>";
			}
			text += "</ul>";
			
			document.getElementById("skillList").innerHTML = text;
			
			
			
		}
	}
}

function GetXmlHttpObject()
{
	var xmlHttp=null;
	try
	 {
		 // Firefox, Opera 8.0+, Safari
		 xmlHttp=new XMLHttpRequest();
	 }
	catch (e)
	 {
		//Internet Explorer
		 try
		  {
			  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		  }
		 catch (e)
		  {
			  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		  }
	 }
return xmlHttp;
}
