function vote(form, vote_id) {

	var res = false;
	for (var i = 0; form.elements.length > i; i++)
		if (form.elements[i].checked)
			res = form.elements[i].value;
			
	if (res) {
		jQuery.ajax({
			url : '/vote/post/' + res + '/?m=' + new Date().getTime(),
			dataType: 'html',
			success: function(data){eval(data)}
		});
		jQuery.ajax({
			url: '/udata://vote/results/' + vote_id + '/?transform=modules/vote/insertlast.xsl&m=' + new Date().getTime(),
			dataType: 'html',
			success: function(data){jQuery(form.parentNode).html(data)}
		});
	}
	else alert('Не выбран ни один вариант');
};

$(function(){

	new Banners($('#banners'));
	
});
function Banners(elem){
	this.root=elem;
	this.banners=this.root.find('.vitrina');
	this.buttons=$('<div id="buttons"></div>');
	this.next=$('<a class="next" href="" >Следующее предложение &raquo;</a>');	
	/*this.prev=$('<a class="prev" href="" >&laquo; предыдущий</a>');*/
	
	this.init();
}

Banners.prototype={
	init:function(){
		var me=this;
		/*this.buttons.append(this.prev);*/
		this.buttons.append(this.next);
		this.root.append(this.buttons);
		
		$('#buttons .next').click(function(){
				me.nextBan();
				clearInterval(me.timer);
				this.timer
				return false;
			});
		$('#buttons .prev').click(function(){
				me.prevBan();
				return false;
			});
		
		this.banners.eq(0).addClass('active');
		this.timer=setInterval(function(){me.nextBan()}, 10000);
	},
	
	changeBan:function(i){
		var me=this;
		me.banners.hide();
		me.banners.removeClass('active');
		me.banners.eq(i).addClass('active');
		me.banners.eq(i).fadeIn();
	},
	
	nextBan:function(){
		var a=this.root.find('.active');
		var i=a.index()+1;		
		if(i>=this.banners.size()){
			i=0;
		}		
		this.changeBan(i);
	},
	prevBan:function(){
		var a=this.root.find('.active');
		var i=a.index()-1;		
		if(i < 0){
			i=this.banners.size()-1;
		}		
		this.changeBan(i);
	}
}




