// JavaScript Document
var pageURL = 'http://www.wearevapour.com/';
var xmlHttp;
var workID;
var workPage;
var imagesTotal;
var toDo;

function getWork(id,theWorkPage,anything)
 { 
 xmlHttp=GetXmlHttpObject();
 if (xmlHttp==null)
  {
  alert ("Browser does not support HTTP Request");
  return;
  } 
 var url="http://www.wearevapour.com/work_xml.php";
 url=url+"?id="+id;
 url=url+"&sid="+Math.random();
 workID=id;
 workPage=theWorkPage;
 toDo=anything;
 xmlHttp.onreadystatechange=stateChanged;
 xmlHttp.open("GET",url,true);
 xmlHttp.send(null);
 }

function stateChanged() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{
 xmlDoc=xmlHttp.responseXML;
 var i=1;
 y.clear();
 imageThisTotal=xmlDoc.getElementsByTagName('imageTotal')[0].childNodes[0].nodeValue;
 if (workPage==1) {
  while (i<=imageThisTotal)
  {
   if ($('work' + workID +'pic' + i)) {
	    if (xmlDoc.getElementsByTagName('image' + i)[0].childNodes[0].nodeValue != null) {
		   imageToUse = xmlDoc.getElementsByTagName('image' + i)[0].childNodes[0].nodeValue;
	   }
    if (imageToUse == null) {
		imageToUse='spacer.gif';
	}
     $('work'+workID+'pic'+i).src=pageURL+'images/work/'+imageToUse;
	 theTextNumber=parseInt(i);
	 imageTextToUse=xmlDoc.getElementsByTagName('imageText' + i)[0].childNodes[0].nodeValue;
	 if (imageTextToUse == 'nope') {
		imageTextToUse=''; 
	 }
	 y[theTextNumber]= imageTextToUse;
   }
  i=i+1;
  }
 }
 else {
  while (i<=imageThisTotal)
  {
   if ($('pic' + i)) {
	   if (xmlDoc.getElementsByTagName('image' + i)[0].childNodes[0].nodeValue != null) {
		   imageToUse = xmlDoc.getElementsByTagName('image' + i)[0].childNodes[0].nodeValue;
	   }
    if (imageToUse == null) {
		imageToUse='spacer.gif';
	}
     $('pic'+i).src=pageURL+'images/work/'+imageToUse;
	 theTextNumber=parseInt(i);
	 imageTextToUse=xmlDoc.getElementsByTagName('imageText' + i)[0].childNodes[0].nodeValue;
	 if (imageTextToUse == 'nope') {
		imageTextToUse=''; 
	 }
	 y[theTextNumber]= imageTextToUse;
   }
  i=i+1;
  }
 }
 $(imageTextArea).innerHTML=y['1'];
 $(imageNumberTextArea).innerHTML="1 of " + imageThisTotal;
 if (toDo==1) {
	if (imageThisTotal>1) {
    doOnLoad('workCaseContainer',1);
    } 
 }
 if (toDo==2) {
	if (imageThisTotal>1) {
    timer2 = setInterval(function() {scrollDiv2(workArea,863,direction2,20,1)},timerTime);
    } 
 }
 }
} 

function GetXmlHttpObject()
 { 
 var objXMLHttp=null;
 if (window.XMLHttpRequest)
  {
  objXMLHttp=new XMLHttpRequest();
  }
 else if (window.ActiveXObject)
  {
  objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
 return objXMLHttp;
 }