jQuery.preloadImages = function() {
  for(var i = 0; i<arguments.length; i++) {
	 jQuery('<img>').attr('src', arguments[i]);
  }
}
	
function addBookmark() {
	title = 'Kelet-Balatoni Területfejlesztési Önkormányzati Társulás';
	url = 'http://www.keletbalaton.hu';

	if($.browser.mozilla) {
		window.sidebar.addPanel(title,url,'');
	} else if($.browser.msie) {
		window.external.AddFavorite(url,title);
	} else {
		return true;
	}
}

function setHomePage() {
	if($.browser.msie) {
		document.body.style.behavior='url(#default#homepage)';
		document.body.setHomePage('http://www.keletbalaton.hu');
	}
}

function selectCity(name) {
	var mCity = $('#mCity');
			
	switch(name) {
		case 'alsoors':
			mCity.html($('#mAlsoors').html());
			mCity.css('margin-top',0);
			break;
		case 'balatonalmadi':
			mCity.html($('#mBalmadi').html());
			mCity.css('margin-top',16);
			break;
		case 'balatonfokajar':
			mCity.html($('#mBfokajar').html());
			mCity.css('margin-top',32);
			break;
		case 'balatonfuzfo':
			mCity.html($('#mBfuzfo').html());
			mCity.css('margin-top',48);
			break;
		case 'balatonkenese':
			mCity.html($('#mBkenese').html());
			mCity.css('margin-top',64);
			break;
		case 'balatonvilagos':
			mCity.html($('#mBvilagos').html());
			mCity.css('margin-top',80);
			break;
		case 'csajag':
			mCity.html($('#mCsajag').html());
			mCity.css('margin-top',96);
			break;
		case 'felsoors':
			mCity.html($('#mFelsoors').html());
			mCity.css('margin-top',112);
			break;
		case 'kungos':
			mCity.html($('#mKungos').html());
			mCity.css('margin-top',128);
			break;
		case 'liter':
			mCity.html($('#mLiter').html());
			mCity.css('margin-top',144);
			break;
		/*case 'lovas':
			mCity.html($('#mLovas').html());
			mCity.css('margin-top',160);
			break;*/
		case 'szentkiraly':
			mCity.html($('#mSzkszabadja').html());
			mCity.css('margin-top',160);
			break;
	}
}

$(document).ready(function() {
  $('input[@type=radio],input[@type=checkbox]').each(function() {
		$(this).css('border-width','0px');
		$(this).css('background-color','transparent');
		$(this).css('background-image','none');
	});

	$('img.hover').each(function() {
		var imgSrc = $(this).attr('src');

		$(this).mouseover(function() {
			$(this).attr('src',imgSrc.replace(/off\./,'on.'));
			
			var parts = imgSrc.split('_');
			
			selectCity(parts[1]);
		});

		$(this).mouseout(function() {
			$(this).attr('src',imgSrc.replace(/on\./,'off.'));
		});
	});

	$('form[@name=form-newForumTopic]').each(function() {
		$(this).submit(function() {
			if($('#message').val() == '') {
				alert('A hozzászólás megadása kötelező!');
				return false;
			}
		});
	});
});
