//-----------------------------------------------------------------
// Licensed Materials - Property of IBM
//
// WebSphere Commerce
//
// (C) Copyright IBM Corp. 2008, 2010 All Rights Reserved.
//
// US Government Users Restricted Rights - Use, duplication or
// disclosure restricted by GSA ADP Schedule Contract with
// IBM Corp.
//-----------------------------------------------------------------

/** 
 * @fileOverview This file provides the common render context variables and functions, 
 * and defines all the render contexts needed throughout the store.
 */

dojo.require("wc.render.common");

/** 
 * @class The CommonContextsJS class defines all the common variables and functions 
 * for the render contexts across all store pages.
 */
CommonContextsJS = {
	/**
	 * This variable stores the ID of the language that the store is currently using.
	 * @private
	 */
	langId: "-1",

	/**
	 * This variable stores the ID of the current store.
	 * @private
	 */	
	storeId: "",

	/**
	 * This variable stores the ID of the catalog that is used in the store.
	 * @private
	 */	
	catalogId: "",

	/** 
	 * Sets the common ids used in the store - language id, store id, and catalog id.
	 * 
	 * @param {string} langId The id of the store language.
	 * @param {string} storeId The id of the store.
	 * @param {string} langId The id of the catalog used in the store.
	 */
	setCommonParameters:function(langId,storeId,catalogId){
			this.langId = langId;
			this.storeId = storeId;
			this.catalogId = catalogId;
	},

	/** 
	 * Updates the specified context's property and assign it the desired value.
	 * 
	 * @param {string} contextId The id of the render context 
	 * @param {string} property The name of the context's property to update
	 * @param {string} value The value to update the specified property to
	 */
	setContextProperty:function(contextId,property,value){
		wc.render.getContextById(contextId).properties[property] = value;
	}

}

/**
 * Declares a new render context for Multiple Shipment Shipping & Billing display.
 */
wc.render.declareContext("multipleShipmentDetailsContext", {shipmentDetailsArea: "update"},""),

/**
 * Declares a new render context for Single Shipment Shipping Charge display.
 */
wc.render.declareContext("singleShipmentShipChargeContext", null,""),

/**
 * Declares a new render context for Multiple Shipment Shipping Charge display.
 */
wc.render.declareContext("multipleShipmentShipChargeContext", null,""),

/**
 * Declares a new render context for Single Shipment Shipping & Billing display.
 */
wc.render.declareContext("traditionalShipmentDetailsContext",{shipmentDetailsArea: "update"},""),

/**
 * Declares a new render context for the Current Order Totals display.
 */
wc.render.declareContext("currentOrder_Context",null,""),

/**
 * Declares a new render context for creating/editing the shipping address
 * and initializes it with the shipping address id and address type to the default placeholder values.
 */
wc.render.declareContext("editShippingAddressContext",{shippingAddress: "0",addressType: "ShippingAndBilling"},"","Main"),

/**
 * Declares a new render context for the select Billing Address dropdowns,
 * and initializes each Billing Address dropdown with address id and billing url placeholders.
 * Even though BillingURL1, 2, 3 point to same BillingAddressDropDisplay.jsp we cannot use only one URL to submit 3 requests.
 * There are 3 billing dropdown boxes in the Checkout page and all needs to be refreshed on address add/change.
 * But using the same URL and submitting 3 requests separately to refresh 3 dropdown boxes doesn't work, 
 * and invariably one of the request doesn't come back with response. Solution is to use 3 different URLs as a workaround.
 * BillingURL1,2,3 are set to correct <c:url values in .JSP page using setContextPRoperty method..
 */
wc.render.declareContext("billingAddressDropDownBoxContext",{billingAddress1: "0", billingAddress2: "0", billingAddress3: "0", billingURL1: "",billingURL2:"",billingURL3:"",areaNumber:'0',payment1: "", payment2: "", payment3: "", paymentTCId1: "", paymentTCId2: "", paymentTCId3: ""},""),

/**
 * Declares a new render context for showing/hiding the address form on the Checkout pages,
 * and initializes the show and hide area to a placeholder value.  
 */
wc.render.declareContext("contextForMainAndAddressDiv",{showArea: "0",hideArea: "0"},""),

/**
 * Declares a new render context for showing/hiding the address form on the Checkout pages,
 * and initializes the show and hide area to a placeholder value.  
 */
wc.render.declareContext("contextForMainAndAddressDivNew",{showArea: "0",hideArea: "0"},""),

