// behr.js
// Behr's function used in the integration with Foresee


//
//
var pageViewsList=["Explore Color with ColorSmart","ultravcc","ppvcc","app_colorsmart","Store Locator",
                   "Browse Our Galleries", "Design Library", "Inspiration", "Explore How",
                   "Browse Our Products", "paint_world", "woodsmart"]; // literal array
var FSRTagList=["ExploreColorSmart","Ultravcc","PPvcc","AppColorsmart","StoreLocator",
                "BrowseGalleries", "DesignLibrary", "Inspiration", "ExploreHowTo",
                "BrowseProducts", "paint_world", "woodsmart"]; // this is a 1-to-1 relationship with pageViewsList
var loggedIn = "/workbook/project_summary.html";

function sendToFSR(list) {
  	if (list.length%2==0){
		for (var i=0;i<list.length;i+=2){
			if (list[i] == "DCS.dcsuri"){
			    // page views
				for (var j=0;j<pageViewsList.length;j++){
    	           if (list[i+1].indexOf(pageViewsList[j]) >= 0){
			          FSR.CPPS.set("Behr_"+FSRTagList[j], "Y");
			       }
                }

				if (list[i+1] == loggedIn) {
				    FSR.CPPS.set("Behr_LoggedIn", "Y");
				}
			} else if (list[i] == "WT.mc_id"){
			    // Campaign tag
				FSR.CPPS.set("Behr_CampaignId", list[i+1]);
			} else if (list[i] == "DCSext.cart_items") {
			    // number of cart items
				FSR.CPPS.set("Behr_NoCartItems", list[i+1]);
			}
		}
		// timezone
	    var dCurrent=new Date();
	    var wt_tz=parseInt(dCurrent.getTimezoneOffset()/60*-1)||"0";
	    FSR.CPPS.set("Behr_Timezone",wt_tz);
	}

}
