window.onload = function(){
	//var so = new SWFObject("site/graphics/baner.swf", "baner", "623px", "328px", "8", "#fff", "transparent");
	//so.write("baner");
}

$(document).ready(function() {
	//check if window is < 1024
	if(window.innerWidth < 1024){
		$('body').css('overflow', 'auto');
	}
	//events-contents tabs
	$('#events-list .menu-tab').each(function(e){
		$(this).click(function() {
			var id = $(this).attr('id').replace('click-','');

			$('.events-list-content').hide();
			$('#events-list .menu-tab').removeClass('menu-tab-active');
			$('#'+id).show();
			$(this).addClass('menu-tab-active');
		});
	});
	//search-engine
	$('#search-engine .search-title').each(function(e){
		$(this).click(function() {
			$('#search-engine .search-title').removeClass('search-title-active');
			$(this).addClass('search-title-active');
			$('#search-engine-strType').attr('value', $(this).attr('id'));
			$('.main-box-search').hide();
			$('#'+$(this).attr('id')+'-Search').show();
		});
	});

	//search-engine
	$('#recently-joined .search-title').each(function(e){
		$(this).click(function() {
			var id = $(this).attr('id').replace('click-','');
				
			$('.recently-joined-content').hide();
			$('.recently-tab').removeClass('recently-tab-active');
			$(this).addClass('recently-tab-active');
			$('#'+id).show();
		});
	});

	//event-content tab
	$('#event-menu li').each(function(e){
		$(this).click(function() {
			var id = $(this).attr('id').replace('li-','');
			$('#event-menu li').removeClass('li-title-active');
			$(this).addClass('li-title-active');
			$('.event-content').hide();
			$('#'+id).show();
			//$('#search-engine-strType').attr('value', $(this).attr('id'));
		});
		/*$(this).click(function() {
		$('#search-engine .search-title').removeClass('search-title-active');
		$(this).addClass('search-title-active');
		$('#search-engine-strType').attr('value', $(this).attr('id'));
		});*/
	});

});

//zaladowanie kalendarza
$(document).ready(function() {
	ajax('calendar.html', 'calendar');
	ajax('searchBox.html', 'search');
	ajax('eventsOn.html', 'events-on-box');
});


function showMenu(id){
	$('#'+id).slideToggle("fast");
	if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)){ //test for MSIE x.x;
	var ieversion = new Number(RegExp.$1);
}
}

function ajax( url, content, form, callback ){
	if ( $('#'+form) ){
		var jsonForm = $('#'+form).serializeArray();
	}
	$.ajax({
		url: url,
		type: 'POST',
		data: jsonForm,
		cache: false,
		success: function(html){
			$('#'+content).html(html);
			eval(''+callback+'');
			//fix();
		}
	});
}

function IsYourEvent(o, name){
	if (/sub event/.test(o.value)) {
		$('#'+name).show();
	} else {
		$('#'+name).hide();
		$('#strNameOfMainEvent').attr('value','');
	}
}

function changeEventTab(name){
	$(".tab").removeClass('active0');
	$(".tab").removeClass('active');
	$(".tabs-content").hide();
	$('#'+name+'-click').addClass('active0');
	$('#'+name+'-content').show();
}
