var firsttime=true;
var hasvscroll=false;
isie6=navigator.userAgent.indexOf('MSIE 6')>0;
issafari=navigator.userAgent.indexOf('Safari')>0;
function di(a){return document.getElementById(a)}
function loadit(){
    window.onresize=window.onscroll=scrollit;
    setTimeout(startscroll,100);
}
function startscroll()
{
  var ftr=di('footer');
    if(di('vtc2'))
    {
    if(document.location.href.indexOf('/events')>0 || document.location.href.indexOf('/product_display')>0 || document.location.href.indexOf('/exhibitions')>0)
     di('vtc2').style.left='669px'
     di('vtc2').style.display='';
    }
    ftr.style.display='';
  scrollit();
                var justcame=firsttime;
    if(firsttime)
    {
    var hre=document.location.href;
    if(hre.indexOf('exhibitions.html?id=5')>0)showpop(5)
    else if(hre.indexOf('exhibitions.html?id=6')>0)showpop(6)
    else if(hre.indexOf('events.html?id=3')>0)showpop(3)

    //make logo clickable to home page
    var hlg=dc();hlg.className='hlg';hlg.onclick=function(){document.location.href='index.html'}
    //if(hasvscroll)hlg.style.top='10px'
    di('main').getElementsByTagName('div')[0].appendChild(hlg);
    firsttime=false;
    }
}

var resizedone=false;//indicates the d
var prevheight=0;prevwidth=0;
function scrollit()
{
    var d=document.documentElement;var ftr=di('footer');
    if(prevheight==d.clientHeight && prevwidth==d.clientWidth)return;
    prevheight=d.clientHeight;prevwidth=d.clientWidth

    hasvscroll=(issafari?document.body.scrollHeight:d.scrollHeight)>d.clientHeight;

    if(hasvscroll)
    {
      var htt=Math.floor((d.clientHeight-500-40)/2);
      if(htt<20)htt=20;
      di('main').style.paddingTop=htt+'px'
    }
    ftr.style.left='0px';
    if(di('main').offsetLeft<0){
      di('main').style.left='0px';di('main').style.marginLeft='10px';ftr.style.width=(di('main').offsetWidth+10)+'px'
      ftr.getElementsByTagName('div')[0].style.marginLeft='0px';ftr.getElementsByTagName('div')[0].style.left='10px'
    } else if(resizedone)
    {
      di('main').style.left='-417px';di('main').style.marginLeft='50%';ftr.style.width='100%'
      ftr.getElementsByTagName('div')[0].style.marginLeft='50%';ftr.getElementsByTagName('div')[0].style.left='-417px'
    }

      resizedone=true;
      var st=d.scrollTop||document.body.scrollTop;
       if(!hasvscroll)
       {
       ftr.style.position=isie6?'absolute':'fixed';ftr.style.bottom='0px';
       if(ftr.style.top)ftr.style.top=null
       }
       else
       {
         ftr.style.position='absolute';ftr.style.top=(105+di('main').offsetHeight)+'px';
         if(ftr.style.bottom)ftr.style.bottom=null
       }
       var vht=d.clientHeight,vtt;
       vtt=(Math.ceil((vht-780)/2));
       di('main').style.top=((vht<780)?0:vtt)+'px'
       di('vtc').style.top=(vht<740)?'0px':'38px'

      if(di('3dzone'))createPop()
      adjustVTC();setTimeout(adjustVTC,100)
      di('main').style.visibility='visible'
 }
 function adjustVTC(){
   var sht=issafari?document.body.scrollHeight:document.documentElement.scrollHeight
   var dch=document.documentElement.clientHeight
       if(di('vtc'))di('vtc').style.height=(hasvscroll?sht-15:(dch>740?(dch>=780?740:dch-di('vtc').offsetTop-15):dch-15))+'px'
      if(di('vtc2')){di('vtc2').style.height=di('vtc').style.height;di('vtc2').style.top=di('vtc').style.top}
      if(di('vtc3')){di('vtc3').style.height=di('vtc').style.height;di('vtc3').style.top=di('vtc').style.top}
 }
