$(function(){
	       var q = $('#top-menu').find('a').length - 1
	       $('#top-menu').find('a').each(function(i){
	           $(this).addClass('link-'+i).find('span.bot').css('opacity', '0.5')
              
               $(this).bind('mouseenter', function(){
                var k = $(this).index()
                    if(k==0){
                        $(this).css({
                            backgroundImage     :   'url(/siteimg/top-menu-hv.png)',
                            backgroundPosition  :   'left top'
                        })
                        console.log(k)
                    }
                    if(k==4){
                        $(this).css({
                            backgroundImage     :   'url(/siteimg/top-menu-hv.png)',
                            backgroundPosition  :   'right top'
                        }).prev('a').css({
                            backgroundPosition  :   '-20px top'
                        })
                    }
                    if(k > 0 && k < 4){
                        $(this).css({
                            backgroundImage     :   'url(/siteimg/top-menu-hv.png)',
                            backgroundPosition  :   '-20px top'
                        }).prev('a').not('.act').css({
                            backgroundPosition  :   '-20px top'
                        })                        
                    }
                    
                    $(this).find('span.bot').show()
               })
               $(this).bind('mouseleave', function(){
                var k = $(this).index()
                    if(k==0){
                        $(this).css({
                            backgroundImage     :   'url(/siteimg/top-menu-sep.png)',
                            backgroundPosition  :   'right center'
                        })
                    }
                    if(k==4){
                        $(this).css({
                            backgroundImage     :   '',
                            backgroundPosition  :   'right center'
                        }).prev('a').css({
                            backgroundPosition  :   'right center'
                        })
                    }
                    if(k > 0 && k < 4) {
                        
                        if($(this).next('a').is('.act')){
                            $(this).css({
                                backgroundImage     :   'url(/siteimg/top-menu-sep.png)',
                                backgroundPosition  :   '-20px center'
                            })
                        }
                        else {
                            $(this).css({
                                backgroundImage     :   'url(/siteimg/top-menu-sep.png)',
                                backgroundPosition  :   'right center'
                            }).prev('a').not('.act').css({
                                backgroundPosition  :   'right center'
                            })
                        }
                        $(this).prev('a').not('.act').css({
                                backgroundPosition  :   'right center'
                            })
                    }
                    
                    $(this).find('span.bot').hide()
               })
	       })
           $('#top-menu').find('a.act').each(function(){
            var k = $(this).index()
                  if(k==0){
                        $(this).css({
                            backgroundImage     :   'url(/siteimg/top-menu-hv.png)',
                            backgroundPosition  :   'left top'
                        }).unbind('mouseenter').unbind('mouseleave')
                  }
                  if(k==4){
                        $(this).css({
                            backgroundImage     :   'url(/siteimg/top-menu-hv.png)',
                            backgroundPosition  :   'right top'
                        }).unbind('mouseenter').unbind('mouseleave').prev('a').css({
                            backgroundPosition  :   '-20px center'
                        })
                  }
                  if(k > 0 && k < 4) {
                        $(this).css({
                            backgroundImage     :   'url(/siteimg/top-menu-hv.png)',
                            backgroundPosition  :   '-20px top'
                        }).unbind('mouseenter').unbind('mouseleave').prev('a').css({
                            backgroundPosition  :   '-20px center'
                        })
                  }
                  $(this).find('span.bot').show()
           })
           
           
           
	   })
