var bReady      = false;
window.onbeforeunload=CheckBasket;
var iCheckBasket = 1;
var strTheme    = '';
var strMainMenu = '';
var strSubMenu  = 'SubMenuPHOTOS';
var strContent  = '';
var iCurLang    = 1;
var iCurMenuPHOTO  = 0;
var iCurMenuINFO  = 0;
var strCurImgID = '';
var strLastImgID = '';
var strCurImgText = '';
var strLastImgText = '';
var strInfo     = 'Info' + iCurMenuINFO;
var nCatImages = new Array (16,16,16,0);
var CurCatImg = new Array (0,0,0,-1);
CatID = new Array ('1','2','3');
CatNames = new Array ('New York','American weddings','Mali');
CatText =  new MakeArray(3); 
CatText[0] = '<p>At times, Philippe Dollo&rsquo;s camera manages to catch a glimpse of the city&rsquo;s potential for existence, of its identity as a place in flux, rather than a motionless spot on a listed map. Through his lens, New York becomes an underworld where objects, people, gaps and lines are blurred not for lack of light, but because of their own velocity and haste. Dollo&rsquo;s vision of New York reflects his talent for plunging deep into the true alchemy of photography: he catches the ghost of a building reflected in a puddle, or a body in a trance under the spell of a gospel song. Alchemy indeed, in the literal sense: <em>the birth of a solid substance into a liquid phase</em>.</p><p>E.B. White, one of New York&rsquo;s few oracles, once imagined its paralysis, its asphyxia, its drowning &ndash; in short, its self-destruction. Although the plagues he thought of have yet to sweep this city away, its vulnerability is undeniable: New York can and will go wrong. A fire, a power cut, the shrouded tops of buildings in a sudden appearance of fog, all remind us, subconsciously at least, of the colossus&rsquo; weakness and therefore, of our own. On September 11, 2001, when &quot;Downtown&quot;, the city&rsquo;s throbbing matrix, was cut off and sealed, isolated from the neighboring streets and boroughs, New York became a dislocated place, fragile, interrupted. Ground Zero&rsquo;s wound was beyond repair, and quite suddenly, the world&rsquo;s big cities rediscovered what they really are: intimately fragile cities.</p><p>David Boratav, Journalist</p>'; 
CatText[1] = '<p>&quot;Philippe Dollo is the eye slipping in and stepping about to hem in on those brief moments of complicity, doubt, difficulty, anxiety or confrontation that are drowned in the rapid sequence of events of a very particular day, this unique&nbsp;passage in the history of a couple, this gathering of close ones that will never happen again.&quot;</p><p>Celine Curiol, Author</p>'; 
CatText[2] = '<p>&quot;If your name is Dollo, you can only be originally from here, from Dini in the Dogon country. If you are Dollo, we are family&quot;</p><p>We are in the heart of Mali, on top of the Biandagara cliffs. The man who states these words is an elderly gentleman; a tribal elder amongst the elders who come together each evening after the heat of the day, to chat beneath the baobab tree in the centre of the village. I show them the colour of my skin. They shrug their shoulders. &quot;All of this has no importance.&quot;</p><p>A major project is born for me, the French Caucasian from Brooklyn - to photograph my Dogon family and simply transmit the message: skin colour has no importance, mon Frere.</p><p>Philippe Dollo, April 2007</p>'; 
InfoID = new Array ('profile');
InfoNames = new Array ('Profil');
var nImagesLoaded = 0; 
var nImagesTotal  = 48; 
ImageSource =  new MakeArray(3); 
ImageSource[0] = new Array('dollo-01.jpg','dollo-02.jpg','dollo-03.jpg','dollo-04.jpg','dollo-04bis.jpg','dollo-05.jpg','dollo-06.jpg','dollo-07.jpg','dollo-08.jpg','dollo-09.jpg','dollo-10.jpg','dollo-11.jpg','dollo-12.jpg','dollo-13.jpg','dollo-14.jpg','dollo-15.jpg','');
ImageSource[1] = new Array('c193.jpg','c195.jpg','c196.jpg','c198.jpg','c202.jpg','c203.jpg','c204.jpg','c208.jpg','c211.jpg','c212.jpg','c214.jpg','c215.jpg','c216.jpg','c217.jpg','c219.jpg','c220.jpg','');
ImageSource[2] = new Array('c279.jpg','c280.jpg','c281.jpg','c282.jpg','c283.jpg','c284.jpg','c285.jpg','c286.jpg','c289.jpg','c290.jpg','c291.jpg','c294.jpg','c295.jpg','c296.jpg','c297.jpg','c299.jpg','');
ImageThumbSource =  new MakeArray(3); 
ImageThumbSource[0] = new Array('dollo-01T.jpg','dollo-02T.jpg','dollo-03T.jpg','dollo-04T.jpg','dollo-04bisT.jpg','dollo-05T.jpg','dollo-06T.jpg','dollo-07T.jpg','dollo-08T.jpg','dollo-09T.jpg','dollo-10T.jpg','dollo-11T.jpg','dollo-12T.jpg','dollo-13T.jpg','dollo-14T.jpg','dollo-15T.jpg','');
ImageThumbSource[1] = new Array('c193T.jpg','c195T.jpg','c196T.jpg','c198T.jpg','c202T.jpg','c203T.jpg','c204T.jpg','c208T.jpg','c211T.jpg','c212T.jpg','c214T.jpg','c215T.jpg','c216T.jpg','c217T.jpg','c219T.jpg','c220T.jpg','');
ImageThumbSource[2] = new Array('c279T.jpg','c280T.jpg','c281T.jpg','c282T.jpg','c283T.jpg','c284T.jpg','c285T.jpg','c286T.jpg','c289T.jpg','c290T.jpg','c291T.jpg','c294T.jpg','c295T.jpg','c296T.jpg','c297T.jpg','c299T.jpg','');
ImageRef =  new MakeArray(3); 
ImageRef[0] = new Array('dollo-01','dollo-02','dollo-03','dollo-04','dollo-04bis','dollo-05','dollo-06','dollo-07','dollo-08','dollo-09','dollo-10','dollo-11','dollo-12','dollo-13','dollo-14','dollo-15','');
ImageRef[1] = new Array('c193','c195','c196','c198','c202','c203','c204','c208','c211','c212','c214','c215','c216','c217','c219','c220','');
ImageRef[2] = new Array('c279','c280','c281','c282','c283','c284','c285','c286','c289','c290','c291','c294','c295','c296','c297','c299','');
ImageText =  new MakeArray(3); 
ImageText[0] = new Array('','','','','','','','','','','','','','','','','');
ImageText[1] = new Array('','','','','','','','','','','','','','','','','');
ImageText[2] = new Array('','','','','','','','','','','','','','','','','');
var iOrderMethod = 1; 
 
