$(document).ready(function(){
   $("#main-nav .arrows").click(function(){
      if ( $("#main-nav").css('top') == '-168px' ) {
    $("#main-nav").animate({top: '0'}, 1000);
  } else {
    $("#main-nav").animate({top: '-168px'}, 1000);
  }
          });
   
   $("#sub-nav .arrows").click(function(){
              if ( $("#sub-nav").css('top') == '-449px' ) {
    $("#sub-nav").animate({top: '-190px'}, 1000);
  } else {
    $("#sub-nav").animate({top: '-449px'}, 1000);
  }
          });
   $("#main-nav .arrows").click(function(){
              if ( $("#sub-nav").css('top') == '-190px' ) {
    $("#sub-nav").animate({top: '0px'}, 1000);
  } 
          });
   $("#sub-nav .arrows").click(function(){
              $("#sub-nav .arrows").toggleClass("revers");
          });
      
	$("#main-nav .arrows").click(function(){
              $("#main-nav .arrows").toggleClass("revers");
          });

	  $("form .textfield").focus(function(){
              if ($(this).val() == 'Поиск') {
				$(this).val("");
			  }
          });
	  $("form .textfield").blur(function(){
              if ($(this).val() == '') {
				$(this).val("Поиск");
			  }
          });
	
	
var _pics = new Array();
var i_pics = 0;
$(".photo-viewer img").click(function(){
var _initial = function(id,x,y){
if (x && y) _pics[id] = [x,y];
if ( !_pics[id]) return Array();
return _pics[id];
}

var w = $(this).css('width');
var h = $(this).css('height');
var me = $(this);
var wh = function () {
if (!me.attr('id')) {
i_pics++;
me.attr({'id':'img'+ i_pics});
_initial('img'+ i_pics, w,h);
}
}
wh();
if ( $(this).css('width') != '278px' ) {
$(this).animate({width: '278px', height:'278px'}, 300);
$(this).css({zIndex:'1000'});
} else {
var init = _initial($(this).attr('id')); 
$(this).animate({width: init[0], height: init[1] }, 300, layers);

}
});

function layers(){$(this).css({zIndex:'1'})};
      });
