preloader = function(objPr, bottomImg, topImg, frameSize, imgHeight, workTime, callback){
	var prInterval = undefined;
	var intervalDuration = Math.round ( workTime / ( imgHeight / frameSize ) );
	
	var prInt = function(){
		var nowBotImgTop = parseInt( jQuery( bottomImg ).css('top') );
		
		if( Math.abs( nowBotImgTop ) <= ( imgHeight - frameSize * 2 ) ){
			jQuery( bottomImg ).css({'top': ( nowBotImgTop - frameSize ) + 'px'});
			jQuery( topImg ).animate({'opacity': 0}, 300, 'linear', function(){
				jQuery( topImg ).css({'top': ( nowBotImgTop - frameSize ) + 'px', 'opacity': 1});
			});
		}else{
			clearInterval( prInterval );
			jQuery( bottomImg ).css({'top': '0px'});
			jQuery( topImg ).animate({'opacity': 0}, 300, 'linear', function(){
				jQuery( topImg ).css({'top': '0px', 'opacity': 1});
			});
			callback();
		}
	}
	
	prInterval = setInterval(function(){ prInt(); }, intervalDuration);
}
initPreloader = function(){
	var headerImages = [
		{
			src: 'assets/templates/main/images/headers/topBg0.jpg',
			next: 1
		},
		{
			src: 'assets/templates/main/images/headers/topBg1.jpg',
			next: 2
		},
		{
			src: 'assets/templates/main/images/headers/topBg2.jpg',
			next: 3
		},
		{
			src: 'assets/templates/main/images/headers/topBg3.jpg',
			next: 4
		},
		{
			src: 'assets/templates/main/images/headers/topBg4.jpg',
			next: 5
		},
		/*
		{
			src: 'assets/templates/main/images/headers/topBg5.jpg',
			next: 6
		},
		{
			src: 'assets/templates/main/images/headers/topBg6.jpg',
			next: 7
		},
		*/
		{
			src: 'assets/templates/main/images/headers/topBg7.jpg',
			next: 0
		}
	];
	var nextImage = function(id){
		jQuery( '#headerImg' + id ).animate({'opacity': 0}, 3000, 'swing', function(){
			jQuery( '#headerImg' + headerImages[id].next ).animate({'opacity': 1}, 3000, 'swing', function(){
				setTimeout(function(){ nextImage( headerImages[id].next ); }, 5000);
			});
		});
	}
	var imgsOut = '';
	for ( var i = headerImages.length-1; i >= 0; i-- ){
		imgsOut = imgsOut + '<img id="headerImg' + i + '" src="' + headerImages[i].src + '" alt="">';
	}
	jQuery('#header').append('<div id="animateHeader">'+imgsOut+'</div>');
	setTimeout(function(){
		jQuery('#header').css({'backgroundImage': 'url(assets/templates/main/images/headerBgBlank.jpg)'});
		jQuery('#animateHeader img').not('#headerImg0').css({'opacity': 0});
		jQuery('#animateHeader').css({'visibility': 'visible'});
		setTimeout(function(){ nextImage(0); }, 5000);
	}, 300);
}
mainInitFunction = function(){
	jQuery('div.actionBlock>div.action>a>img.color').css({'opacity': 0, 'top': 0});
	jQuery('div.actionBlock>div.action>a').hover(function(){
		jQuery(this).find('img.color').animate({'opacity': 1}, {'duration': 300, 'queue': false});
	}, function(){
		jQuery(this).find('img.color').animate({'opacity': 0}, {'duration': 300, 'queue': false});		
	});
	var menuBgTopPos = 0;
	jQuery('#mainMenu li').each(function(){
		var activator = jQuery('<div class="activator"></div>');
		var link = jQuery(this).find('a');
		link.clone(true).appendTo(activator);
		var realHeight = parseInt(jQuery(this).innerHeight()-11);
		var realWidth = parseInt(jQuery(this).innerWidth()-50);
		jQuery(activator).css('height',realHeight+'px');
		jQuery(activator).css('width',realWidth+'px');
		jQuery(activator).css('opacity','0.0');
		jQuery(activator).hover(function(){
			jQuery(this).animate({'opacity':'1.0',
								  'paddingTop': '16px',
								  'paddingLeft':'55px',
								  'fontSize': '1.4em',
								  'left': '-5px',
								  'top':'-5px',
								  'height': (realHeight+10+'px'),
								  'width': (realWidth +10+'px')
								  },{'duration':200, 'queue':true});
			},function(){
			jQuery(this).animate({'opacity':'0.0',
								  'paddingTop': '11px',
								  'paddingLeft':'50px',
								  'fontSize': '1em',
								  'left': '0px',
								  'top':'0px',
								  'height': (realHeight+'px'),
								  'width': (realWidth+'px')
								  },{'duration':200, 'queue':true});

				})
		activator.appendTo(this);
	});
	initPreloader();
}
jQuery.noConflict();
jQuery(document).ready(mainInitFunction);