function Stats(){

    /** variable declarations */
    this.tags;
    this.current_environment;
    this.current_feature;
    this.settings = new Array;
    
    /** function declarations */
    this.init = init;
    this.send = send;
    this._doLoad = _doLoad;
    this._doClick = _doClick;
    this.setGlobals = setGlobals;
    this._setOmnitureTag = _setOmnitureTag;
    this._doOmniture = _doOmniture;

    this.init();
    
    /** get xml */
    function init(){
	jQuery.noConflict();
	jQuery.ajax({
	    type: "GET",
	    url: "./xml/tags.xml",
	    dataType: "xml",	    
	    success: function(data, text_status){		
		Stats.tags = data;
		Stats.setGlobals();
		//send HOME load
		//Stats.send('load', 'home');		
	    }
	});
    }


    /** main work method: set info and trigger omniture call */
    function send(type, feature, trigger){
	//get tags via a method depending on type
	var result;
	if(type == "load"){
	    result = this._doLoad(feature);
	} else if(type == "click"){
	    result = this._doClick(feature, trigger);
	}
	if(result){
	    this._doOmniture(type);
	}
    }

    /** record page load */
    function _doLoad(feature){
	jQuery(this.tags).find("loads tag[feature='"+feature+"']").each(function(){
	    Stats._setOmnitureTag(jQuery(this).attr('name'), jQuery(this).text());
	    Stats.current_environment = jQuery(this).attr('environment');
	    Stats.current_feature = jQuery(this).attr('feature');
	    return false; //break for each
	});
	return true;
    }

    /** record user click */
    function _doClick(feature, trigger){
	//if we don't know the feature, use the current feature.
	if(!feature){
	    feature = this.current_feature;
	}
	//get all click tags for this feature
	jQuery(this.tags).find("clicks tag[feature='"+feature+"']").each(function(){
	    //set tag IF trigger matches
	    xml_trigger = jQuery(this).attr('trigger');
	    if(xml_trigger.indexOf(trigger) != -1){
		name = jQuery(this).attr('name');
		value = jQuery(this).text();
		tag = xml_trigger;
		return false; //break for each
	    } else {
		tag = false;
		return true; //continue each
	    }
	});
	if(tag){
	    this._setOmnitureTag(name, value);
	    return true;
	} else {
		
	    return false;
	}
    }
    
    /** set global stats settings */
    function setGlobals(){	
	jQuery(this.tags).find('globals tag').each(function(){
	    Stats._setOmnitureTag(jQuery(this).attr('name'), jQuery(this).text());
	});	
    }
    
    /** tell omniture code to set a setting */
    function _setOmnitureTag(name, value){
	this.settings[name] = value;
    }

    /** tell omniture code to record load/click */
    function _doOmniture(type){
	s.visitorNamespace = this.settings['s.visitorNamespace'];
	s.prop10 = this.settings['s.prop10'];
	s.prop11 = this.settings['s.prop11'];
	s.channel = this.settings['s.channel'];
	s.pageName = this.settings['s.pageName'];

	if(type == "load"){	  
	    void(s.t());
	} else if(type == "click"){
	    void(s.tl());	    
	}
    }


}