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='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='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;}
var direction2="left";var timer="";var timer2="";var timer3="";var timer4="";var workArea;var workBox;var workText;var imageTextArea;var imageNumberTextArea;var currentImage=1;var doText;var imageThisTotal;var scrollingAlready=0;function scrollDiv(id,scrollAmount,direction,toScroll,text){if(imageThisTotal>1){if(scrollingAlready<1){scrollingAlready=1;doText=text;if(currentImage>=imageThisTotal){direction="right"}
if(currentImage<=1){direction="left"}
clearAllTimers()
timer=setInterval(function(){if(scrollAmount>=toScroll){scrollAmount=scrollAmount-toScroll;}
else{toScroll=scrollAmount;scrollAmount=0;}
if(direction=="left"){direction2="left"
$(id).scrollLeft+=toScroll;}
else{direction2="right"
$(id).scrollLeft-=toScroll;}
if(scrollAmount===0){scrollingAlready=0;if(timer!=""){clearInterval(timer);timer="";}
if(direction=="left"){currentImage=currentImage+1;}
else{currentImage=currentImage-1;}
if(text==1){theTextNumber=parseInt(currentImage);$(imageTextArea).innerHTML=y[theTextNumber];$(imageNumberTextArea).innerHTML=currentImage+" of "+imageThisTotal;}
timer2=setInterval(function(){scrollDiv2(workArea,863,direction2,20,doText)},timerTime);}},4);}}}
function scrollDiv2(id,scrollAmount,direction,toScroll,text){if(imageThisTotal>1){doText=text;if(currentImage>=imageThisTotal){clearAllTimers()
scrollAmountTotal=imageThisTotal*863;scrollAmountTotal2=imageThisTotal*18;scrollAmountTotal2=234;scrollDiv3(workArea,scrollAmountTotal,'right',scrollAmountTotal2,doText);currentImage=1;}
else{if(currentImage<=1){direction="left"}
timer3=setInterval(function(){if(scrollAmount>=toScroll){scrollAmount=scrollAmount-toScroll;}
else{toScroll=scrollAmount;scrollAmount=0;}
if(direction=="left"){direction2="left"
$(id).scrollLeft+=toScroll;}
else{direction2="right"
$(id).scrollLeft-=toScroll;}
if(scrollAmount===0){if(timer3!=""){clearInterval(timer3);timer3="";}
if(direction=="left"){currentImage=currentImage+1;}
else{currentImage=currentImage-1;}
if(text==1){theTextNumber=parseInt(currentImage);$(imageTextArea).innerHTML=y[theTextNumber];$(imageNumberTextArea).innerHTML=currentImage+" of "+imageThisTotal;}}},4);}}}
function scrollDiv3(id,scrollAmount,direction,toScroll,text){clearAllTimers()
timer=setInterval(function(){if(scrollAmount>=toScroll){scrollAmount=scrollAmount-toScroll;}
else{toScroll=scrollAmount;scrollAmount=0;}
if(direction=="left"){direction2="left"
$(id).scrollLeft+=toScroll;}
else{direction2="right"
$(id).scrollLeft-=toScroll;}
if(scrollAmount===0){clearAllTimers();currentImage=1;if(text==1){theTextNumber=parseInt(currentImage);$(imageTextArea).innerHTML=y[theTextNumber];$(imageNumberTextArea).innerHTML=currentImage+" of "+imageThisTotal;}
timer2=setInterval(function(){scrollDiv2(workArea,863,'left',20,doText)},timerTime);}},4);}
function doOnLoad(id,text,page){doText=text;workArea='workCaseContainer';workBox='workCaseBox';workText='workText'+id;imageTextArea="imageText";imageNumberTextArea="imageNumberText";$(id).scrollLeft=0;if(page=='services'){$('service1').style.backgroundPosition="-185px 0";}
if(imageThisTotal>1){timer4=setInterval(function(){scrollDiv2(workArea,863,direction2,20,doText)},timerTime);}}
function clearAllTimers(){if(timer!=""){clearInterval(timer);timer="";}
if(timer2!=""){clearInterval(timer2);timer2="";}
if(timer3!=""){clearInterval(timer3);timer3="";}
if(timer4!=""){clearInterval(timer4);timer4="";}}
function toStart(id){$(id).scrollLeft=0;}
function doTheBlind(theID){clearAllTimers();if(currentBlind!='workCaseBox'+theID){if(somethingHappening!=1){somethingHappening=1;workArea='workCaseContainer'+theID;workBox='workCaseBox'+theID;workLogo='workLogo'+theID;workText='workText'+theID;timerTime=caseTime;theDamnID=theID;imageTextArea='imageText'+theID;imageNumberTextArea='imageNumberText'+theID;$('work'+theDamnID).style.backgroundPosition="-899px 0";if(currentBlind!=null){new Effect.ScrollTo('container1',{duration:1.0,afterFinish:function leftIT2(){$(currentWorkLine).style.backgroundPosition="0 0";$(currentWorkArea).scrollLeft=0;new Effect.BlindUp(currentBlind)
clearAllTimers()
new Effect.BlindDown(workBox,{delay:1.0,afterFinish:function leftIT5(){getWork(theDamnID,1,2);$(workArea).scrollLeft=0;new Effect.ScrollTo('work'+theDamnID,{duration:1.0,afterFinish:function leftIT8(){somethingHappening=0;}});currentBlind=workBox;currentWorkArea=workArea;currentWorkLine='work'+theDamnID;currentImage=1;}});}});}
else{new Effect.BlindDown(workBox,{afterFinish:function leftIT(){getWork(theDamnID,1,2);$(workArea).scrollLeft=0;new Effect.ScrollTo('work'+theDamnID,{duration:1.0,afterFinish:function leftIT8(){somethingHappening=0;}});currentBlind=workBox;currentWorkArea=workArea;currentWorkLine='work'+theDamnID;currentImage=1;}});}}}
else{if(somethingHappening!=1){somethingHappening=1;currentImage=1;$(currentWorkArea).scrollLeft=0;new Effect.ScrollTo('container1',{duration:1.0,afterFinish:function leftIT3(){new Effect.BlindUp(currentBlind,{afterFinish:function leftIT8(){somethingHappening=0;}});$('work'+theDamnID).style.backgroundPosition="0 0";currentBlind=null;currentWorkLine=null;clearAllTimers();theDamnID=null;imageThisTotal=imageThisTotal2;timerTime=workTime;doOnLoad('workCaseContainer',0,'index');}});}}}
function backgroundImage(work,inout){if(('work'+work!=currentWorkLine)&&(work!=theDamnID)){if(inout===1){$('work'+work).style.backgroundPosition="-899px 0";}
else{$('work'+work).style.backgroundPosition="0 0";}}}