function fotoView(id)
{
  var loader = document.getElementById('loader');
  loader.style.display='block';
  loader.innerHTML = "<div class=previewBack></div><table cellpadding=0 cellspacing=0 class=fotoView width=100% height=100% onclick='fotoViewClose(event);'><tr><td height=30px colspan=4></td><td width=30px><a href='javascript:fotoViewCloseNow();'><img style='position:absolute;top:-4px;right:-1px;' src='/images/close.png'></a><img src='/images/trans.gif' width=40px height=40px></td></tr><tr><td width=40px></td><td width=120px id=previewBox valign=top></td><td align=center id=fotoViewTable valign=top><table height=100% cellpadding=0 cellspacing=0><tr><td width=50px align=left><a id='generalFotoViewLink' class=none href='javascript:fotoLinerBack();'><div class=controlBtn>&#9668;</div></a></td><td class=description id='mainPortfolio'></td><td width=50px align=right><a id='generalFotoViewLink' class=none href='javascript:fotoLinerNext();'><div class=controlBtn>&#9658;</div></a></td></tr></table></td><td width=280px align=left valign=top><div class=description id=descriptionBox></div></td><td width=30px valign=top></td></tr><tr><td height=30px colspan=6><img src='/images/trans.gif' width=40px height=40px></td></tr><tr><td height=160px colspan=7 bgcolor=#FFFFFF valign=top><table id='fotoLinerTable' height=160px width=" + loader.offsetWidth + "px;' cellspacing=0 cellpadding=0 bgcolor=#FFFFFF><tr><td><a href='javascript:void(0);' id='lastFoto'><div class=btn1></div></a></td><td valign=center><div class=fotoLiner id='fotoLiner' style='width:" + (loader.offsetWidth - 113) + "px;'></div></td><td><a href='javascript:void(0);' id='nextFoto'><div class=btn2></div></a></td></tr></table></td></tr></table>";
  
  jQuery('#nextFoto').mouseup(function(){
      jQuery('#fotoLiner').stop();
    }).mousedown(function(){
      var temp = jQuery('#fotoLiner')[0].scrollWidth;
      jQuery('#fotoLiner').animate({'scrollLeft':temp}, 4000); 
    });

  jQuery('#lastFoto').mouseup(function(){
      jQuery('#fotoLiner').stop();
    }).mousedown(function(){
      jQuery('#fotoLiner').animate({'scrollLeft':0}, 3000); 
    });
    
  ajax_loadInto('/ajax/galary.php?id=' + id + '&r=' + Math.random(), 'fotoLiner');
}

function loadPortfolioCell(id)
{
  ajax_loadInto('/ajax/galary.php?cmd=work&height=' + heightWindow + '&id=' + id + '&r=' + Math.random(), 'descriptionBox');
}

function changePreview(id)
{
  ajax_loadInto('/ajax/galary.php?cmd=preview&height=' + heightWindow + '&id=' + id + '&r=' + Math.random(), 'mainPortfolio');  
}

function fotoViewClose(event)
{
  if (!event) event = window.event;
  if (!event.target) {
    event.target = event.srcElement
  }
  if (event.target.id == 'fotoViewTable') fotoViewCloseNow();
}

function fotoViewCloseNow()
{
    document.getElementById('loader').style.display = 'none';
}

function fotoLinerNext()
{
  if (fotoNumNow > 0) lastfotoNumNow = fotoNumNow;
  ++fotoNumNow;
  var nextFoto = imageArray[fotoNumNow];
  if (nextFoto){
    anchors[(lastfotoNumNow - 1)].getElementsByTagName('img')[0].className = 'notActiveLiner';
    loadPortfolioCell(nextFoto); scrollingLiner(); anchors[(fotoNumNow - 1)].getElementsByTagName('img')[0].className = 'ActiveLiner'; 
  }else{ lastfotoNumNow = (fotoNumNow - 1); fotoNumNow = 0; fotoLinerNext(); }
}

function fotoLinerBack()
{
  if (fotoNumNow < imageArray.length) lastfotoNumNow = fotoNumNow;
  fotoNumNow -= 1;
  var nextFoto = imageArray[fotoNumNow];
  if (nextFoto){
    anchors[(lastfotoNumNow - 1)].getElementsByTagName('img')[0].className = 'notActiveLiner';
    loadPortfolioCell(nextFoto); scrollingLiner(); anchors[(fotoNumNow - 1)].getElementsByTagName('img')[0].className = 'ActiveLiner'; 
  }else{ lastfotoNumNow = fotoNumNow + 1; fotoNumNow = imageArray.length; fotoLinerBack(); }
}

function scrollingLiner()
{
  jQuery('#fotoLiner').stop();
  var temp = (((fotoNumNow - 1) * 160) - (Number(document.getElementById('loader').offsetWidth) / 2) + 160);
  jQuery('#fotoLiner').animate({'scrollLeft':temp}, 2000); 
}

function chCN(){
  var args = chCN.arguments; 
  for(var i = 0; i < args.length; i += 2) { if (is_object(args[i]) === true){args[i].className = args[i+1];}else{ if(document.getElementById(args[i]) != null) document.getElementById(args[i]).className = args[i+1];} }
}
function is_object( obj ){  return obj instanceof Object; }

