/**
 * aheadWorks Co.
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the EULA
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://ecommerce.aheadworks.com/LICENSE-M1.txt
 *
 * @category   AW
 * @package    AW_Seacrhautocomplete
 * @copyright  Copyright (c) 2003-2010 aheadWorks Co. (http://www.aheadworks.com)
 * @license    http://ecommerce.aheadworks.com/LICENSE-M1.txt
 */

var Searchcomplete = Class.create();
Searchcomplete.prototype = {
    field: "",
    initialize : function(){
        this.field = $('myInput');
    },
    initAutocomplete : function(url, destinationElement){
        var SACautocompleter = new Ajax.Autocompleter(
            this.field,
            destinationElement,
            url,
            {
                paramName: this.field.name,
                method: 'get',
                minChars: 3,
                frequency: queryDelay,
                onShow : function(element, update) {
                    var posSC = $('myInput').cumulativeOffset();
//                    posSC.top = posSC.top + parseInt($('myInput').getHeight()) + 3;
                    posSC.top = posSC.top + parseInt($('myInput').getHeight()) + 12;
                    if (!Prototype.Browser.IE)
//                        posSC.left -= (parseInt($('myInput').getStyle('padding-left')) + 3);
                        posSC.left -= (parseInt($('myInput').getStyle('padding-left')) - 17);

                    $('myContainer').setStyle({
                        top: posSC.top+"px",
                        left: posSC.left+"px"
                    });

                    update.show();
                    $('myContainer').show();
                },
                onHide : function(element, update)
                {
                    $('myContainer').hide();
                    update.hide();
                },
                updateElement : function(element)
                {
                    return false;
                }
            }
        );
        SACautocompleter.startIndicator = function(){
            this.element.setStyle({
                backgroundImage: 'url("'+preloaderImage+'")',
                backgroundRepeat: 'no-repeat',
                backgroundPosition: 'right'
            });
        }
        SACautocompleter.stopIndicator = function(){
            this.element.style.backgroundImage = 'none';
        }
    }
}