var nMaxBasketItems = 9; 
var nBasketItems    = 0; 
var iBasketIndex    = -1; 
BasketImgID  = new MakeArray(nMaxBasketItems); 
BasketImgSrc  = new MakeArray(nMaxBasketItems); 
BasketImgRef  = new MakeArray(nMaxBasketItems); 
BasketImgIdx  = new MakeArray(nMaxBasketItems); 
var strBuyImgDir = 'user_PhDo'; 
var strBuyPhotographer = 'Philippe Dollo';  
var strBuyCustomName = ''; 
var strBuyCustomAddr = ''; 
var strBuyCustomMail = ''; 
var strBuyCustomTele = ''; 
var strBuyCustomNote = ''; 
var strBuyOrderDir = 'user_PhDo'; 
var strBuyOrderMail = 'phdollo@yahoo.com';     
var strBuyOrderLink = '';     
var strBuyOrderLine = ''; 

function SetReady () {
  bReady = true; 
  HideSection ('ProgressBarArea'); 
  HideSection ('IntroImageArea'); 
  ShowSection ('ThumbScrollArea'); 
  ShowSection ('ThumbArea'); 
  ShowSection ('Cat0'); 
  ShowSection ('SubMenuArea'); 
  ShowSection ('SubMenuPHOTOS'); 
  ShowSection ('MenuScrollArea'); 
  ShowSection ('ImageArea'); 
  ShowSection ('ImageTextArea'); 
  ShowSection ('ImageText'); 
  ShowSection ('ImageTextScrollArea'); 
  ShowSection ('InfoArea'); 
  ShowSection ('InfoTextArea'); 
  ShowSection (strInfo); 
  ShowSection ('InfoTextScrollArea'); 
  var wndo = new dw_scrollObj ('ThumbArea', 'Cat0'); 
  wndo.setUpScrollbar ('ThumbScrollDragbar', 'ThumbScrollTrack', 'h', 1, 1); 
  wndo = new dw_scrollObj ('SubMenuArea', 'SubMenuPHOTOS'); 
  wndo.setUpScrollbar ('MenuScrollDragbar', 'MenuScrollTrack', 'v', 1, 1); 
  wndo = new dw_scrollObj ('ImageTextArea', 'ImageText'); 
  wndo.setUpScrollbar ('ImageTextScrollDragbar', 'ImageTextScrollTrack', 'v', 1, 1); 
  wndo = new dw_scrollObj ('InfoTextArea', 'Info0'); 
  wndo.setUpScrollbar ('InfoTextScrollDragbar', 'InfoTextScrollTrack', 'v', 1, 1); 
  PerformMenu ('START'); 
  var strUrl = document.URL; 
  var iArticle = -1; 
  var iTheme   = -1; 
  var ipos = strUrl.indexOf('?'); 
  var nc   = strUrl.length; 
  while (ipos > 0 && ipos < nc) { 
    var jpos = strUrl.indexOf('=', ipos); 
    if (jpos > 0) { 
      var kpos = strUrl.indexOf('&', jpos); 
      if (kpos <= 0) kpos = nc; 
      var strID  = strUrl.substring (ipos+1, jpos); 
      var strVal = strUrl.substring (jpos+1, kpos); 
      strID  = strID.toLowerCase(); 
      strVal = strVal.toLowerCase(); 
      if (strID == 'article') { 
        for (i = 0; i < InfoID.length; i++) { 
          if (strVal == InfoID[i]) iArticle = i; 
        } 
      } 
      if (strID == 'theme') { 
        for (i = 0; i < CatID.length; i++) { 
          if (strVal == CatID[i]) iTheme = i; 
        } 
      } 
      ipos = kpos; 
    } 
    else ipos = -1; 
  } 
  if (iTheme >= 0) { 
    iCurMenuPHOTO = iTheme; 
     PerformMenu ('PHOTOS'); 
  } 
  else if (iArticle >= 0) { 
    iCurMenuINFO = iArticle; 
     PerformMenu ('INFO'); 
  } 
  else {
    PerformMenu ('PHOTOS'); 
  } 
} 

