

function city()
{
	if (document.getElementById('citylist').style.display=='')
	{
		document.getElementById('citylist').style.display='none';
	} else {
		document.getElementById('citylist').style.display='';
	}

	return false;
}

function content(id, count)
{
	document.getElementById('maincontent').innerHTML=document.getElementById('content'+id).innerHTML;
	for (var i = 1; i <= count; i++) 
	{ 
		document.getElementById('contentlink'+i).className="";
		if (i==id)
		{
			document.getElementById('contentlink'+i).className="current";
		}
	}   
}


function contentmore(id)
{
	document.getElementById('morecontent'+id).style.display='';
	document.getElementById('morecontentlink'+id).style.display='none';
}


function contenthidden(id)
{
	document.getElementById('morecontent'+id).style.display='none';
	document.getElementById('morecontentlink'+id).style.display='';
}



function change_matras_price(id)
{
	var price = $("#price" + id).text();
	
	if (price != "")
	{
		$("p.cart a").css({'visibility':'visible'});
		$("span#price-desc").css({'visibility':'visible'});
		$("span#price").text(price);
	} else {
		$("p.cart a").css({'visibility':'hidden'});
		$("span#price-desc").css({'visibility':'hidden'});
		$("span#price").text(price);
	}
}



function change_chair_price(id)
{

	var price = $("#price" + id).text();

	
	$("#_chair input:checkbox").removeAttr('checked');
	$("#_chair input#chair" + id + ":checkbox").attr('checked', 'checked');


	if (price != "")
	{
		$("p.cart a").css({'visibility':'visible'});
		$("span#price-desc").css({'visibility':'visible'});
		$("span#price").text(price);
		
	} else {
		$("p.cart a").css({'visibility':'hidden'});
		$("span#price-desc").css({'visibility':'hidden'});
		$("span#price").text(price);
	}
}



function change_chair_karkas(id)
{
	var price = $("#price" + id).text();
	
	$("#_chair_karkas input:checkbox").removeAttr('checked');
	$("#_chair_karkas input#chair_karkas" + id + ":checkbox").attr('checked', 'checked');
}






function check_checked()
{
	$("input:checkbox:^checked[chk=true]").attr('checked', 'checked');
}


function check_default_tkan()
{
	var cat_id = $("p.tkan a[current=true]").attr("id");
	change_soft_cat(cat_id);
	
	$("span#price").text($("p.tkan a.cur").attr("price"));

	$("form#fs input:checkbox").removeAttr('checked');
	$("form#fs input:checkbox").removeAttr('chk');
	$("input:checkbox[current=true]").attr('checked', 'checked');
	$("input:checkbox[current=true]").attr('chk', true);
	
	$("input:checkbox").attr('disabled', '');

	$("input:checkbox").prev().prev().each( function () {
		$(this).css('cursor', 'pointer');	
		$(this).attr('href', '#');
	});	
}


function change_soft_cat(id)
{
	var cat_id = $("p.tkan a.cur").attr("id");
	
	if (cat_id == id)
		return false;

	$("p.tkan a.cur").removeClass();
	$("p.tkan a#" + id).addClass('cur');
	
	$("a.tkancolors").each( function() {
		
		var tkan_id = $(this).attr("id");
		
		var layer_id = $('div#cur' + tkan_id + ' table').attr('id');
		
//		alert($("div#cur" + tkan_id).html());
			
		$("div#layer_" + layer_id).html( $("div#cur" + tkan_id).html() );
		
		$("div#cur" + tkan_id).html( $("div#layer_" + id + "_" + tkan_id).html() );
		
	});
	
	check_checked();
		
	
	return false;
}



function check_soft_tkan(sost_id, tkan_id)
{
	var cat_id = $("p.tkan a.cur").attr("id");
	
	var chk_id = "#tkan" + cat_id + "_" + sost_id + "_" + tkan_id + "";
	
	if ($(chk_id).attr('disabled') || $(chk_id).attr('chk'))
	{
		return;
	}
	
	var price = $("p.tkan a.cur").attr("price");
	var price_cur = $("span#price").text();
	
	if (price == '')
	{
		$("span#price").text('');
	}
	else if (price_cur <= price)
	{
		$("span#price").text(price);
	}
	
	$("form#fs input:checkbox").removeAttr('checked');
	$("form#fs input:checkbox").removeAttr('chk');
	
	$("a.tkancolors").each( function() {
		
		var all_tkan_id = $(this).attr("id");

		$("#tkan" + cat_id + "_" + all_tkan_id + "_" + tkan_id + "").attr('chk', true);
		
	});
	
	$("input:checkbox[chk!=true]").attr('disabled', true);

	$("input:checkbox[chk!=true]").prev().prev().each( function () {
		$(this).css('cursor', 'default');
		$(this).removeAttr('href');
	});
	
	
	check_checked();
	
	return false;
}



function open_soft_tkan(id)
{
	var cat_id = $("p.tkan a.cur").attr("id");

	if ($("div#cur" + id).html() == '')
	{
		$("div#cur" + id).html($("div#layer_" + cat_id + "_" + id).html());
		$("div#layer_" + cat_id + "_" + id).html('');
	}

	$("div#cur" + id).toggle();
	
	check_checked();	

	return false;

}



