function polling(id) {
	var rad_val = 0;
	for (var i=0; i < document.poll.vot.length; i++) {
		if (document.poll.vot[i].checked) {
			rad_val = document.poll.vot[i].value;
		}
	}
	if (rad_val > 0) {
		new Ajax.Updater('poll_div', 'poll.php?page=polling&id='+id+'-'+rad_val);
		var cokie_txt = readCookie("poll");
		if (cokie_txt) {
			document.cookie = "poll=" + escape(cokie_txt+","+id) + ";";
		} else {
			document.cookie = "poll=" + escape(id) + ";";
		}
	}
	else {
		new Ajax.Updater('poll_div', 'poll.php?page=poll&id='+id);
	}
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function poll(id) {
	new Ajax.Updater('poll_div', 'poll.php?page=poll&id='+id);
}

function poll_results(id) {
	new Ajax.Updater('poll_div', 'poll.php?page=poll_results&id='+id);
}

function add_comment(form) {
	var conf = {
		parameters: $(form).serialize(true),
		onSuccess: function() {
			$('comment_form').enable();
		}
	};
	new Ajax.Updater('comment_div', 'add_comments.html', conf );
	$('comment_form').disable();
}

function preview_vent(form) {
	new Ajax.Updater('preview_div', 'preview_vent.html', { parameters: $(form).serialize(true) });
}

function add_minivent(form,chars) {
	forma = document.getElementById('mv_form');
	var regex = new RegExp('((ftp://|https?://)?([a-zA-Z0-9_%+-]*(:[a-zA-Z0-9_%+-]*\\@)?)?[a-zA-Z0-9_%+-]*\\.[a-zA-Z]{2,6}(:[0-9]*)?(/[a-zA-Z0-9_%+-]*)*(/?|\\.[a-zA-Z]{1,6})?)+');
	var match = regex.test(forma.vent_t.value);
	var is_ok = 1;
	if (forma.message.value.length < chars) {
		alert('You need to say more.');
		forma.message.focus();
		is_ok = 0;
	}
	if (match) {
		alert('Sorry, no URLs please.');
		is_ok = 0;
	}
	if (forma.code.value.length < 1) {
		alert('Code cannot be empty.');
		forma.code.focus();
		is_ok = 0;
	}
	//alert($(form).name);
	if( is_ok == 1) {
		new Ajax.Updater('mv_div', 'add_minivents.html', { parameters: $(form).serialize(true) });
		$(form).message.value='';
	}
}
/* marian / popup */
function popUp( url, name, popW, popH, scrollbars)
{
	if (!( url.length>0)) return false;
	var winleft=(screen.width - popW) / 2;
	var wintop=(screen.height - popH) / 2;
	popFullH = popH + 60;
	popFullW = popW + 24;
	winProp='width='+popFullW+',height='+popFullH+',left='+winleft+',top='+wintop+',scrollbars='+(scrollbars?1:0)+',status=1,resizable=1';
	name=window.open( url, name, winProp);
	name.focus();
	return true;
}
/* show */
var show = function( id ) {
	document.getElementById( id ).style.display = 'block';
}
/* hide */
var hide = function( id ) {
	document.getElementById( id ).style.display = 'none';
}