/*
Process to build a decision wizard
1.	Copy the modified version of promo_dw.jsp into the store you are working in. This
	file is identical to the global promo .jsp except that the html wrapper and javascript
	has been removed.
2.	Copy the nessessary files needed for express shop into the store and follow
	the install specific guide for express shop for decision wizards as you continue
	this install of a decision wizard.
3. 	confirm web store service is setup in the specific environment and
	store or a proxy is in place to aviod cross-domain calls. Test The Service
	via a web browser to confirm it returning the proper data and format. Do this
	for skus, pids, express shop, and promos
4.	copy the following files into the store folder in the following structure:
		'store'
			css
				DF_DFT_main.css //optional css library
				PG_DFT_dw2.css //required decision wizard style sheet
				PG_DFT_tip.css //required if using tool tips
			js
				DF_DFT_main.js //required adds commonly used javascript
				LIB_drag.js //required for drag and drop or sliders
				LIB_ajax.js
				LIB_core.js
				LIB_move.js
				LIB_opacity.js
				LIB_size.js
				WIZ_DFT_Slider.js //required for sliders
				WIZ_DFT_tip.js //required if using tool tips
				WIZ_DFT_combo.js //required for sorting results
			images
				WIZ_DFT_dw //images specific to decision wizards
					*
			'decision wizard'
				expressShop.css //required for express shop
				expressShop.js //required for express shop
				config.js //this file
				utility.js //required for basic js extentions
				dw.js //required the heart of the filtering funtionality
				effects.js //required if you want to seperate effects from program logic
				index.jsp //required shell for the decision wizards application
				loader.js //required for loader
				views.js //required for seperation of product format
				promo_dw.jsp  //required if promotional info is used
5. 	modifiy the sku call in index.jsp
6.	edit markup, css, views, effects, and this config file to your liking
*/

