$(function(){

	var days_into_future = 30;


	//set cooklie:
	if ($('#pollform_submit').length){
		$('#pollform_submit').parents('form').submit(function(e){
			if($('input:checked[name="pollsvar"]').val() != '' && $('input:checked[name="pollsvar"]').val() != undefined){
				var pollkey = 'p3poll_' + $('#pollkey').val();
				var cookieexpires = new Date().getTime() + days_into_future * 24 * 60 * 60 * 1000;
				var strexpires = new Date(cookieexpires).toGMTString();
				var path = 'path=/;';
				//var path ='';
				document.cookie = pollkey + '=done;' + path + 'expires=' + strexpires;
			}
		});
	}
	
	//ugly window.open stuff - my projectmanager made me do this shit ;-)
	if ($('.pollform_view_results').length){
		$('.pollform_view_results').click(function(e){
			e.preventDefault();
			window.open($(this).attr('href'),'poll','width=410,height=530');
		});
	}
});
