////////////////////////////////////////////////////////////////////////////////
/* jQuery IE6 hover support */
(function(a){a.extend({ie6hover:function(o){if(!a.browser.msie||a.browser.version!="6.0"){return}var k=o===true?"live":"bind",A=/^1\.[4-9]/.test(a.fn.jquery),m=A||!o?"mouseenter":"mouseover",b=A||!o?"mouseleave":"mouseout",h=document.styleSheets,c=/(.*?)(:hover)\b/g,D=/\bA([#\.].*)*:hover\b/ig,y=/\.(\S+?)\b/ig,r="hover-ie6",l="",f=[],g={_default:r},u,v,w,t,x,C,d,p,n,q,E,s,z;if(!h.length){return}for(w=0,C=h.length;w<C;w++){d=h[w];try{p=d.rules}catch(B){continue}if(!p||!p.length){continue}for(t=0,x=p.length;t<x;t++){n=p[t];q=n.selectorText;E=[];s="";c.lastIndex=0;D.lastIndex=0;if(c.test(q)&&!D.test(q)){l=r;u="";c.lastIndex=0;while((v=c.exec(q))){z=c.lastIndex;u+=v[1];f.push(u);s=v[1];y.lastIndex=0;s=s.replace(y,function(e,i){l=i+"-"+r;return""})+"."+l;if(l!==r){g[u]=l}E.push(s)}if(z<q.length){E.push(q.substr(z))}q=E.join("");d.addRule(q,n.style.cssText,t);t++;x++;a.ie6hover.selectors.css.push([q,n.style.cssText])}}}if(f.length){if(f.length>1){f=(function(F){for(var G=[],H={},j=0,e=F.length,I;j<e;j++){I=F[j];if(!H[I]){H[I]=true;G.push(I)}}return G})(f)}a.ie6hover.selectors.jQuery=f;a(function(){a.each(f,function(F,j){var e=g[j]||g._default;a(j)[k](m,function(){a(this).addClass(e)})[k](b,function(){a(this).removeClass(e)})})})}}});a.ie6hover.selectors={css:[],jQuery:[]}})(jQuery);
$.ie6hover(true);
////////////////////////////////////////////////////////////////////////////////



$(document).ready(function(){

////////////////////////////// mainMenu ////////////////////////////////////////
  $('#mainMenu li').hover(
      function() {
        var curOffset = $(this).offset();
        var curWidth = $(this).outerWidth();
        var docWidth = $(document).width();
        var waitWidth = curWidth*2 + curOffset.left ;
        var istopheader = $(this).parents("ul").length==1 ? true : false;
        var subWidth = parseInt($(this).find('ul:first > li > a').css("width")) + parseInt($(this).find('ul:first > li > a').css("padding-left")) + parseInt($(this).find('ul:first > li > a').css("padding-right"));
        if ( !istopheader && waitWidth > docWidth ) {
          var leftOffset = "-" + (curWidth -1) + "px";
        } else if ( !istopheader ) {
          var leftOffset = (curWidth -1) + "px";
        } else if ( istopheader && ((curOffset.left + subWidth) > docWidth) ) {
          var leftOffset = "-" + (subWidth-curWidth) + "px";
        } else {
          var leftOffset = "0px";
        }
        $(this).addClass('hover');
        $(this).find('ul:first').css({"left":leftOffset, "zIndex":1000}).slideDown(150);
      },
      function() {
        $(this).removeClass('hover');
        $(this).find('ul').slideUp(80);
      }
  );
////////////////////////////////////////////////////////////////////////////////





//////////////////////////////// Карусели //////////////////////////////////////
  $("#carousel").carouFredSel({
      items: 11,
      prev : "#crslLeft",
      next : "#crslRight",
      scroll: {
        items: 11,
        duration: 800,
        pauseOnHover    : true
      },
      auto: {
        pauseDuration: 7000,
        pauseOnHover    : true
      }
  });
  $("#carouselAvatar").carouFredSel({
      items: 8,
      prev : "#crslAvLeft",
      next : "#crslAvRight",
      scroll: {
        items: 7,
        duration: 800,
        pauseOnHover    : true
      },
      auto: {
        pauseDuration: 5000,
        pauseOnHover    : true
      }
  });
  $("#topMachoCarusel-01").carouFredSel({
      items: 7,
      prev : '#tmLeft-01',
      next : '#tmRight-01',
      scroll: {
        items: 6,
        duration: 800,
        pauseOnHover    : true
      },
      auto: false
  });
  $("#topMachoCarusel-02").carouFredSel({
      items: 7,
      prev : '#tmLeft-02',
      next : '#tmRight-02',
      scroll: {
        items: 6,
        duration: 800,
        pauseOnHover    : true
      },
      auto: false
  });
  $("#topMachoCarusel-03").carouFredSel({
      items: 7,
      prev : '#tmLeft-03',
      next : '#tmRight-03',
      scroll: {
        items: 6,
        duration: 800,
        pauseOnHover    : true
      },
      auto: false
  });
  $("#topMachoCarusel-04").carouFredSel({
      items: 7,
      prev : '#tmLeft-04',
      next : '#tmRight-04',
      scroll: {
        items: 6,
        duration: 800,
        pauseOnHover    : true
      },
      auto: false
  });
  $("#promoFhotoSmall").carouFredSel({
      items: 5,
      prev : "#pFsLeft",
      next : "#pFsRight",
      scroll: {
        items: 4,
        duration: 800,
        pauseOnHover : true
      },
      auto: false
  });
  $("#avatarSelect").carouFredSel({
      items: 8,
      prev : "#asLeft",
      next : "#asRight",
      scroll: {
        items: 7,
        duration: 800,
        pauseOnHover : true
      },
      auto: false
  });
////////////////////////////////////////////////////////////////////////////////



//////////////////////////////// Закладки //////////////////////////////////////
  $("#profileTabs>ul>li:last-child").css("margin-right","0");
  $("#profileTabs").tabs({
    cookie: { expires: 7, name: "startTab" },
    fx: { opacity: "toggle" },
    cache: false,
    select: function() {
	      $("#profileTabs>ul>li>a").blur();
	  }
  });
////////////////////////////////////////////////////////////////////////////////




////////////////////////////////////////////////////////////////////////////////
  $("div.topMachoItem:last").css("background","none");
  $("#blockZnakomstva > .item:last").css("background","none");
////////////////////////////////////////////////////////////////////////////////

});





//////////////////////////////// facebox //////////////////////////////////////
$(document).ready(function($) {
  $('a[rel*=facebox]').facebox({
    loadingImage : 'popUp/images/loading.gif',
    closeImage   : 'popUp/images/closelabel.png'
  })
});
////////////////////////////////////////////////////////////////////////////////



////////////////////////// Всплывающие подсказки ///////////////////////////////
$(document).ready(function(){
//	$("a[hint]").CreateBubblePopup();
	$("a[hint]").mouseover(function(){
	  $(this).ShowBubblePopup({
			innerHtml: $(this).attr("hint"),
			innerHtmlStyle: {
				color:'#666666',
				'text-align':'center',
				'font-size':'11px'
			},
			distance: 10,
			openingSpeed: 200,
			closingSpeed: 200,
			position: 'top',
			themeName: 	'grey',
			themePath: 	'javascript/bubblepopup/theme'
	  });
	});
});
////////////////////////////////////////////////////////////////////////////////











