var xmlHttp

// AJAX
function showPoem(poemno)
 {


//alert (poemno);
//return


		




 xmlHttp=GetXmlHttpObject()
 if (xmlHttp==null)
  {
  alert ("Browser does not support HTTP Request")
  return
  } 
 var url="CPDpages/poem"
 url=url+poemno+".htm";
// url=url+"&sid="+Math.random()
 	  
//  document.getElementById("test").innerHTML=url //url developmetn-----------------------delete

xmlHttp.onreadystatechange=stateChanged 
 xmlHttp.open("GET",url,true)
 xmlHttp.send(null)
 }function stateChanged() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{
 textdoc=xmlHttp.responseText;


	document.getElementById("poemcontent").innerHTML = textdoc;
 return
//  PROJECT DETAIL module

projecno = xmlDoc.getElementsByTagName("projectnod")[0].childNodes[0].nodeValue;
projectti = xmlDoc.getElementsByTagName("projecttitled")[0].childNodes[0].nodeValue;
projectclnam = xmlDoc.getElementsByTagName("companyname")[0].childNodes[0].nodeValue;
projectclno = document.forms.storageformprj.clientprj.value;


	document.getElementById("projecttitled").innerHTML = projectti;
	document.getElementById("projectnod").innerHTML = projecno+' | ';
	document.getElementById("clientnamed").innerHTML = projectclnam;
	document.forms.storageformprj.clientprj.value;
// client number  document.getElementById("clientd").innerHTML = xmlDoc.getElementsByTagName("clientd")[0].childNodes[0].nodeValue;
	document.getElementById("statusd").innerHTML = xmlDoc.getElementsByTagName("statusd")[0].childNodes[0].nodeValue;
	document.getElementById("dated").innerHTML = xmlDoc.getElementsByTagName("dated")[0].childNodes[0].nodeValue;

	
//the history notes	
	
	var hx=xmlDoc.getElementsByTagName("history");
	var histlist="";
hxl=hx.length;
	for (i=0;i<hx.length;i++)
  {			

	histlist +=  "<p class='histdate'>" + hx[i].getElementsByTagName("historydate")[0].childNodes[0].nodeValue + "</p>";
	histlist +=  "<p class='histnote'>" + hx[i].getElementsByTagName("historydetails")[0].childNodes[0].nodeValue + "</p>";

  };
  
  
      document.getElementById("productcoded").innerHTML = xmlDoc.getElementsByTagName("productcoded")[0].childNodes[0].nodeValue;
	document.getElementById("sourced").innerHTML = xmlDoc.getElementsByTagName("sourced")[0].childNodes[0].nodeValue;
 
 //---- administrator buttons store values on form on index page
 
//adbuts = '<form action="../Admin/index.php" method="post" name="prjform" style="DISPLAY:INLINE; margin-bottom: 0">';
//<input type="button" value="Submit" onclick="submitclinfo()" tabindex="9" name="submitbutton">
adbuts = '';
adbuts += '<input type="button" value="Expenditure" onclick="gotoadmin(\'Expenditure\')" class="but" title="Go to Expenditure for ' + projectti + '" />';
adbuts += '<input type="button" value="Invoices" onclick="gotoadmin(\'Invoices\')" class="but"  title="Go to Invoices for ' + projectti + '" />';
adbuts += '<input type="button" value="Mileage" onclick="gotoadmin(\'Mileage\')" class="but" title="Go to Mileage for ' + projectti + '" />';
adbuts += '<input type="button" value="Time" onclick="gotoadmin(\'Timewriting\')" class="but" title="Go to Timewriting for ' + projectti + '" />';


/*adbuts += '<button name="adminpage" value="Expenditure" type="submit" class="but" />Expenditure</button>';
adbuts += '<button type="submit" name="adminpage" value="Invoices" class="but" />Invoices</button>';
adbuts += '<button type="submit" name="adminpage" value="Mileage" class="but" />Mileage</button>';
adbuts += '<button type="submit" name="adminpage" value="Timewriting" class="but" />Time</button>';
*/

//adbuts += '<input type="hidden"  name="projecno" value="'+projecno+'">';
document.forms.storageformadmin.projecno.value = projecno;
//adbuts += '<input type="hidden"  name="projectti" value="'+projectti+'">';
document.forms.storageformadmin.projectti.value = projectti;

//adbuts += '<input type="hidden"  name="projectclnam" value="'+projectclnam+'">';
document.forms.storageformadmin.projectclnam.value = projectclnam;


//adbuts += '<input type="hidden"  name="projectclno" value="'+xmlDoc.getElementsByTagName("clientd")[0].childNodes[0].nodeValue+'">';
document.forms.storageformadmin.projectclno.value = xmlDoc.getElementsByTagName("clientd")[0].childNodes[0].nodeValue;

adbuts += '</form>';

	 	    document.getElementById("prbuttonsadmin").innerHTML = adbuts
  
  
  
  
  
	document.getElementById("historyd").innerHTML = histlist; 

 

			
// main PROJECTS table

if (xmlDoc.getElementsByTagName("project")[0]){
	
	
// company name or sort type title 
//	
sortcd = xmlDoc.getElementsByTagName("sort")[0].childNodes[0].nodeValue;

clientname = xmlDoc.getElementsByTagName("companyname")[0].childNodes[0].nodeValue;
	clxmain = xmlDoc.getElementsByTagName("client")[0].childNodes[0].nodeValue;
if (sortcd != '-')
{clientname=sortcd + ' projects';}
else
{clientname = "<a href='#' title='View Client details for " + clientname + "' onclick='gotoclient("+ clxmain +")'><img src='../images/arrow_left.png' /></a>" + clientname + " " + "<a href='#' title='View all projects' onclick='showProject(\"\",\"\",\"all\")'><img src='../images/cross.png' /></a>"};

document.getElementById("companyname").innerHTML = clientname;


	prlist = '';
//previous button if there	
if (xmlDoc.getElementsByTagName("links")[0]){
	  prlist += xmlDoc.getElementsByTagName("links")[0].childNodes[0].nodeValue + " ";
  }
  
  //pages x of y if there	
if (xmlDoc.getElementsByTagName("links")[1]){
	  prlist += "" + xmlDoc.getElementsByTagName("links")[1].childNodes[0].nodeValue + " ";
  }
//next button if there	
if (xmlDoc.getElementsByTagName("links")[2]){	
	  prlist += " " + xmlDoc.getElementsByTagName("links")[2].childNodes[0].nodeValue;
  }
	
	prlist += '<br style="clear:both" /><table class="mytable" cellspacing="0" summary="Projects" width="100%">'
	prlist += '<tr valign="center"><th>Project</th><th>No.</th><th>Prod.</th><th>Client</th><th>Date</th><th scope="col">Status</th></tr>'
//removed <th>Source</th>

for (i=0;i<x.length;i++)
{
//this is to remember the view of client if it's there
clshow = document.forms.storageformprj.clientprj.value;

  
	clx = x[i].getElementsByTagName("client")[0].childNodes[0].nodeValue;
	prx = x[i].getElementsByTagName("projectno")[0].childNodes[0].nodeValue;
		conamex = x[i].getElementsByTagName("companynamelist")[0].childNodes[0].nodeValue;

$row_class = (( !(i % 2) ) ? 'alt1' : 'alt2');
blank="";
	
	projecttit=x[i].getElementsByTagName("projecttitle")[0].childNodes[0].nodeValue;
	
prlist += "<tr class='" + $row_class + "'><th><a href='javascript:showProject(\""+clshow+"\","+ prx +")' title=\'See Project detail for " + projecttit + "'>" + projecttit + "</a></th>";
prlist += "<td>" + prx + "</td>";
prlist += "<td>" + x[i].getElementsByTagName("productcode")[0].childNodes[0].nodeValue + "&nbsp;</td>";



prlist += "<td><a href='#' title=\'Click to sort by " +conamex + "\' onClick='showProject("+clx+","+prx +")'>" + conamex + "</a></td>";
//prlist += "<td>" + x[i].getElementsByTagName("source")[0].childNodes[0].nodeValue + "&nbsp;</td>";

prlist += "<td>" + x[i].getElementsByTagName("date")[0].childNodes[0].nodeValue + "</td>";
prlist += "<td>" + x[i].getElementsByTagName("status")[0].childNodes[0].nodeValue + "&nbsp;</td>";



  };
  
  	prlist += '</table>';
       document.getElementById("prmaintable").innerHTML = prlist;
	   
};

 
 
 }
} function GetXmlHttpObject()
 { 
 var objXMLHttp=null
 if (window.XMLHttpRequest)
  {
  objXMLHttp=new XMLHttpRequest()
  }
 else if (window.ActiveXObject)
  {
  objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
  }
 return objXMLHttp
 }