function CheckBasket() { 
  if (iCheckBasket > 0 && nBasketItems > 0) { 
    var strMess = 'Du har ' + nBasketItems + ' fotos i din bestillingskurv'; 
    return strMess; 
  } 
  iCheckBasket = 1; 
} 

function UnCheckBasket() { 
  iCheckBasket = 0; 
} 

function SelectedText() { 
  document.selection.empty();
} 

function PerformMenu (id) {
  if (!bReady) return; 
  if (id == 'START') {  
    strMainMenu = id; 
    HideSection ('IntroImageArea'); 
    HideSection ('IDArea'); 
    ShowSection ('FuncArea'); 
    ShowSection ('MenuArea'); 
    ShowSection ('SubMenuArea'); 
    ShowSection ('ImageArea'); 
    ShowSection ('ImageTextArea'); 
    ShowSection ('ThumbArea'); 
    for (var i = 0; i < nMaxBasketItems; i++) { 
      strName = 'BasketImage' + i; 
      BasketImgIdx[i] = FindImage (strName); 
    } 
    ShowImage (0,0,0); 
    strCurImgID = '0_0'; 
  } 
  else if (id == 'PHOTOS') { 
    strMainMenu = id; 
    ShowSection ('SubMenuArea'); 
    ShowSubMenu ('PHOTOS'); 
    HideSection ('InfoBannerArea'); 
    MarkMenu   ('PHOTOS'); 
    UnmarkMenu ('INFO'  ); 
    HideSection ('InfoArea'); 
    ShowSection ('ThumbArea'); 
    ShowSection ('ImageArea'); 
    ShowSection ('ImageTextArea'); 
    ShowSubMenuPHOTO (iCurMenuPHOTO); 
    UnmarkFunc ('FULLSIZE'); 
    ShowOrder(); 
  } 
  else if (id == 'INFO') {  
    strMainMenu = id; 
    ShowSection ('SubMenuArea'); 
    ShowSubMenu ('INFO'); 
    ShowSection ('InfoBannerArea'); 
    MarkMenu   ('INFO'  ); 
    UnmarkMenu ('PHOTOS'); 
    HideSection ('BasketStrip'); 
    HideSection ('ThumbArea'); 
    HideSection ('ImageArea'); 
    HideSection ('ImageTextArea'); 
    ShowSection ('InfoArea'); 
    ShowSubMenuINFO (iCurMenuINFO); 
    DimMenu('FULLSIZE'); 
    ShowOrder(); 
  } 
  else if (id == 'FULLSIZE') { 
    urchinTracker('/Gallery/Fullsize');
    NewImageWindow(); 
  } 
  else if (id == 'PORTAL') { 
    document.location = '../Index.html'; 
  } 
  else if (id == 'CATALOG') { 
    urchinTracker('/Gallery/GalleryCatalog');
    win = window.open ("Catalog_PhDo_Native.pdf", "", "menubar=1,toolbar=0,resizable=1,scrollbars=1"); 
  } 
  else if (id == 'PRINT') { 
    PrintPage ();
  } 
  else if (id == 'ADDORDER') { 
    if (strMainMenu == 'PHOTOS') { 
      AddCurImageToBasket(); 
      ShowOrder(); 
    } 
  } 
  else if (id == 'REMORDER') { 
    if (strMainMenu == 'PHOTOS') { 
      RemoveFromBasket(); 
      ShowOrder(); 
    } 
  } 
  else if (id == 'CLRORDER') { 
    if (strMainMenu == 'PHOTOS') { 
      ClearBasket(); 
      ShowOrder(); 
    } 
  } 
  else if (id == 'DOORDER') { 
    urchinTracker('/Gallery/Order');
    if (nBasketItems > 0) {
      BuyBasketPopup(); 
    } 
  } 
} 

function ShowOrderLink () { 
  var win = window.open ("../BuyLink.html", "", "left=100,top=100,directories=0,location=0,menubar=1,resizable=1,scrollbars=1,status=0,toolbar=0,width=500,height=500");
} 

