/**
*	@author vaneys@gmail.com (Ivan Maslennikov)
*	@fileoverview Top menu functionality
*/
var mouse_is_inside = false;
$(function() {

	$('header[role="main"] nav li.top').hover(function(){
        mouse_is_inside=true;
    }, function(){
        mouse_is_inside=false;
    });

	$("body").mouseup(function() { if (!mouse_is_inside) $('header[role="main"] nav li.top').removeClass('active');});
	$('header[role="main"] nav li').removeClass('topcss');
	$('header[role="main"] nav li.top a.top').click(function(e) {
		e.preventDefault();
		if ($(this).parent().hasClass('active'))
			$('header[role="main"] nav li.top').removeClass('active');
		else
		{
			$('header[role="main"] nav li.top').removeClass('active');
			$(this).parent().toggleClass('active');
		}
	});

  $("#login_btn.iframe").attr('href', '/crm/managekit/login/login/').fancybox({
	type			:	'iframe',
	transitionIn	:	'elastic',
	transitionOut	:	'elastic',
	speedIn			:	400,
	speedOut		:	200,
	overlayShow		:	true,
	overlayColor	:	'#fff',
    width        	:	315,
	height			: 	325,
    scrolling     	: 	'no'
  });

  //$("#signup_btn.iframe, section#signup a.button").attr('href', '/crm/managekit/signup/signupwidget/?css=homepage&campaignID=$srcCampaignID&autofocus=$isAutoFocus').fancybox({
  $("#signup_btn.iframe, section#signup a.button").fancybox({
	type			:	'iframe',
	transitionIn	:	'elastic',
	transitionOut	:	'elastic',
	speedIn			:	300,
	speedOut		:	200,
	overlayShow		:	true,
	overlayColor	:	'#fff',
	hideOnOverlayClick:	false,
	padding			:	0,
    width        	: 	650,
    height        	: 	285,
    scrolling     	: 	'no'
  });
});

function changeIframeSize(NewHeight,NewWidth){
	if(NewHeight){
	   $('#fancybox-wrap').animate({"height" : NewHeight + "px"},300);
	   $('#fancybox-inner').animate({"height" : (NewHeight-20) + "px"},300);
	}
	if(NewWidth){
	   $('#fancybox-wrap').animate({"width" : ""+NewWidth+"px"},300);
	   $('#fancybox-inner').animate({"width" : ""+NewWidth+"px"},300);
	}
}

