
$(document).ready(function(){
			 
			
			
			
    jQuery('#id1,#id5 a,#id5 p').mouseover(function() {
			 
        jQuery('#id4').stop(true);
        jQuery('#id1').stop(true);
    });
			 
			
			 
			 
    jQuery('.imglink,#id5,#id5 a,#id5 p').mouseout(function() {
						 
        mousedelay = 0;
			 
        //jQuery('#id4').stop(true);


        jQuery('#id1').stop(true);
				
        $('#id4').animate({
            "width" : "492px"
        }, 300);
        
               

        $('#id1').animate({
            "width" : "523px"
        }, 300);
				
				
        
    });
			 
                                 
								 
								 
	
						 

			 
			 
			 
    jQuery('#id6').mouseover(function() {
		   
        mousedelay = 1;
        count1 = 1;
		  
        jQuery('#id4').stop(true);
        jQuery('#id1').stop(true);
				
        $('#id1').animate({
            "width" : "705px"
        }, 500);
       
    });






    jQuery('#id6').mouseout(function() {
               
        jQuery('#id4').stop(true);
        jQuery('#id1').stop(true);
                  

        $('#id4').animate({
            "width" : "492px"
        }, 300);
        
               

        $('#id1').animate({
            "width" : "523px"
        }, 300);
        
		
    });
   
	
				
				
			// Возврат в исходное состояние
				
    
    jQuery('#id2').click(function() {
			 
        mousedelay = 0;
        $('#id4').animate({
            "width" : "492px"
        }, 300);
        
               

        $('#id1').animate({
            "width" : "523px"
        }, 300);
        
    });
						 
						  
						  
						  
    jQuery('#main').mouseover(function() {
			 
        mousedelay = 0;
        $('#id4').animate({
            "width" : "492px"
        }, 300);
        
               

        $('#id1').animate({
            "width" : "523px"
        }, 300);
        
    });
			
		
		
		
		
			jQuery('.imglink').mouseover(function() {
				
        mousedelay = 1;
        count1 = 1;
				
        $(".imglink").removeClass('selected');
        $(this).addClass('selected');
		
        var img = $(this).attr("rel");
        changeimage(img);
    // $("#id11").text(arr[3]);
    //$('#id1').animate({ "width" : "523px" }, 800);
        
       

    });
								
						
	// Запуск автопрокрутки	
        function preload(listOfImgs)
{
var gcount = 0;
var arrimg=listOfImgs.split(',');

for (var k = 0; k < arrimg.length; k++) {

			
		var imgurl = "/site/images/" + arrimg[k] + ".png";	
//alert(imgurl); 


var img = $("<img>").appendTo("body").css({
					top: -10000+"px",
					left: -10000+"px",
					position: "absolute"
				}).load(function() {
				gcount++;
				
			
				
				if (gcount == arrimg.length)
				{
				launch();
				}
					
				}).attr("src", imgurl);	
												
}		



		
	


}

	
    mousedelay = 0; // mousedelay = 1; - остановка автопрокрутки
    count1 = 1; // Счетчик. Обнуляется при остановке прокрутки.
    preload('img1,img3');
			
		function launch()
		
		
		
{		
    setInterval(function(){
						
        if (mousedelay == 0) 
        {
            if (count1 == 1)
            {
			 
                $(".imglink").removeClass('selected');
                $(".imglink:first").addClass('selected');
			  
	
                var img = $(".imglink:first").attr("rel");
			   
                changeimage(img);
				
			  
                count1++; 
                count1 = (count1 > $(".rotate").children().length) ? 1 : count1; 
            }
            else
            {
	
                $(".imglink.selected").removeClass('selected').next().addClass('selected');
			 
			 
                var img = $(".imglink.selected").attr("rel");
				
                changeimage(img);
				
				
				
				
				
                count1++; 
                count1 = (count1 > $(".rotate").children().length) ? 1 : count1; 
            }
			 
			
        }
    }, 4000);
		}	 
			 
			
	    
//
			
    function changeimage(img)
    {

        //alert(img);
        var arr=img.split('--');
		
				 
        var img1url = "url('/site/images/" + arr[0] + ".png')";
        var img2url = "url('/site/images/tovar/" + arr[1] + ".png')";
		 
        //$('#id4').fadeOut(500, function() {$('#id4').css("background-image", img1url)});
		 
        if ($('div.i1').css("z-index") == 3)
        {
	
            $('div.i2').css('background-image', img1url);
            $('div.i2').fadeIn(500);
	
            $('div.i1').fadeOut(500, function () {
                $('div.i1').css('z-index', '2');
                $('div.i2').css('z-index', '3');
            });

        }
				
        else
				
        {
            $('div.i1').fadeIn(500);
            $('div.i1').css('background-image', img1url);
				
            $('div.i2').fadeOut(500, function () {
                $('div.i2').css('z-index', '2');
                $('div.i1').css('z-index', '3');
            });
	
        }
	
        $('#id2').css("background-image", img2url);
				
        $("#id5 p").text(arr[2]);


    }
	
	
	
$('.login a').click(function() {
if ($('.w').length == 0)
{


$('<div class="w"></div>').prependTo(".lscontainer").css({'background-color' : 'white', 'border' : '1px solid #9E9EA4', 'width' : '200px', 'display' : 'none', 'position' : 'absolute', 'left' : '0', 'opacity' : '1', 'height' : '175px','z-index' : '8'});
	
	
	
	
	$('.login').clone(true).appendTo(".w");
	
	var formhtml='<div style="padding: 5px; clear: both;"> <form method="post"><table><tr><td style="color: #61606B;">Логин:</td><td><input name="user" style="width: 100px;"></td><td></td></tr><tr><td style="color: #61606B;">Пароль:</td><td><input name="pwd" type="password" style="width: 100px; "></td><td></td></tr><tr><td></td><td ><input type="submit"  style="color: #61606B; padding: 1px;" value="Вход"></td><td></td></tr></table></form></div>';
	   
	
	$('.w').append(formhtml);
	
	$('.w').fadeIn(500, function() {
	
	});
	
	
	}
	
	else
	
	{
	$('.w').fadeOut(500, function() {
	$(this).remove();
	});
	
	
	}
	return false;
	
	//settimeout
});

$('.search a').click(function() {
if ($('.w').length == 0)
{
$('<div class="w"></div>').prependTo(".lscontainer").css({'background-color' : 'white', 'border' : '1px solid #9E9EA4', 'width' : '200px', 'display' : 'none', 'position' : 'absolute', 'right' : '25px', 'height' : '170px','z-index' : '8', 'opacity' : '1'});
	
	
	$('.search').clone(true).appendTo(".w").css('margin', '0 0 0 15px');
	//css({'text-align' : 'center'}).find('input').val('hello');
	var formhtml=' <div style="padding: 5px 0 0 15px; clear: both;"><form  action="/search" method="post" ><table ><tr><td style="color: #61606B;">Слово для поиска:</td><td></td></tr><tr><td colspan=2 style="color: #61606B;"><input name="search" style="width: 150px; "></td></tr><tr><td><input type="submit"  style="color: #61606B; padding: 1px;" value="Найти"></td><td></td></tr></table></form></div>';
	
	$('.w').append(formhtml);
	
	
	
	$('.w').fadeIn(500);
	
	return false;
	}
	
	else
	
	{
	//$('.search').appendTo(".lsconteiner");
	
	//$(".search").insertBefore(".lsconteiner div.clear");
	
	$('.w').fadeOut(500, function() {
	$(this).remove();
	});
	
	return false;
	}
	return false;
	
	//settimeout
});





});


			
$(function()
{

    $('#pane1').jScrollPane({
        scrollbarOnLeft:true, 
        showArrows:false, 
        scrollbarWidth:9, 
        scrollbarMargin:1
    });

});
										
			
