/**
 * SpexLive AutoComplete Configuration File.
 * Here you can define your DOM Ids required for AutoComplete feature.
 * 
 * @version 1.0.0
 * @author: Waqas Memon (wmemon@etilizepak.com)
 * 			Etilize Pvt. Ltd. (A GFK Product Data Company) 
 */

function SpexLiveAutoCompleteConfig(){ 

	
/**
 * Server URL is the URL that responds to AJAX requests for Autocomplete
 */	
	this.serverURL = "http://ws2.spexlive.net/service/rest/autocomplete?method=getSuggestions";	

/**
 * Etilize Assigned Authentication Key.
 * REPLACE 'YOUR AUTHENTICATION KEY HERE' With the 32-character long authentication key provided by Etilize 
 * e.g this.AUTH_KEY = 'c8377ad2a50ff65de28b11dfc628d75c';
 *
 */	
	this.AUTH_KEY = 'b5b5acf876ef5912a24e8c74b7a841cd';
	
	
/**
 * RESPONSE_KEYWORDS_SIZE is the maximum size of the keywords matching the input of the user.
 * NOTE: maximum suggestions supported are 5 in number currently
 */

	if (navigator.appVersion.indexOf('MSIE 7.0') >= 0) {
	  this.RESPONSE_KEYWORDS_SIZE = 2;
	} else {
	  this.RESPONSE_KEYWORDS_SIZE = 10;
  }
	

	
/**
 * autoCompleteField is id of the HTML element (Input Text Field) that you want to integrate autocomplete with.
 */
	this.autoCompleteField = "txtSearch";
	
/**
 * localeField is the id of the HTML field (element) where you store selected locale. Please use a hidden input field for storing site locale
 * Add a default locale if your site operates on single locale. 
 */	
	this.localeField = "selectedLocale";
	this.defaultLocale = "en_US";


/**
 * Default Search : set it to 1 if you want to trigger search functionality on selection of suggestions.
 */	
	this.defaultSearch = 1;
	
/**
 * DEBUG MODE: set it to 1 if you want to enable debug mode to see all error messages, set it to 0 to ignore all messages.
 * 
 */
	this.DEBUG_MODE = 0;

	

/**
 * CSS Classes for The Autocomplete Suggestions List.<br>
 * suggestionBoxCSSClass is css class for The box which holds the autocomplete list
 * suggestionListCSSClass is the class for list items
 * listItemHoverClass is the class for hover
 * 
 * Example of the CSS Classes that will be used in DOM
 * <div style="display: none;" id="suggestionsBox" class="suggestionsBox">
 *   <div id="autoSuggestionsList" class="suggestionList">
 *     <li id="keywordElement" class=""></li>
 *     <li id="keywordElement" class=""></li>
 *     <li id="keywordElement" class=""></li>
 *   </div>
 * </div>
 */
	this.suggestionBoxCSSClass = "suggestionsBox"; 
	this.suggestionListCSSClass = "suggestionList";
	this.listItemHoverClass = "itemhover";
	
			
}

var spxautocompleteconfig = new SpexLiveAutoCompleteConfig (); 

/**
 * Implement here how you handle your website search requests. Further details in README-WWW.txt 
 */
spxautocompleteconfig.prototype = { 

	defaultSearch: function(keyword){
		//Please use this method unFixQuotes(searchValue) to resolve JavaScript quotes issue. 
		//single and double quotes were encoded and this method will decode them.
		keyword = unFixQuotes(keyword); 
	
		if(spxautocompleteconfig.defaultSearch==1){
			
			//IMPLEMENT HERE by discarding following 2 lines..

			//TODO: Implement here your default search mechanism when user selects any keyword from suggestion list. For your understanding we have redirect to SpexLive Search.

			//EXAMPLE # 1
			//window.location.href = "http://spexlive.net/web/secure/search.view?keywords="+escape(keyword)+"&locale="+spxautocompleteconfig.LOCALE+"&catalogID=spr&type=keywords";window.location.href = "http://spexlive.net/web/secure/search.view?keywords="+escape(keyword)+"&locale="+spxautocompleteconfig.LOCALE+"&catalogID=spr&type=keywords";
			window.location.href = "SearchResults.aspx?search="+escape(keyword);
			
			//EXAMPLE # 2 : This is a sample code for submitting the form, try this example in simple.html.
			//document.searchForm.submit();
			
		
		}	
	}
};



