﻿// JScript File

/*
** How to markup to show a tooltip on a word :
** <[tag name] class="tp_[Word_to_define] tooltip"></[tag name]>
**
** The tooltip can be implemented on any html tag.
** It is important that these 2 classes are used in that exact order.
** Replace word's white spaces with _ .

** How to define the word for the tooltip's window
** "Word_to_define" : {
        "en" : [ "tooltip's title", "tooltip's content" ],
        "fr" : [ "tooltip's title", "tooltip's content" ]
    }
**  
** The Word_to_define has to be writen exactly the same way as in the class name ( case sensitive ).
** If the content of a language is empty, it will not cause an error but will simply not show up a tooltip window.
*************************************************************************************************************** */


var tp = {
    boxName : "myTooltip",
    culture : "en",
    widthSize : "250px",
    prefix : "tp_",
    searchClass : "tooltip"
}

var myTooltips = YAHOO.util.Dom.getElementsByClassName(tp.searchClass);
YAHOO.util.Event.addListener(myTooltips, "mouseover", manageTip, tp);
YAHOO.util.Event.addListener(myTooltips, "mouseout", manageTip, tp);

function manageTip(e, tp){		
		e = e  || event;
		
		var boxName = tp.boxName || "myTooltip";
		var culture = tp.culture || "en";
		var widthSize = tp.widthSize || "250px";
		var prefix = tp.prefix || "tp_";
		var searchClass = tp.searchClass || "tooltip";
		var classTerm = " " + searchClass;
		
		var itemID = this.id;
		var itemName = this.className;
		var wordID = itemName.slice(itemName.indexOf(prefix)+prefix.length, itemName.indexOf(classTerm));
		wordID = wordID.toLowerCase();
		
	    if(document.getElementById(boxName)){
	        var oldWindow = document.body.removeChild(document.getElementById(boxName).parentNode);
	    }
	    
        if(e.type == "mouseover" && tooltipList[wordID][culture][0] != "" && tooltipList[wordID][culture][1] != ""){	        
	        createTip(itemID, boxName, widthSize);
	        myTooltip.setHeader("<h4>"+ tooltipList[wordID][culture][0] +"</h4>");
	        myTooltip.setBody("<p>"+ tooltipList[wordID][culture][1] +"</p>");
	        myTooltip.render(document.body);
	        myTooltip.show();
	    }
}

function createTip(itemID, divName, tpWidth){    
        
    var panelConfig = {
        width : tpWidth,
        constraintoviewport : true,
        close : true,
        visible : false
    }
    
    if (itemID == ""){
        panelConfig.fixedcenter = true;
    } else {
        panelConfig.context = [itemID,"tl","bl"];
        panelConfig.xy = [10,10];
    }
    
    myTooltip = new YAHOO.widget.Panel(divName, panelConfig);
}

