$(document).ready(function () {	
	
    setRating = function(obj, params) {
	obj.store = new Store( '/ajax/spec_rating.html' );
	obj.store.method = 'GET';
	obj.store.params = params;
	obj.store.attachObserver( 'Loaded', obj.sRLoaded );
	obj.store.load();	    
    }
    
    $('td.rating a.active').click(function(){
	if (this.className == 'active') {
	    var params = {'SpecAction_Id': this.parentNode.id, 'SpecAction': 'Change', 'Debug': 'False'};
	    this.sRLoaded = function (result, obj) {
		var td = document.getElementById(result.Id);
		td.lastChild.className = 'inactive';
		td.firstChild.className = 'balloon png';
		td.firstChild.innerHTML = '+' + result.InterestCounter;
	    }
	    setRating(this, params);
	}	    
	return false;
    });
    
    //Спецпредложения
    $('#spec_offers a.reload').click(function(){
	var sOffersParent = $('#spec_offers');
	var sAnchor = $(this);
	var sOffers = $('#spec_offers .spec_offer');
	var sGroups = Math.ceil( sOffers.length /3 );
	var expand = true;
    if (sGroup==1) {
        $('#spec_offers .spec_offer').slideDown('slow', function() {
                $('#spec_offers a.reload').html('свернуть').attr('class', 'unload');
                sGroup++;
            }	    
        );
    }
    else {
        $('#spec_offers .spec_offer:not(.group1)').slideUp('slow', function() {                
                $('#spec_offers a.unload').html('другие спецпредложения').attr('class', 'reload');
                if (jQuery.browser.msie && jQuery.browser.version == '6.0') {
                //шаманские штучки, чтобы побороть ИА-6
                    $('#spec_offers .balloon').removeClass('balloon').addClass('balloon');
                    $('#spec_offers .active').removeClass('active').addClass('active');
                    $('#spec_offers .inactive').removeClass('inactive').addClass('inactive');
                     $('#spec_offers .title').removeClass('title').addClass('title');
                }
               sOffers.removeAttr('style');
               sGroup=1;
            }	    
        );
    }
	return false;
    });
    
    //Форма обратной связи
    $('#feedback a.feedback').click(function(){
        $('#feedback_form').slideToggle('slow', function() {
	    $(this).removeClass('hiiden');
	    $('#feedback a.feedback').toggleClass('expanded');
	});
        return false;
    });
});