/* 
 * Omniture clear variables
 * The comments are to express origination only.  These may be overwritten by other javascript calls.
 */ 
function invp_omniClear() {
    s.pageName="";	//set by omniture_page_code.jsp and can be cleared.
    s.channel="";  	//currently not used
    s.pageType=""; 	//currently not used
    s.prop1="";		//used in s_code.js and can be cleared.
    s.prop2="";		//used in s_code.js and can be cleared.
    s.prop3="";		//currently not used
    s.prop4="";		//currently not used
    s.prop5="";		//currently not used
    //s.prop6="";	//set by s_code.js and should not be cleared - Sets hour
    //s.prop7="";	//set by s_code.js and should not be cleared - Sets day
    //s.prop8="";	//set by s_code.js and should not be cleared - Sets Weekend / Weekday
    s.prop9="";		//used in s_code.js and can be cleared.
    s.prop10="";	//currently not used
    //s.prop11="";	//set by omniture_page_code.jsp and should not be cleared - Sets User Id
    //s.prop12="";	//set by omniture_page_code.jsp and should not be cleared - Sets User Name
    //s.prop13="";	//set by omniture_page_code.jsp and should not be cleared - Sets User Role
    //s.prop14="";	//set by omniture_page_code.jsp and should not be cleared - Sets User Franchise
    //s.prop15="";  //set by omniture linkhandler plugin
    s.prop16="";	//currently not used
    s.prop17="";	//currently not used
    //s.prop18="";  //set by omniture linkhandler plugin
    //s.prop19="";  //set by omniture linkhandler plugin
    s.prop20="";	
    s.prop21="";	
    s.prop22="";	
    s.prop23="";	
    s.prop24="";	
    s.prop25="";	
    s.prop26="";
    s.prop27="";	
    s.prop28="";	
    s.prop29="";	
    s.prop30="";	
    s.prop31="";	
    s.prop32="";		
    //s.hier1="";	//Disabled by Omniture per Marc Olsen - 4/21/2008		
    s.hier2="";			
    s.hier3="";			
    s.hier4="";		
    
    s.events="";
    s.products="";
    s.campaign="";
    s.eVar1="";
    s.eVar2="";
    s.eVar3="";
    s.eVar4="";
    //eVar5 - eVar10 automatically set and should not be cleared.
    //s.eVar11="";	//set by omniture_page_code.jsp and should not be cleared - Sets User Id
    //s.eVar12="";	//set by omniture_page_code.jsp and should not be cleared - Sets User Id
    //s.eVar13="";	//set by omniture_page_code.jsp and should not be cleared - Sets User Id
    //s.eVar14="";	//set by omniture_page_code.jsp and should not be cleared - Sets User Id
    s.eVar15="";
    s.eVar16="";
    s.eVar17="";
    s.eVar18="";
    s.eVar19="";
    s.eVar20="";
    s.eVar21="";
    s.eVar22="";
    s.eVar23="";
}

/* 
 * Log a standard Omniture link clicks
 * @argument event The click event
 * @argument name The name of the link or null
 * @argument products The complete products string variable contents
 * @argument vars Object containing props and eVars to modify (optional)
 */
function invp_omniLogClick(event, name, products, vars) {
    invp_omniClear();
    s.events = (event) ? event : "link";

    if (products) {
        s.products = products;
    }
    
    // Add/modify the s object with passed in values
    if (vars) {
        invp_extend(s, vars);
    }
    
    name = (name) ? name : "";
    s.tl(this, "o", name);
}

/* 
 * Log a standard Omniture link clicks
 * @argument name The name of the page or null
 * @argument channel - Site selections or null
 * @argument vars Object containing props and eVars to modify (optional)
 */
function invp_omniLogPage(name, channel, vars) {
    invp_omniClear();
    
    if (name) {
        s.pageName = name;
    }
    
    if (channel) {
        s.channel = channel;
    }
    
    if (vars) {
        invp_extend(s, vars);
    }
    
    s.t();
}

/*
 *	This is the same function as the JQuery function extend.
 */
function invp_extend() {
	var target = arguments[0], a = 1;
	
	if ( arguments.length == 1 ) {
		target = this;
		a = 0;
	}
	
	var prop;
	while (prop = arguments[a++]) {
		//alert(prop);
		for ( var i in prop ) {
			//alert(i + " " + prop[i]);
			target[i] = prop[i];
		}
	}	
	return target;
}	