			// Teimuraz Tsomaia
			var buttonTimeout = 1000;
			

			var popupTimeout = 500;
			

			var reactOnMouseClick = true;
			

		    var buttonYPos = null;  
		    var buttonHeight = null;
			

			var popupHeight = 400;
			var popupWidth = 800;
			var backgroundTransparency = 0.3;
			var popupLeft = null;
			var popupTop = null;
			

	    	var headerHeight = 182;
	    	var ownCurrentScroll = 0;
	    	var lastOpenedId = '';
			
			function showPopup(popup, buttonTrigger){
				thisButtonYPos = findPosY(document.getElementById(buttonTrigger));
				buttonHeight = parseInt($('#' + buttonTrigger).css("height").substring(0, $('#' + buttonTrigger).css("height").indexOf("px")));
				
				popupLeft = buttonXPos - popupWidth;
        		popupTop = (thisButtonYPos - (popupHeight - buttonHeight) / 2) - $(document).scrollTop();

        		popup.css('top', popupTop + 'px');
        		popup.css('left', buttonXPos + 'px');
        		popup.css('height', popupHeight + 'px');
        		
        		popup.show(0, function(){
					$('#blockage').show();
					$('#blockage').css('opacity', backgroundTransparency);
					
	        		popup.animate({
						height: popupHeight + 'px',
						width: popupWidth + 'px',
						left: popupLeft + 'px',
						top: popupTop + 'px'
					}, popupTimeout, function() {
						$('#blockage').click(function() {
							hidePopup(popup);
						});
					});
        		});
			}
			
			function hidePopup(popup){				
        		popupLeft = buttonXPos;
        		
        		popup.animate({
					width: '0px',
					left: popupLeft + 'px',
					top: popupTop + 'px'
				}, popupTimeout, function(){
					popup.hide();
					$('#blockage').hide();


					popup.queue('fx', []);
					$('#blockage').queue('fx', []);
       			});
			}

			function findPosX(obj)
			{
			  var curleft = 0;
			  if(obj.offsetParent)
			      while(1) 
			      {
			        curleft += obj.offsetLeft;
			        if(!obj.offsetParent)
			          break;
			        obj = obj.offsetParent;
			      }
			  else if(obj.x)
			      curleft += obj.x;
			  return curleft;
			}

			function findPosY(obj)
			{
			  var curtop = 0;
			  if(obj.offsetParent)
			      while(1)
			      {
			        curtop += obj.offsetTop;
			        if(!obj.offsetParent)
			          break;
			        obj = obj.offsetParent;
			      }
			  else if(obj.y)
			      curtop += obj.y;
			  return curtop;
			}
	    	
		    $(document).ready(function(){
		        if(reactOnMouseClick){
			    	$('.option').click(function() {
				    	var id = $(this).attr('id');
			    		var h = $('#sub_' + id).css('height');
			    		var w = $('#sub_' + id).css('width');
			    		var ow = $(this).css('width');
			    		var oh = $(this).css('height');

			    		oh = oh.replace('px', ''); 
			    		ow = ow.replace('px', ''); 
			    		
			    		var initx = findPosX(document.getElementById("o0"));
			    		var x = findPosX(document.getElementById(id));
			    		var y;

						if(lastOpenedId != '') {
							$('#sub_' + lastOpenedId).hide();
						}
						lastOpenedId = id;
			    		
			    		if ($('#newmenu').css('position') == 'fixed')
			    			y = findPosY(document.getElementById(id)) + 42 + currentScroll;
			    		else
			    			y = findPosY(document.getElementById(id)) + 42;
			    			
			    		var nl = x + (ow / 2); 
			    		
			    		$('#sub_' + id).css('width', '1px');
			    		$('#sub_' + id).css('height', '0px');
			    		$('#sub_' + id).css('left', nl + 'px');
			    		$('#sub_' + id).css('top', y + 'px');
			    		$('#sub_' + id).show();
			    	
			    		$('#sub_' + id).animate({
			    			height: h
						}, 500, function() {
	
			    		}).animate({
			    		    width: w,
			    		    left: initx
			    		}, 500, function(){});

			    		$('#sub_' + id).mouseleave(function() {
				    		$('#sub_' + id).hide();
			    		});
			    	});
		        }else{			    
			    	$('.option').mouseenter(function() {
				    	var id = $(this).attr('id'); 
			    		var h = $('#sub_' + id).css('height');
			    		var w = $('#sub_' + id).css('width');
			    		var ow = $(this).css('width');
			    		var oh = $(this).css('height');

			    		oh = oh.replace('px', ''); 
			    		ow = ow.replace('px', ''); 
			    		
			    		var initx = findPosX(document.getElementById("o0"));
			    		var x = findPosX(document.getElementById(id));
			    		var y;
			    		
			    		if ($('#newmenu').css('position') == 'fixed')
			    			y = findPosY(document.getElementById(id)) + 42 + currentScroll;
			    		else
			    			y = findPosY(document.getElementById(id)) + 42;
			    			
			    		var nl = x + (ow / 2); 
			    		
			    		$('#sub_' + id).css('width', '5px');
			    		$('#sub_' + id).css('height', '0px');
			    		$('#sub_' + id).css('left', nl + 'px');
			    		$('#sub_' + id).css('top', y + 'px');
			    		$('#sub_' + id).show();
			    	
			    		$('#sub_' + id).animate({
			    			height: h
						}, 500, function() {
	
			    		}).animate({
			    		    width: w,
			    		    left: initx
			    		}, 500, function(){});
			    	});

			    	$('.option').mouseleave(function() {
			    		var id = $(this).attr('id'); 
			    		
			    		$('#sub_' + id).hide();
			    	});
		        }


			    var popup1 = $('#popup1').hide();
			    var popup2 = $('#popup2').hide();
			    var popup3 = $('#popup3').hide();
			    
		    	try{
 buttonYPos = parseInt($('#floatingButton').css("top").substring(0, $('#floatingButton').css("top").indexOf("px")));
 buttonXPos = findPosX(document.getElementById('floatingButton'));
 } catch(err) {
 buttonYPos = 0;
 buttonXPos = 0;
 }
		    			        
		        if(reactOnMouseClick){
		        	$('#floatingButton1').click(function(){
						showPopup(popup1, 'floatingButton2');
		        	});	
		        	$('#floatingButton2').click(function(){
						showPopup(popup2, 'floatingButton2');
		        	});	
		        	$('#floatingButton3').click(function(){
						showPopup(popup3, 'floatingButton2');
		        	});	
		        } else {
		        	$('#floatingButton1').hover(function(){
		        		showPopup(popup1);
		        	});
		        	$('#floatingButton2').hover(function(){
		        		showPopup(popup2);
		        	});
		        	$('#floatingButton3').hover(function(){
		        		showPopup(popup3);
		        	});
		        }
	    		
		        $(window).scroll(function () {  
		            var offset = buttonYPos + $(document).scrollTop() + "px";
		            $('#floatingButton').animate({top:offset}, {duration:buttonTimeout, easing:'easeOutExpo', queue:false});

		            var w = $('#newmenu').css('width');
					currentScroll = $(this).scrollTop();

					$('#sub_' + lastOpenedId).hide();
					
					if ($(this).scrollTop() > headerHeight && $('#newmenu').css('position') != 'fixed'){ 
						$('#newmenu').css({'position':'fixed', 'top':'0px', 'width':w});  
					} else if ($(this).scrollTop() < headerHeight && $('#newmenu').css('position') == 'fixed'){ 
						$('#newmenu').css({'position':'relative', 'top':''});
					}
		        });
		    });
