﻿var JS;

JS = {

	_min_w: 800,
	_min_h: 500,
	_max_w: 1400,
	_max_h: 900,
	_keret: 20,
	_w: false,
	_h: false,

	igazitas: function() {

		w = $(window).width();
		h = $(window).height();

		torzs_w = w - 2*JS._keret;
		torzs_h = h - 2*JS._keret;

		if (torzs_w > JS._max_w) torzs_w = JS._max_w;
		if (torzs_h > JS._max_h) torzs_h = JS._max_h;

		if (torzs_w < JS._min_w) torzs_w = JS._min_w;
		if (torzs_h < JS._min_h) torzs_h = JS._min_h;

		if (w > torzs_w + 2*JS._keret) left_px = Math.round((w - torzs_w) / 2);
		else left_px = JS.keret;

		if (h > torzs_h + 2*JS._keret) top_px = Math.round((h - torzs_h) / 2);
		else top_px = JS._keret;

		$('#torzs').css({ height: torzs_h, left: left_px, right: left_px, top: top_px, bottom: top_px });

		cpy_top = top_px + torzs_h;
		$('#cpy').css({ top: cpy_top });

		// alert(torzs_w + ' * ' + torzs_h);

		CORE.initGalleriaBG(torzs_w, torzs_h);

		JS._w = w;
		JS._h = h;

	},

	kezdolap_anim: function() {

		$("#logo, #nyelvek, #also_menu, #menupont_1, #menupont_2, #menupont_3, #menupont_4, #menupont_fb, #menupont_hl, #galleriaImgBG, #tartalom_belso, #cpy").css({ opacity: 0 }); // , filter: "alpha(opacity=0)"

		$("#logo").delay(1000).fadeTo(1000, 1, function () {

			$("#nyelvek").delay(10).fadeTo(500, 1, function () {
				
				$("#also_menu").delay(100).fadeTo(1000, 1, function () {
				
					$("#menupont_1").delay(10).fadeTo(300, 1, function () {

						$("#menupont_2").delay(10).fadeTo(300, 1, function () {

							$("#menupont_3").delay(10).fadeTo(300, 1, function () {

								$("#menupont_4").delay(10).fadeTo(300, 1, function () {

									$("#menupont_hl").delay(10).fadeTo(300, 1, function () {

										$("#menupont_fb").delay(10).fadeTo(300, 1, function () {

											$("#galleriaImgBG").delay(100).fadeTo(1000, 1, function () {

												$("#tartalom_belso").delay(100).fadeTo(500, 1, function () {

													$("#cpy").delay(500).fadeTo(500, 1, function () {

													});

												});

											});

										});
					
									});
							
								});
					
							});

						});

					});

				});
			
			});

		});

	},

	hirlevelOn: function() {
			
		$('#hirlevel_form').animate({
			right: 0
		}, 1000);

		return false;

	},

	hirlevelOff: function() {
	
		$('#hirlevel_form').animate({
			right: -470
		}, 1000);

		return false;

	},

	hirlevelSubmit: function() {
		
		_input_error = false;

		rx1 = CORE.regexCheck("hirlevel_nev_input", true, 'Nem adta meg a nevét!');
		rx2 = CORE.regexCheck("hirlevel_email_input", 'email', 'Nem e-mail címet adott meg!');

		if (rx1 && rx2) {

			$.post('modulok/hirlevel_feldolgozas.php', $("#hirlevel_form").serialize(), function(data) {

				// alert(data);
			   
				if (data == 'ok') {

					alert('Ok!');
					JS.hirlevelOff();

				}
				else alert('Error!');

			});

		}

		return false;

	},

	init: function() {

		JS.igazitas();
		if (kell_kezdolap_anim == 1) JS.kezdolap_anim();

		$(window).resize(function() {

			JS.igazitas();
		
		});

	}

};

// jQuery.noConflict();
jQuery(document).ready(function($){

	JS.init();

});