/**
 * Declares a new render context for the select Shipping Address dropdown.
 */
wc.render.declareContext("shippingAddressDropDownBoxContext",null,""),

/**
 * Declares a new render context for the select Shipping Address dropdown.
 */
wc.render.declareContext("shippingAddressDropDownBoxContextNew",null,""),

/**
 * Declares a new render context for the Mini Shopping Cart.
 */
wc.render.declareContext("MiniShoppingCartContext",null,""),

/**
 * Declares a new render context for the Mini Shopping Cart dropdown contents.
 */
wc.render.declareContext("MiniShopCartDropDownContext",null,""),

/**
 * Declares a new render context for the Category display with pagination.
 */
wc.render.declareContext("CategoryDisplay_Context",{pageView:"", beginIndex:""},""),

/**
 * Declares a new render context for the Sub-category display with pagination.
 */
wc.render.declareContext("SubCategoryDisplay_Context",null,""),

/**
 * Declares a new render context for the Wishlist display,
 * and initializes it with the post URL to load. 
 */
wc.render.declareContext("WishlistDisplay_Context",{url:""},""),

/**
 * Declares a new render context for the Shared Wishlist display,
 * and initializes it with the post URL to load. 
 */
wc.render.declareContext("SharedWishlistDisplay_Context",{url:""},""),

/**
 * Declares a new render context for Shopping Cart with pagination,
 * and initializes it with the beginning index value. 
 */
wc.render.declareContext("ShopCartPaginationDisplay_Context",{},""),
/**
* Declares a new render context for Pending order details page with pagination,
* and initializes it with the beginning index value. 
*/
wc.render.declareContext("PendingOrderPaginationDisplay_Context",{},""),
/**
* Declares a new render context for the pending order details page with pagination,
* and initializes it with the beginning index value. 
*/
wc.render.declareContext("PendingOrderDisplay_Context",{beginIndex: "0"},""),

/**
 * Declares a new render context for Single Shipment Order Summmary/Confirmation with pagination,
 * and initializes it with the beginning index value. 
 */
wc.render.declareContext("OrderItemPaginationDisplay_Context",{beginIndex: "0"},""),

/**
 * Declares a new render context for the Order Status Details with pagination,
 * and initializes it with the beginning index value. 
 */
wc.render.declareContext("OrderDetailPaginationDisplay_Context",{beginIndex: "0"},""),

/**
 * Declares a new render context for Multiple Shipment Order Summary/Confirmation with pagination,
 * and initializes it with the beginning index value.
 */
wc.render.declareContext("MSOrderItemPaginationDisplay_Context",{beginIndex: "0"},""),

/**
 * Declares a new render context for the Coupon Wallet display.
 */
wc.render.declareContext("CouponDisplay_Context",null,""),
/**
 * Declares a new render context for the Promotion Choice of free gifts pop-up display.
 */
wc.render.declareContext("PromotionFreeGifts_Context",null,""),

/**
 *  Declares a new render context for the saved orders list.
 */
wc.render.declareContext("ListOrdersDisplay_Context",{startNumber: "0"},""),

/**
 * Declares a new render context for the scheduled orders status display.
 */
wc.render.declareContext("ScheduledOrdersStatusDisplay_Context",{beginIndex: "0", selectedTab: "Scheduled"},""),

/**
 * Declares a new render context for the processed orders status display.
 */
wc.render.declareContext("ProcessedOrdersStatusDisplay_Context",{beginIndex: "0", selectedTab: "PreviouslyProcessed"},""),

/**
 * Declares a new render context for the waiting-for-approval orders status display.
 */
wc.render.declareContext("WaitingForApprovalOrdersStatusDisplay_Context",{beginIndex: "0", selectedTab: "WaitingForApproval"},""),

/**
 * Declares a new render context for the Browsing History Espot.
 */
wc.render.declareContext("BrowsingHistoryContext",{status:"init"},""),

/**
 * Declares a new render context for the Browsing History Display in My Account.
 */
wc.render.declareContext("BrowsingHistoryDisplay_Context",{currentPage: "0", pageView: ""},""),

/**
 * Declares a new render context for the subscription display area on category pages.
 */
wc.render.declareContext("CategorySubscriptionContext",null,""),

/**
 * Declares a new render context for the Quick View display on category pages.
 */
wc.render.declareContext("QuickView_Context",null,""),

/**
 * Declares a new render context for the Overlay display.
 */
wc.render.declareContext("OverLay_Context",null,"")
