var _id = 'info-list';
var _slideEl = 'div';
var _duration = 300;
var _hide = true;

jQuery(document).ready(function() {
	jQuery('#'+_id+' h3').click(function () {
//		if (_hide) hideLevels(this);
		jQuery(this).parent().toggleClass('active');
		return false;
	});
	jQuery('#'+_id+' h4').click(function () {
		jQuery(this).parent().toggleClass('active');
		return false;
	});
	jQuery('#content .content-text span.tooltip[title]').qtip({
      position: {
         corner: {
            target: 'topRight',
            tooltip: 'bottomLeft'
         }
      },
	  content: {
         text: false // Use each elements title attribute
      },
      style: {
         name: 'blue',
         padding: '10px 15px',
		 border: {
                     width: 1,
                     radius: 5
                  },

         width: {
            max: 210,
            min: 0
         },
         tip: true
      }
   });
	 jQuery('a[rel="modal"]:first').qtip(
   {
      content: {
		  url:  'http://dev.10x.co.za/sensible-investment-strategy',
         title: {
            text: 'Tip',
            button: 'Close'
         }/*,*/
         
      },
      position: {
         target: jQuery(document.body), // Position it via the document body...
         corner: 'center' // ...at the center of the viewport
      },
      show: {
         when: 'click', // Show it on click
         solo: true // And hide all other tooltips
      },
      hide: false,
      style: {
         width: { max: 350 },
         padding: '14px',
         border: {
            width: 9,
            radius: 9,
            color: '#ffffff'
         },
         name: 'light'
      },
      api: {
         beforeShow: function()
         {
            // Fade in the modal "blanket" using the defined show speed
            jQuery('#qtip-blanket').fadeIn(this.options.show.effect.length);
         },
         beforeHide: function()
         {
            // Fade out the modal "blanket" using the defined hide speed
            jQuery('#qtip-blanket').fadeOut(this.options.hide.effect.length);
         }
      }
   });

   // Create the modal backdrop on document load so all modal tooltips can use it
   jQuery('<div id="qtip-blanket">')
      .css({
         position: 'absolute',
         top: jQuery(document).scrollTop(), // Use document scrollTop so it's on-screen even if the window is scrolled
         left: 0,
         height: jQuery(document).height(), // Span the full document height...
         width: '100%', // ...and full width

         opacity: 0.5, // Make it slightly transparent
         backgroundColor: 'black',
         zIndex: 5000  // Make sure the zIndex is below 6000 to keep it below tooltips!
      })
      .appendTo(document.body) // Append to the document body
      .hide(); // Hide it initially

});

function hideLevels(_this){
	jQuery('#'+_id+' li').each(function() {
		var _f = false;
		var _a = jQuery('h3', this).each(function(i, _el) {
			if (_el == _this) _f = true;
		});
		if (!_f)  {
			jQuery(_slideEl, this).hide(_duration);
			jQuery(this).removeClass('active');
		}
	});
}

