var ln_omniture = new Class({
    Implements: [Options, Events],
    options: {
        omni_data: {}
    },
    initialize: function(options){
        this.setOptions(options);

		this.options.omni_data.pageName = ($defined(this.options.pageName)) ? this.options.pageName : '';
		this.options.omni_data.channel = ($defined(this.options.channel)) ? this.options.channel : '';
		this.options.omni_data.pageType = ($defined(this.options.pageType)) ? this.options.pageType : '';
		this.options.omni_data.prop1 = ($defined(this.options.prop1)) ? this.options.prop1 : '';
		this.options.omni_data.prop2 = ($defined(this.options.prop2)) ? this.options.prop2 : '';
		this.options.omni_data.prop3 = ($defined(this.options.prop3)) ? this.options.prop3 : '';
		this.options.omni_data.prop4 = ($defined(this.options.prop4)) ? this.options.prop4 : '';
		this.options.omni_data.prop5 = ($defined(this.options.prop5)) ? this.options.prop5 : '';
		this.options.omni_data.prop6 = ($defined(this.options.prop6)) ? this.options.prop6 : '';
		this.options.omni_data.prop7 = ($defined(this.options.prop7)) ? this.options.prop7 : '';
		this.options.omni_data.prop8 = ($defined(this.options.prop8)) ? this.options.prop8 : '';
		this.options.omni_data.prop9 = ($defined(this.options.prop9)) ? this.options.prop9 : '';
		this.options.omni_data.prop10 = ($defined(this.options.prop10)) ? this.options.prop10 : '';
		this.options.omni_data.prop11 = ($defined(this.options.prop11)) ? this.options.prop11 : '';
		this.options.omni_data.prop12 = ($defined(this.options.prop12)) ? this.options.prop12 : '';
		this.options.omni_data.prop13 = ($defined(this.options.prop13)) ? this.options.prop13 : '';
		this.options.omni_data.prop14 = ($defined(this.options.prop14)) ? this.options.prop14 : '';
		this.options.omni_data.prop15 = ($defined(this.options.prop15)) ? this.options.prop15 : '';
		this.options.omni_data.prop16 = ($defined(this.options.prop16)) ? this.options.prop16 : '';
		this.options.omni_data.prop17 = ($defined(this.options.prop17)) ? this.options.prop17 : '';
		this.options.omni_data.prop18 = ($defined(this.options.prop18)) ? this.options.prop18 : '';
		this.options.omni_data.prop19 = ($defined(this.options.prop19)) ? this.options.prop19 : '';		
		this.options.omni_data.prop20 = ($defined(this.options.prop20)) ? this.options.prop20 : '';		
		this.options.omni_data.prop21 = ($defined(this.options.prop21)) ? this.options.prop21 : '';		
		this.options.omni_data.prop22 = ($defined(this.options.prop22)) ? this.options.prop22 : '';		
		this.options.omni_data.prop23 = ($defined(this.options.prop23)) ? this.options.prop23 : '';		
		this.options.omni_data.prop24 = ($defined(this.options.prop24)) ? this.options.prop24 : '';		
		this.options.omni_data.prop25 = ($defined(this.options.prop25)) ? this.options.prop25 : '';		
		this.options.omni_data.prop26 = ($defined(this.options.prop26)) ? this.options.prop26 : '';		
		this.options.omni_data.prop27 = ($defined(this.options.prop27)) ? this.options.prop27 : '';		
		this.options.omni_data.prop28 = ($defined(this.options.prop28)) ? this.options.prop28 : '';		
		this.options.omni_data.prop29 = ($defined(this.options.prop29)) ? this.options.prop29 : '';	
        this.options.omni_data.prop30 = ($defined(this.options.prop30)) ? this.options.prop30 : '';
        this.options.omni_data.prop31 = ($defined(this.options.prop31)) ? this.options.prop31 : '';
        this.options.omni_data.prop32 = ($defined(this.options.prop32)) ? this.options.prop32 : ''; 			
		this.options.omni_data.campaign = ($defined(this.options.campaign)) ? this.options.campaign : '';
		this.options.omni_data.state = ($defined(this.options.state)) ? this.options.state : '';
		this.options.omni_data.zip = ($defined(this.options.zip)) ? this.options.zip : '';
		this.options.omni_data.events = ($defined(this.options.events)) ? this.options.events : '';
		this.options.omni_data.products = ($defined(this.options.products)) ? this.options.products : '';
		this.options.omni_data.purchasID = ($defined(this.options.purchaseID)) ? this.options.purchaseID : '';
		this.options.omni_data.eVar1 = ($defined(this.options.eVar1)) ? this.options.eVar1 : '';
		this.options.omni_data.eVar2 = ($defined(this.options.eVar2)) ? this.options.eVar2 : '';
		this.options.omni_data.eVar3 = ($defined(this.options.eVar3)) ? this.options.eVar3 : '';
		this.options.omni_data.eVar4 = ($defined(this.options.eVar4)) ? this.options.eVar4 : '';
		this.options.omni_data.eVar5 = ($defined(this.options.eVar5)) ? this.options.eVar5 : '';
		this.options.omni_data.eVar6 = ($defined(this.options.eVar6)) ? this.options.eVar6 : '';
		this.options.omni_data.eVar7 = ($defined(this.options.eVar7)) ? this.options.eVar7 : '';
		this.options.omni_data.eVar8 = ($defined(this.options.eVar8)) ? this.options.eVar8 : '';
		this.options.omni_data.eVar9 = ($defined(this.options.eVar9)) ? this.options.eVar9 : '';
		this.options.omni_data.eVar10 = ($defined(this.options.eVar10)) ? this.options.eVar10 : '';
		this.options.omni_data.eVar11 = ($defined(this.options.eVar11)) ? this.options.eVar11 : '';
		this.options.omni_data.eVar12 = ($defined(this.options.eVar12)) ? this.options.eVar12 : '';
		this.options.omni_data.eVar13 = ($defined(this.options.eVar13)) ? this.options.eVar13 : '';
		this.options.omni_data.eVar14 = ($defined(this.options.eVar14)) ? this.options.eVar14 : '';
		this.options.omni_data.eVar15 = ($defined(this.options.eVar15)) ? this.options.eVar15 : '';
		this.options.omni_data.eVar16 = ($defined(this.options.eVar16)) ? this.options.eVar16 : '';
		this.options.omni_data.eVar17 = ($defined(this.options.eVar17)) ? this.options.eVar17 : '';
		this.options.omni_data.eVar18 = ($defined(this.options.eVar18)) ? this.options.eVar18 : '';
		this.options.omni_data.eVar19 = ($defined(this.options.eVar19)) ? this.options.eVar19 : '';
		this.options.omni_data.eVar20 = ($defined(this.options.eVar20)) ? this.options.eVar20 : '';
		this.options.omni_data.eVar21 = ($defined(this.options.eVar21)) ? this.options.eVar21 : '';		
		this.options.omni_data.eVar22 = ($defined(this.options.eVar22)) ? this.options.eVar22 : '';
		this.options.omni_data.eVar23 = ($defined(this.options.eVar23)) ? this.options.eVar23 : '';
		this.options.omni_data.eVar24 = ($defined(this.options.eVar24)) ? this.options.eVar24 : '';
		this.options.omni_data.eVar25 = ($defined(this.options.eVar25)) ? this.options.eVar25 : '';
		this.options.omni_data.eVar26 = ($defined(this.options.eVar26)) ? this.options.eVar26 : '';
		this.options.omni_data.eVar27 = ($defined(this.options.eVar27)) ? this.options.eVar27 : '';
		this.options.omni_data.eVar28 = ($defined(this.options.eVar28)) ? this.options.eVar28 : '';			
		this.options.omni_data.eVar29 = ($defined(this.options.eVar29)) ? this.options.eVar29 : '';			
		this.options.omni_data.eVar30 = ($defined(this.options.eVar30)) ? this.options.eVar30 : '';			
		this.options.omni_data.eVar31 = ($defined(this.options.eVar31)) ? this.options.eVar31 : '';			
		this.options.omni_data.eVar32 = ($defined(this.options.eVar32)) ? this.options.eVar32 : '';	
        this.options.omni_data.eVar33 = ($defined(this.options.eVar33)) ? this.options.eVar33 : '';
        this.options.omni_data.eVar34 = ($defined(this.options.eVar34)) ? this.options.eVar34 : '';
        this.options.omni_data.eVar35 = ($defined(this.options.eVar35)) ? this.options.eVar35 : '';
        this.options.omni_data.eVar36 = ($defined(this.options.eVar36)) ? this.options.eVar36 : ''; 
        this.options.omni_data.eVar37 = ($defined(this.options.eVar37)) ? this.options.eVar37 : '';        
        this.options.omni_data.eVar38 = ($defined(this.options.eVar38)) ? this.options.eVar38 : '';        
		this.options.omni_data.linkTrackVars = ($defined(this.options.linkTrackVars)) ? this.options.linkTrackVars : '';
		this.options.omni_data.linkTrackEvents = ($defined(this.options.linkTrackEvents)) ? this.options.linkTrackEvents : '';
		
    },
	map_to_s: function(embedded) {
		$each(this.options.omni_data, function(value, key){
			if ((s[key] != null) && (value != '')) {
				if ( ($defined(embedded)) && (s[key] != '') ) {
					s[key] += ',' + value;
				} else  {
					s[key] = value;
				}
			}
		});
	},
    send_to_omniture: function() {
        this.map_to_s();
        s.t();
    },
    send_to_omniture_tl: function(linkElement, description) {
        this.map_to_s(true);
        if(description) {
            s.tl(this, 'o', description);
        }
        else {
            s.tl(this, 'o', 'Buy Now Button');
        }
    },
    send_to_omniture_sl: function(inTable) {
        this.map_to_s(true);
        s.tl(this, 'o', inTable + ' Table Link to EDP');
    },
    show_s: function() {
        LIVENATION.global.log(s);
    }
});