function ShowOrder () {
  if (strMainMenu == 'PHOTOS') { 
    if (nBasketItems < nMaxBasketItems) UnmarkFunc ('ADDORDER'); 
    else                                DimMenu    ('ADDORDER'); 
    if (nBasketItems > 0) UnmarkFunc ('CLRORDER'); 
    else                  DimMenu    ('CLRORDER'); 
    if (nBasketItems > 0) UnmarkFunc ('DOORDER'); 
    else                  DimMenu    ('DOORDER'); 
    if (nBasketItems > 0 && iBasketIndex >= 0) UnmarkFunc ('REMORDER'); 
    else                                       DimMenu    ('REMORDER'); 
    if (nBasketItems > 0) ShowSection ('ImageBasketArea'); 
    else                  HideSection ('ImageBasketArea'); 
  } 
  if (strMainMenu == 'INFO') { 
    DimMenu ('ADDORDER'); 
    DimMenu ('REMORDER'); 
    DimMenu ('CLRORDER'); 
    if (nBasketItems > 0) UnmarkFunc ('DOORDER'); 
    else                  DimMenu    ('DOORDER'); 
    HideSection ('ImageBasketArea'); 
  } 
} 

function ImageIsLoaded () { 
  if(bReady) return; 
  nImagesLoaded++; 
  UpdateImageProgress(); 
  if (nImagesLoaded == nImagesTotal - 3) SetReady();
} 

function UpdateImageProgress () {
  if (nImagesTotal == 0) return; 
  var progress = parseFloat(nImagesLoaded) / parseFloat(nImagesTotal); 
  m = document.getElementById('ProgressBarArea'); 
  progress *= 471; 
  progress += 5; 
  var src = '<div style="position:absolute;left:0px;width:' + parseInt(progress) + 'px;height:100%;background-color:#C6C6C6;">'; 
  src += '</div>' 
  if (m) m.innerHTML = src; 
} 

function NoAction () {
} 

function InitThumbScroll(dir) { 
  dw_scrollObj.initScroll('ThumbArea', dir); 
} 

function StopThumbScroll() { 
  dw_scrollObj.stopScroll('ThumbArea'); 
} 

function InitMenuScroll(dir) { 
  dw_scrollObj.initScroll('SubMenuArea', dir); 
} 

function StopMenuScroll() { 
  dw_scrollObj.stopScroll('SubMenuArea'); 
} 

function InitImageTextScroll(dir) { 
  dw_scrollObj.initScroll('ImageTextArea', dir); 
} 

function StopImageTextScroll() { 
  dw_scrollObj.stopScroll('ImageTextArea'); 
} 

function InitInfoTextScroll(dir) { 
  dw_scrollObj.initScroll('InfoTextArea', dir); 
} 

function StopInfoTextScroll() { 
  dw_scrollObj.stopScroll('InfoTextArea'); 
} 
 

function MakeArray(n) { 
 this.length = n; 
 for (var i = 0; i < n; i++) this[i] = 0; 
 return this; 
} 
 

function MarkMenu (id) {
  MoveFocus();
  if (id == '') return; 
  strName = 'MI' + id; 
  index = FindImage (strName); 
  if (index >= 0) document.images[index].className='MenuSquareSelected'; 
  strName = 'MT' + id; 
  index = FindAnchor (strName); 
  if (index >= 0) document.anchors[index].className='MenuTextSelected'; 
} 

function MouseoverMenu (id) {
  strName = 'MI' + id; 
  index = FindImage (strName); 
  if (index >= 0) { 
    if (document.images[index].className == 'MenuSquareSelected') return; 
    if (document.images[index].className == 'MenuSquareDimmed'  ) return; 
    document.images[index].className='MenuSquareMouseover'; 
  } 
  strName = 'MT' + id; 
  index = FindAnchor (strName); 
  if (index >= 0) document.anchors[index].className='MenuTextMouseover'; 
} 

function MouseoutMenu (id) {
  strName = 'MI' + id; 
  index = FindImage (strName); 
  if (index >= 0) { 
    if (document.images[index].className != 'MenuSquareMouseover') return; 
    document.images[index].className='MenuSquare'; 
  } 
  strName = 'MT' + id; 
  index = FindAnchor (strName); 
  if (index >= 0) document.anchors[index].className='MenuText'; 
} 

function MouseoverFunc (id) {
  strName = 'MI' + id; 
  index = FindImage (strName); 
  if (index >= 0) { 
    if (document.images[index].className == 'MenuSquareSelected') return; 
    if (document.images[index].className == 'MenuSquareDimmed'  ) return; 
    document.images[index].className='MenuSquareMouseover'; 
  } 
  strName = 'MT' + id; 
  index = FindAnchor (strName); 
  if (index >= 0) document.anchors[index].className='MenuTextMouseover'; 
} 

function MouseoutFunc (id) {
  strName = 'MI' + id; 
  index = FindImage (strName); 
  if (index >= 0) { 
    if (document.images[index].className != 'MenuSquareMouseover') return; 
    document.images[index].className='FuncSquare'; 
  } 
  strName = 'MT' + id; 
  index = FindAnchor (strName); 
  if (index >= 0) document.anchors[index].className='MenuText'; 
} 

