function initform() {

    var text = null;
    var text = $('.text-field2 textarea').val();
    if (text != "") {
        $('.capcha').slideDown();
    } else {
        $('.capcha').slideUp();
    }

}
$(function() {

	if ($.browser.msie && $.browser.version <= '7.0') {
		$('#header-menu').clone('#header-menu').insertAfter('.main').css({
			position: 'absolute',
			top: '209px',
			left: '20px'
		})
		$('#header-menu').remove();

		$('#header-menu li').hover(function() {
			$(this).addClass('jhover');
			},function () {
			$(this).removeClass('jhover');
		});		
	} else {}
});

$(document).ready(function() {

 tmp = $("#item_content p:gt(1)")
if (tmp.length)
{
       $("#item_content p:gt(1)").hide()
       $("#show").show()
       $("#hide").hide()

}
       $("#show").click(function(){
               $("#item_content p, #hide").show()
               $(this).hide()
       })

       $("#hide").click(function(){
               $("#item_content p:gt(1)").hide()
               $(this).hide()
               $("#show").show()
       })



	$('#header-menu li').hover(
	function()
	{
		$(this).addClass('jhover');
	},function ()
	{
		$(this).removeClass('jhover');
	});
	
    initform();
    $('.text-field2 textarea').keyup(function(){
        initform();
    });
    $('.text-field2 textarea').change(function(){
        initform();
    });
	
	$('.catalog-item').hover(
	function()
	{
		$(this).find('div.jcarousel-next').fadeIn(250);
		$(this).find('div.jcarousel-prev').fadeIn(250);
	},function ()
	{
		$(this).find('div.jcarousel-next').fadeOut(250);
		$(this).find('div.jcarousel-prev').fadeOut(250);
	});

//	$('.catalog-item-wrapper').jcarousel({scroll: 1 });

	$('.catalog-item, .catalog-z-item, .sub').append("<i class='tl'></i><i class='tr'></i><i class='br'></i><i class='bl'></i>");

	$('.icatalog tbody tr').hover(
	function()
	{
		$(this).addClass('tr-hover');
	},function ()
	{
		$(this).removeClass('tr-hover');
	});
	
	$('.icatalog tr').click(function () {
		check = $(this).find('input:checkbox');

		if (check.attr("checked")) {
			$(check).removeAttr("checked","checked");
		} else {
			$(check).attr("checked","checked");
		}
	});
	$('.icatalog tr input:checkbox').click(function () {
		check = $(this);
		if (check.attr("checked")) {
			$(this).removeAttr("checked","checked");
		} else {
			$(this).attr("checked","checked");
		}
	});
	
    $("select.nom1").change(function () {
		var str = "Раздел: ";
		
		nn = $('select.nom1 option:selected').val();
		
		if ( nn == 0 ) { } else {
		
		$("select.nom1 option:selected").each(function () {
			str += $(this).text() + " ";
			});
		$("div.nom1res").text(str).css({display:'block', textDecoration: 'underline', color: 'red', cursor: 'pointer'});
		$(this).css({display: 'none'});
		$('.d2').css({display: 'block'});
		}
    }).change();
	
    $("select.nom2").change(function () {
		var str = "Раздел: ";
		
		nn2 = $('select.nom1 option:selected').val();
		
		if ( nn2 == 1 ) {  $("select.nom2").css({display: 'none'});  } else {
		
		$("select.nom2 option:selected").each(function () {
			str += $(this).text() + " ";
			});
		$("div.nom2res").text(str).css({display:'block', textDecoration: 'underline', color: 'red', cursor: 'pointer'});
		$(this).css({display: 'none'});
		$('.d3').css({display: 'block'});
		}
    }).change();
	
    $("select.nom3").change(function () {
		var str = "Раздел: ";
		
		nn3 = $('select.nom3 option:selected').val();
		
		if ( nn3 == 2 ) { $("select.nom3").css({display: 'none'}); } else {
		
		$("select.nom3 option:selected").each(function () {
			str += $(this).text() + " ";
			});
		$("div.nom3res").text(str).css({display:'block', textDecoration: 'underline', color: 'red', cursor: 'pointer'});
		$(this).css({display: 'none'});
		}
    }).change();
	
	$("div.nom1res").click(function() {
		$(this).css({display:'none'});
	    $("select.nom1").css({display:'block'});
	});
	
	$("div.nom2res").click(function() {
		$(this).css({display:'none'});
	    $("select.nom2").css({display:'block'});
	});
	
	$("div.nom3res").click(function() {
		$(this).css({display:'none'});
	    $("select.nom3").css({display:'block'});
	});

});