﻿Type.registerNamespace('Vehix.Presentation.Research.JDPowerContent'); 
Vehix.Presentation.Research.JDPowerContent = function()
{
    Vehix.Presentation.Research.JDPowerContent.initializeBase(this);
}

Vehix.Presentation.Research.JDPowerContent.prototype = 
{
    Definition : function() 
    {
       //New Object.  Late Bound
    },
    
    TrimItem : function()
    {
        var trimItems = new Object();
        trimItems.header = "";
        trimItems.definitionCode = "";
        trimItems.label = "";
	    trimItems.trim1 = "";
	    trimItems.trim2 = "";
	    trimItems.trim3 = "";
	    return trimItems;
    },
    
    InsertRow : function (trimItem, rowOn, container)
    {
	    var sOn;
	    
	    rowOn ? sOn = 'On' : sOn = 'Off';
	    var columnDataRowCSSClass = "dataRow" + sOn;
	    var div = newDiv();
	    div.className = "dataContainerRow";
    	
	    var divLeft = newDiv();
	    divLeft.className = "dataRow" + sOn + "Left";
	    divLeft.appendChild(this._addLabel(trimItem.label, trimItem.definitionCode));
	    
	    div.appendChild(divLeft);
	    var div1 = newDiv();
	    div1.className = "dataRow" + sOn + "1";
	    div1.appendChild(this._addRating(columnDataRowCSSClass, trimItem.label, trimItem.trim1, trimItem.definitionCode));
	    
	    div.appendChild(div1);

	    var div2 = newDiv();
	    div2.className = "dataRow" + sOn + "2";
	    div2.appendChild(this._addRating(columnDataRowCSSClass, trimItem.label, trimItem.trim2, trimItem.definitionCode));

	    div.appendChild(div2);
    	
	    var div3 = newDiv();
	    div3.className = "dataRow" + sOn + "3";
	    div3.appendChild(this._addRating(columnDataRowCSSClass, trimItem.label, trimItem.trim3, trimItem.definitionCode));
        
        div.appendChild(div3);
        
	    document.getElementById(container).appendChild(div);
    },
    
    _addLabel : function (label, definition)
    {
	    var c1 = newDiv();
	    c1.className = "specsColumn1";
	    var a = newAnchor();
	    a.className = "grayLink";
	    a.appendChild(newTextNode(label));
	    a.href = "javascript:null";
	    a.onclick = function()
	    {
		    return false;
	    }
	    
	    var t = eval("JDPowerContent.Definition." + definition);;
	    a.onmouseover = function(event)
	    {
		    var e = event;
		    if(typeof(e) == "undefined")
			    e = window.event;
		    oDiv = $v("jdp_definitions");
		    if ($.browser.msie)
		    {
			    oDiv.style.top = e.clientY - e.offsetY - 325 + document.documentElement.scrollTop + 'px';
			    if(e.clientY > 600)
				    oDiv.style.top = e.clientY - e.offsetY - 345 + document.documentElement.scrollTop + 'px';
		    }else{
			    oDiv.style.top = (e.pageY - e.layerY - 225) + 'px';
		    }
		    oDiv.innerHTML = "";
		    oDiv.appendChild(newTextNode(t));
		    oDiv.style.display = "block";
	    }
	    a.onmouseout = function()
	    {
		    $v("jdp_definitions").style.display = "none";
	    }
	    c1.appendChild(a);
	    return c1;        
    },
        
    _addRating : function(css, txt, imgt, def)
    {
	    var rdiv = newDiv();
	    rdiv.className = css;
	    
	    var column = newDiv();
	    column.className = "specsColumn2";
        if(imgt == "" || imgt == "No Data" || imgt == null )
        {
            imgt = (imgt == null) ? "" : imgt;
            var span = newSpan();
            span.className = "jdp_image";
            span.setAttribute("style","font-size:11px;");
            span.appendChild(newTextNode(imgt));
            column.appendChild(span);
        }
        else
        {
            var img = new Image();
            imgt = imgt.replace(".0","");
            img.src = Uri.resolveUrl("~/_images/jdp_" + imgt + ".gif").toString();
            img.className = "jdp_image";
            img.setAttribute("style","margin-top:2px;");
            column.appendChild(img);
	    }
	    
	    rdiv.appendChild(column);
	    return column;
    },
    
    
    JDPowerScoringLegend : function(containerName)
    {
        var divContainer = document.getElementById(containerName);
        var divl = newDiv();
        var divImages = newDiv();
        
        var imgr = new Image();
        var a = newAnchor();
        imgr.src = Uri.resolveUrl("~/_images/jdp_circle_ratings.gif").toString();
        imgr.className = "jdp_legend_img";
        a.href = "javascript:JDPowerContent.JDPowerOmnitureClick('Home', 'http://www.jdpower.com')";
        a.appendChild(imgr);
        divImages.appendChild(a);
        imgr = new Image();
        imgr.className = "jdp_legend_img";
        imgr.src = Uri.resolveUrl("~/_images/jdp_key_5.gif").toString();
        divImages.appendChild(imgr);
        imgr = new Image();
        imgr.className = "jdp_legend_img";
        imgr.src = Uri.resolveUrl("~/_images/jdp_key_4.gif").toString();
        divImages.appendChild(imgr);
        imgr = new Image();
        imgr.className = "jdp_legend_img";
        imgr.src = Uri.resolveUrl("~/_images/jdp_key_3.gif").toString();
        divImages.appendChild(imgr);
        imgr = new Image();
        imgr.className = "jdp_legend_img";
        imgr.src = Uri.resolveUrl("~/_images/jdp_key_2.gif").toString();
        imgr.style.marginRight = "0px";
        divImages.appendChild(imgr);
        divImages.className = "jdp_image_container";
        divl.className = "jdp_legend_container";
        divl.appendChild(divImages);
        divContainer.appendChild(divl);
        return divl;
    },

    JDPowerInfoAndDisclaimer : function(divl)
    {
        var sp = newDiv();
        sp.id = "paragraph1";
        sp.className = "jdp_blackBold";
        sp.appendChild(newTextNode("Please note that "));
        a = newAnchor();
        a.appendChild(newTextNode("JDPower.com"));
        a.href = "javascript:JDPowerContent.JDPowerOmnitureClick('Home', 'http://www.jdpower.com/')";
        sp.appendChild(a); 
        sp.appendChild(newTextNode(" may not include all information used to determine J.D. Power and Associates awards."));
        divl.appendChild(sp);
        sp = newDiv();
        sp.id = "paragraph2";
        sp.appendChild(newTextNode("View make and body style "));
        a = newAnchor();
        a.appendChild(newTextNode("car ratings"));
        a.href = "javascript:JDPowerContent.JDPowerOmnitureClick('Ratings', 'http://www.jdpower.com/autos/ratings/')";
        sp.appendChild(a);
        sp.appendChild(newTextNode(" for "));
        a = newAnchor();
        a.appendChild(newTextNode("initial quality"));
        a.href = "javascript:JDPowerContent.JDPowerOmnitureClick('Quality', 'http://www.jdpower.com/autos/quality-ratings/')";
        sp.appendChild(a);
        sp.appendChild(newTextNode(", "));
        a = newAnchor();
        a.appendChild(newTextNode("dependability"));
        a.href = "javascript:JDPowerContent.JDPowerOmnitureClick('Dependability', 'http://www.jdpower.com/autos/ratings/dependability-ratings')";
        sp.appendChild(a);
        sp.appendChild(newTextNode(", and "));
        a = newAnchor();
        a.appendChild(newTextNode("performance and design"));
        a.href = "javascript:JDPowerContent.JDPowerOmnitureClick('Performance', 'http://www.jdpower.com/autos/performance&design-ratings')";
        sp.appendChild(a);
        sp.appendChild(newTextNode(" at "));
        a = newAnchor();
        a.appendChild(newTextNode("JDPower.com"));
        a.href = "javascript:JDPowerContent.JDPowerOmnitureClick('JDPower Home', 'http://www.jdpower.com/')";
        sp.appendChild(a);
        sp.appendChild(newTextNode("."));
        divl.appendChild(sp);
        sp = newDiv();
        sp.id = "paragraph3";
        var spn = newSpan();
        spn.className = "jdp_blackBold";
        spn.appendChild(newTextNode("About J.D. Power Associates: "));
        sp.appendChild(spn);
        sp.appendChild(newTextNode("Established in 1968, J.D. Power and Associates is a global marketing information firm that conducts independent and unbiased surveys of customer satisfaction, product quality and buyer behavior. Today, the firm’s services include industry-wide syndicated studies; proprietary (commissioned) tracking studies; media studies; forecasting; and training services, as well as business operations analyses, and consultancies on customer satisfaction trends. On April 1, 2005, J.D. Power and Associates became a business unit of The McGraw-Hill Companies."));
        divl.appendChild(sp);
        sp = newDiv();
        spn = newSpan();
        spn.className = "jdp_disclaimer";
        spn.appendChild(newTextNode("Disclaimer"));
        sp.appendChild(spn);
        sp.id = "paragraph4";
        sp.appendChild(newTextNode("All information provided by J.D. Power and Associates is proprietary information owned by J.D. Power and Associates and is protected by U.S. and international copyright law and conventions. Reproduction of this information, in whole or in part, by any means is prohibited without the express written consent of J.D. Power and Associates, other than printing copies of the J.D. Power and Associates content by site visitors for their personal use. J.D. Power and Associates® is a registered trademark of J.D. Power and Associates."));
        divl.appendChild(sp);
        return divl;
    },


    JDPowerOmnitureClick : function(linkName, url)
    {
	    jdpowerWindow = window.open(url, "JDPower", "toolbar=no,scrollbars=yes,resizable=yes,status=yes");
	    jdpowerWindow.focus();
    	
	    var omniture=s_gi(s_account);
	    omniture.events = 'purchase';
	    omniture.products = ';JDPower ' + linkName;
	    omniture.linkTrackVars = 'events, products';
	    omniture.linkTrackEvents = 'purchase';	
	    omniture.tl(this,'o', omniture.products);
    }
}
