
var CoutureClass = Class.create();

CoutureClass.prototype = {

  initialize: function() { },

layeredPopup: {
		dragger:null,
		hiddenDropDowns:null,
		effects:null,
		isOpen:false,
		popupId:"",
		
		/**
		 * layeredPopups can have different styles.  Each object within styles contains everything required to display differently.
		 * 
		 * @author Byung Kim
		 * @date 1/8/2008
		 */
		styles : {

			/**
			 * commonTemplates contains templates that are common to all styles
			 * 
			 * @author Byung Kim
			 * @date 1/8/2008
			 */
			commonTemplates : {
				iFrameContentTemplate : new Template('<iframe id="#{id}PopupContent" name="#{id}PopupContent" src="#{src}" class="content" style="width:#{width}px;height:#{height}px;" frameborder="0"></iframe>'),
				markupContentTemplate : new Template('<div id="#{id}PopupContent" class="content" style="width:#{width}px;height:#{height}px;">#{content}</div>'),
				closeAnchorTemplate : new Template('<a href="#" onclick="return coutureLib.layeredPopup.closeLayeredPopup();">#{text}</a>'),
				universalCloseButtonTemplate : new Template('<img src="/assets/common/clear.gif" alt="#{altText}" class="universalButtonSprite universalButtonSpriteCloseWindowOn"/>')
			},
			
			/**
			 * brandedPopup is a style type for layeredPopup display
			 * 
			 * @author Byung Kim
			 * @date 1/8/2008
			 */
			brandedPopup : {
				constants : brandConst,
				templates : {
					mainTemplate : new Template(
						'<div id="popupMain" style="width:#{totalWidth}px;">' +
							'<div class="topBorder clearfix">' +
								'<div class="topLeftCorner"></div>' +
								'<div id="layeredPopup#{topId}FrameTop" class="topMiddle#{topClass}" style="width:#{topWidth}px;">#{title}</div>' +
								'<div class="topCloseButton"><a href="#" onclick="return coutureLib.layeredPopup.closeLayeredPopup();">&#160;</a></div>' +
								'<div class="topRightCorner"></div>' +
							'</div>' +
							'<div class="mainContent clearfix">' +
								'<div class="leftBar" style="height:#{borderHeight}px;"></div>' +
								'#{content}' +
								'<div class="rightBar" style="height:#{borderHeight}px;"></div>' +
							'</div>' +
							'<div class="bottom clearfix ">' +
								'<div class="bottomLeftCorner"></div>' +
								'<div class="bottomMiddle" style="width:#{innerContentWidth}px;">#{bottonCloseButton}</div>' +
								'<div class="bottomRightCorner"></div>' +
							'</div>' +
						'</div>'
					)
				},
				
				/**
				 * getMarkup returns the markup for brandedPopup styled popups
				 * 
				 * @author Byung Kim
				 * @date 1/8/2008
				 */
				getMarkup:function(useIFrame, width, height, title, strContent, id) {
					var constants = this.constants;
					var templates = this.templates;
					var commonTemplates = coutureLib.layeredPopup.styles.commonTemplates;
					var topId = ""
					var topClass = "";
					var content = "";
					var bottomCloseButton = (brandConst.LAYERED_POPUP_CLOSE_COPY != "" ? commonTemplates.closeAnchorTemplate.evaluate({copy:brandConst.LAYERED_POPUP_CLOSE_COPY}) : "");
					var topTitle = brandConst.LAYERED_POPUP_BRAND_NAME + (title && title != "" ? " - " + title : "");
					if (!topTitle || topTitle == "") topTitle = "&#160;";

					var innerContentWidth = width - constants.LAYERED_POPUP_SIDE_IMAGE_WIDTH;
					var borderHeight = height + constants.LAYERED_POPUP_CONTENT_COMBINED_BORDER_HEIGHT;
		
					if (useIFrame) {
						topId = "NoDrag";
						content = commonTemplates.iFrameContentTemplate.evaluate({
							id:id,
							src:gidLib.addCurrentDomain(strContent),
							width:innerContentWidth,
							height:height
						});
					} else {
						topClass = " cursorMove";
						content = commonTemplates.markupContentTemplate.evaluate({
							id:id,
							content:strContent,
							width:innerContentWidth,
							height:height
						});
					}
		
					return templates.mainTemplate.evaluate({
						topId:topId,
						topClass:topClass,
						totalWidth:width+constants.LAYERED_POPUP_COMBINED_BORDER_WIDTH+constants.LAYERED_POPUP_CONTENT_COMBINED_BORDER_WIDTH+constants.LAYERED_POPUP_SHADOW_WIDTH,
						topWidth:width-constants.LAYERED_POPUP_MAIN_WIDTH_OFFSET,
						innerContentWidth:innerContentWidth,
						borderHeight:borderHeight,
						title:topTitle,
						content:content,
						bottomCloseButton:bottomCloseButton
					});
				}
			},
			
			/**
			 * universalPopup is a style type for layeredPopup display
			 * 
			 * @author Byung Kim
			 * @date 1/8/2008
			 */
			universalPopup : {
				constants : {
					LAYERED_POPUP_COMBINED_BORDER_WIDTH: 21, // left and right border combined widths
					LAYERED_POPUP_COMBINED_BORDER_HEIGHT: 59, // top and bottom border combined heights 
					LAYERED_POPUP_MAIN_WIDTH_OFFSET:19 // close window button width
				},
				templates : {
					mainTemplate : new Template(
						'<div id="popupMain" class="universalLayeredPopup" style="width:#{popupWidth}px;">' +
							'<div class="topBorder clearfix">' +
								'<div class="pop-sprites topLeftCorner"></div>' +
								'<div id="layeredPopup#{topId}FrameTop" class=" pop-sprites topMiddle#{topClass}" style="width:#{topWidth}px;">#{title}</div>' +
								'<div class="topCloseButton">#{topCloseButton}</div>' +
								'<div class="pop-sprites topRightCorner"></div>' +
							'</div>' +
							'<div class="mainContent clearfix">' +
								'<div class="leftBar" style="height:#{borderHeight}px;"></div>' +
								'#{content}' +
								'<div class="rightBar" style="height:#{borderHeight}px;"></div>' +
							'</div>' +
							'<div class="bottom clearfix ">' +
								'<div class="pop-sprites bottomLeftCorner"></div>' +
								'<div class="pop-sprites bottomMiddle" style="width:#{innerContentWidth}px;"></div>' +
								'<div class="pop-sprites bottomRightCorner"></div>' +
							'</div>' +
						'</div>'
					)
				},

				/**
				 * getMarkup returns the markup for universalPopup styled popups
				 * 
				 * @author Byung Kim
				 * @date 1/8/2008
				 */
				getMarkup:function(useIFrame, width, height, title, strContent, id) {
					var constants = this.constants;
					var templates = this.templates;
					var commonTemplates = coutureLib.layeredPopup.styles.commonTemplates;
					var topId = ""
					var topClass = "";
					var content = "";
					var topCloseButton = commonTemplates.closeAnchorTemplate.evaluate({text:commonTemplates.universalCloseButtonTemplate.evaluate({path:brandConst.UNIVERSAL_BUTTON_CONTENT_PATH,altText:resourceBundleValues.infoPopupsAltTextClose })});
					var topTitle = title;
					if (!topTitle || topTitle == "") topTitle = "&#160;";
		
					if (useIFrame) {
						topId = "NoDrag";
						content = commonTemplates.iFrameContentTemplate.evaluate({
							id:id,
							src:gidLib.addCurrentDomain(strContent),
							width:width,
							height:height
						});
					} else {
						topClass = " cursorMove";
						content = commonTemplates.markupContentTemplate.evaluate({
							id:id,
							content:strContent,
							width:width,
							height:height
						});
					}
		
					return templates.mainTemplate.evaluate({
						popupWidth:width + constants.LAYERED_POPUP_COMBINED_BORDER_WIDTH,
						topId:topId,
						topClass:topClass,
						topWidth:width-constants.LAYERED_POPUP_MAIN_WIDTH_OFFSET,
						innerContentWidth:width,
						borderHeight:height,
						title:topTitle,
						content:content,
						topCloseButton:topCloseButton
					});
				}
			},
			
			/**
			 * universalPanel is a style type for layeredPopup display
			 * 
			 * @author Byung Kim
			 * @date 1/8/2008
			 */
			universalPanel : {
				constants : {
					PANEL_COMBINED_BORDER_WIDTH: 14, // left and right border combined widths
					PANEL_MAIN_WIDTH_OFFSET:27, // to calculate the main width from the content width
					PANEL_TITLE_WIDTH_OFFSET:50 // to calculate the title width
				},
				templates : {
					mainTemplate : new Template(
						'<div id="popupMain" class="universalPanel" style="width:#{mainWidth}px;">' +
							'<div class="row top clearfix" style="width:#{topBottomWidth}px;">' +
								'<div class="pop-sprites topLeft">&#160;</div>' +
								'<div class="pop-sprites topCenter" style="width:#{topBottomCenterWidth}px;">&#160;</div>' +
								'<div class="pop-sprites topRight">&#160;</div>' +
							'</div>' +
							'<div class="row">' +
								'<div class="leftCenter clearfix" style="width:#{leftCenterWidth}px;">' +
									'#{calloutLeft}' +
									'<div class="rightCenter" style="width:#{rightCenterWidth}px;#{offset}">' +
										'<div class="close" style="width:#{closeWidth}px;">' +
											'#{topBar}' +
											'<div class="panelContent" style="width:#{contentWidth}px;height:#{contentHeight}px;">#{content}</div>' +
										'</div>' +
									'</div>' +
								'</div>' +
							'</div>' +
							'<div class="row bottom clearfix" style="width:#{topBottomWidth}px;">' +
								'<div class="pop-sprites bottomLeft">&#160;</div>' +
								'<div class="pop-sprites bottomCenter" style="width:#{topBottomCenterWidth}px;">&#160;</div>' +
								'<div class="pop-sprites bottomRight">&#160;</div>' +
							'</div>' +
							'#{calloutBottom}' +
						'</div>'
					),
					
					panelCalloutBottomTemplate : new Template('<div class="pop-sprites row callout" style="#{offset}">&#160;</div>'),
					panelCalloutLeftTemplate : new Template('<div id="universalPanelLeftCallout" class="pop-sprites calloutLeft" style="#{offset}">&#160;</div>'),
					panelTitleTemplate : new Template('<div class="panelTitle" style="width:#{width}px;">#{title}</div>'),
					panelCloseButtonTemplate : new Template('<div class="closeButton">#{topCloseButton}</div>'),
					panelTopBarTemplate : new Template('<div class="clearfix">#{titleTemplate}#{buttonTemplate}</div>')
				},

				/**
				 * getMarkup returns the markup for universalPanel styled popups
				 * 
				 * @author Byung Kim
				 * @date 1/8/2008
				 */
				getMarkup:function(useIFrame, width, height, title, strContent, id, style) {
					var constants = this.constants;
					var templates = this.templates;
					var commonTemplates = coutureLib.layeredPopup.styles.commonTemplates;
					var hasCloseButton = true;
					var callout = null;
					var calloutOffset = null;
					var content = "";
					var mainWidth = width+constants.PANEL_MAIN_WIDTH_OFFSET;
					if (style && style.hasCloseButton != undefined) hasCloseButton = style.hasCloseButton;
					if (style && style.callout) callout = style.callout;
					if (style && style.calloutOffset) calloutOffset = style.calloutOffset;
					var topTitle = "";
					var topCloseButton = "";
					var calloutLeft = "";
					var calloutBottom = "";
					var topBar = "";
					
					if (title) {
						topTitle = templates.panelTitleTemplate.evaluate({
							title:title,
							width:mainWidth-constants.PANEL_TITLE_WIDTH_OFFSET
						})
					}

					if (hasCloseButton) {
						topCloseButton = templates.panelCloseButtonTemplate.evaluate({
							topCloseButton:commonTemplates.closeAnchorTemplate.evaluate({
								text:commonTemplates.universalCloseButtonTemplate.evaluate({
									path:brandConst.UNIVERSAL_BUTTON_CONTENT_PATH, altText:resourceBundleValues.infoPopupsAltTextClose
								})
							})
						})
					}
					
					if (title || hasCloseButton) {
						topBar = templates.panelTopBarTemplate.evaluate({
							titleTemplate:topTitle,
							buttonTemplate:topCloseButton
						});
					}
					
					if (callout == "left") {
						calloutOffset = "top:"+calloutOffset+"px;"
						calloutLeft = templates.panelCalloutLeftTemplate.evaluate({offset:calloutOffset});
					} else if (callout == "bottom") {
						calloutOffset = "left:"+calloutOffset+"px;"
						calloutBottom = templates.panelCalloutBottomTemplate.evaluate({offset:calloutOffset});
					}
					
					if (useIFrame) {
						topId = "NoDrag";
						content = commonTemplates.iFrameContentTemplate.evaluate({
							id:id,
							src:gidLib.addCurrentDomain(strContent),
							width:width,
							height:height
						});
					} else {
						topClass = " cursorMove";
						content = commonTemplates.markupContentTemplate.evaluate({

							id:id,
							content:strContent,
							width:width,
							height:height
						});
					}
		
					return templates.mainTemplate.evaluate({
						mainWidth:mainWidth,
						topBottomWidth:mainWidth,
						topBottomCenterWidth:(mainWidth-constants.PANEL_COMBINED_BORDER_WIDTH),
						leftCenterWidth:mainWidth,
						rightCenterWidth:mainWidth,
						closeWidth:width,
						topBar:topBar,
						contentWidth:width,
						contentHeight:height,
						content:content,
						calloutLeft:calloutLeft,
						calloutBottom:calloutBottom
					});
				}
			}
		},

		/**
		 * openLayeredPopup opens a DHTML layer that looks like a popup.
		 * @param {object} argsGraph The JSON object with values for the popup
		 * 		str : The content of the layered Popup.  This can be a string of HTML, a URL to open, or a form to submit 
		 * 		id : The id for the layer parent element
		 * 		width : The width of the popup
		 * 		height : The height of the popup
		 * 		title : The title to display in the fake titlebar
		 * 		left : The x coordinate to position the popup
		 * 		top : The y coordinate to position the popup
		 * 		calleeElement : The calling element for the event
		 *		isDraggable : Whether the popover is draggable by clicking on it 
		 * 		style : A JSON object for the look and feel of the popup.
		 * 			name : which template to use (optional, default is the brandedPopup template)
		 * 			hasCloseButton : whether to display the close button for the universalPanel (optional, default is true)
		 * 			callout : used for displaying a callout for the universalPanel. values are 'left' or 'bottom' (optional, default is no callout)
		 * 			calloutOffset : used to offset the callout on the left or top depending on which is used.
		 *			isDraggable : Whether the poopup is draggagle (defaults to true)
		 * 		interstitial : JSON object -- when it exists, display as an interstitial (rest of the page greys out)
		 * 			color: hex value color of the interstitial (e.g. "#fff")
		 * 			opacity: opacity of the interstitial (e.g. "0.7" is 70%)
		 * 			buzz: whether to buzz the popup if a user clicks on the interstitial (e.g. true or false)
		 * 		effects : JSON object describing how to show and hide the layeredPopup.  Default is CSS visibility visible/hidden
		 * 			show : JSON object for showing the layered popup
		 * 				method : Scriptaculous Effect method
		 * 				args : JSON object of arguments for the method
		 * 			hide : JSON object for hiding the layered popup
		 * 				method : Scriptaculous Effect method
		 * 				args : JSON object of arguments for the method
		 * 			
		 * 
		 * Modified 12/19/2007 Byung Kim - converted method arguments to JSON with legacy API support
		 * Modified 1/1/2008 Byung Kim - reorganized to accept different styles
		 * Modified 1/8/2008 Byung Kim - updated FORM submit implementation
		 * Modified 1/31/2008 Byung Kim - added interstitial option
		 * Modified 7/25/2008 Byung Kim - added effects option for showing / hiding layered popup
		 * Modified 7/31/2008 Byung Kim - added callee element arg for returning focus to the callee once the popup closes
		 * 
		 * TODO: refactor implementation to use only JSON
		 * TODO: implement a dynamic root element for the popups 
		 * 
		 * @author Byung Kim
		 * @date 10/24/2007
		 */
		openLayeredPopup:function(argsGraph) {
			var args = arguments;
			if (args.length > 1) {
				// FOR LEGACY SUPPORT ONLY.  New implementations should use JSON object graph for arguments
				var str = args[0];
				var id = args[1];
				var width = args[2];
				var height = args[3];
				var title = args[4];
				var left = args[5];
				var top = args[6];
			} else {
				var str = argsGraph.str;
				var id = argsGraph.id;
				var width = argsGraph.width;
				var height = argsGraph.height;
				var title = argsGraph.title;
				var left = argsGraph.left;
				var top = argsGraph.top;
				var isDraggable = argsGraph.isDraggable;
				var style = argsGraph.style;
				var interstitial = argsGraph.interstitial;
				this.effects = argsGraph.effects;
				this.calleeElement = argsGraph.calleeElement;
			}
			var popup = $("popupContent");
			
			var layerStyle = this.styles[(style && style.name ? style.name : "brandedPopup")]; 
			var constants = layerStyle.constants;
			var useIFrame = false;
			var isForm = false;
			var strContent = "";
			var strIgnoredFormTypes = "submit,button,image,file,reset";
			this.popupId = id;

			popup.setStyle({visibility:"hidden",display:"block"});

			if (str.match(/^(\/|http|about)/)) {
				useIFrame = true;
				strContent = str;
				var cid = str.substr(str.indexOf('?')+1, str.length);
			} else {
				var targetElement = $(str);
				if (targetElement) {
					if (targetElement.tagName && targetElement.tagName.toLowerCase() == 'form') {
						useIFrame = true;
						isForm = true;
						strContent = "/gid/html/en/blank.html";
						targetElement.target = id + "PopupContent";
					} else {
						// Copy the innerHTML
						strContent = targetElement.innerHTML;
					}
				} else {
					// Copy the string literally
					strContent = str;
				}
			}
			popup.update(layerStyle.getMarkup(useIFrame,width,height,title,strContent,id,style));
			if (!useIFrame && isDraggable) {
				gidLib.setButtonEvents("popupContent");
				this.dragger = new Draggable('popupContent',{handle:'layeredPopupFrameTop'});
			}
			this.hiddenDropDowns = gidLib.hideDropDownsUnderElement(popup);
			if (interstitial) this.openInterstitialDisplay(interstitial);
			this.setPosition(popup,left,top);
			this.launchLayeredPopup(id);
			if (isForm) targetElement.submit();
			return false;
		},
		
		/**
		 * setPosition sets the position of the layeredPopup
		 * 
		 * Modified 7/23/2008 - Byung Kim : removed scrollTop, scrollLeft calculation on x,y coordinates.  values passed to openlayeredpopup should account for the scroll values
		 * 
		 * @author Byung Kim
		 * @date 1/8/2008
		 */
		setPosition : function(popup,x,y) {
			var popupX = parseInt(x);
			var popupY = parseInt(y);
			var dimensions = popup.getDimensions();
			if (isNaN(popupX) || isNaN(popupY)) {
				var clientWidth = (document.documentElement && document.documentElement.clientWidth ? document.documentElement.clientWidth : document.body.clientWidth);
				var clientHeight = (document.documentElement && document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body.clientHeight);
				var scrollLeft = (document.documentElement && document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft);
				var scrollTop = (document.documentElement && document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop);
				if (clientBrowser.isSafari) {
					/*
					TD 14933: Safari does not seem to properly support the document.documentElement.clientHeight -
					reporting a constant value of 1330.
					*/
					var clientHeight = window.innerHeight;
				}
				popupX = Math.max(0,clientWidth/2 - dimensions.width/2)+scrollLeft;
				popupY = Math.max(0,clientHeight/2 - dimensions.height/2)+scrollTop;
				// alert("clientBrowser.isSafari = " + clientBrowser.isSafari + "\rwindow.innerHeight = " + window.innerHeight + "\rdocument.documentElement.clientHeight = " + document.documentElement.clientHeight + "\r\rclientHeight = " + clientHeight + "\rclientWidth = " + clientWidth + "\r\rpopupX = " + popupX + "\rpopupY = " + popupY);
			}
			gidLib.setObjPosition(popup,popupX,popupY);
		},
		
		/**
		 * launchLayeredPopup reveals the layered popup
		 * 
		 * @author Byung Kim
		 * @date 7/25/2008
		 */
		launchLayeredPopup : function(id) {
			var effects = this.effects;
			var popup = $("popupContent");
			
			var afterFinish = function(id) {
				setTimeout("gidLib.setFocus($('popupContent'))",100);
				this.isOpen = true;
			};
			
			if (effects && effects.show && effects.show.method) {
				popup.setStyle({display:"none",visibility:"visible"});
				var method = effects.show.method;
				var args = effects.show.args;
				var aF = {afterFinish:afterFinish.bind(this,id)};
				if (args) {
					Object.extend(args,aF);
					method(popup,args);
				} else {
					method(popup,aF);
				}
			} else {
				popup.setStyle({visibility:"visible",display:"block"});
				afterFinish(id);
			}
		},

		/**
		 * closeLayeredPopup closes the layered popup
		 * 
		 * Modified 7/25/2008 Byung Kim - added effect
		 * Modified 7/31/2008 Byung Kim - added returning focus to the callee element
		 * 
		 * @author Byung Kim
		 * @date 10/24/2007
		 */
		closeLayeredPopup:function() {
			var popup = $("popupContent");
			this.closeInterstitialDisplay();
			$('popupContent').removeClassName('couturePopup');
			var afterFinish = function() {
				while(popup.hasChildNodes()) {
					popup.removeChild(popup.firstChild);
				}
				gidLib.showDropDowns(this.hiddenDropDowns);
				this.hiddenDropDowns = null;
				if (this.dragger) this.dragger.destroy();
				if (this.calleeElement) {
					gidLib.setFocus(this.calleeElement);
				}
				this.isOpen = false;
				this.popupId = "";
			};

			var effects = this.effects;
			if (effects && effects.hide && effects.hide.method) {
				var method = effects.hide.method;
				var args = effects.hide.args;
				var aF = {afterFinish:afterFinish.bind(this)};
				if (args) {
					Object.extend(args,aF);
					method(popup,args);
				} else {
					method(popup,aF);
				}
			} else {
				popup.setStyle({visibility:"hidden",display:"block"});
				afterFinish();
			}
			return false;
		},
		
		/**
		 * openInterstitialDisplay adds an interstitial layer behind the layeredPopup to grey out the page. 
		 * 
		 * @author Byung Kim
		 * @date 1/30/2008
		 */
		openInterstitialDisplay:function(args) {
			var color = (args.color ? args.color : "#fff");
			var opacity = (args.opacity ? args.opacity : "0.65");
			this.hasBuzz = (args.buzz != undefined ? args.buzz : true);
			var id = "layeredPopupInterstitial";
			var interstitial = $(id);
			if (!interstitial) {
				var interstitial = $(document.createElement("div"));
				interstitial.id = id;
				document.body.appendChild(interstitial);
				Event.observe(interstitial,"click",this.interstitialBuzzEffect.bind(this));
			}
			var clientWidth = (document.documentElement && document.documentElement.clientWidth ? document.documentElement.clientWidth : document.body.clientWidth);
			var clientHeight = (document.documentElement && document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body.clientHeight);
			var scrollLeft = (document.documentElement && document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft);
			var scrollTop = (document.documentElement && document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop);
			var docW = clientWidth + scrollLeft;
			var docH = (clientBrowser.isIE ? document.body.offsetHeight : (document.documentElement ? document.documentElement.offsetHeight : document.body.offsetHeight)); 
			if (clientHeight > docH) docH = clientHeight;
			interstitial.setStyle({
				position:"absolute",
				top:"0px",
				left:"0px",
				width:docW+"px",
				height:docH+"px",
				display:"block",
				background:color,
				zIndex:"98",
				opacity:opacity,
				filter:"alpha(opacity=" + (opacity*100) + ")" 
			});
		},
		
		/**
		 * closeInterstitialDisplay hides the interstitial layer
		 * 
		 * @author Byung Kim
		 * @date 1/30/2008
		 */
		closeInterstitialDisplay:function() {
			var interstitial = $("layeredPopupInterstitial");
			if (interstitial) {
				interstitial.setStyle({display:"none"});
				Event.stopObserving(interstitial,"click",this.interstitialBuzzEffect.bind(this));
			}
		},
		
		/**
		 * interstitialBuzzEffect does the effect for the popup
		 * 
		 * @author Byung Kim
		 * @date 1/31/2008
		 */
		interstitialBuzzEffect:function(hasBuzz) {
			if (this.hasBuzz) Effect.Shake("popupContent");
		}
	},

  addToBag : function() {
		if (objInlineBag.isOpen || objInlineBag.isAnimating) {
			setTimeout(this.addToBag.bind(this), 250);
		} else {
			this.checkErrors();
			if (!this.isColorError &&
				!this.isSizeDimension1Error &&
				!this.isSizeDimension2Error &&
				(this.isSkuInStock(this.selectedColor,this.selectedSizeDimension1,this.selectedSizeDimension2) || this.isSkuOnOrder(this.selectedColor,this.selectedSizeDimension1,this.selectedSizeDimension2) || this.isSkuLowInventory(this.selectedColor,this.selectedSizeDimension1,this.selectedSizeDimension2))) {

				if (this.objV.objStyleSizeInfo.intSizeDimensionsCount >= 1) {
					var strColorId = this.objV.arrayVariantStyleColors[this.selectedColor].strColorCodeId;
					var strSize1Id = this.arrayAllSizeDimension1[this.selectedSizeDimension1].strId;
					var strSize2Id = "";
				}
				if (this.objV.objStyleSizeInfo.intSizeDimensionsCount == 2) {
					strSize2Id = this.arrayAllSizeDimension2[this.selectedSizeDimension2].strId;
				}
				var strSkuID = this.objV.arrayVariantSkus[strColorId + "_" + strSize1Id + "_" + strSize2Id].strSkuId;

				var inlineBagUrl = this.templates.INLINE_BAG_URL.evaluate({sku:strSkuID, qty:this.strSelectedQty, cid:this.strDefaultCategoryId});
				if (this.hasInlineBagErrors && this.arrayAddtoBagErrors.get(this.objP.strCatalogItemId) &&
                    this.arrayAddtoBagErrors.get(this.objP.strCatalogItemId) == 1) {
					inlineBagUrl += "&addOnOrderItem=true";
					this.hasInlineBagErrors = false;
				}
				objInlineBag.doOpenBag = true;

				// --------------------------------------
				// AJAX INLINE BAG DATA LOADER
				new Ajax.Request(
					inlineBagUrl,
					{
						method: 'get',
						onComplete: parent.window.parseInlineBagAjaxResponse.bind(parent.window)
					}
				);
				// ---------------------------------------
				this.setAddtoBagState(true, true);
			}
		}
  }
}
	  
var coutureLib = new CoutureClass();


