$(function() {

    // Set up variables
    var $el, $parentWrap, $otherWrap, 
        $allTitles = $(".info-col dt").css({
			paddingTop: 5,
            paddingRight: 6,
            paddingBottom: 9,
            paddingLeft: 6
           //padding: 5, // setting the padding here prevents a weird situation, where it would start animating at 0 padding instead of 5
            //"cursor": "pointer" // make it seem clickable
        }),
        $allCells = $(".info-col dd").css({
            position: "relative",
            top: 0,
            left: 0,
            display: "none" // info cells are just kicked off the page with CSS (for accessibility)
        });
    
	$(".info-col dd.first").css({
            position: "relative",
            top: -1,
            left: 0,
            display: "block"
        });
	
    // clicking image of inactive column just opens column, doesn't go to link   
    //$(".page-wrap").delegate("a","click", function(e) { 
        
    //    if ( !$(this).parent().hasClass("curCol") ) {         
   //         e.preventDefault(); 
   //         $(this).next().find('.info-col dt:first').click(); 
   //     } 
		
   // });
    
    // clicking on titles does stuff
    $(".page-wrap").delegate(".info-col dt", "click", function() {
        
        // cache this, as always, is good form
        $el = $(this);
        
        // if this is already the active cell, don't do anything
        if (!$el.hasClass("current")) {
        
            $parentWrap = $el.parent().parent();
            $otherWraps = $(".info-col").not($parentWrap);
            
            // remove current cell from selection of all cells
            $allTitles = $(".info-col dt").not(this);
			//$allTitles = $el.parent().("dt").not(this);
            
            // close all info cells
            $allCells.slideUp();
            
            // return all titles (except current one) to normal size
            $allTitles.animate({
                fontSize: "13px",
                paddingTop: 5,
                paddingRight: 6,
                paddingBottom: 9,
                paddingLeft: 6
            });
            
            // animate current title to larger size            
            $el.animate({
               // "font-size": "20px",
               // paddingTop: 10,
               // paddingRight: 5,
               // paddingBottom: 0,
               // paddingLeft: 10
            }).next().slideDown();
            
            // make the current column the large size
            $parentWrap.animate({
                width: 302
            }).addClass("curCol");
            
            // make other columns the small size
            $otherWraps.animate({
                //width: 140
            }).removeClass("curCol");
            
            // make sure the correct column is current
            $allTitles.removeClass("current");
            $el.addClass("current");  
        
        }
        
    });
    
    // кликаем по области вне всплывашки и всплывашка закрывается
    
    $("#overlay").click(function(){
		
			$(this).css("display","none");
	        $(".page-wrap").css("display","none");
	        
	        $('.clients').css({'z-index':'12'});
	     	$('.clients .zoom2').css({'display':'block'});
	
	     	$(".no-act-ca").removeClass("no-act-ca");
	     	
			return false;
	     });
	     
	$(".close-lnk a").click(function(){
	        
	        $('.clients').css({'z-index':'12'});
	     	$('.clients .zoom2').css({'display':'block'});
	
	     	$(".no-act-ca").removeClass("no-act-ca");
	     	
			return false;
	     });
	     
	/*$(".menu-pic .services, .menu-pic .corporate, .menu-pic .developer, .menu-pic .business-center, .menu-pic .business").hover(function(){
	        
	        $('.clients').css({'z-index':'1'});
	     	$('.clients .zoom2').css({'display':'none', 'left':'-45px', 'top':'-50px'});
	
			return false;
	     });*/
	   

	
	$(".menu-pic .services, .menu-pic .corporate, .menu-pic .developer, .menu-pic .business-center, .menu-pic .business").mouseleave(function(){
	        //$(".zoom2").css({'display':'none'});
	     //   $('.clients').css({'z-index':'12'});
	     //	$('.clients .zoom2').css({'left':'-45px', 'top':'-50px'}).fadeIn(600);
	
			return false;
	     });
	     
	 $(".zoom2").mouseleave(function(){
	 	//$(this).css({'display':'none'});
	 	//$(this).parent().css({'z-index':'1'});
	 	
	    //$(".zoom2").css({'display':'none'});
	     //   $('.clients').css({'z-index':'12'});
	     //	$('.clients .zoom2').css({'left':'-45px', 'top':'-50px'}).fadeIn(600);
	
			return false;
	     });
	     
	     
	     
  /*  $(".menu-pic, #middle, body, .news-idx, .title, html, #container").hover(function(){
	        
	        $('.clients').css({'z-index':'12'});
	     	$('.clients .zoom2').css({'left':'-45px', 'top':'-50px'}).fadeIn(600);
	
			return false;
	     });
	     
	    */ 
	$(".page-wrap").hover(function(){
	        
	        $('.clients').css({'z-index':'1'});
	     	$('.clients .zoom2').css({'display':'none'});
	
			return false;
	     });
	     
	     
	// не активность у ЦА
	
	$(".menu-pic .ca").click(function(){
	        
	        $(this).siblings("a").addClass("no-act-ca");
			return false;
	     });
	     
    
    $("#starter").trigger("click");
    
});
