
function OmnitureClass(){};

OmnitureClass.prototype.max_selected_qty = new Array();
OmnitureClass.prototype.selected_tabs = new Array();
OmnitureClass.prototype.accountName = '';
OmnitureClass.prototype.productCode = '';
OmnitureClass.prototype.event_queue = new Array();

OmnitureClass.prototype.addEventToQueue = function(method_name){
    this.event_queue.push(method_name);
}

OmnitureClass.prototype.executeQueueEvents = function(){
    for(i=0;i < this.event_queue.length;i++){
	eval(this.event_queue[i]);
    }
    this.event_queue = new Array();
}

OmnitureClass.prototype.trackAddToBag = function(barcode,addedFrom) {
    var s=s_gi(this.accountName);
    s.linkTrackVars='products,events,eVar28';
    s.linkTrackEvents='scAdd';
    s.events='scAdd';
    s.eVar28=addedFrom;
    s.products=';' + this.productCode  + ';;;;evar5=' + barcode;
    s.tl(this,'o','Cart Additions');
};

OmnitureClass.prototype.handleEmailToMe = function(){
    var s=s_gi(this.accountName);
    s.linkTrackVars='products,events';
    s.linkTrackEvents='event5';
    s.events='event5';
    s.products=';' + this.productCode;
    s.tl(this,'o','E-mail Me');
};

OmnitureClass.prototype.handleNewslleter = function(){
    if(document.getElementById('f-mailinglist').checked){
	var s=s_gi(this.accountName);
	s.linkTrackVars='eVar9,events';
	s.linkTrackEvents='event7';
	s.events='event7';
	s.eVar9='Checkout Page'; 
	s.tl(this,'o','Sign To Newsletter');
    }
};

OmnitureClass.prototype.handlePopup = function(popupName){
    var s=s_gi(this.accountName);
    s.linkTrackVars='eVar10,events';
    s.linkTrackEvents='event8';
    s.events='event8';
    s.eVar10=popupName; 
    s.tl(this,'o','Popup');
};

OmnitureClass.prototype.sendErrorsFromForm = function(pageName, formName, elementError){
    s.sendFormEvent('e', pageName, formName, elementError);
};

OmnitureClass.prototype.omniSendFormSuccess = function(pageName, formName){
    s.sendFormEvent('s', pageName, formName);
};

OmnitureClass.prototype.omniHandleNOSItem = function(){
    var s=s_gi(this.accountName);
    s.linkTrackVars='products,events';
    s.linkTrackEvents='event9';
    s.events='event9';
    s.products=';' + this.productCode;
    s.tl(this,'o','Unavailable Nos Item');
};

OmnitureClass.prototype.trackNavigation = function(navigatedFrom){
    var s=s_gi(this.accountName);
    s.linkTrackVars='events,eVar29';
    s.linkTrackEvents='event14';
    s.events='event14';
    s.eVar29=navigatedFrom;
    s.tl(this,'o','Navigation');
};

OmnitureClass.prototype.trackHeaderNavigation = function(){
    this.trackNavigation('Header');
    return true;
};

OmnitureClass.prototype.trackLeftNavigation = function(){
    this.trackNavigation('Left Navigation');
    return true;
};

OmnitureClass.prototype.trackDropdownNavigation = function(){
    this.trackNavigation('Dropdown');
    return true;
};

OmnitureClass.prototype.trackImageBanner = function(){
    this.trackNavigation('Image Banner');
    return true;
}

OmnitureClass.prototype.trackFlashBanner = function(){
    this.trackNavigation('Flash Banner');
    return true;
}

OmnitureClass.prototype.trackQuantityDropdown = function(selectedValue,barcode){
    this.max_selected_qty[barcode] = this.max_selected_qty[barcode] || 0;
    if (this.max_selected_qty[barcode] < parseInt(selectedValue)) {	
	this.max_selected_qty[barcode] = selectedValue;

	var s=s_gi(this.accountName);
	s.linkTrackVars='products,events,eVar27';
	s.linkTrackEvents='event34';
	s.events='event34';
	s.eVar27=this.max_selected_qty[barcode];
	s.products=';' + this.productCode + ';;;;evar5=' + barcode;
	s.tl(this,'o','Maximum Qty Selected');
    }
    return true;
};

OmnitureClass.prototype.trackItemPageTabs = function(selectedTab){
    if( this.selected_tabs.indexOf(selectedTab)<0 ) {
        this.selected_tabs.push(selectedTab);

	var s=s_gi(this.accountName);
	s.linkTrackVars='products,events,eVar32';
	s.linkTrackEvents='event35';
	s.events='event35';
	s.eVar32=selectedTab;
	s.products=';' + this.productCode;
	s.tl(this,'o','Item Tab Clicked');
    }
    return true;
};

OmnitureClass.prototype.startWatchingVideo = function(videoTitle,videoType){
    this.watchingVideoImplementation(videoTitle,videoType,'event37','Started Watching Video');
};

OmnitureClass.prototype.finishWatchingVideo = function(videoTitle,videoType){
    this.watchingVideoImplementation(videoTitle,videoType,'event38','Finished Watching Video');
};

OmnitureClass.prototype.watchingVideoImplementation = function(videoTitle,videoType,event,trackLinkMessage){
    var s=s_gi(this.accountName);
    s.linkTrackVars='events,eVar35,eVar36';
    s.linkTrackEvents=event;
    s.events=event;
    s.eVar35=videoTitle;
    s.eVar36=videoType;
    s.tl(this,'o',trackLinkMessage);
};

OmnitureClass.prototype.abFix = function () {
    if(s.fa && s.fa.vu) {
	s[s.fa.vu]='';
	s.fa.va[0]='';
	s.fa.va[3]='';
    }
    return true;
}

var Omniture = new OmnitureClass;
