function checkCookie(name) {
	cookies = document.cookie.split(';');
	var ret = false;
	for (i = 0; i < cookies.length; i++) {
		cookie_ = cookies[i].split('=');
		if (cookie_[0].replace(/(^\s+)?(\s+$)?/, '') == name) {
			ret = true;
			break;
		}
	}
	return ret;
}

function ajaxSubmit(form, url) {
	if ($('activity_indicator') != null) $('activity_indicator').title = 'hidden';
	
	idx = '';
	if (arguments.length >= 4) idx = arguments[3];

	successAction = null;
	if (arguments.length >= 3) successAction = arguments[2];
	
	$('button' + idx).hide();
	$('loader' + idx).show();		
	new Ajax.Request(url, {
		parameters: Form.serialize($(form)),
		onComplete: function(t) {
			if ($('activity_indicator') != null) $('activity_indicator').title = '';
			
			$('button' + idx).show();
			$('loader' + idx).hide();
			//status = t.responseText; //.replace(/^\s+|\s+$/g, '');
			//alert(t.responseText);

			if (t.responseText == 'ok' && successAction != null) successAction();
			if (t.responseText != 'ok') alert(t.responseText);
		}
	});
}

function showNotify(str) {
	alert(str);
	/*
	$('notify_text').innerHTML = str;
	Element.setStyle('notify', {top: Math.round((screen.height / 2) - 150) + 'px'});
	Element.setStyle('notify', {left: Math.round((screen.width / 2) - 126) + 'px'});
	location.href = location.href.replace(/#+/, '') + '#';
	Element.setStyle('notify', {display: 'block'});
	new Effect.Highlight('notify', {duration: 3});
	setTimeout('hideNotify()', 4000);*/
}

function hideNotify() {
	if (Element.getStyle('notify', 'display') != 'none')
		new Effect.Fade('notify', {duration:0.5});
}

function preloadImages() {
	var imgs = new Array();
	for (var i = 0; i < arguments.length; i++) {
		imgs[i] = new Image();
		imgs[i].src = arguments[i];
	}
}

function leveledHeight() {
	var maxHeight = 0;
	var height = 0;
	for (var i = 0; i < arguments.length; i++)
		if ($(arguments[i]) != null) {
			height = $(arguments[i]).getHeight() - $(arguments[i]).getStyle('padding-top').replace(/px/, '') - $(arguments[i]).getStyle('padding-bottom').replace(/px/, '');
			maxHeight = maxHeight < height ? height : maxHeight;
		}
		
	for (var i = 0; i < arguments.length; i++)
		if ($(arguments[i]) != null) 
			$(arguments[i]).setStyle({ height: maxHeight + 'px' });
}
