function checkpoll( form ) {
	var polloptions = document.getElementsByName( "poll_option" );
	for ( i = 0; i < polloptions.length; i++ ) {
		if ( polloptions[i].checked == true ) {
			vote( form.pollId.value, form.poll_option[i].value );
			return false;
		}
	}
	alert( "Please select a poll option." );
	return false;
}

function validateSubscribe(form){
	var email = form.txtEmail;

	if(email.value == ''){
		alert('Please enter your email address.');
		email.focus();
		return false;
	}
	alert( "Thank you. Your email address has been added to our recipient list." );
	return true;
}

function validateComment( form ) {
	if ( form.name.value == "" ) {
		alert( 'Invalid name.' );
		form.name.focus();
		return false;
	}
	if ( form.txtComment.value == "" ) {
		alert( 'Invalid comment.' );
		form.txtComment.focus();
		return false;
	}
	if ( form.prevention.value == "" || form.prevention.value != form.val_key.value ) {
		alert( 'Invalid validation number' );
		form.prevention.focus();
		return false;
	}
	return true;
}

function removeComment( id ) {
	if ( confirm( "Click OK to permanently delete this comment." )) {
		var ajax = new Ajax();
		ajax.post( SYSTEM_URL + "/magazine/index/deleteComment", magStateChanged, [ ["id", encodeURI( id )] ] );
	}
}

function vote( pollId, optionId ) {
	var ajax = new Ajax();
	ajax.post( SYSTEM_URL + "/magazine/index/vote", magStateChanged, [ 
		["pollId", encodeURI( pollId )],
		["optionId", encodeURI( optionId )]
	] );
}

function magStateChanged( msg ) {
//	alert(msg);
	window.location = window.location;
}
