
/**
 * @class SearchError_Bubble
 * This class is responsible for displaying search error in the ajax bubbles
 */
Core_SearchError_Class=function() {
    this.Bubble_DivID = "SearchError_Bubble";
    this._MapPopUp;

    /**
     * Shows the search error in bubble if one is there, otherwise sends to next page
     */    
    this.ShowBubble=function(absoluteURL){
       try {
            this._MapPopUp = new Core.ModalPopUp(); 
        }
       catch(err) {
          this._MapPopUp = new Core_ModalPopUp(); 
       }
        
        this._MapPopUp._PopupControlID=this.Bubble_DivID;
        this.SearchKeyword(absoluteURL);
    }
    
    this.HideMe=function()
    {
            try {
                  if (AJAX_IsIE6()) {
                  
                       ToggleStateList('visible');
                  }
             }
              catch(err) { }     
         this._MapPopUp.HideModal();
    }    
    
    /**
     * Retrieves map for specific store
     * @param {string} absoluteURL The absoluteURL
     */
    this.SearchKeyword=function(absoluteURL) {
        if(!IsAjaxLibraryLoaded) {return false;}
        try {
            //DoWait();
	        var mf = GetMainFormName();		
	        if (mf==null) return;
	        var searchVal = document.forms[mf].elements["SearchKeywords"].value;
	        
	        // remove " and ' double and single quotes
	        var i;
	        var returnString = "";
	        var filteredValues = "'\"";     // Characters stripped out
	        
            for (i = 0; i < searchVal.length; i++) {
                var c = searchVal.charAt(i);
                if (filteredValues.indexOf(c) == -1) 
                    returnString += c;
            }
	        
	        searchVal = returnString.toLowerCase();
	        
	        if (typeof(absoluteURL)!='undefined') {
	        document.forms[mf].action=absoluteURL + "/search/index.aspx?SearchKeywords=" + searchVal;
	        }
	        else {
	        document.forms[mf].action="/search/index.aspx?SearchKeywords=" + searchVal;
	        }
	        
	        // if keyword is 'search' display error
	        if (searchVal.toLowerCase() == "search products")
	        {
	            _SearchError_Class._MapPopUp.ShowModal();
	        }
	        else
	        {
	            document.forms[mf].submit();
	        }
            
        }
        catch (e) {
            DoDefault();
            window.status = e.message;
        }
        return false;
    }
    
}
 
 /**
 * It instantiates an object of type Core.SearchError_Class
 */
var _SearchError_Class=new Core_SearchError_Class();


