var newClass = function() {
	return function() {
		return this.init.apply(this, arguments);
	}
}

var Smena = newClass();

Smena.prototype = {

  init: function() {
	 var t = this;
	 LineAH = $("div.LineAH");
	 numLP = 0;
	 numberDivLineAH = $(".LineAH div").size();
	 avc = numberDivLineAH*67;

  $(".RamkaGray").mouseover(function() {
	$(this).find("img").toggleClass("DisplayNone");													  
    });

	$(".RamkaGray").mouseout(function() {
	$(this).find("img").toggleClass("DisplayNone");													  
    });
	
  $(".LeftOC").mouseover(function() {
	$(this).find("img").toggleClass("DisplayNone");													  
    });

	$(".LeftOC").mouseout(function() {
	$(this).find("img").toggleClass("DisplayNone");													  
    });	

  $(".RightOC").mouseover(function() {
	$(this).find("img").toggleClass("DisplayNone");													  
    });

	$(".RightOC").mouseout(function() {
	$(this).find("img").toggleClass("DisplayNone");													  
    });	

  $(".RamkaGray").mouseover(function() {
	$(this).css("background", "url(/i/ramka_r.gif) no-repeat 0 0")
	});

	$(".RamkaGray").mouseout(function() {
	$(this).css("background", "url(/i/ramka.gif) no-repeat 0 0")
	});	
	
	$(".Menu li").mouseover(function() {
	$(".Menu li").removeClass("OverSelect");
	$(this).addClass("OverSelect");
	});
	
	$(".Menu li").mouseout(function() {
	$(".Menu li").removeClass("OverSelect");
	});
	
	$(".Cross span, .MMLeft .DostTitle a").click(function() {
		$(".BlackPage").fadeIn("fast");
		$(".MapCross").fadeIn("slow");
		return false;
	});
	
	$(".BlackPage").click(function() {
		$(".MapCross").fadeOut("slow");
		$(".BlackPage").fadeOut("fast");
		$(".InterBanner").fadeOut("fast");
	});
	
	$(".MapCross").mouseleave(function() {
		t.hideMC();
	});
	
	$(".MapCross").mouseenter(function() {
		clearTimeout(t.timer);
	});
	
	$(".MiddleBan a").click(function() {
		$(".InterBanner").css({width: 600+ "px", height: 400 + "px", top:0});
		$(".FlashBlockIB div").css({'display' : 'none'});
		$(".BlockBanners, .CloseCBP").fadeIn(0);
		$(".BlackPage").fadeIn("fast");
		$(".InterBanner").fadeIn("slow");
		
		return false;
	});

	$(".IntPortfolio").click(function() {
		$(".InterBanner").css({width: 600+ "px", height: 400 + "px", top:0});
		$(".FlashBlockIB div").css({'display' : 'none'});
		$(".BlockBanners, .CloseCBP").fadeIn(0);
		$(".BlackPage").fadeIn("fast");
		$(".InterBanner").fadeIn("slow");
		return false;
	});
	

	$("area.RightIB, area.LeftIB").mouseenter(function() {
		ban_cur = $(this).attr("class");
		$(".InterBanner img." +  ban_cur).fadeIn("fast");		
	});
	
	$("area.RightIB, area.LeftIB").mouseleave(function() {
		ban_hid = $(this).attr("class");
		$(".InterBanner img." + ban_hid).fadeOut("fast");
	});
	
	
	$(".RamkaNM img").mouseenter(function() {
		$(".ButtonNM a").css({'background-position':'0 -44px'});
	});
	
	$(".RamkaNM img").mouseleave(function() {
		$(".ButtonNM a").css({'background-position':''});
	});
	
	$(".RamkaPM img").mouseenter(function() {
		$(".ButtonPM a").css({'background-position':'0 -45px'});
	});
	
	$(".RamkaPM img").mouseleave(function() {
		$(".ButtonPM a").css({'background-position':''});
	});
	
	

	$(".CloseCBP").click(function() {
		t.hideAllMC();						  
	});
	
	$(".BlockBanners area").click(function() {
		$(".BlockBanners").fadeOut("fast");
		$(".InterBanner").animate({width: 980+ "px", height: 870 + "px", top: -100 + "px"}, 1000).addClass("ABC");
		
		if ($(this).is(".LeftIB")) {
			$(".VichyFlash").fadeIn("fast");
		}
		
		if ($(this).is(".RightIB")) {
			$(".SwedBankFlash").fadeIn("fast");
		}
		
		return false;
		
	});
	
	
	
	 document.onkeydown = function(e) {

        if (e == null) { // ie
        	keyCode = event.keyCode;
        } else { // mozilla
        	keyCode = e.which;
        }

		if (keyCode == 27){
		   t.hideAllMC();
		};
     };
	

	$(".Searchblock .TextSB ul li:odd, .SearchblockR .TextSB ul li:odd, .SearchblockM .TextSB ul li:odd").css("background-color", "#F5F5F5");
	
	$(".ToLeftLAH, .ToRightLAH").mouseenter(function() {
		classNav = $(this);
		t.moveLAH();

	});	
	
	$(".ToLeftLAH, .ToRightLAH").mouseleave(function() {
		clearInterval(int);
	});
	
	$(".MidAH a").click(function() {
		var srcPageYear = $(this).attr("href");		
		$(".MidAH").removeClass("Select");
		$(this).parents(".MidAH").addClass("Select");
		$(".HistoryPage").addClass("BgHistoryPage").html("");
		
		
		
		if ($(".AboutHistory").hasClass("AboutPrize")) {
			$(".HistoryPage").load('history_ajax.php' + srcPageYear + "&TYPE=" + "AWARDS", {limit: 25}, function(){
				$(".HistoryPage").removeClass("BgHistoryPage");
			});
		} else 
		{
			$(".HistoryPage").load('history_ajax.php' + srcPageYear, {limit: 25}, function(){
				$(".HistoryPage").removeClass("BgHistoryPage");
			});

		}
		
		
		return false;
	});
},
 
moveLAH: function() {
	var t = this;
    int = setInterval(function() { t.avc() }, 20);

},
 
avc:function() {
		afc = $(".LineAH").css('right').replace("px","");
		xc = Math.abs(afc);

		if (classNav.hasClass("ToLeftLAH")) {
			if (xc >= avc-740) {
				clearInterval(int);
			} else  
			{
			LineAH.animate({right: '-=2px'}, 0);
			}
		}
		
		if (classNav.hasClass("ToRightLAH")) {
			if (xc <= 0) {
				clearInterval(int);
			} else  
			{
			LineAH.animate({right: '+=2px'}, 0);
			}
		}
		
},
 
hideMC: function() {
	var t = this;
    t.timer = setTimeout(function(){t.hideAllMC()}, 1000);
},



hideAllMC: function() {
	var t = this;
	$(".MapCross").fadeOut("slow");
	$(".BlackPage").fadeOut("fast");
	$(".InterBanner").fadeOut("fast");
 }
 
};

