var hideMapTip = true;

jQuery(function($) {
  $('ul.mapLinks li a').mouseover(function(){
    hideMapTip = false;
    $("div.mapItem_" + $(this).parent().attr('class').substr(-2)).trigger('mouseover');
  });
  $('ul.mapLinks li a').mouseout(function(){
    hideMapTip = true;
    $("div.mapItem_" + $(this).parent().attr('class').substr(-2)).trigger('mouseout');
  });

  $('a[tooltip]').each(function() {
    $(this).qtip({
      content: $(this).attr('tooltip'),
      position: {
        type: 'absolute',
        corner: {
          target: 'bottomMiddle',
          tooltip: 'topMiddle'
        },
        adjust: {
          x: parseInt($(this).attr('ttx'),10),
          y: parseInt($(this).attr('tty'),10)
        }
      },
      style: {
        width: 259,
        padding: 0,
        background: 'none',
        textAlign: 'left',
        border: {
          width: 0,
          radius: 0,
          color: '#d9af6b'
        },
        tip: {
          corner: false
        },
        classes: {
          tip: 'hide-tip'
        }
      },
      hide: { effect: { type: 'fade', length: 500} },
      show: {
        effect: {
          type: 'fade',
          length: 500,
          opacity: 0.8
        }
      }
    });
  });

  $('div[tooltip]').each(function() {
    $(this).qtip({
      content: $(this).attr('tooltip'),
      maptip: true,
      position: {
        type: 'absolute',
        corner: {
          target: 'bottomMiddle',
          tooltip: 'topMiddle'
        },
        adjust: {
          x: parseInt($(this).attr('ttx'),10),
          y: parseInt($(this).attr('tty'),10)
        }
      },
      style: {
        width: 259,
        padding: 0,
        zIndex: $(this).attr('zindex') || null,
        background: 'none',
        textAlign: 'left',
        border: {
          width: 0,
          radius: 0,
          color: '#d9af6b'
        },
        tip: {
          corner: false
        },
        classes: {
          tip: 'hide-tip'
        }
      },
      hide: { effect: { type: 'fade', length: 500} },
      show: {
        effect: {
          type: 'fade',
          length: 500,
          opacity: 0.8
        }
      }
    });
  });
});

