// product-vote.js

var vote = {


	send: function(productcode) {

		var options = new Array();
		var oi = 0;
		var do_contact = $F('vote_email')!=''?1:0;
		var have_message = $F('vote_message')!=''?1:0;

		var cbs = $$('.vote_checkbox');
		for(var i=0;i<cbs.length;i++) {
			if(cbs[i].checked) {
				options[oi++] = cbs[i].value;
			}
		}

		new Ajax.Request(
			'/product-vote',
			{
				method:'POST',
				onSuccess: function(tx) {
					$('vote_pad').update("Vielen Dank für Ihren Verbesserungsvorschlag!");
				},
				onFailure: function(tx) {
					$('vote_pad').update("Sorry, der Vorschlag konnte aufgrund eines technischen Problems nicht entgegengenommen werden. Bitte versuchen Sie es später erneut!");
				},
				parameters: {
					aj:true,
					action:'send',
					productcode: productcode,
					xoptions: options.toJSON(),
					do_contact: do_contact,
					email: $F('vote_email'),
					name: $F('vote_name'),
					message: have_message?$F('vote_message'):''
				}
			}
		);

	}

}

