
	var initialized = false;
	
	$(function(){
	
		var subscribe_text = $(".subscribe_text");
		var default_text_subscribe = subscribe_text.val();
		
		subscribe_text.focus(function()
		{
			var $this = $(this);
			
			if( default_text_subscribe == $this.val() )
			{
				$this.css("color", "#FFF");
				$this.val("");
			}
		});
		
		subscribe_text.blur(function()
		{
			var $this = $(this);
			
			if( $this.val() == '' )
			{
				$this.css("color", "#2E3032");
				$this.val(default_text_subscribe);
			}
		});
		
		
		subscribe_text.keyup(function(ev)
		{
			if(ev.keyCode == 13)
			{
				if( subscribe_text.attr("data-submitted") )
					return false;
					
				if( subscribe_text.val().match(/^[a-z0-9\.\-_]+@[a-z0-9\.\-]+\.[a-z]{2,6}$/) )
				{
					$(".subscribe_ajax_loader").fadeIn("slow");
					$(".subscribe_error_message").hide();
					
					$.post("index.php", {subscribe_email: subscribe_text.val()}, function(data)
					{
						$(".subscribe_ajax_loader").fadeOut(function()
						{
							if( Number(data) == 1 )
							{
								subscribe_text.attr("data-submitted", "true");
								$(".subscribe_error_message").hide();
								$(".subscribe_success_message").fadeIn("slow");
							}
							else
							{
								$(".subscribe_error_message").html("You are already subscribed!").fadeIn("slow");
							}
						});
					});
				}
				else
				{
					$('.subscribe_error_message').html('Please enter valid email!').fadeIn("slow");
				}
			}
		});
	
		$(document).ready(function(){
			$("#trokit").hover(makeTall,makeShort);
		}); // close document.ready
	
		function makeTall(){ $(this).stop().animate({"height":91, top: 0}, 200);}
		function makeShort(){ $(this).stop().animate({"height":65, top: 14}, 200);}
		
	    $('.bubbleInfo').each(function() {
	        var distance = 10;
	        var time = 250;
	        var hideDelay = 500;
			
			var id = $(this).attr("id");
			
	        var hideDelayTimer = null;
	
	        var beingShown = false;
	        var shown = false;
	        var trigger = $('.trigger', this);
	        var info = $('.popup', this).css('opacity', 0);
	
	
	        $([trigger.get(0), info.get(0)]).mouseover(function() {
	            if (hideDelayTimer) clearTimeout(hideDelayTimer);
	            if (beingShown || shown) {
	                // don't trigger the animation again
	                return;
	            } else {
	                // reset position of info box
	                beingShown = true;
	
	                info.css({
	                    top: -150,
	                    left: -20,
	                    display: 'block'
	                }).animate({
	                    top: '-=' + distance + 'px',
	                    opacity: 1
	                }, time, 'swing', function() {
	                    beingShown = false;
	                    shown = true;
	                    
	                    if( !initialized && id && id == "map-location" )
	                    {
	                   		initialize();
	                   		initialized = true;
	                    }
	                });
	            }
	
	            return false;
	        }).mouseout(function() {
	            if (hideDelayTimer) clearTimeout(hideDelayTimer);
	            hideDelayTimer = setTimeout(function() {
	                hideDelayTimer = null;
	                info.animate({
	                    top: '-=' + distance + 'px',
	                    opacity: 0
	                }, time, 'swing', function() {
	                    shown = false;
	                    info.css('display', 'none');
	                });
	
	            }, hideDelay);
	
	            return false;
	        });
	    });
	    
	    $(".fb").append('<div class="fb_inner"></div>');
	
	    $(".fb").hover(function() {
	        $(this).find('.fb_inner').fadeIn("slow");
	    }, function() {
	        $(this).find('.fb_inner').fadeOut("slow");
	    });
	    
	    $(".be").append('<div class="be_inner"></div>');
	
	    $(".be").hover(function() {
	        $(this).find('.be_inner').fadeIn("slow");
	    }, function() {
	        $(this).find('.be_inner').fadeOut("slow");
	    });
	    
	    $(".tw").append('<div class="tw_inner"></div>');
	
	    $(".tw").hover(function() {
	        $(this).find('.tw_inner').fadeIn("slow");
	    }, function() {
	        $(this).find('.tw_inner').fadeOut("slow");
	    });
	    
	    
	    // Preload CSS Images
	    $.preloadCssImages();
	}); 
