var arImg = new Array();
var iAboutPageStepChanger=0;
  
function AboutImgChanger2()
{  
  $("img#about_img_changer").fadeTo(800, 0.1);
  
  setTimeout('AboutImgChanger();', 800);
}

function AboutImgChanger()
{
  iAboutPageStepChanger++;
  if(iAboutPageStepChanger>3) iAboutPageStepChanger=0;
  
  $("img#about_img_changer").attr("src", arImg[iAboutPageStepChanger].src);

  $("img#about_img_changer").fadeTo(800, 1.0);
   
  setTimeout('AboutImgChanger2();', 3000);
}

var ScrollPos=0;
var ScrollNull=1;
  
function ScrollUp(iStep)
{
  if (ScrollPos>=iStep) ScrollPos-=iStep;
  else if (ScrollPos<iStep && ScrollPos>=0) ScrollPos=0;
  $(".main").scrollTop(ScrollPos);
  if (ScrollNull) setTimeout('ScrollUp('+iStep+');', 20);
  else ScrollNull=1;
}

function ScrollDown(iStep)
{
  var scroll=$(".main").scrollTop();
  if ((ScrollPos-5)<=scroll) ScrollPos+=iStep;
  else if ((ScrollPos-5)>scroll) ScrollPos=scroll;
  $(".main").scrollTop(ScrollPos);
  if (ScrollNull) setTimeout('ScrollDown('+iStep+');', 20);
  else ScrollNull=1;
}

//--------------------------------------------------------------

var ScrollPosV2=0;
var ScrollNullV2=1;
  
function ScrollUpV2(iStep)
{
  if (ScrollPosV2>=iStep) ScrollPosV2-=iStep;
  else if (ScrollPosV2<iStep && ScrollPosV2>=0) ScrollPosV2=0;
  $(".main1").scrollTop(ScrollPosV2);
  if (ScrollNullV2) setTimeout('ScrollUpV2('+iStep+');', 20);
  else ScrollNullV2=1;
}

function ScrollDownV2(iStep)
{
  var scroll=$(".main1").scrollTop();
  if ((ScrollPosV2-5)<=scroll) ScrollPosV2+=iStep;
  else if ((ScrollPosV2-5)>scroll) ScrollPosV2=scroll;
  $(".main1").scrollTop(ScrollPosV2);
  if (ScrollNullV2) setTimeout('ScrollDownV2('+iStep+');', 20);
  else ScrollNullV2=1;
}

//------------------------------------------------------------------
//-------------------------------------------------------------------

