$(window).load(function(){
    if($('.jac').length) $(".jac").jac({
        childSizeFixed: false,
        rightText: next,
        leftText: prev
    });
})
$(function(){

    $('#carousel').jcarousel({scroll: 1, wrap: 'circular'});
    $('.jac ul').width(9999)
    $.each($.browser, function(i, val) {
        if(i=='safari')
            $('#carousel_wrp ul').width(9999)
    });

    $('#carousel .slide_wrapper').hover(function(){
        $(this).parent().addClass('boxgrid').addClass('captionfull')
        $('.cover', this).stop().animate({left:'225px'},{queue:false,duration:160});
    }, function(){
        $('.cover', this).stop().animate({left:'472px'},{queue:false,duration:160});
    })

    // clients carousel
    $('.jac img').css('opacity', '0.6')
    $('.jac img').hover(function(){
        $(this).animate({opacity: '1'})
    },function(){
        $(this).animate({opacity: '0.6'})
    })

    if(!$('.pagination a').length)
        $('.pagination').hide()


    $(".big_images a").fancybox({
                'titleShow' : false,
		    'padding': 0,
		    'margin':0,
                'transitionIn'  : 'elastic',
                'transitionOut' : 'elastic',
                'hideOnContentClick': true ,
                'overlayShow': true ,
		    
		    'autoScale':false,
                zoomSpeedIn:0 ,
                zoomSpeedOut:0
        });

var fboxHeight;
var fboxWidth;

$('.swf').each(function() {
   fboxHeight = $(this).parent().children('.razm_param').height();
   fboxWidth = $(this).parent().children('.razm_param').width();
  

   $(this).fancybox({
	
	
  'padding'           : 0,
  'autoScale'      : false,
 'transitionIn'  : 'elastic',
'transitionOut' : 'elastic',
'hideOnContentClick': false ,
'overlayShow': true ,
  'width': fboxWidth,
  'height': fboxHeight,
  'opacity': false,
 'swf':{'wmode': 'opaque'}
 })
  });


    // navigation
    $('body').append('<div class="submenu" />')
    $('.nav li#14').hover(function(){
        if($('ul li', this).length)
        {
            if(typeof(timer) == 'nubmer')
            {
                clearTimeout(timer)
                timer = null
            }
            show = true;
            $('.submenu:hidden')
                .html('<div class="block"><div class="arrow"></div><ul>'+$('ul', this).html()+'</ul></div>')
                .css({top: $(this).offset().top+20, left: $(this).offset().left-169})
                .stop()
                .animate({'opacity': 'toggle', 'height': 'toggle'}, 'fast')
        }
        else {
            $('.submenu:visible').stop()
                .animate({'opacity': 'toggle', 'height': 'toggle'}, 'fast').hide()
        }
    },function(){
        show = false
        timer = setTimeout(function(){
            if(!show)
                $('.submenu:visible').animate({'opacity': 'toggle', 'height': 'toggle'}, 'fast')
            timer = null
        }, 500)
    })
    $('.nav li#145 ').hover(function(){
        if($('ul li', this).length)
        {
            if(typeof(timer) == 'nubmer')
            {
                clearTimeout(timer)
                timer = null
            }
            show = true;
            $('.submenu:hidden')
                .html('<div class="block"><div class="arrow"></div><ul>'+$('ul', this).html()+'</ul></div>')
                .css({top: $(this).offset().top+20, left: $(this).offset().left})
                .stop()
                .animate({'opacity': 'toggle', 'height': 'toggle'}, 'fast')
        }
        else {
            $('.submenu:visible').stop()
                .animate({'opacity': 'toggle', 'height': 'toggle'}, 'fast').hide()
        }
    },function(){
        show = false
        timer = setTimeout(function(){
            if(!show)
                $('.submenu:visible').animate({'opacity': 'toggle', 'height': 'toggle'}, 'fast')
            timer = null
        }, 500)
    
    })
 
    
    $('#148 a, #14 a, #145 a').click(function(){return false;}).mouseover(function(){$(this).css({color: 'white'})})


    $('.submenu').hover(function(){
        clearTimeout(timer)
        timer = null
    },function(){
        show = false
        timer = setTimeout(function(){
            if(!show)
                $('.submenu:visible').animate({'opacity': 'toggle', 'height': 'toggle'}, 'fast').hide()
            timer = null
        }, 500)
    })


})
var timer;
var show = false;

$(document).ready(function() {
$('.flash_item .readmore').hide();
$('.flash_item').mouseleave(function(){
	$(this).children('.readmore').fadeOut('fast');
	})
$('.flash_item').mouseenter(function(){
	
	$(this).children('.readmore').fadeIn('fast');
	})
})
 $('.flash_item').click(function(){
	 $(this).children('.readmore').fadeOut('fast');
	 })
 