function UnmarkMenu (id) {
  strName = 'MI' + id; 
  index = FindImage (strName); 
  if (index >= 0) document.images[index].className='MenuSquare'; 
  strName = 'MT' + id; 
  index = FindAnchor (strName); 
  if (index >= 0) document.anchors[index].className='MenuText'; 
} 

function UnmarkFunc (id) {
  strName = 'MI' + id; 
  index = FindImage (strName); 
  if (index >= 0) document.images[index].className='FuncSquare'; 
  strName = 'MT' + id; 
  index = FindAnchor (strName); 
  if (index >= 0) document.anchors[index].className='MenuText'; 
} 

function DimMenu (id) {
  strName = 'MI' + id; 
  index = FindImage (strName); 
  if (index >= 0) document.images[index].className='MenuSquareDimmed'; 
  strName = 'MT' + id; 
  index = FindAnchor (strName); 
  if (index >= 0) document.anchors[index].className='MenuTextDimmed'; 
} 

function ShowSubMenuPHOTO (icat) {
  if (!bReady) return; 
  UnmarkMenu ('SP' + iCurMenuPHOTO); 
  MarkMenu   ('SP' + icat); 
  iCurMenuPHOTO = icat; 
  ShowTheme (icat); 
} 

function ShowSubMenuINFO (icat) {
  if (!bReady) return; 
  UnmarkMenu ('SI' + iCurMenuINFO); 
  MarkMenu   ('SI' + icat); 
  iCurMenuINFO = icat; 
  ShowInfo (icat); 
} 

function ShowSubMenu (id) {
  if (!bReady) return; 
  HideSection (strSubMenu); 
  strSubMenu = 'SubMenu' + id; 
  ShowSection (strSubMenu); 
  var layer = document.getElementById(strSubMenu); 
  var ylayer = layer ? layer.offsetHeight : 0;
  var yarea  = 132; 
  ShowSection ('MenuScrollArea'); 
  dw_scrollObj.loadLayer ('SubMenuArea', strSubMenu); 
  if (ylayer <= yarea) HideSection ('MenuScrollArea'); 
} 

function ShowTheme (icat) {
  if (!bReady) return; 
  HideSection (strTheme); 
  strTheme = 'Cat' + icat; 
  ShowSection (strTheme); 
  ShowInfoTitle (CatNames[icat]); 
  if (icat >= 0) { 
    nImages = nCatImages[icat]; 
    if (nImages > 16) ShowSection('ThumbScrollArea'); 
    else              HideSection('ThumbScrollArea'); 
    dw_scrollObj.loadLayer ('ThumbArea', strTheme); 
    strCurImgID = '' + icat + '_' + CurCatImg[icat];
    strLastImgID = strCurImgID;
    ShowImage (icat, CurCatImg[icat], 1);
  } 
  else { 
    HideSection('ThumbScrollArea'); 
    ShowImage (icat, 0, 1);
    strCurImgID = '';
    strLastImgID = strCurImgID;
  } 
} 

function ShowInfo (info) {
  HideSection('ThumbScrollArea'); 
  HideSection (strInfo); 
  ShowInfoTitle (InfoNames[info]); 
  strInfo = 'Info' + info; 
  ShowSection (strInfo); 
  var area = document.getElementById('InfoTextArea'); 
  if (area) area.style.width = '634px'; 
  var layer = document.getElementById(strInfo); 
  if (layer) layer.style.width = '634px'; 
  var yarea  = 471; 
  var ylayer = layer ? layer.offsetHeight : 0;
  ShowSection ('InfoTextScrollArea'); 
  dw_scrollObj.loadLayer ('InfoTextArea', strInfo); 
  if (ylayer > yarea) { 
    area.style.width = '612px'; 
    layer.style.width = '612px'; 
  } 
  else { 
    HideSection ('InfoTextScrollArea'); 
  } 
} 

function GetThumbSource(id) { 
  var img  = -1; 
  var index = id.indexOf('_'); 
  if (index > 0) { 
    var str = id.substring(0,index); 
    var icat = parseInt (str); 
    str = id.substring(index+1,id.length); 
    var img = parseInt (str); 
    if (img >= 0) return ImageThumbSource[icat][img]; 
  } 
  return ''; 
} 
 

function GetImageSource(id) { 
  var img  = -1; 
  var index = id.indexOf('_'); 
  if (index > 0) { 
    var str = id.substring(0,index); 
    var icat = parseInt (str); 
    str = id.substring(index+1,id.length); 
    var img = parseInt (str); 
    if (img >= 0) return ImageSource[icat][img]; 
  } 
  return ''; 
} 
 

function GetImageRef(id) { 
  var img  = -1; 
  var index = id.indexOf('_'); 
  if (index > 0) { 
    var str = id.substring(0,index); 
    var icat = parseInt (str); 
    str = id.substring(index+1,id.length); 
    var img = parseInt (str); 
    if (img >= 0) return ImageRef[icat][img]; 
  } 
  return GetImageSource(id); 
} 
 

function FindAnchor (name) {
  if (document.anchors) { 
    for (i = 0; i < document.anchors.length; i++) { 
      if (document.anchors[i].name == name) return i; 
      }; 
  } 
  return -1; 
} 