dw.config= {

		//identifier for the application
		appId:'dw_ringfinder_cashmoney',

		//load all the service paths and default parameters used by the application
		services: {

			//gets the full data set for a product
			getPids:{
				href: '/svc/CatalogServices/ProductData',
				method:'get',
				pars: {
					format:'json',
					appId:'cpwmGF',
					catId:'3530061',
					stoken:'vBFX49FnL71kJhXcMhMj3g==',
					locale:'en_US',
					storeCode:'CPWM'
				}
			},

			//loads variables into the express shop call
			getExpressShop: {
				href:'../include/productDetails.jsp',
				pars: {
					catId:'3530061'
				}
			},

			//path to a modified promo jsp file
			getPromo: {
				method:'get',
				href:'promo_dw.jsp'
			},
/*
			//path to file to get images that are pad attribs that are not sending the url in the pad
			getPadImages: {
				method:'get',
				href:'/js/jeanfinder/padImages_dw.jsp'
			},
*/
			//path to a modified promo jsp file
			getMemory: {
				method:'get',
				href:'session.jsp'
			}
		},

		//its a shame i had to do this one but here it is. This function will take the skus
		//one by one and allow you to refactor them before the application parses them.
		//ie. you don't get what you need from the service.
		//example: taking the size attribute in the sku object and splicing it into
		//size and width attributes.

		refactorSku: function(sku) { 						// optional (false|function)
			if (sku.cpwmRecipient.indexOf(",") > -1) {
				sku.cpwmRecipient = sku.cpwmRecipient.split(",");
			}
			return sku;
		},

		//the attributes that will be used for filtering
		filters:[

			{
				//filter specific
				filter:'cpwmRecipient', //required ('sku attribute')
				displayName:'Recipient', //required ('string')
				displayType:'checkBox', //required ('checkBox'|'rangeSlider')
				info: false, //optional
				infoHeader:false,//optional
				//holderClass: 'scrolling', //optional ('class Name')
				loadState:'open', //required ('open'|'closed')
				retainScrollTop: false, //(true|false)

				//filter options specific
				//optionsFilter = filter
				//optionsFilterFn: function(s){return parseFloat(s)}, //optional (function) applyed to sorting only
				optionsDisplay:'cpwmRecipient', //required ('sku attribute')
				//optionsDisplayFn:function(s){return s.caps()}, //optional function
				optionsSortParameter:'filter', //optional - required if optionsSortFn is set ('filter'|'optionsDisplay')
				optionsSortFn:function(a){a.ascend('filter')} //optional function

			},

			{
				//filter specific

				filter:'price', //required ('sku attribute')
				displayName:'Price', //required ('string')
				displayType:'rangeSlider', //required ('checkBox'|'rangeSlider')
				info:false, //optional
				//holderClass: 'swatch', //optional ('class Name')
				loadState:'open', //required ('open'|'closed')
				retainScrollTop: false, //(true|false)
				//filter options specific
				//optionsFilter = filter
				optionsFilterFn: function(s){return parseFloat(s)}, //optional (function) applyed to sorting only
				optionsDisplay:'price', //required ('sku attribute')
				optionsDisplayFn:function(s){return s.dollars()}, //optional function
				optionsSortParameter:'filter',//, //optional - required if optionsSortFn is set ('filter'|'optionsDisplay')
				optionsSortFn:function(a){a.ascend('filter')} //optional function
			},

			{
				//filter specific
				filter:'cpwmOccasion', //required ('sku attribute')
				displayName:'Occasion', //required ('string')
				displayType:'checkBox', //required ('checkBox'|'rangeSlider')
				info:false, //optional
				//holderClass: 'scrolling', //optional ('class Name')
				loadState:'open', //required ('open'|'closed')
				retainScrollTop: false, //(true|false)

				//filter options specific
				//optionsFilter = filter
				//optionsFilterFn: function(s){return parseFloat(s)}, //optional (function) applyed to sorting only
				optionsDisplay:'cpwmOccasion', //required ('sku attribute')
				//optionsDisplayFn:function(s){return s.caps()}, //optional function
				optionsSortParameter:'filter', //optional - required if optionsSortFn is set ('filter'|'optionsDisplay')
				optionsSortFn:function(a){a.ascend('filter')} //optional function

			}
		],

		filterMemory: 600000*5, //(ms|false)

                filterPath: '/giftwizard',  //(root folder for dw|false)

		hideEmptyFilters: false, //(true|false)

		stickyFilters: true, //(true|false)

		displayClickOrder: false, //(true|false)

		//populate the dropdown list for sorting results (comment object for no sorters)
		//a = the list of skus in your result set. this set is used to build a unique list if pids.
		//first one is the load state and default view in the dropdown
		//available array sorters:
		//	a.DESC('parameter')
		//	a.ASC('parameter')
		//	a.custom callback function
		sorters: [
			//sorts results by rank
			{
				label:'Top Rated',
				fn:function(a){
					a.descend('averageRating')
				}
			},

			//sorts results by price ascending
			{
				label:'Price Low to High',
				fn:function(a){
					a.ascend('price')
				}
			},

			//sorts results by price desending
			{
				label:'Price High to Low',
				fn:function(a){
					a.descend('price')
				}
			}
		],

		//the way the results will be displayed
		views: [
			{
				min:0, //required (int) minimum filtered results needed to display product view
				displayFunction:views.pidDetail, //required (function) function called to display html of view - index and data is sent as parameters
				dragReplaceFunction:views.buildDragImagePidDetail, //required (function) function called to rewrite dragable action
				recSet: 12, //required (int) count of products to display for each page of the view
				recsPerLine: 4 //required (int) count of products to display for each line per page of the view

			}/*,

			{
				min:64, //required (int) minimum filtered results needed to display product view
				displayFunction:views.pidThumb, //required (function) function called to display html of view - index and data is sent as parameters
				dragReplaceFunction:views.buildDragImagePidThumb, //required (function) function called to rewrite dragable action
				recSet: 8 //required (int) count of products to display for each page of the view
			},

			{
				min:111, //required (int) minimum filtered results needed to display product view
				displayFunction:views.pidList, //required (function) function called to display html of view - index and data is sent as parameters
				dragReplaceFunction:views.buildDragImagePidList, //required (function) function called to rewrite dragable action
				recSet: 11 //required (int) count of products to display for each page of the view
			}*/
		],

		//function to display pagination
		paginationType: "reload", //required ("static"|"reload")
		paginationFn: views.buildPagination, //required (function)

		//function happens only the first time the application is viewed (cookie based)
		firstTimeLoad: false, //optional (false|function)

		//function happens every time the application is loaded
		everyTimeLoad: false, //optional (false|function)

		//path to prepend product images
		absPath: '',

		//comp grid
		//products to scroll at a time in the comp grid
		scrollItemsBy: 1, //(1|2|3)

		//flag for weather or not the compare attributes should come from product flags
		useCompareFlag: true,

		//attributes used in the comp grid value must be a pid level attribute
		compareAttributes: [
			//{filter: 'levisTTWaist', label: 'Waist', seq:-1}

		],


		compareAttributesSoringFn: function(a){
			a.ascend('seq')
		},

		stripUnusedAtts: true,

		//Express shop
		expressShop: false, //(true|false)
		addToCartSource: 'mens'
	}
