﻿$(document).ready(function() {
    
    // Tooltip rollover
    $("div.tooltip-mark-fond-gris").hover(
		function() {
		    $(this).find("div.tooltip-box").css("visibility", "visible");
		},
		function() {
		    $(this).find("div.tooltip-box").css("visibility", "hidden");
		}
	);


	/*** FAQ answers slider ***/
	$("div.faq-item h5").toggle(
	function() {
	    $(this).parent().find("div.faq-item-slider").slideDown('300');
	    return false;
	},
	function() {
	    $(this).parent().find("div.faq-item-slider").slideUp('300');
	    return false;
	}
	);

});


// Equalize height of elements
// Note: use the fix on <tr> instead of <td> for this to work on all browsers.
$.fn.equalheight = function() {
    var maxHeight = 0;
    return this.each(function() {
        if ($(this).height() > maxHeight) {
            maxHeight = $(this).height();
        }
    }).height(maxHeight);
}



/* Shorcut method to add a Qtip by element with data-tooltip */
function applyTooltip(dataTooltip, strContent, position) {
    createQtip(dataTooltip, strContent, position);
}

/* Shorcut method to aAdd a Qtip by element class */
function applyQTip(strClass, strContent) {
    createQtip('div.' + strClass + ' input', strContent);
}


function createQtip(selector, strContent, position) {
    var corner;
    switch (position) {
        case 'bottom':
            corner = { target: 'bottomMiddle', tooltip: 'topMiddle' };
            tip = 'topMiddle';
            break;
        case 'right':
            corner = { target: 'rightMiddle', tooltip: 'leftMiddle' };
            tip = 'leftMiddle';
            break;
        case 'left':
            corner = { target: 'leftMiddle', tooltip: 'rightMiddle' };
            tip = 'rightMiddle';
            break;
        default:
            corner = { target: 'topMiddle', tooltip: 'bottomMiddle' };
            tip = 'bottomMiddle';
            break;
    }
    
    $(selector).qtip({
        content: strContent,
        show: { when: { event: 'mouseover'} },
        hide: 'mouseout',
        position: {
            corner: corner
        },
        style: {
            tip: tip,
            name: 'cream',
            color: '#724D05',
            border: {
                width: 2,
                color: '#D9C96E'
            }
        }
    });

}