function dc(){return document.createElement('div')}
var imgEvents=[0,3,4,4,3,5,3,2,3];
var imgExhi=[0,3,3,4,4,3,4,3,4,4,3,4,4];
var imgProd=[0,4,3,3,5];
var txtEvents=['',
"<strong>ACP Womans Day</strong><div>MCA Sydney, Crown Melbourne</div><div>Media Launch</div><div>Concept Design + Implementation",
"<strong>APL Corbis Launch</strong><div>Tank Night Club | Sydney</div><div>150 High People</div><div>Concept Design + Implementation",
"<strong>Cisco Challenge</strong><div>Brisbane Conference Centre</div><div>Game Show Environment</div><div>Design Logistics + Implementation",
"<strong>APL Corbis Launch</strong><div>Tank Night Club | Sydney</div><div>150 High People</div><div>Concept Design + Implementation",
"<strong>Fovo Christmas Party</strong><div>Warehouse Surry Hills | Sydney</div><div>200 People</div><div>Concept Design + Implementation",
"<strong>GE Health</strong><div>Healthymagination Dinner – Sydney</div><div>Media Launch</div><div>Concept Design + Implementation",
"<strong>Qantas Dinner Conference</strong><div>Dinner  – Sydney</div><div>400 People</div><div>Concept Event Management + Implementation",
"<strong>Qantas Sales Conference</strong><div>World Sales Conference – Sydney</div><div>400 People</div><div>Concept Design + Implementation"
];
var txtExhi=['',
"<strong>Australian Fine China</strong><div>GHA Australia - Melbourne</div><div>9x6 Exhibition Stand</div><div>Concept Design + Implementation",
"<strong>Cisco Systems</strong><div>Auscert Conference – Gold Coast</div><div>7x3 Exhibition Stand</div><div>Concept Design + Implementation",
"<strong>Forbo</strong><div>Designex – Melbourne</div><div>7x3 Exhibition Stand</div><div>Concept Design + Implementation",
"<strong>GE Health</strong><div>World Federation for Ultrasound in Medicine and Biology - Sydney</div><div>7x3 Exhibition Stand</div><div>Concept Design + Implementation",
"<strong>Hayman</strong><div>Australian Tourism Exchange – Adelaide</div><div>6x3 Exhibition Stand</div><div>Concept Design + Implementation",
"<strong>Lotus</strong><div>Australian International Motorshow – Melbourne</div><div>6x3 Exhibition Stand</div><div>Concept Design + Implementation",
"<strong>Moccopan</strong><div>Fine Food – Sydney</div><div>6x3 Exhibition Stand</div><div>Concept Event Management + Implementation",
"<strong>Philippine Dept Tourism</strong><div>Australian Incentive Marketing Exhibition – Melbourne</div><div>6x3 Exhibition Stand</div><div>Concept Design + Implementation",
"<strong>Qantas Airways</strong><div>Australian Tourism Exchange – Brisbane</div><div>25x13 Exhibition Stand</div><div>Concept Design + Implementation",
"<strong>Sennheiser</strong><div>Cebit – Sydney</div><div>6x3 Exhibition Stand</div><div>Concept Design + Implementation",
"<strong>Workcover</strong><div>Safety in Action – Sydney</div><div>9x6 Exhibition Stand</div><div>Concept Design + Implementation",
"<strong>Young Blood</strong><div>Sydney International Spa and Beauty Expo – Sydney</div><div>6x6 Exhibition Stand</div><div>Concept Design + Implementation"
];
var txtProd=['',
"<strong>Bose / David Jones Doncaster</strong><div>Bose Fixtures in David Jones</div><div>Doncaster Bondi Junction</div><div>Production + Implementation",
"<strong>Cisco Mobility Centre</strong><div>Cisco Head Office North Sydney</div><div>Temporary Product Display Environment</div><div>Concept Design + Implementation",
"<strong>BIG W - FujiFilm - Photo Lab</strong><div>New Photolab Concept</div><div>Rollout BIG W Stores Nationwide</div><div>Concept Design + Documentation",
"<strong>IBM Technology Centre</strong><div>Training Centre Frenches Forest Sydney</div><div>Technology Showcase Environment</div><div>Concept Design + Implementation",
];
function createPop()
{
  //document.body.style.overflowX='hidden';
  var base,popbase,zone,popzone;
  var created=di('3dbase')?true:false;
  var vleft=di('main').getElementsByTagName('div')[0].offsetWidth+di('main').offsetLeft,vtop=di('vtc').offsetTop,vwidth=document.body.offsetWidth-di('main').offsetLeft-400+4,vheight=(di('main').offsetHeight+di('footer').offsetHeight+66);
  if(created)
  {
    base=di('3dbase');popbase=di('3dpopbase');zone=di('3dzone');popzone=di('3dpopzone');
  }
  else
  {
  base=dc();base.id="3dbase";popbase=dc();popbase.id='3dpopbase';zone=dc();zone.id='3dzone';popzone=dc();popzone.id='3dpopzone'
  }


  //if screen is wider than bg image then position the large photo images on the RHS of the bg image
  if(document.documentElement.clientWidth>1400)
  {vleft=Math.floor(((document.documentElement.clientWidth-1400)/2))+di('main').offsetLeft+di('vtc').offsetLeft;vwidth=780}

  var vht=document.documentElement.clientHeight;
  base.style.top=(vht<780)?'0px':(((vht-780)/2)+39)+'px';



  base.style.width=vwidth+'px';base.style.height=vheight+'px';
  base.style.left=vleft+'px';
  popbase.style.left=(vleft+40)+'px'

  if(!created)
  {
  base.className='bse'
//  if(hasvscroll)base.style.top='0px'
  if(navigator.userAgent.indexOf('MSIE 6.0')>0)base.style.position='absolute'

  document.body.appendChild(base);
  popbase.className='tnp rad pbase';
  document.body.appendChild(popbase);

  if(di('vtc2'))di('vtc2').style.display='none';
  di('vtc').style.display='none';

  zone=dc();zone.id='3dzone';popzone=dc();popzone.id='3dpopzone';zone.className='zone tnp';popzone.className='popzone';
  var closeimg=document.createElement('img');
  closeimg.id='3dclosezone';closeimg.src='images/x.png'
  closeimg.className='closezone';closeimg.onclick=hidepopwin;
  var previmg=document.createElement('img');
  previmg.id='3dprevzone';previmg.src='images/back.png'
  previmg.className='prevzone';previmg.onclick=prevpop;
  var nextimg=document.createElement('img');
  nextimg.id='3dnextzone';nextimg.src='images/next.png'
  nextimg.className='nextzone';nextimg.onclick=nextpop;
  var loadimg=document.createElement('img');
  loadimg.id='3dloadzone';loadimg.src='images/load.gif'
  loadimg.className='loadzone';

  loadimg.style.display=zone.style.display=popzone.style.display=closeimg.style.display=previmg.style.display=nextimg.style.display='none';
  document.body.appendChild(zone);
  document.body.appendChild(popzone);
  document.body.appendChild(closeimg);document.body.appendChild(previmg);document.body.appendChild(nextimg);document.body.appendChild(loadimg);
  }
}
var cur_set='',cur_img_id=0,cur_img_inx=0,loaded_imgs='';
function prevpop(){if(cur_img_inx>1){cur_img_inx--;di('3dpopzone').style.backgroundImage=getimgurl(cur_set,cur_img_id,cur_img_inx);}else{cur_img_inx=cur_arr[cur_img_id]-1;nextpop()}}
function nextpop(){if(cur_img_inx<cur_arr[cur_img_id]){cur_img_inx++;di('3dpopzone').style.backgroundImage=getimgurl(cur_set,cur_img_id,cur_img_inx);}else{cur_img_inx=2;prevpop()}}
function hidepopwin()
{
  if(hasvscroll)    document.body.style.overflow='scroll';
  di('3dloadzone').style.display=di('3dprevzone').style.display=di('3dnextzone').style.display=di('3dzone').style.display=di('3dpopzone').style.display=di('3dclosezone').style.display='none'
}
function gobck(){var dl=document.location.href;if(dl.indexOf('?id=')>0)document.location.href=document.referrer;else window.location.reload();}
function showpop(id)
{
  di('rbr').style.display='none';
  var base,popbase,zone,popzone;if(!di('3dbase'))createPop();
    base=di('3dbase');popbase=di('3dpopbase')

  var u=document.location.href,pfx=u.indexOf('/events')>0?'event':(u.indexOf('/exhibitions')>0?'exhibition':'product');
  var arr=u.indexOf('/events')>0?imgEvents:(u.indexOf('/exhibitions')>0?imgExhi:imgProd)
  var arrtxt=u.indexOf('/events')>0?txtEvents:(u.indexOf('/exhibitions')>0?txtExhi:txtProd)
  cur_arr=arr;
  base.style.backgroundImage='url('+pfx+'s/'+pfx+id+'.jpg)';popbase.style.width=(((arr[id]+1)*125)-60)+'px';
  var i;popbase.innerHTML="<img src='images/x.png' id='3dhidezone' class='hidezone' onclick='gobck()' />";
  for(i=1;i<=arr[id];i++)
    popbase.innerHTML+='<img onclick="showpopwin(\''+pfx+'\','+id+','+i+')" class="imgpopsm" src="'+pfx+'s/'+pfx+id+'-'+i+'.jpg"/></a>';
  popbase.innerHTML+=arrtxt[id]
}
function showpopwin(u,id,ix)
{
  window.scrollTo(0,0)
    cur_set=u;cur_img_id=id;cur_img_inx=ix;
    di('3dprevzone').style.display=di('3dnextzone').style.display=di('3dclosezone').style.display=di('3dzone').style.display=di('3dpopzone').style.display='';
    di('3dpopzone').style.backgroundImage='url("images/load.gif")';
    di('3dpopzone').style.backgroundImage=getimgurl(u,id,ix);
    if(hasvscroll)document.body.style.overflow='hidden';
}
function hideload(){di('3dloadzone').style.display='none'}
function getimgurl(u,id,ix){var srl='url("'+u+'s/'+u+id+'-'+ix+'a.jpg")';
  if(loaded_imgs.indexOf(srl)<0)
  {di('3dloadzone').style.display='';setTimeout(hideload,2000);loaded_imgs+=srl;}
  return srl;}