//-------------------------------------------------------------------------------
// functions
//-------------------------------------------------------------------------------
	function preloadImages(imgs){
		var picArr = [];
		for (i = 0; i<imgs.length; i++){
			picArr[i]= new Image(100,100); 
			picArr[i].src=imgs[i]; 
		}
	}
//-------------------------------------------------------------------------------
// exec
//-------------------------------------------------------------------------------
	preloadImages([
		'/images/loading.gif',
		'/images/loading-small.gif',
		'/images/header-menu-item-hover.png',
		'/images/icon/plus.png',
		'/images/icon/minus.png'
	]);
	$.ajaxSetup({timeout: 10000});
	$(document).ready(function(){
		//loader
		$('body').prepend("<div id='layer-loading' style='width:100%;height:100%;z-index:9999;position:fixed;background:url(/images/loading.gif) center center no-repeat;display:none;cursor:wait;'><div style='width:100%;height:100%;background-color:#fff;opacity:0.1;filter:alpha(opacity=10);'><img src='/images/spacer.gif' width='100%' height='100%' style='float:left;border:0 none;' /></div></div>");
		//fontFix
		$('h1, #product-categories div.main, #col-main div.price, #col-main table.list th, #col-main a.label, #fancybox-title-inside').ieffembedfix();
		//search
		if($('input', '#col-left div.search').val() == '') $('div.search input').val('Keresés…').one('click', function(){$(this).val('');});
		//left menu
		$('#product-categories li').filter(function(){return $(this).children('ul').length > 0}).children('a').click(function(event){
			$(this).children('div').toggleClass('open');
			$(this).siblings('ul').stop(true, true).slideToggle('slow');
			$.cookie($(this).attr('id'), $(this).children('div').hasClass('open') ? 'open' : null, {path: '/'});
			event.preventDefault();
		});
		//login
		$('a[name=login]', 'div.login').click(function(event){
			event.preventDefault();
			$.post('/include/user.communication.php', {action: 'login', email: $(this).siblings('input[name=email]').val(), password: $(this).siblings('input[name=password]').val()}, $.proxy(function(response){
				if(response == 'validationError'){$(this).siblings('input').addClass('error');return;}
				window.location.reload();			
			}, this));
		});
		//logout
		$('a[name=logout]', 'div.login').click(function(event){
			event.preventDefault();
			$.post('/include/user.communication.php', {action: 'logout'}, $.proxy(function(){
				window.location.href = this.href;
			}, this));
		});
		//fancyBox
		$('a[rel]').fancybox({overlayColor: '#357', titlePosition: 'inside'});
	}).ajaxStart(function(){
		$('#layer-loading').css('display', 'block');
	}).ajaxComplete(function(){
		$('#layer-loading').css('display', 'none');
	}).ajaxError(function(event, xhr){
		alert('A műveletet nem sikerült végrehajtani…\nPróbálja meg mégyegyszer!');
	});