function FindImage (name) {
  if (document.images) { 
    for (i = 0; i < document.images.length; i++) { 
      if (document.images[i].name == name) return i; 
      }; 
  } 
  return -1; 
} 

function SelectThumbImage (id) {
  strName = 'T' + strCurImgID; 
  index = FindImage (strName); 
  if (index >= 0) document.images[index].className='ThumbImage'; 
  strName = 'T' + id; 
  index = FindImage (strName); 
  if (index >= 0) document.images[index].className='ThumbImageSelect'; 
  strCurImgID = id; 
} 

function Replace (strText, strFrom, strTo) {
  var strNow = strText; 
  var ipos = strText.indexOf(strFrom); 
  if (ipos >= 0) { 
    strNow = strText.substring(0, ipos); 
    strNow += strTo; 
    strNow += strText.substring(ipos + strFrom.length, strText.length); 
  } 
  return strNow; 
} 

function PlaceSection (id, pos) {
  if (document.getElementById && document.createTextNode) { 
    var m = document.getElementById(id); 
    if (m) m.style.top = pos; 
  } 
} 

function ShowSection (id) {
  if (document.getElementById && document.createTextNode) { 
    var m = document.getElementById(id); 
    if (m) m.style.display="block"; 
  } 
} 

function HideSection (id) {
  if (document.getElementById && document.createTextNode) { 
    var m = document.getElementById(id); 
    if (m) m.style.display="none"; 
  } 
} 

function  ShowContent (id) {
  if (!bReady) return; 
  HideSection (strContent); 
  strContent = id; 
  ShowSection (strContent); 
} 

function NewImageWindow() {
  var strImage = GetImageSource(strCurImgID); 
  if (strImage.length <= 0) return; 
  win = window.open ("", "", "fullscreen=yes");
  win.document.open ();
  win.document.write ('<html>');
  win.document.write ('<head>');
  win.document.write ('<title>Image: ' + strImage + '</title>');
  win.document.write ('<link rel="stylesheet" type="text/css" href="../PhotoSite.css" />');
  win.document.write ('<script type="text/Javascript">');
  win.document.write ('var color = 6; ');
  win.document.write ('function ChangeColor(idir) { '); 
  win.document.write ('  color += idir; '); 
  win.document.write ('  if (color  > 8) color = 8; ');
  win.document.write ('  if (color  < 0) color = 0; ');
  win.document.write ('  if (color == 0) document.body.style.backgroundColor="#000000"; '); 
  win.document.write ('  if (color == 1) document.body.style.backgroundColor="#202020"; '); 
  win.document.write ('  if (color == 2) document.body.style.backgroundColor="#404040"; '); 
  win.document.write ('  if (color == 3) document.body.style.backgroundColor="#606060"; '); 
  win.document.write ('  if (color == 4) document.body.style.backgroundColor="#808080"; '); 
  win.document.write ('  if (color == 5) document.body.style.backgroundColor="#A0A0A0"; '); 
  win.document.write ('  if (color == 6) document.body.style.backgroundColor="#C0C0C0"; '); 
  win.document.write ('  if (color == 7) document.body.style.backgroundColor="#E0E0E0"; '); 
  win.document.write ('  if (color == 8) document.body.style.backgroundColor="#FFFFFF"; '); 
  win.document.write ('} '); 
  win.document.write ('function ChangeColorX() { '); 
  win.document.write ('  color++; '); 
  win.document.write ('  if (color  > 8) color = 0; ');
  win.document.write ('  if (color == 0) document.body.style.backgroundColor="#000000"; '); 
  win.document.write ('  if (color == 1) document.body.style.backgroundColor="#202020"; '); 
  win.document.write ('  if (color == 2) document.body.style.backgroundColor="#404040"; '); 
  win.document.write ('  if (color == 3) document.body.style.backgroundColor="#606060"; '); 
  win.document.write ('  if (color == 4) document.body.style.backgroundColor="#808080"; '); 
  win.document.write ('  if (color == 5) document.body.style.backgroundColor="#A0A0A0"; '); 
  win.document.write ('  if (color == 6) document.body.style.backgroundColor="#C0C0C0"; '); 
  win.document.write ('  if (color == 7) document.body.style.backgroundColor="#E0E0E0"; '); 
  win.document.write ('  if (color == 8) document.body.style.backgroundColor="#FFFFFF"; '); 
  win.document.write ('} '); 
  win.document.write ('</sc' + 'ript>'); 
  win.document.write ('</head>');
  win.document.write ('<body onLoad="ChangeColor(0)">'); 
  win.document.write ('<table width="100%" height="100%" style="text-align:center"><tr><td valign="middle">'); 
  win.document.write ('<img src="' + strImage + '" border="0" />');
  win.document.write ('</td></tr></table>'); 
  win.document.write ('<div style="position:absolute; bottom:20px; left:30px; text-align:left;">'); 
  win.document.write ('<div class="MenuLine" onmousedown="ChangeColorX()">'); 
  win.document.write ('<img src="../blank.gif" class="MenuSquare" />');
  win.document.write ('<span class="MenuText">Background tone</span>'); 
  win.document.write ('</div>'); 
  win.document.write ('<div class="MenuLine" onmousedown="window.close()">'); 
  win.document.write ('<img src="../blank.gif" class="MenuSquare" />');
  win.document.write ('<span class="MenuText">Close window</span>'); 
  win.document.write ('</div>'); 
  win.document.write ('</div>'); 
  win.document.write ('</body>'); 
  win.document.write ('</html>'); 
  win.document.close ();
} 