(jQuery);
(function(e){
  e.dirtyClipboard=function(g,k){
    if(g)e(k?k:document).mouseup(function(){
      var o,A,v,z;
      e("span.dirty-clipboard").remove();
      if(window.getSelection){
        o=window.getSelection();
        v=o.toString();
        if(!v||v.length<30)
          return;
        A=o.getRangeAt(0);
        v=A.cloneRange();
        v.collapse(false);
        z=e('<span class="dirty-clipboard">'+g+"</span>").css("position","absolute")[0];
        v.insertNode(z);
        A.setEndAfter(z);
        o.removeAllRanges();
        o.addRange(A)
      } else if(o=document.selection){
        A=o.createRange();
        v=A.text;
        if(!v||v.length<30)
          return;
        v=A.duplicate();
        v.collapse(false);
        v.pasteHTML('<span class="dirty-clipboard" style="position: absolute;">'+g+"</span>");
        A.setEndPoint("EndToEnd",v);
        A.select()
      }
      e("span.dirty-clipboard").css({overflow:"hidden",width:"1px",height:"1px"})
    })
  }
})(jQuery);

jQuery(function(){$.dirtyClipboard("<br><br>\u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435: <a href='"+location.href+"'>"+location.href+"</a>","#notice, #text")});

$(document).ready(function(){
	new	Smena();
});
