
	/*
	 * Simakin Dmitry dima@foreline.ru
	 */

	/*
	 * Меняет картинки в шапке
	 */
	
	var s_i = 0;
 
	function nextSlide() {
		
		if (0 <= s_i) {
			
			
			image = arSlides[s_i].IMAGE;
			
			$('#teaserHeader').html(arSlides[s_i].COUNTRY);
			$('#teaserPriceFrom').html(arSlides[s_i].PRICE_FROM);
			$('#teaserInfo').html(arSlides[s_i].ANOUNCE);
			$('#teaserDescription').html(arSlides[s_i].DETAIL);
			$('#teaserDetailURL').html('<a href="'+arSlides[s_i].URL+'">'+'подробнее'+'</a>');
			
			var j = 0;
			
			$('#headerImageContainer').attr({
				'src': image
			}).load(function(){
				
				j++;
				
				if (j == 1) {
				
					//console.log('Debug 1');
					
					$('#headerContainerBackground').css({
						'background-image': 'url(' + image + ')',
						'width': '100px',
						'height': '50px',
					}).animate({
						'width': '980px',
						'height': '341px'
					}, '600', function(){
						// Тизер с текстом
						
						
						teaserHeight = $('#headerTeaser').css('height');
						teaserHeight = teaserHeight.replace('px', '');
						
						//percent = 100/teaserHeight;
						//console.log('teaserHeight: ' + teaserHeight);
						k1 = parseInt(teaserHeight + (teaserHeight * 3.5) / 100);
						//console.log(k1);
						k2 = parseInt(teaserHeight - teaserHeight * 20 / 100);
						k3 = parseInt(teaserHeight + teaserHeight * 6 / 100);
						k4 = parseInt(teaserHeight);
						
						k1 = 294;
						k2 = 264;
						k3 = 290;
						k4 = 284;
						
						k1 = 264;
						k2 = 234;
						k3 = 260;
						k4 = 254;
						
						$('#headerTeaser').css({
							'height': '0px'
						}).animate({
							'height': k1 + 'px'
						}, '400').animate({
							'height': k2 + 'px'
						}, '200').animate({
							'height': k3 + 'px'
						}, '200').animate({
							'height': k4 + 'px'
						}, '200');
						
					});
				}
				
			});
			

		}
		
		if ( (arSlides.length - 1 ) <= s_i ) {
			s_i = 0;
		} else {
			s_i++;
		}
		
		var t = setTimeout('nextSlide()', 10000);
		
	}

