//JS

function findOdds(node, arr) {
  var space = /^[^\u0021-\uffff]*$/g;
  if(node.nodeType == 3) {
    if(node.nodeValue.match(space)) {
      arr.push(node);
    }
  }
  else if(node.nodeType == 1) {
    for(var n = node.firstChild; n; n = n.nextSibling) {
      findOdds(n, arr);
    }
  }
}
function removeOdds(node) {
  var odds = new Array();
  findOdds(node, odds);
  for(var i = 0; i < odds.length; i++) {
    odds[i].parentNode.removeChild(odds[i]);
  }
}
window.onload = function(){
  removeOdds(document.documentElement); //Удаление паразитных пробелов и переносов строки
  var menu = document.getElementById('topMenu');
  for(var n = menu.firstChild; n; n = n.nextSibling) {
    n.lastChild.style.visibility = 'hidden';
    n.onmouseover = function() {
      if(this.lastChild.style.visibility == 'hidden') {
      this.lastChild.style.visibility = 'visible';
      }
      else {
      this.lastChild.style.visibility = 'hidden';
      }
    }
    n.onmouseout = function() {
      if(this.lastChild.style.visibility == 'visible') {
      this.lastChild.style.visibility = 'hidden';
      }
      else {
      this.lastChild.style.visibility = 'visible';
      }
    }
  }
  
  
  

  
  function marginMove(order, id) {
    // Опеределим шаг прокрутки в пикселях
    var step = 219;
    // Получим доступ к ДИВу
    var movedDiv;
    if (!(movedDiv = document.getElementById(id))) return;
    // Опеределим существующие значения marginLeft
    var left = movedDiv.style.marginLeft ? parseInt(movedDiv.style.marginLeft) : 0;
    // Установим новые значения margin, в зависимости от направления прокрутки
    switch (order) {
        case "left" :
          if(left > -1390){
            movedDiv.style.marginLeft = (left - step) + "px";
          }
        break;
        case "right" :
          if(left != 0){
            movedDiv.style.marginLeft = (left + step) + "px";
          }
        break;
        default :
            // Nothing
        break;
    }   
    return false;
  }
  
  
  
  var allPics = document.getElementById('allPics');
  var arrowLeft = document.getElementById('arrowLeft');
  var arrowRight = document.getElementById('arrowRight');
  var arrowLeftTop = document.getElementById('arrowLeftTop');
  var arrowRightTop = document.getElementById('arrowRightTop');
  
  arrowLeft.onclick = function(){
    marginMove('right', 'allPics');
    return false;
  }
  arrowRight.onclick = function(){
    marginMove('left', 'allPics');
    return false;
  }
  
  arrowLeft.onmousemove = function(){
    arrowLeftTop.style.visibility = 'visible';
  } 
  arrowLeft.onmouseout = function(){
    arrowLeftTop.style.visibility = 'hidden';
  }
  arrowRight.onmousemove = function(){
     arrowRightTop.style.visibility = 'visible';
  } 
  arrowRight.onmouseout = function(){
     arrowRightTop.style.visibility = 'hidden';
  }
  
  
  
  
  
  
  
  
  
  
  
  
} // window.onload = function(){
