function fixPngImages() {
    DD_belatedPNG.fix('.logo img, #header, #footer');   
}

$(document).ready(function(){
    if ($.browser.msie) {
	if ($.browser.version=='6.0') {
	    fixPngImages();
	}
    }
    $('#clipregion').clipregion({
				'itemHeight':245,
				'itemWidth':185,
				'totalItems':$('ul > li',$('#catalogs')).size(),
				'itemsToShow':3,
				'itemStep':true
			});
    $('#clipregion2').clipregion2({
				'itemHeight':245,
				'itemWidth':185,
				'totalItems':$('ul > li',$('#catalogs2')).size(),
				'itemsToShow':3,
				'itemStep':true
			});
    $('#clipregion3').clipregion3({
				'itemHeight':190,
				'itemWidth':240,
				'totalItems':$('ul > li',$('#catalogs3')).size(),
				'itemsToShow':2,
				'itemStep':true
			});
    $('#catalogs2').css({overflow: 'hidden'});
    $('#catalogs3').css({overflow: 'hidden'});
    $('#cat-next').click(function(){
	$.clipregion.next();
	return false;
    });
    $('#cat-nextnew').click(function(){
	$.clipregion2.next();
	return false;
    });
    $('#cat-nextnew2').click(function(){
	$.clipregion3.next();
	return false;
    });
    $('#cat-prev').click(function(){
	$.clipregion.prev();
	return false;
    });
    $('#cat-prevnew').click(function(){
	$.clipregion2.prev();
	return false;
    });
    $('#cat-prevnew2').click(function(){
	$.clipregion3.prev();
	return false;
    });
    $('#test1').crossSlide({
      speed: 45,
      fade: 1
    }, [
      { src: '/js/1.jpg', dir: 'up'   },
      { src: '/js/3.jpg', dir: 'down' },
      { src: '/js/2.jpg', dir: 'up'   },
      { src: '/js/5.jpg', dir: 'down' },
      { src: '/js/4.jpg', dir: 'up'   },
      { src: '/js/6.jpg', dir: 'down' },
      { src: '/js/7.jpg', dir: 'up'   },
      { src: '/js/8.jpg', dir: 'down' }
    ]);
		
	$("#request_catalog").click(function(){
		boxy = new Boxy($("#get_catalog"));
		return false;
	});
	$('#get_catalog form').submit(function(){
		nameField = $.trim($('#get_catalog input[name=name]').val());
		placeField = $.trim($('#get_catalog input[name=place]').val());
		adresField = $.trim($('#get_catalog input[name=adres]').val());
		fioField = $.trim($('#get_catalog input[name=fio]').val());
		firmaField = $.trim($('#get_catalog input[name=firma]').val());
		indexField = $.trim($('#get_catalog input[name=index]').val());
		adrespField = $.trim($('#get_catalog input[name=adresp]').val());
		phoneField = $.trim($('#get_catalog input[name=phone]').val());
		emailField = $.trim($('#get_catalog input[name=email]').val());
		descrField = $.trim($('#get_catalog textarea').val());
		if (nameField.length==0 || placeField.length==0 || adresField.length==0 || fioField.length==0 || indexField.length==0 || adrespField.length==0 || phoneField.length==0) {
			alert('Вы не заполнили все обязательные поля в форме.');
		} else {
			var html = $(this).html();
			var that = $(this);
			$(this).html('Идет отправка данных.');
			$.post('/form_catalog.php', {
					name: nameField, 
					place: placeField, 
					adres: adresField, 
					fio: fioField, 
					firma: firmaField, 
					index: indexField, 
					adresp: adrespField, 
					phone: phoneField, 
					email: emailField,
					descr: descrField
				}, function(){
				that.html(html);
				boxy.hide();				
			});
		}
		return false;
	});
		
	$("#request_phone").click(function(){
		boxy = new Boxy($("#feedback"));
		return false;
	});
	$('#feedback form').submit(function(){
		nameField = $.trim($('#feedback input[name=name]').val());
		phoneField = $.trim($('#feedback input[name=phone]').val());
		descrField = $.trim($('#feedback textarea').val());
		if (nameField.length==0 || phoneField.length==0 || descrField.length==0) {
			alert('Вы не заполнили все обязательные поля в форме.');
		} else {
			var html = $(this).html();
			var that = $(this);
			$(this).html('Идет отправка данных.');
			$.post('/form.php', {name: nameField, phone: phoneField, descr: descrField}, function(){
				that.html(html);
				boxy.hide();				
			});
		}
		return false;
	});
	
});