function PrintPage() {
  var strID = ''; 
  if (strMainMenu == 'PHOTOS') strID = strCurImgID; 
  if (strMainMenu == 'INFO'  ) strID = InfoID[iCurMenuINFO]; 
  if (strID == '') return; 
  var strFile  = '';
  var strTitle = '';
  var strText  = '';
  if (strMainMenu == 'PHOTOS') {; 
    strTitle = CatNames[iCurMenuPHOTO]; 
    strFile = GetImageSource(strID);
    if (strFile == '') return; 
    if (document.getElementById && document.createTextNode) { 
      var mt= document.getElementById('ImageText'); 
      if (mt) strText = mt.innerHTML;
    } 
  } 
  if (strMainMenu == 'INFO') {; 
    if (document.getElementById && document.createTextNode) { 
      var mt= document.getElementById(strInfo); 
      if (mt) strText = mt.innerHTML;
      strTitle = InfoNames[iCurMenuINFO];
    } 
  } 
  win = window.open ("", "", "left=100,top=100,toolbar=1,menubar=1,scrollbars=1,resizeable=1,width=700,height=600");
  win.document.open ();
  win.document.write ('<html>\n');
  win.document.write ('<head>\n');
  win.document.write ('<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1" />\n');
  win.document.write ('<link rel="stylesheet" type="text/css" href="../PhotoSitePopupPrint.css" />\n');
  win.document.write ('</head>\n');
  win.document.write ('<body onload="window.print()" >\n'); 
  win.document.write ('<div id="mainpage">\n');
  win.document.write ('<div id="LogoArea">\n');
  win.document.write ('<img src="../Logo_gallery.gif" width="100%" />\n'); 
  win.document.write ('</div>\n');
  win.document.write ('<div id="IdentArea">\n');
  win.document.write ('<b>PHOTOMONDO - PHOTOGRAPHY</b><br/><br/>\n'); 
  win.document.write ('<b>Fotograf Philippe Dollo</b><br/><br/>\n'); 
  win.document.write ('www.photomondo.dk/PhilippeDollo/dk <br/>\n'); 
  win.document.write ('phdollo@yahoo.com \n'); 
  win.document.write ('</div>\n');
  win.document.write ('<div id="InfoTitleArea">\n');
  win.document.write (strTitle); 
  win.document.write ('</div>\n');
  win.document.write ('<div id="InfoArea">\n');
  if (strMainMenu == 'PHOTOS') {; 
    win.document.write ('<img src="' + strFile + '" />\n'); 
    win.document.write ('<br/>\n');
    win.document.write ('Filnavn: <i>' + strFile + '</i><br/><br/>\n');
  } 
  win.document.write (strText); 
  win.document.write ('\n</div>\n');
  win.document.write ('\n</div>\n');
  win.document.write ('</body>\n'); 
  win.document.write ('</html>\n'); 
  win.document.close ();
} 

function ShowImage (icat, img, sel) {
  var strText = '';
  var strID = '';
  if (icat >= 0 && img >= 0) { 
    strText += ImageText[icat][img];
    if (strText.length > 0) strText += '<br/><br/>';
    strText += CatText[icat];
    strID = '' + icat + '_' + img; 
    if (sel > 0) { 
      SelectThumbImage (strID); 
      CurCatImg[icat] = img; 
      strCurImgID = strID; 
      strCurImgText = strText; 
    } 
  } 
  strLastImgID = strID; 
  strLastImgText = strText; 
  strNow = 'Img' + strID; 
  ShowContent (strNow); 
  ShowImageText (strLastImgText); 
} 

function ShowInfoTitle (str, color) {
  var area = document.getElementById('InfoTitleArea'); 
  if (area) { 
    area.innerHTML = str; 
    if (color) area.style.color = color; 
    else       area.style.color = 'black'; 
  } 
} 

function ShowImageText (str) {
  var area = document.getElementById('ImageTextArea'); 
  if (area) area.style.width = '145px'; 
  var layer = document.getElementById('ImageText'); 
  if (layer) layer.innerHTML = str; 
  var ylayer = layer ? layer.offsetHeight : 0;
  var yarea  = 310;
  HideSection ('ImageTextScrollArea'); 
  if (ylayer > yarea) { 
    area.style.width = '124px'; 
    ShowSection ('ImageTextScrollArea'); 
    dw_scrollObj.loadLayer ('ImageTextArea', 'ImageText'); 
  }; 
} 

function SetMenuText (id, text, color) { 
  index = FindAnchor ('MT' + id); 
  if (index >= 0) { 
    document.anchors[index].innerHTML = text; 
    if (color) document.anchors[index].style.color = color; 
  } 
} 