$(document).ready(function(){
  function get_fade_speed()
  {
    return "slow";
  }
  //start photo_view
  $(".main .collectionimages a").focus(function(){
    $(this).blur();
  }).click(function(){
    var $preview_link = $(this);
    var $preview = $("img", this);
    var $large_pic_holder = $(".large_photo_place img.large");
    if ($large_pic_holder.hasClass("processing"))
      return false;
    $("a.selected", $preview_link.parents("div")).removeClass("selected");
    $preview_link.addClass("selected");
    $large_pic_holder.addClass("processing").fadeTo(get_fade_speed(), 0.1, function(){
      $(".large_photo_preloader").show();
      $large_pic_holder.attr("src", $preview.attr("path"));
    });
    return false;
  });
  
  $(".main .shopscitieslist a").click(function(){
    var CityID = $(this).attr('id');
    
    var arExp = CityID.split("_");
    
	  if(arExp.length > 1)
    {
      $(".shopscitieslist a").removeClass("select");
      $(this).addClass("select");
     // $(this).html($(this).html() + "<span> <img src=\"/img/li.jpg\" alt=\"\" /></span>");
      
      $("#main_scroll_place1 div").css('display', 'none');
      $("div .main2").html("");
      $("#main_scroll_place1 #city_shop_grp_" + arExp[1] + " a").removeClass("select");
      $("#main_scroll_place1 #city_shop_grp_" + arExp[1]).css('display', 'block');
    }
                
    return false;
  });
  
  $(".large_photo_place img.large").load(function(){
    $(".large_photo_preloader").hide();
    $(this).animate({opacity: 1}, get_fade_speed(), function(){
      $(this).removeClass("processing");
    });
  });
  
  //about_img_changer
        
  arImg[0] = new Image();
  arImg[0].src = "/about/NY1.jpg";
  arImg[1] = new Image();
  arImg[1].src = "/about/NY2.jpg";
  arImg[2] = new Image();
  arImg[2].src = "/about/NY3.jpg";
  arImg[3] = new Image();
  arImg[3].src = "/about/NY4.jpg";
        
  setTimeout('AboutImgChanger2();', 3000);
  
  //-----------------------------------------------------
  
  //start scrolling 1
  $(".main").mousewheel(function(e, delta){
    if($.browser.opera)
    {
      if(delta > 0) delta = -1;
      else delta = 1;
    }
		if(delta > 0)
		{
		  ScrollNull = 0;
		  ScrollUp(40);
		  if($(".down .off")) $(".down").removeClass("off");
      if($(".main").scrollTop() <= 0) $(".up").addClass("off");
		}
		else
		{
		  ScrollNull = 0;
		  ScrollDown(40);
		  if($(".up .off")) $(".up").removeClass("off");
      var ScrollingHeight = document.getElementById('main_scroll_place').scrollHeight;
      if($(".main").scrollTop()+$(".main").innerHeight() >= ScrollingHeight) $(".down").addClass("off");
		}

		return false;
	});
  
  $(".up").mousedown(function(){
    ScrollUp(20);
  });
  $(".up").mouseup(function(){
    if(ScrollNull) ScrollNull=0;
    else ScrollNull=1;
    if($(".down .off")) $(".down").removeClass("off");
    if($(".main").scrollTop() <= 0) $(".up").addClass("off");
  });
  $(".down").mousedown(function(){
    ScrollDown(20);
  });
  $(".down").mouseup(function(){
    if(ScrollNull) ScrollNull=0;
    else ScrollNull=1;
    if($(".up .off")) $(".up").removeClass("off");
    var ScrollingHeight = document.getElementById('main_scroll_place').scrollHeight;
    if($(".main").scrollTop()+$(".main").innerHeight() >= ScrollingHeight) $(".down").addClass("off");
  });
  //end scrolling 1
  //----------------------------------------------------------------------------------------------------
  
  //start scrolling 2
  $(".main1").mousewheel(function(e, delta){
    if($.browser.opera)
    {
      if(delta > 0) delta = -1;
      else delta = 1;
    }
		if(delta > 0)
		{
		  ScrollNullV2 = 0;
		  ScrollUpV2(40);
		  if($(".down1 .off1")) $(".down1").removeClass("off1");
      if($(".main1").scrollTop() <= 0) $(".up1").addClass("off1");
		}
		else
		{
		  ScrollNullV2 = 0;
		  ScrollDownV2(40);
		  if($(".up1 .off1")) $(".up1").removeClass("off1");
      var ScrollingHeight = document.getElementById('main_scroll_place1').scrollHeight;
      if($(".main1").scrollTop()+$(".main1").innerHeight() >= ScrollingHeight) $(".down1").addClass("off1");
		}

		return false;
	});
  
  $(".up1").mousedown(function(){
    ScrollUpV2(20);
  });
  $(".up1").mouseup(function(){
    if(ScrollNullV2) ScrollNullV2=0;
    else ScrollNullV2=1;
    if($(".down1 .off1")) $(".down1").removeClass("off1");
    if($(".main1").scrollTop() <= 0) $(".up1").addClass("off1");
  });
  $(".down1").mousedown(function(){
    ScrollDownV2(20);
  });
  $(".down1").mouseup(function(){
    if(ScrollNullV2) ScrollNullV2=0;
    else ScrollNullV2=1;
    if($(".up1 .off1")) $(".up1").removeClass("off1");
    var ScrollingHeight = document.getElementById('main_scroll_place1').scrollHeight;
    if($(".main1").scrollTop()+$(".main1").innerHeight() >= ScrollingHeight) $(".down1").addClass("off1");
  });
  //end scrolling 2
});

