jQuery(document).ready(function($){
	$(".r-star-shape").hover(
		function () {
			if (!$(this).hasClass('main')) { $(this).addClass("active"); }
		},
		function () {
			if (!$(this).hasClass('main')) { $(this).removeClass("active"); }
		}
	);

	$(".chat_expert li").click(
		function() {
			$(".chat_expert li").removeClass("active");

			var id = $(this)[0].id.split('_', 2);
			$.ajax(
			{
			  type: "POST",
			  url: "/components/chatu/ajax.php",
			  data: "chat_user="+id[1],
			  success:  function(msg){
			  }
			});
			$("#toroom").val(id[1]);
			prepare_change_room();
			$(this).addClass('active');


		});
	
	if ($('#chat_dialog').dialog)
	{
		var $dialog = $('#chat_dialog')
			.dialog({
				autoOpen: false,
				minWidth: 600,
				height: 400
			});

		$('.chat_link').click(function() {
			$dialog.dialog('open');
			return false;
		});
	}	

	$('._head').click(
		function() {
			if($('._cell2').css('width') == '230px')
			{
				$('._cell2').css({'width': '30px'});
				$('._cont').hide();
				$('#__clTag').css({'width': '30px'});
			}
			else 
			{
				$('._cell2').css({'width': '230px'});
				$('#__tTagText__').css({'width': '230px'});
				$('._cont').show();
				$('#__clTag').css({'width': '270px'});
			}
	});
});

function openpoint(what) 
{
	var x = what.id;
	if (what.parentNode.className.search(/close/) == -1) 
	{
		what.parentNode.className+=' close';
		what.title = "Открыть";
		what.className = what.className.replace(/minus/, '');
		what.className += " plus";
	} else 
	{
		what.parentNode.className = what.parentNode.className.replace(/close/, '');
		what.title = "Закрыть";
		what.className = what.className.replace(/plus/, '');
		what.className += " minus";
	}
}

function opendesc(what)
{
	var x = what.id;
	if (what.parentNode.className.search(/close/) == -1) 
	{
		what.parentNode.className+=' close';
		what.title = "Открыть";
		what.className = what.className.replace(/minus/, '');
		what.className += " plus";
	} else 
	{
		what.parentNode.className = what.parentNode.className.replace(/close/, '');
		what.title = "Закрыть";
		what.className = what.className.replace(/plus/, '');
		what.className += " minus";
	}

}

function ins_file()
{
	var newdiv=document.createElement("div");
	newdiv.className = "mp3_file_row";
	newdiv.innerHTML = '<div class="mp3_file_row">Наименование: <br/><input name="mp3_name[]" value="" maxlength="255" style="width: 99%"/><br/>Файл или ссылка на файл: <br/><input name="mp3_file[]" type="file"/><input name="mp3_url[]" type="text" maxlength="255" style="width: 50%"/><input type="checkbox" name="public_file[]" checked="checked">Публиковать?&nbsp;Порядок&nbsp;<input type="text" size="4" name="ord_file[]"></div>';
	document.getElementById("new_mp3_file").appendChild(newdiv);
	
}

function ins_personal()
{
	var newdiv=document.createElement("div");
	newdiv.className = "personal_row";
	newdiv.innerHTML = document.getElementById("personal_hidden").innerHTML;
	document.getElementById("new_personal").appendChild(newdiv);
}

var num_service=0;
function ins_service()
{
	num_service++;
	var newdiv=document.createElement("div");
	newdiv.className = "service_row";
											
	newdiv.innerHTML = '<div class="service_row_new_'+num_service+'">'+document.getElementById("service_hidden").innerHTML+"&nbsp;<a href='javascript:void(0);' onclick='del_service(&quot;new_"+num_service+"&quot;); return false'>Отмена</a>"+'</div>';
	document.getElementById("new_service").appendChild(newdiv);
}

function del_service(id)
{
	$('.service_row_'+id).html('');
}

// JavaScript Document
function checkSumm(total){
	var i=1;
	var summ = 0;

	for(i=1; i<=total; i++){
	 	summ += Number(document.listform["price"+i].value) * Number(document.listform["kolvo["+document.listform["item"+i].value+"]"].value);
	}

	document.listform.summField.value = String(summ);
	
}
