/*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
    
    le.messages.js

    I'm collecting all the messages in one spot for easy editing.  The functions
    are for dynamic messages.
    
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*/
function ErrorMessage(code,messageText){
	var thisErrorMessage = this;
	var code;
	var messageText;
	
	// If boolean value true is passed in as the first parameter, then the metric will be recored. If additional 
	// parameters are required to complete the error message and you do not want to send a metric, then populate 
	// the first parameter value with boolean value false. If additional values are required to complete the error 
	// message then they should be populated into the parameter list in the order that they should appear in the 
	// error message. 
	//
	// Example - simple error message: Please select a color
	// To send metric and get the error message back: getMessageText(true);
	// To just get the error message back: getMessageText();
	// 
	// Example - error message with parameters: Nickname entered was {1} characters long, please enter a nickname that does not exceed {2} characters, do the math {1} - {2}.
	// To send metric and get the error message back: getMessageText(true,25,20);
	// To just get the error message back: getMessageText(false,25,20);
	//
	this.getMessageText = function(){
		var text = messageText;
		
		// check to see if metric should be sent
		if(arguments.length > 0 && arguments[0] != null && arguments[0] != undefined && typeof(arguments[0]) == 'boolean' && arguments[0] == true){
			this.sendMetric();
		} 
		
		// populate additional parameters into the message
		if(arguments.length > 1){
			var i = 1;
			for(;i < arguments.length;i++){
				var reg = new RegExp('param' + i,'g');
				text = text.replace(reg,arguments[i]);
			} 
		}
		
		return text;
	}
	
	this.getErrorCode = function(){
		return code;
	}
	
	this.sendMetric = function(){
		s_omtr = s_gi(s_account);
        s_omtr.linkTrackVars='events,eVar6';
        s_omtr.linkTrackEvents='event4';
        s_omtr.events='event4';
        s_omtr.eVar6 = code;
        s_omtr.tl(true,'o','Link');
	}
	
	this.toString = function(){
		return messageText;
	}
}

