﻿function ConfigureOmniture() {
    var omnitureProject = "aspenms-ajantunes";

    //Bind Omniture trackback events to all links containing a 'linkName' attribute.

    var OmnitureLinks = $("a[linkName]");

    OmnitureLinks.click(function () {
        //Most of the tracked links are for downloadable pdf's and therefore call the Omniture script that uses the "d" parameter.
        var linkFunction = OmnitureDownloadLink;

        //... but if the link is to an external page, use the other "e" function.
        //if ($(this).attr("href").substr(0, 4) == "http")
        //	linkFunction = OmnitureExternalLink;
        //... similarly, if the link is to an internal page, use that function too (this is just to catch stragglers).
        //else if ($(this).attr("target") == "_self")
        //	linkFunction = OmnitureExternalLink;

        linkFunction($(this).attr("linkName"));
    });
}

/* Not being used anymore, per Sarah
//Bind Omniture trackback events to all links containing an 'externalLinkName' attribute.

var ExternalLinks = $("a[externalLinkName]");

ExternalLinks.click(function() {
	OmnitureExternalLink($(this).attr("externalLinkName"));
});

//Bind Omniture trackback events to all links classed as 'ExternalManual' with a 'model' attribute
// (used by the Roundup and Vizion division's category pages).

var ExternalManualLinks = $("a.ExternalManual");

ExternalManualLinks.click(function() {
	var model = $(this).attr("model");
	if (model) {
	OmnitureExternalLink(model + " - Owners Manual"); //same as linkName="ES-600 - Owners Manual"

	//Populate hyperlink for external link based on model name
	//http://www.4emweb.com/verify.asp?login=ajaweb&password=ajaweb&sendto=modelsearch&manufacturer=ROU&key1=ES-600
	//$(this).attr("href", "http://www.4emweb.com/verify.asp?login=ajaweb&password=ajaweb&sendto=modelsearch&manufacturer=ROU&key1=" + model);
	}
});

//Bind Omniture trackback events to all links classed as 'ExternalManual2' with a 'model' attribute
// (the "Controls" division uses these, necessary ONLY because of the different link name requirement).

var ExternalManualLinks = $("a.ExternalManual2");

ExternalManualLinks.click(function() {
	var model = $(this).attr("model");
	if (model)
	OmnitureExternalLink(model + " - Installation Information");
});
*/
////////////////////////////////////////////////////////

//Internal download trackback (DEFAULT)
//var s = s_gi('aspenms-ajantunes');
//s.linkTrackVars = 'prop3,eVar1,events';
//s.linkTrackEvents = 'event1';
//s.prop3 = 'LD-10 - Specs';
//s.eVar1 = 'LD-10 - Specs';
//s.events = 'event1';
//s.tl(this, 'd', 'LD-10 - Specs');

function OmnitureDownloadLink(linkName) {
	//alert("dl: " + linkName);

	var s = s_gi(omnitureProject);
	s.linkTrackVars = 'prop3,eVar1,events';
	s.linkTrackEvents = 'event1';
	s.prop3 = linkName;
	s.eVar1 = linkName;
	s.events = 'event1';
	s.tl(this, 'd', linkName); // 'd' for download

	//Clear out macro variables because of voodoo double-posting behavior
	s.pageName = s.channel = s.prop1 = s.prop2 = s.events = "";
}

//External link trackback (DEFAULT)
//var s=s_gi('aspenms-ajantunes');
//s.linkTrackVars='prop4,events';
//s.linkTrackEvents='event2';
//s.prop4='[LINK NAME]';
//s.events='event2';
//s.tl(this,'e','[LINK NAME]');"

/* Not being used anymore, per Sarah
function OmnitureExternalLink(linkName) {
	alert("ext: " + linkName);
	var s = s_gi(omnitureProject);
	s.linkTrackVars = 'prop4,events';
	s.linkTrackEvents = 'event2';
	s.prop4 = linkName;
	s.events = 'event2';
	s.tl(this, 'e', linkName); // 'e' for external
}*/

//External link trackback ('EM WEB' redirects in Resources menu and on Resources page)
//var s=s_gi('aspenms-ajantunes');
//s.linkTrackVars='prop4,events';
//s.linkTrackEvents='event10';
//s.prop4='[LINK NAME]';
//s.events='event10';
//s.tl(this,'e','[LINK NAME]');"

function OmnitureEMWebExternalLink() {
	//alert("emweb link");
	
	var s = s_gi(omnitureProject);
	s.linkTrackVars = 'prop4,events';
	s.linkTrackEvents = 'event10';
	s.prop4 = 'EM Web';
	s.events = 'event10';
	s.tl(this, 'e', 'EM Web'); // 'e' for external

	//Clear out macro variables because of voodoo double-posting behavior
	s.pageName = s.channel = s.prop1 = s.prop2 = s.events = "";
}