function UpdateBasketIcons () { 
} 

function DisplayBasket () { 
  for (var i = 0; i < nMaxBasketItems; i++) { 
    DisplayBasketUnit (i); 
  } 
} 

function DisplayBasketUnit (i) { 
  strName = 'BasketImage' + i; 
  ShowSection (strName); 
  strImgSrc  = GetThumbSource(BasketImgID[i]); 
  if (strImgSrc == '') strImgSrc = '../blank.gif'; 
  var index = FindImage (strName); 
  if (index >= 0) document.images[index].src = strImgSrc; 
} 

function AddCurImageToBasket () { 
  if (strCurImgID.length > 0 && nBasketItems < nMaxBasketItems) { 
    var index = -1; 
    for (var i = nMaxBasketItems - 1; i >= 0; i = i-1) { 
      if (BasketImgID [i] == '') index = i; 
    } 
    if (index >= 0) { 
      BasketImgID [index] = strCurImgID; 
      BasketImgSrc[index] = GetThumbSource(strCurImgID); 
      BasketImgRef[index] = GetImageRef(strCurImgID); 
      nBasketItems++; 
      SelectBasketImage (index); 
      DisplayBasketUnit(index); 
      UpdateBasketIcons(); 
    } 
  } 
} 

function BuyCurBasket () { 
} 

function RemoveFromBasket () { 
  if (iBasketIndex >= 0) { 
    for (var i = iBasketIndex; i < nBasketItems - 1; i++) { 
      BasketImgID [i] = BasketImgID[i+1]; 
      BasketImgSrc[i] = BasketImgSrc[i+1]; 
      BasketImgRef[i] = BasketImgRef[i+1]; 
      DisplayBasketUnit(i); 
    } 
    BasketImgID [nBasketItems-1] = ''; 
    DisplayBasketUnit(nBasketItems-1); 
    nBasketItems = nBasketItems - 1; 
    if (nBasketItems > 0) SelectBasketImage(nBasketItems-1); 
    UpdateBasketIcons(); 
  } 
} 

function ClearBasket () { 
  if (iBasketIndex >= 0) { 
    UnselectBasketImage(); 
  } 
  for (var i = 0; i < nMaxBasketItems; i++) { 
    BasketImgID [i] = ''; 
    DisplayBasketUnit(i); 
  } 
  iBasketIndex = -1; 
  nBasketItems = 0; 
  UpdateBasketIcons(); 
} 

function BuyBasketPopup() {
  if (nBasketItems > 0) { 
    strBuyOrderLine = ''; 
    for (var i = 0; i < nBasketItems; i++) { 
      if (strBuyOrderLine != '') strBuyOrderLine += ', '; 
      strBuyOrderLine += BasketImgRef[i]; 
    } 
    window.open ("../BuyForm.html", "", "left=100,top=100,directories=0,location=0,menubar=0,resizable=0,scrollbars=0,status=0,toolbar=0,width=530,height=570");
  }
}

function ShowBasketImage (index, sel) {
  if (sel == 0) return; 
  strID = BasketImgID[index]; 
  if (strID == '') return; 
  if (sel > 0) { 
    SelectThumbImage (strID); 
    SelectBasketImage (index); 
  } 
  strNow = 'Img' + strID; 
  ShowContent (strNow); 
  if (sel > 0) UpdateBasketIcons(); 
} 

function SelectBasketImage (i) {
  UnselectBasketImage(); 
  index = BasketImgIdx[i]; 
  if (index >= 0) { 
    document.images[index].className='BasketImageSelect'; 
    iBasketIndex = i; 
  } 
} 

function UnselectBasketImage () {
  for (var i = 0; i < nMaxBasketItems; i++) {
    index = BasketImgIdx[i]; 
    if (index >= 0) document.images[index].className='BasketImage'; 
  } 
  iBasketIndex = -1; 
} 

function ShowSelectedImage () {
  if (strCurImgID == '') return; 
  strNow = 'Img' + strCurImgID; 
  ShowContent (strNow); 
  ShowImageText (strCurImgText); 
  strLastImgID   = strCurImgID; 
  strLastImgText = strCurImgText; 
} 

function ShowLastImage () {
  strNow = 'Img' + strLastImgID; 
  ShowContent (strNow); 
  ShowImageText (strLastImgText); 
} 

function MoveFocus() {
  var move = false; 
  var agent = navigator.userAgent.toLowerCase();
  var is_ie     = (agent.indexOf('msie')  != -1);
  var is_opera  = (agent.indexOf('opera') != -1);
  var is_mac	  = (agent.indexOf('mac')   != -1);
  var is_mac_ie = (is_ie && is_mac);
  var is_win_ie = (is_ie && !is_mac);
  var is_gecko  = (navigator.product == 'Gecko');
  if (is_gecko) move = true; 
  if (move) { 
    var index = FindAnchor ('DummyLink'); 
    if (index >= 0) document.anchors[index].focus(); 
  } 
} 

