$(document).ready(function() {
	if (jQuery.browser.msie) {
		if(parseInt(jQuery.browser.version) <= 7) {
		// Internet Explorer 7 and older
		//To idio horis to opacity giati ehei bug
			$("#signature a").hover(showSignatureBalloon2, hideSignatureBalloon2);
		} else {
		// Internet Explorer 8 and newer
			$("#signature a").hover(showSignatureBalloon, hideSignatureBalloon);
		}
	} else {
	//Other Browsers
		$("#signature a").hover(showSignatureBalloon, hideSignatureBalloon);
	}
	
	var time = 3000;
	$("#mainArt").css('height','70px');
	$("#mainArt").css('overflow','hidden');
	$("#mainArt").animate({
	height: 1024 + 'px'
	}, time, 'swing',function() {
		$("#mainArt").css('height','');
	});
});

var beingShown = false;
var shown = false;
// options
var distance = 10;
var time = 250;
var hideDelay = 500;

var hideDelayTimer = null;

	
$(window).bind('load', function() {
	var _images = ['../img/balloon.png'];

	$.each(_images,function(e) {
		$(new Image()).load().attr('src',this);
	});
});

function showSignatureBalloon() {

	if (beingShown || shown) {
		return;
	  } else {
		beingShown = true;

		// reset position of popup box
		$("#signature a span").css({
		top: '-77px',
		display: 'block'
		})// brings the popup back in to view

		// (we're using chaining on the popup) now animate it's opacity and position
		.animate({
		  top: '-=' + distance + 'px',
		  opacity: 1
		}, time, 'swing', function() {
		  // once the animation is complete, set the tracker variables
		  beingShown = false;
		  shown = true;
		});
	}
}

function hideSignatureBalloon() {
	// reset the timer if we get fired again - avoids double animations
    if (hideDelayTimer) clearTimeout(hideDelayTimer);
      
      // store the timer so that it can be cleared in the mouseover if required
    hideDelayTimer = setTimeout(function () {
        hideDelayTimer = null;
        $("#signature a span").animate({
          top: '-=' + distance + 'px',
          opacity: 0
        }, time, 'swing', function () {
          // once the animate is complete, set the tracker variables
          shown = false;
          // hide the popup entirely after the effect (opacity alone doesn't do the job)
          $("#signature a span").css('display', 'none');
        });
	});
}

function showSignatureBalloon2() {

	if (beingShown || shown) {
		return;
	  } else {
		beingShown = true;

		// reset position of popup box
		$("#signature a span").css({
		top: '-77px',
		display: 'block'
		})// brings the popup back in to view

		// (we're using chaining on the popup) now animate it's opacity and position
		.animate({
		  top: '-=' + distance + 'px'
		}, time, 'swing', function() {
		  // once the animation is complete, set the tracker variables
		  beingShown = false;
		  shown = true;
		});
	}
}

function hideSignatureBalloon2() {
	// reset the timer if we get fired again - avoids double animations
    if (hideDelayTimer) clearTimeout(hideDelayTimer);
      
      // store the timer so that it can be cleared in the mouseover if required
    hideDelayTimer = setTimeout(function () {
        hideDelayTimer = null;
        $("#signature a span").animate({
          top: '-=' + distance + 'px'
        }, time, 'swing', function () {
          // once the animate is complete, set the tracker variables
          shown = false;
          // hide the popup entirely after the effect (opacity alone doesn't do the job)
          $("#signature a span").css('display', 'none');
        });
	});
}