jQuery.noConflict();


jQuery(document).ready(function(){



// mainMenu
jQuery(".mainMenu>li>a").mouseenter(function() {
	jQuery("#beer").stop();
	var obj=jQuery(this);
	jQuery(".popupMenu").hide();
	var pos=obj.position();
	var newpos= pos.left+69+ obj.width()/2 -130;
	jQuery("#beer").animate( { left:newpos } , 1000 );

	timeoutID = setTimeout(function()
	{
		jQuery(".popupMenu").hide();
		obj.next(".popupMenu").slideDown();
	}, 500);

});

jQuery(".mainMenu a").mouseleave(function() {
	clearTimeout(timeoutID);
	jQuery("#beer").stop();

});


jQuery(".mainMenu .active").mouseenter(function() {
	jQuery("#beer").stop();
	var obj=jQuery(this);
	jQuery(".popupMenu").hide();
		
	var pos=obj.position();
	var newpos= pos.left+69+ obj.width()/2 -130;
	jQuery("#beer").animate( { left:newpos } , 1000 );

	timeoutID = setTimeout(function()
	{
		jQuery(".popupMenu").hide();
		obj.next(".popupMenu").slideDown();
	}, 600);

});

jQuery(".mainMenu .active").mouseleave(function() {
	 clearTimeout(timeoutID);
	 jQuery("#beer").stop();
	
});




jQuery(".mainMenu").mouseleave(function() {
		var spanpos = 350;							
		if(jQuery(".mainMenu .active").length) spanpos = jQuery(".mainMenu .active").position();
		var beerpos = 350;
		if(jQuery(".mainMenu .active").length) beerpos = spanpos.left+ 69+ jQuery(".mainMenu .active").width()/2 -130;
        jQuery("#beer").animate( { left:beerpos } , 1000 );

	timeoutID2 = setTimeout(function()
	{
		jQuery(".popupMenu").hide();	
	}, 1000);

});


jQuery(".popupMenu").mouseenter(function() {
	jQuery("#beer").stop();
	clearTimeout(timeoutID2);
});


jQuery(window).resize(function(){
	var flsh= jQuery(".forFlash").width();
	flsh=flsh/2-950;
	jQuery(".shiftFlash").css("left",flsh);
});



//initiation beer
var spanposstart = jQuery(".mainMenu .active").position();

var beerposstart = 350 ;

if(jQuery(".mainMenu .active").length) beerposstart= spanposstart.left+ 69+ jQuery(".mainMenu .active").width()/2 -130;

jQuery("#beer").css("left",beerposstart);
jQuery("#beer").css("display","block");



//flash shift
var flsh= jQuery(".forFlash").width();

flsh=flsh/2-950;
jQuery(".shiftFlash").css("left",flsh);



//barMenu
jQuery(".barMenu li").hover(
  function () {
	jQuery(this).find("img").animate({
	width: "+=10px",
	height: "+=10px",
	}, 200 );
  }, 
  function () {
	jQuery(this).find("img").animate({ 
    width: "-=10px",
	height:"-=10px"
  }, 200 );
}
);

// arrows
jQuery(".headerArrow").hover(
  function () {
	jQuery(this).animate({
	opacity: 1,
	}, 200 );
  }, 
  function () {
	jQuery(this).animate({
	opacity: 0.5,
	}, 200 );
}
);





jQuery("#headerArrowRight").click(function() {

		jQuery(".otherBack1").css("left","100%");	
		jQuery(".otherBack1").animate({
		left: 0,
		}, 1500 );
		jQuery(".ownBack").animate({
		left: "-100%"
		}, 1500 );
				   
	timeoutID = setTimeout(function()
	{		
	window.location="http://pokrovka.gbsbar.ru/";
	}, 1500);
});

jQuery("#headerArrowLeft").click(function() {

		jQuery(".otherBack").css("left","-100%");	
		jQuery(".otherBack").animate({
		left: 0
		}, 1500 );
		jQuery(".ownBack").animate({
		left: "100%"
		}, 1500 );
	timeoutID = setTimeout(function()
	{
	window.location="http://ilicha.gbsbar.ru/";
		}, 1500);

});




//images  

preload([
		'../images/popup-menu.png',
		'../images/popup-menu-bot.png',
		'../images/popup-menu-top.png',

]);

function preload(images) {
    if (typeof document.body == "undefined") return;
    try {

        var div = document.createElement("div");
        var s = div.style;
		    s.position = "absolute";
        s.top = s.left = 0;
        s.visibility = "hidden";
        document.body.appendChild(div);
		div.innerHTML = "<img src=\"" + images.join("\" /><img src=\"") + "\" />";
		var lastImg = div.lastChild;
		lastImg.onload = function() { document.body.removeChild(document.body.lastChild); };
	 }
	 catch(e) {
        // Error. Do nothing.
	}
}




});




