var R = 250,               // радиус окружности 	a = 0,                // угол (в радианах) 	da = 50000, 						   // приращение угла 	delay = 30;           // задержка (в мсек.) 	var moveFunctionInterval; var showPhraseInterval;var moveFlag = true;      var dragFlag = false;var accelFlag = true;var phraseFlag = true;var brakingFlag = false;var speed;///////////////////////function startMove(){	speed = 20000;	clearInterval(showPhraseInterval);	clearInterval(moveFunctionInterval);	moveFunctionInterval = setInterval("moveElem()", delay);	showPhraseInterval = setInterval("phrase()", 4500);}//////////////////////function phrase(){if(phraseFlag == true){	var rnd = Math.floor(Math.random() * (8 - 1) + 1);		$('.small-bubble-'+rnd+' .phrase .phrase-4').fadeIn(500,		function(){$('.small-bubble-'+rnd+' .phrase .phrase-3').fadeIn(500,		function(){$('.small-bubble-'+rnd+' .phrase .phrase-3').fadeOut(500,		function(){$('.small-bubble-'+rnd+' .phrase .phrase-2').fadeIn(500,		function(){$('.small-bubble-'+rnd+' .phrase .phrase-2').fadeOut(500,		function(){$('.small-bubble-'+rnd+' .phrase .phrase-1').fadeIn(500,		function(){$('.small-bubble-'+rnd+' .phrase .phrase-1').fadeOut(500,		function(){					if($('.big-bubble-'+rnd).css('display')=='block')			{				$('.small-bubble-'+rnd+' .phrase .phrase-4').fadeIn(500);			}			else			{				$('.small-bubble-'+rnd+' .phrase .phrase-4').fadeOut(500);			}					}				)})})})})})})}						} ///////////////////function phrase2(id){				$('.small-bubble-'+id+' .phrase .phrase-4').fadeIn(500,	function(){$('.small-bubble-'+id+' .phrase .phrase-3').fadeIn(500,	function(){$('.small-bubble-'+id+' .phrase .phrase-3').fadeOut(500,	function(){$('.small-bubble-'+id+' .phrase .phrase-2').fadeIn(500,	function(){$('.small-bubble-'+id+' .phrase .phrase-2').fadeOut(500,	function(){$('.small-bubble-'+id+' .phrase .phrase-1').fadeIn(500,	function(){$('.small-bubble-'+id+' .phrase .phrase-1').fadeOut(500)})})})})})})} ////////////////////	function moveElem() {		if(moveFlag == true)	{			if(brakingFlag == true)		{			if(speed < 20000)			{				speed+=2000;			}			else if(speed >= 20000)			{					moveFlag = false;				clearInterval(moveFunctionInterval);				clearInterval(showPhraseInterval);				}		}		else if(accelFlag == true)		{			if(speed > 4000)			{				speed-=2000;			}			}		da = 3*Math.PI/speed;		if(a>=6.28)	a=0;			a+=da;		for(var i=1; i<9; i++)		{			if(parseInt($('.small-bubble-'+i).css('left')) >= 232 && parseInt($('.small-bubble-'+i).css('left')) <= 518) 			{ 				$('.small-bubble-'+i).css('z-index','999');				 			} 			else 			{ 				$('.small-bubble-'+i).css('z-index','10000'); 			}			ii = i;			switch (i) {	   		case 2: ii = i;ii-=0.2;break;	   		case 3: ii = i;ii-=0.4;break;	   		case 4: ii = i;ii-=0.6;break;	   		case 5: ii = i;ii-=0.8;break;	   		case 6: ii = i;ii-=1;break;	   		case 7: ii = i;ii-=1.2;break;	   		case 8: ii = i;ii-=1.4;break;    					}							$('.small-bubble-'+i).css({left: 400 + parseInt(R*Math.cos(a+ii)*1.1)+'px', top: 230 +  parseInt(R*Math.sin(a+ii)*0.9)+'px' });		}		}	}////////////////////// $(document).ready(function(){	$('body *').disableSelection(); 	startMove();	$('.small-bubble').hover(	function(){				phraseFlag = false;		clearInterval(showPhraseInterval);		bubbleNum = $(this).attr('class').substring(13,14);		brakingFlag = true;		accelFlag = false;				phrase2Timeout = setTimeout('phrase2('+bubbleNum+')',400);				phrase2Interval = setInterval('phrase2('+bubbleNum+')',5000);					},	function(){				clearTimeout(phrase2Timeout);		clearInterval(phrase2Interval);		phraseFlag = true;		brakingFlag = false;		accelFlag = true;			moveFlag = true;		setTimeout('startMove()',5000);		if($('.big-bubble-'+bubbleNum).css('display')=='block')		{			$('.small-bubble-'+bubbleNum+' .phrase .phrase-4').fadeIn(500);		}		else		{			$('.small-bubble-'+bubbleNum+' .phrase .phrase-4').fadeOut(500);		}			});	///////Big bubble show/////////		$('.small-bubble').click(function(){		bubbleNum = $(this).attr('class').substring(13,14);		bubbleLeft = parseInt($('.small-bubble-'+bubbleNum).css('left'));		bubbleTop = parseInt($('.small-bubble-'+bubbleNum).css('top'));										if(parseInt($(this).css('left')) >= 390 && parseInt($(this).css('left')) <= 680 && parseInt($(this).css('top')) > 9 && parseInt($(this).css('top')) < 200  ) 		{ 			$('.big-bubble-'+bubbleNum).css({left: bubbleLeft+40+'px' , top: bubbleTop-80+'px'}); 		} 		else if(parseInt($(this).css('left')) > 390 && parseInt($(this).css('left')) < 680 && parseInt($(this).css('top')) > 200 && parseInt($(this).css('top')) < 460  ) 		{ 			$('.big-bubble-'+bubbleNum).css({left: bubbleLeft+10+'px' , top: bubbleTop+'px'}); 		} 		else if(parseInt($(this).css('left')) >= 127 && parseInt($(this).css('left')) <= 390 && parseInt($(this).css('top')) > 200 && parseInt($(this).css('top')) < 460  ) 		{ 			$('.big-bubble-'+bubbleNum).css({left: bubbleLeft-170+'px' , top: bubbleTop+'px'}); 		} 		else if(parseInt($(this).css('left')) > 127 && parseInt($(this).css('left')) < 390 && parseInt($(this).css('top')) > 9 && parseInt($(this).css('top')) < 200  ) 		{ 			$('.big-bubble-'+bubbleNum).css({left: bubbleLeft-200+'px' , top: bubbleTop-80+'px'}); 		}		if($('.big-bubble-'+bubbleNum).css('display')=='none')		{			$('.big-bubble-'+bubbleNum).css({display: 'block'});			$('.big-bubble-'+bubbleNum).css('z-index','10000');		}		else		{			$('.big-bubble-'+bubbleNum).css({display: 'none'});			$('.big-bubble-'+bubbleNum).css('z-index','1');		}						});///////Big bubble show end/////////	//////////Drag and Drop/////////////////	var bigBubbleLeft;var bigBubbleTop;	$('.big-bubble').mousedown(function(e){	 	dragFlag = true;	 	bigBubble = $(this);	 	bigBubbleLeft = parseInt($(this).css('left'));	 	bigBubbleTop = parseInt($(this).css('top'));	 	razX = e.pageX - bigBubbleLeft;	 	razY = e.pageY - bigBubbleTop;	});        	$('body').mousemove(function(e){   	 	if(dragFlag == true) 			 	$(bigBubble).css({left: e.pageX-razX+'px', top: e.pageY-razY+'px'}); 	 	 		 			});  	$('body').mouseup(function(){  	 	dragFlag = false;     					}); 	//////////Drag and drop end/////////////////	 	$(document).keyup(function(event){ 		if (event.keyCode == 27) {  		$('.big-bubble').css('display', 'none'); 		}	});})jQuery.fn.extend({      disableSelection : function() {              this.each(function() {                      this.onselectstart = function() { return false; };                      this.unselectable = "on";                      jQuery(this).css('-moz-user-select', 'none');              });      },     enableSelection : function() {              this.each(function() {                      this.onselectstart = function() {};                      this.unselectable = "off";                      jQuery(this).css('-moz-user-select', 'auto');              });      } });
