$(document).ready(function(){
	MainPage.init();
});
var MainPage = {
	/*Fejér Lipót mutatása*/
	lipotShown: false,
	clickLipot: function(){
		if(!this.lipotShown){
			this.showLipot();
			this.lipotShown = true;
		}
		else{
			this.hideLipot();
			this.lipotShown = false;
		}
	},
	showLipot: function(){
		$.ajax({
			url: appConf.siteUrl + 'fejer',
			success: function(data) {
				$('.lipot').fadeIn(1000);
				$('.lipot').html(data);
			}
		});
	},
	hideLipot: function(){
		$('.lipot').fadeOut(1000);
	},

	clickMail: function(){
		var atsign = '@';
		var dotsign = '.';
		var mAddress = 'ma';
		mAddress += 'il';
		mAddress += 'to:';
		mAddress += 'info';
		mAddress += atsign;
		mAddress += 'stm3';
		mAddress += dotsign;
		mAddress += 'hu';
		window.location = mAddress;
	},
	/*google térkép, foglalás, galéria betöltés*/
	init: function(){
		$('#lipotInfo').click(function(){
			MainPage.clickLipot();
		});

		this.googleMaps();

		$('#s_images').galleria({
			data_source: appConf['smallImages']
		});
		$('#b_images').galleria({
			data_source: appConf['bigImages']
		});
		$('input[type=checkbox]').checkbox({
			empty: 'img/checkbox_empty.png'
		});

		$('#contactmail').click(function(){
			MainPage.clickMail();
		});

		$('.english').click(function(){
			$.ajax({
				url: appConf.siteUrl + 'site/setLang',
				dataType: 'json',
				data: {
					lang: $(this).attr('rel')
				},
				success: function(data) {
					if (data) {
						document.location = appConf.siteUrl;
					}
				}
			});

		});
		
		CalendarController.init();

		$('.calendarHelp').click(function(){
			var textToShow = '';
			textToShow = '<p>' + appConf.texts.index[1] + '<p>';
			textToShow += '<p><big>1.</big>';
			textToShow += appConf.texts.index[2] + '<p>';
			textToShow += '<p><big>2.</big>';
			textToShow += appConf.texts.index[3] + '<p>';
			textToShow += '<p>' + appConf.texts.index[10] + '<p>';
			textToShow += '<p><big>3.</big>';
			textToShow += appConf.texts.index[4] + '<p>';
			textToShow += '<p><big>4.</big>';
			textToShow += appConf.texts.index[5] + '<p>';
			textToShow += '<p><big>5.</big>';
			textToShow += appConf.texts.index[6] + '<p>';
			textToShow += '<p><big>6.</big>';
			textToShow += appConf.texts.index[7] + '<p>';
			textToShow += '<p><big>7.</big>'
			textToShow += appConf.texts.index[8] + '<p>';
			textToShow += '<p>' + appConf.texts.index[9] + '<p>';
			$.prompt(textToShow,{
				classes: 'jqi-info', 
				top: '5%', 
				focus: 1
			});
		});
		//bannerhez
		function toggleLayer(){
			if($('div.bannerLayer').is(':hidden')){
				$('div.bannerLayer').slideDown(800);
			}
			else{
				$('div.bannerLayer').slideUp(800);
			}
		}
		$('.bannerLogo').click(function(){
			toggleLayer();
			return false;
		});
		$('.banner').click(function(){
			toggleLayer();
		});
		
		$('div.bannerLayer .closeBtn').click(function(){
			toggleLayer();
		});
	},
	/*google térkép*/
	googleMaps: function() {
		var latlng = new google.maps.LatLng(46.0777898, 18.2320918);

		var myOptions = {
			zoom: 15,
			center: latlng,
			mapTypeId: google.maps.MapTypeId.ROADMAP
		};
		var map = new google.maps.Map(document.getElementById("map"),myOptions);

		var marker = new google.maps.Marker({
			map: map,
			position: latlng
		});
	}
}