/**
 *  Begin code for click tracking of Post a Review button. This code is here because the Post a Review button
 *  can appear on many pages.
 */ 
var imgParent = $$('img.post_review').getParent();
imgParent.addEvent('click', function(e) {
    // Stop the execution of the onclick event in order to complete the omniture link tracking contained 
    // in the function trackPostReviews
    e.stop();
	trackPostReviews(imgParent);
}.bind(this));

trackPostReviews = function(imgParent) {
    var s=s_gi(s_account);
    s.linkTrackVars='prop3';
    s.prop3='Step 1 - click Post a Review button'; 
    s.tl(true,'o','Post a Review Button');
}
/**
 *  End code for click tracking of Post a Review button
 */

LIVENATION.omniture = new Class({
    accepted_properties: ['pageName','channel','pageType','prop1','prop2','prop3',
            'prop4','prop5','prop6','prop7','prop8','prop9','prop10','prop11','prop12','prop13',
            'prop14','prop15','prop16','prop17','prop18','prop19','prop20','prop21','prop22',
            'prop23','prop24','prop25','prop26','prop27','prop28','prop29','prop30','prop31','prop32','purchaseID','campaign',
            'state','zip','events','products','purchasID','eVar1','eVar2','eVar3','eVar4',
            'eVar5','eVar6','eVar7','eVar8','eVar9','eVar10','eVar11','eVar12','eVar13','eVar14',
            'eVar15','eVar16','eVar17','eVar18','eVar19','eVar20','eVar21','eVar22','eVar23','eVar24',
            'eVar25','eVar26','eVar27','eVar28','eVar29','eVar30','eVar31','eVar32','eVar33','eVar34',
            'eVar35','eVar36','eVar37','eVar38','linkTrackVars','linkTrackEvents'],
    initialize: function(){
        _self = this;/*
        this commented code can be uncommented to provide for a JavaScript-only implementation of Omniture
        _self.accepted_properties.each(function(value, index){
            if($type(LIVENATION.registry.omniture[value]) == 'string'){
                s[value] = LIVENATION.registry.omniture[value];
            } else {
                s[value] = ''; // set to blank if not specified
            }
        });
        self.send();*/
    },
    send: function(property_hash, /*optional*/ anchor, /*optional*/ link_name){
        var _self = this;
        if (anchor && anchor.get && anchor.get('tag') === 'a'){
            s.linkTrackVars = '';
            s.linkTrackEvents='None'; 
            $each(property_hash, function(value, key){
                if(_self.accepted_properties.contains(key)){
                    s[key] = value;
                    s.linkTrackVars += key + ',';
                }
            });
            s.tl(anchor,'o', link_name);
        } else {
            $each(property_hash, function(value, key){
                if(_self.accepted_properties.contains(key)){
                    s[key] = value;
                }
            });
            s.t();
        }
    }
});

LIVENATION.instances.omniture = new LIVENATION.omniture;

Element.implement({
    add_omniture_clicktracking: function(property_hash, /*optional*/ link_name){
        if(this.get('tag') === 'a'){
            var click_handler = function(e){
                e.stopPropagation();
                LIVENATION.instances.omniture.send(property_hash, this, link_name);
            }
            this.addEvent('click', click_handler);
        }
    }
});