var tooltipList = { 
    "tread" : {
        "en" : [ "Tread", "That portion of a tire that comes into contact with the road. It is distinguished by the design of its ribs and grooves. Provides traction in a variety of conditions, withstands high forces, and resists wear, abrasion, and heat." ],
        "fr" : [ "Bande de roulement", "C&#39;est la surface du pneu qui assure le contact avec la route. Elle se distingue par la conception de ses nervures et ses rainures. Elle procure de l&#39;adh&#233;rence dans une vari&#233;t&#233; de conditions et r&#233;siste aux fortes contraintes, &#224; l&#39;usure, &#224; l&#39;abrasion et &#224; la chaleur." ]
    },
    "mounting" : {
        "en" : [ "Mounting", "This is the act of putting the tire on wheel and ensuring that the assembly is balanced. When you purchase new tires, they will need to be professionally mounted. It is also standard for the tire dealer to charge a nominal fee for a valve stem." ],
        "fr" : [ "Montage", "Cette op&#233;ration consiste &#224; monter le pneu sur la roue et &#224; &#233;quilibrer l&#39;ensemble. Lorsque vous faites l&#39;achat de pneus neufs, ceux-ci doivent &#234;tre mont&#233;s par un personnel sp&#233;cialis&#233;. Aussi, il est normal que le d&#233;taillant ajoute des frais nominaux pour les tiges de valve." ]
    },
    "aquaplaning" : {
        "en" : [ "Aquaplaning", "An extremely dangerous situation where water builds up in front of the tires resulting in the tires losing contact with the road surface. The vehicle is skimming on the water surface and is completely out of control at this point. Also called hydroplaning." ],
        "fr" : [ "", "" ]
    },
    "size" : {
        "en" : [ "Size", "The combination of tire width, construction type, aspect ratio, and rim size used in differentiating tires." ],
        "fr" : [ "", "" ]
    },
    "sidewall" : {
        "en" : [ "Sidewall", "That portion of a tire between the tread and the bead. Protects the tire against impacts with curbs, etc. This is also where the sidewall markings can be found which tell you important information regarding the tire." ],
        "fr" : [ "", "" ]
    },
    "shoulder" : {
        "en" : [ "Shoulder", "The area of a tire where the tread and sidewall meet." ],
        "fr" : [ "", "" ]
    },
    "directional_stability" : {
        "en" : [ "Directional stability", "The ability of a vehicle to be driven safely and with confidence in a straight line and at high speed without being affected by pavement irregularities, crosswinds, aerodynamic lifting forces, or other external influences." ],
        "fr" : [ "", "" ]
    },
    "understeer" : {
        "en" : [ "Understeer", "The handling characteristic in which the front tires break loose because they are running a larger slip angle than the rear tires. Also known as plowing." ],
        "fr" : [ "", "" ]
    },
    "oversteer" : {
        "en" : [ "Oversteer", "Condition when the rear wheels are carving a larger arc than the front wheels or the intended line of the turn. Rear 'slip angles' exceed those of the front tires. This is often described as a 'loose' condition, as the car feels like it may swap ends, or be 'twitchy.'" ],
        "fr" : [ "", "" ]
    },
    "alignment" : {
        "en" : [ "Alignment", "Adjusting all wheels on the vehicle so that they are pointed in the optimum direction relative to the road and each other." ],
        "fr" : [ "", "" ]
    },
    "static_balance" : {
        "en" : [ "Static balance", "Exists when the weight mass is evenly distributed around the axis of rotation. Static imbalance can be detected from vibrations through the seat, floor and steering column." ],
        "fr" : [ "", "" ]
    },
    "dynamic_balance" : {
        "en" : [ "Dynamic balance", "Exists when the weight is equally distributed both around its circumference and on either side of its centerline. A tire and wheels assembly that is out of dynamic balance will produce a wobble effect or a shaking from side to side." ],
        "fr" : [ "", "" ]
    },
    "rotation" : {
        "en" : [ "Rotation", "The changing of tires from front to rear or from side-to-side on a vehicle according to a set pattern; provides even treadwear. Rotating your tires on a regular basis (every 10,000-12,000 km) is a simple way to add miles to their life." ],
        "fr" : [ "", "" ]
    },
    "speed_rating" : {
        "en" : [ "Speed rating", "An alphabetical code (A-Z) assigned to a tire indicating the range of speeds at which the tire can carry a load under specified service conditions." ],
        "fr" : [ "", "" ]
    },
    "radial_ply_tire" : {
        "en" : [ "Radial ply tire", "A type of tire with plies arranged so cords in the body run at 90-degree angles to the center line of the tread." ],
        "fr" : [ "", "" ]
    },
    "load_carrying_capacity" : {
        "en" : [ "Load-carrying capacity", "Indicates how much weight a tire is certified to carry at maximum inflation pressure." ],
        "fr" : [ "", "" ]
    },
    "service_description" : {
        "en" : [ "Service description", "Numbers and letters molded into the sidewall indicating the load-carrying capacity, load index, and the speed at which the tire can carry a load under specified conditions, the speed rating. Also known as load index and speed symbol." ],
        "fr" : [ "", "" ]
    }
};