
function getSlideStates(nameS, nameAS) {
    var frm = document.forms[0];
    $('div.form-box').each(function() {
        var _hold = $(this);

        if (_hold.find('div.fSearch').height() != null) {
            if (_hold.hasClass('opened'))
                frm[nameS].value = '1';
            else
                frm[nameS].value = '0';
        }

        if (_hold.find('div.fASearch').height() != null) {
            if (_hold.hasClass('opened'))
                frm[nameAS].value = '1';
            else
                frm[nameAS].value = '0';
        }
    });
}

function initSlide(openedS, openedAS){
	var _duration = 400; //in ms
	$('div.form-box').each(function() {
	    var _hold = $(this);

	    if (openedS && _hold.find('div.fSearch').height() != null) _hold.addClass('opened');
	    if (openedAS && _hold.find('div.fASearch').height() != null) _hold.addClass('opened');

	    var _box = _hold.find('div.slide-block');
	    var _btn = _hold.find('div.heading');
	    var _bottom = _hold.find('div.row-content');
	    var _bottHold = _hold.find('div.total');
	    var _h = _box.height();
	    if (_hold.hasClass('opened')) {
	        _box.show();
	        _bottom.show();
	        _bottHold.css({ height: 'auto' });
	    }
	    else {
	        _box.hide();
	        _bottom.hide();
	        _bottHold.css({ height: 1 });
	    }

	    _btn.click(function() {
	        if (_hold.hasClass('opened')) {
	            _hold.removeClass('opened');
	            _box.stop().animate({ height: 0 }, _duration, function() {
	                $(this).css({ display: 'none', height: 'auto' });
	            });
	            _bottom.stop().animate({ height: 0 }, _duration, function() {
	                $(this).css({ display: 'none', height: 'auto' });
	            });
	            _bottHold.animate({ height: 0 }, _duration, function() {
	            });
	        }
	        else {
	            _hold.addClass('opened');
	            if (_box.is(':hidden')) {
	                _box.show();
	                _h = _box.height();
	                _box.height(0);
	            }
	            if (_bottom.is(':hidden')) {
	                _bottom.show();
	                _hb = _box.height();
	                _bottom.height(0);
	            }
	            _box.stop().animate({ height: _h }, _duration, function() {
	                $(this).height('auto');
	            })
	            _bottom.stop().animate({ height: _hb }, _duration, function() {
	                $(this).height('auto');
	            })
	            _bottHold.animate({ height: 16 }, _duration, function() {
	                $(this).css({ height: 'auto' });
	            });
	        }
	        return false;
	    });

	});
}
$(document).ready(function(){
	initSlideW();
});