function getMessageContent() {


        /*====================================================================
            The error icon can be used when filling innerHTML of an error div.
            It's usually a background image defined in the CSS.
        ====================================================================*/
        messages.icon = "<img src=\"" + ppPath.replace("ProductPage", "") + "/images/errorIcon.gif\" alt=\"\" />",
        
        /*==============================================================================================
            Error messages are usually displayed when the user clicks Add to Bag or Next and has ignored
            info messages or otherwise made a mistake.
        ==============================================================================================*/
        //error   : {
                //sizeNotSelected                     : "Please select a size.",
                //secondarySizeNotSelected            : "Please select a cup size.",
                //colorNotSelected                    : "Please select a color.",
                //inseamNotSelected                   : "Please select an inseam.",
                //inseamHemmingComboNotOffered        : "Sorry. The maximum inseam length allowed with a cuff is 'X' inches. (2 inches of fabric are required to create the cuff.)",
                //sizeColorComboNotOffered            : "We're sorry, this product is not available and cannot be added to your bag.",
                //nicknameNotEntered                  : "Please provide a nickname.",
               // nicknameAlreadyExists               : "This nickname already exists. Please create a new nickname or select the existing nickname from the drop-down menu.",
                //monoTypeNotSelected                 : "Please select a monogram type prior to continuing to step 2.",
                //monoStyleNotSelected                : "Please select a monogram style prior to continuing to step 3.",
                //monoTextNotProvided                 : "Please enter your monogram.",
                //monoNotApplied                      : "Please complete your monogram.",
                //monoUpdatedNotApplied               : "To add to your bag, you must first update (or cancel) your monogram.",
                //monoInvalidCharacters1              : "One or more of the characters entered is invalid and cannot be displayed. Please confirm your selections.",
                //monoInvalidCharacters2              : "Sorry. Your monogram contains an invalid character and cannot be completed as entered. Please change or cancel your monogram. Monograms can contain alpha characters A-Z, numeric characters 0-9 and the non-alphanumeric characters ! # $ - = . , ` / : ; &",
                //monoTooShort                        : function(minLength) {
                //                                        return "You have entered too few characters for your monogram.  Your monogram must be at least " + minLength + " character(s) long.";
                //},
                //monoTooLong                         : function(maxLength) {
                //                                        return "You have entered too many characters for your monogram.  Your monogram must be contain fewer than " + maxLength + " character(s).";
                //},
               // monoIntialsTooShort                 : "The monogram type you've selected requires a minimum of 2 characters. Please provide at least one more character. Or, if you want a single-initial monogram, please return to step 1 and select Single Initial.",
               // schoolUniCodeInvalid                : "The school code is incorrect or invalid. Please verify your school code and re-enter it or call 1-800-469-2222 for assistance.",
                //schoolUniClickConfirm               : "Please click the confirm button to validate your school code before proceeding.",
               // schoolUniAndMonoSelected            : "We're sorry.  We cannot apply both a monogram <strong>and</strong> a school logo to our products. Please remove either the monogram or the logo.",
                //schoolUniSystemDown                 : "Sorry, we are currently experiencing technical issues with this area of our site. For immediate assistance, try LE Live for a text chat or call 1-800-469-2222.",
                //schoolUniLogoNotSelected            : "Please select a logo preference.",
                //dropShipInvalidNumber               : "Please enter a valid phone number.",
                //dropShipNoNumber                    : "Please enter a phone number.",
                //giftBoxNotAvailableStyleChange      : "We're sorry, gift boxing is not available for this style.",
               // monogramNotAvailableStyleChange     : "We're sorry, monogramming is not available for this style.",
               // schoolLogoNotAvailableStyleChange   : "We're sorry, the selected logo cannot be applied to this style.",
                //schoolContrNotAvailableStyleChange  : "We're sorry, the selected style is not eligible for a school contribution.",
                //addToBagEmptySet                    : "You currently have no items in your set.",
                //addToBagMultiItemNothingSelectedStep	: 'There are no items selected to add to the bag. Please return to step 2 or deselect "Remove this item from purchase."',
                //addToBagMultiItemNothingSelected	: 'There are no items selected to add to the bag. Please deselect "Remove this item from purchase."',
                //technicalIssues                     : "Sorry, we are currently experiencing technical issues with this area of our site. For immediate assistance, please call 1-800-288-9091."
        //},
        
        /*=========================================================================================
            Info messages are usually displayed to give the user immediate feedback before an error
            condition occurs.
        =========================================================================================*/
        messages.info = new Object();
        messages.info.productNotAvailable = function(num, color, size) {
                	doDebug("[productNotAvailable] num = " + num);
                	doDebug("[productNotAvailable] color = " + color);
                	doDebug("[productNotAvailable] size = " + size);
                    if ((size != undefined && size != "undefined" && size != "" && size != null) && (color != undefined && color != "undefined" && color != "" && color != null)) {
                        return "This product is not available in <span id=\"invalidColorText_prd_" + num + "\" class=\"invalidColorText\">" + color + "</span>: size <span id=\"invalidSizeText_prd_" + num + "\" class=\"invalidSizeText\">" + size + "</span>.";
                    } else if (size != undefined && size != "undefined" && size != "" && size != null) {
                        return "This product is not available in <span id=\"invalidColorText_prd_" + num + "\" class=\"invalidColorText\">" + size + "</span>.";
                    } else if (color != undefined && color != "undefined" && color != "" && color != null) {
                        return "This product is not available in <span id=\"invalidColorText_prd_" + num + "\" class=\"invalidColorText\">" + color + "</span>.";
                    } else {
                        return "This product is not available.";
                    }
           		}
                
        messages.info.productBackOrdered  = function(num, month, day) {
                    return "Order today - this item is on order and will ship on or about <span id=\"backOrderMonth_prd_" + num + "\" class=\"backOrderMonth\">" + month + "</span> <span id=\"backOrderDay_prd_" + num + "\" class=\"backOrderDay\">" + day + ". <a href=\"#\" onclick=\"LE_popup('/cd/popup/0,,copyName=pop_help_backorder_1006.html'); return false;\"><img src=\"http://aka.landsend.com/pp/images/learnMore.gif\" alt=\"Learn More\" /></a></span>";
                }
                
        messages.info.productNoInventory = function(product, color, size) {
	                if ((size != undefined && size != "undefined" && size != "" && size != null) && (color != undefined && color != "undefined" && color != "" && color != null)) {
	                	return "We're sorry.  The item you've selected, " + product + ", size " + size + " color " + color + ", is no longer available and cannot be added to your bag or backordered."
                    } else if (size != undefined && size != "undefined" && size != "" && size != null) {
                        return "We're sorry.  The item you've selected, " + product + ", size " + size + ", is no longer available and cannot be added to your bag or backordered.";
                    } else if (color != undefined && color != "undefined" && color != "" && color != null){
                        return "We're sorry.  The item you've selected, " + product + ", color " + color + ", is no longer available and cannot be added to your bag or backordered.";
                    } else {
                        return "We're sorry.  The item you've selected, " + product + ", is no longer available and cannot be added to your bag or backordered.";
                    }
              	}

}
