﻿function show_div( id )
{
	var div = document.getElementById( id );
	div.style.display = 'block';
}

function hide_div( id )
{
	var div = document.getElementById( id );
	div.style.display = 'none';
}

function show_hide_div( id )
{
	var div = document.getElementById( id );
	if( id != prev_sub && prev_sub != '' ) {
		hide_div( prev_sub );
	}
	if( div.style.display == 'none' ) {
		show_div( id );
		prev_sub = id;
	} else {
		hide_div( id );
	}
}

function show_displaydiv(id)
{
	div = document.getElementById(id);
	div.style.display = 'block';
	div.style.height = document.getElementById('body_page').scrollHeight + 'px';
}


$(function(){
	$("#link-tab-home-2").click(function(){
		$("#tab-home-1").hide();
		$("#tab-home-2").show();
		$(".jcarousel-skin-home").jcarousel({
			scroll: 4,
			wrap: 'circular'
		});
		return false;
	});
	
	$("#link-tab-home-1").click(function(){
		$("#tab-home-2").hide();
		$("#tab-home-1").show();
		return false;
	});
	
	$(".catalog-item").mouseover(function(){
		$(this).find(".btn_order_hidden").show();
		return false;
	});
	
	$(".catalog-item").mouseout(function(){
		$(this).find(".btn_order_hidden").hide();
		return false;
	});
	
	$(".link-carousel-home-2").click(function(){
		$("#div-carousel-home-1").hide();
		$("#div-carousel-home-3").hide();
		$("#div-carousel-home-2").show();
		$(".jcarousel-skin-home").jcarousel({
			scroll: 4, 
			wrap: 'circular'
		});
		return false;
	});
	
	$(".link-carousel-home-1").click(function(){
		$("#div-carousel-home-2").hide();
		$("#div-carousel-home-3").hide();
		$("#div-carousel-home-1").show();
		$(".jcarousel-skin-home").jcarousel({
			scroll: 4, 
			wrap: 'circular'
		});
		return false;
	});
	
	$(".link-carousel-home-3").click(function(){
		$("#div-carousel-home-2").hide();
		$("#div-carousel-home-1").hide();
		$("#div-carousel-home-3").show();
		$(".jcarousel-skin-home").jcarousel({
			scroll: 4, 
			wrap: 'circular'
		});
		return false;
	});
	
	$(".link_pimg_th").click(function(){
		$(".pimages_th .bg_arrow").removeClass("sel");
		$(this).parent().parent().find(".bg_arrow").addClass("sel");
		var img = $(this).parent().css("backgroundImage");
		var rli = img.indexOf("_th.");
		img = img.substr(0, rli);
		img = img.substr(5);
		$("#pimg_big").css("backgroundImage", "url(" + img + ".jpg)");
		
		return false;
	});
	
	$(".btn_order").click(function(){
		$("#order_product_name").text($(this).find(".btn_order_img").attr("alt"));
		$("#order_product_name_input").val($(this).find(".btn_order_img").attr("alt"));
		show_displaydiv('popup_order');
		return false;
	});
	$(".btn_consultant_left").click(function(){
		show_displaydiv('popup_request');
		//return false;
	});
	
	$(".close_popup").click(function(){
		$(".display_all").hide();
		return false;
	});
	
	//Функция скрытия/развёртывания подробного описания в каталоге
	$(".read_more").click(function()
	{
		$(this).parent().parent().find("div.cat_content_text").toggle(1);
		if ($(this).text() == "Читать далее")
		{
			$(this).text("Скрыть");
		}
		else
		{
			$(this).text("Читать далее");
		}
	}
	);
	
	return false;
});
