var last = null;

Asset.images([
	'images/play2.gif',
	'images/play.gif',
	'images/stop.gif'
]);

window.addEvent('domready', function() {
	var form = $('newsform');

	if (form!=null) {
		form.addEvent('submit', function(e) {
			e.stop();

			var s = $('email').value;

			if (s=='') {
				alert("Óêàæèòå Âàø e-mail");
			}

			if (s.length > 0) {
				a=s.indexOf("@");
				j=s.indexOf(".",a);
				k=s.indexOf(",");
				kk=s.indexOf(" ");
				jj=s.lastIndexOf(".")+1;
				len=s.length;
				if(!(((a>0) && (j>(a+1)) && (k==-1) && (kk==-1) && (len-jj >=2) && (len-jj<=5)))) {
					alert("Óêàæèòå êîððåêòíûé e-mail");
				} else {
					form.submit();
				}
			}

		});
	}
});

function gotopage(el) {
	if (el.value!='') 
	document.location.href = el.value;
}

function handleFlashMenuRelease(id) {
	if (id==4) {
		document.location.href = 'http://www.kultprosvet.info';
		return false;
	} else {
		new Request.HTML({
			evalScripts: true,
			update: 'index',
			url: 'index.php'
		}).send('id=' + id);
	}
}

function audioplayer(id) {
	var push = $('push' + id);
	var track = $('track' + id);

	if (track.opened) {
		push.removeClass('stop');
		track.setStyle('display', 'none');
		track.opened = false;
		track.empty();
	} else {

		if (last!=null) {
			$('push' + last).removeClass('stop');
			$('track' + last).opened = false;
			$('track' + last).setStyle('display', 'none');
			$('track' + last).empty();
		}

		track.opened = true;
		track.setStyle('display', 'block');
		push.addClass('stop');

		new Request.HTML({
			update: track,
			evalScripts: true,
			url: 'discography.php'
		}).send('id=' + id);

		last = id;
	}
}
