
ddaccordion.init({
				headerclass: "glavitem", //Shared CSS class name of headers group
				contentclass: "submenupub", //Shared CSS class name of contents group
				revealtype: "click", //Reveal content when user clicks or onmouseover the header? Valid value: "click" or "mouseover
				mouseoverdelay: 200, //if revealtype="mouseover", set delay in milliseconds before header expands onMouseover
				collapseprev: true, //Collapse previous content (so only one open at any time)? true/false
				defaultexpanded: [], //index of content(s) open by default [index1, index2, etc] [] denotes no content
				onemustopen: false, //Specify whether at least one header should be open always (so never all headers closed)
				animatedefault: true, //Should contents open by default be animated into view?
				persiststate: false, //persist state of opened contents within browser session?
				toggleclass: ["", "selected"], //Two CSS classes to be applied to the header when it's collapsed and expanded, respectively ["class1", "class2"]
				togglehtml: ["", "", ""], //Additional HTML added to the header when it's collapsed and expanded, respectively  ["position", "html1", "html2"] (see docs)
				animatespeed: "fast", //speed of animation: integer in milliseconds (ie: 200), or keywords "fast", "normal", or "slow"
				oninit:function(headers, expandedindices){ //custom code to run when headers have initalized
					//do nothing
					//console.log(headers);
					//console.log(expandedindices);
					/*for(var h=0; h<headers.length; h++)
					{
						if (h == expandedindices)
						{
							if($(headers[h]).attr("ikon") != '')
								$(headers[h]).html("<img src='" + $(headers[h]).attr("ikon") +"' >");
							else
								$(headers[h]).html($(headers[h]).attr('title'));
						}
						else
						{
							if($(headers[h]).attr("ikonact") != '')
								$(headers[h]).attr('onmouseover', 'this.innerHTML = "<img src=" + this.getAttribute("ikonact") +" >"');
							else
								$(headers[h]).attr('onmouseover', 'this.innerHTML = this.getAttribute("title")');
							$(headers[h]).attr('onmouseout', 'this.innerHTML = "<img src=" + this.getAttribute("ikon") +" >"');
							if($(headers[h]).attr("ikon") != '')
								headers[h].innerHTML = "<img src=" + $(headers[h]).attr("ikon") +" >";
						}
					}*/
				},
				onopenclose:function(header, index, state, isuseractivated){ //custom code to run whenever a header is opened or closed
					//do nothing
					if(isuseractivated==true)
					{
						if(state == 'block')
						{
							$(header).attr('state', 0);

							if($(header).attr("ikonact"))
							{
								$('#' + $(header).attr('id') + ' img').attr('src', $(header).attr("ikonact"));
								$('#' + $(header).attr('id') + ' span').empty();
							}
							else
							{
								$('#' + $(header).attr('id') + ' img').attr('src', "/img/spacer.gif");
								$('#' + $(header).attr('id') + ' span').html($(header).attr('title'));
							}
						}
						else if(state == 'none')
						{
							if($(header).attr("ikon"))
							{
								$('#' + $(header).attr('id') + ' img').attr('src', $(header).attr("ikon"));
								$('#' + $(header).attr('id') + ' span').empty();
							}
							else
							{
								$('#' + $(header).attr('id') + ' img').attr('src', "/img/spacer.gif");
								$('#' + $(header).attr('id') + ' span').html($(header).attr('title'));
							}
							$(header).attr('state', 1);
						}
					}
				}
			});

			function changeovermnlf(el)
			{
				if($('#' + el).attr('state') > 0)
				{
					if($('#' + el).attr('ikonact'))
					{
						$('#' + el +' img').attr('src', $('#' + el).attr('ikonact'));
						$('#' + el +' span').empty();
					}
					else
					{
						$('#' + el +' img').attr('src', "/img/spacer.gif");
						$('#' + el + ' span').html($('#' + el).attr('title'));
					}
				}
			}

			function changeoutmnlf(el)
			{
				if($('#' + el).attr('state') > 0)
				{
					if($('#' + el).attr('ikon'))
					{
						$('#' + el +' img').attr('src', $('#' + el).attr('ikon'));
						$('#' + el +' span').empty();
					}
					else
					{
						$('#' + el +' img').attr('src', "/img/spacer.gif");
						$('#' + el +' span').html($('#' + el).attr('title'));
					}
				}
			}

Loading = {
	StartLoading : function()
	{
		if(document.getElementById('Loading'))
			Loading.EndLoading();
		var d = document.createElement("div");
		d.setAttribute("id", "Loading");
		d.className = "Loading";

		d.style.left = document.body.scrollWidth / 2 - 70 + "px";
		d.style.top = (document.documentElement.scrollTop || document.body.scrollTop) + 200 + 'px';

		var text = document.createTextNode("Loading...");
		d.appendChild(text);

		document.body.appendChild(d);
		document.body.style.cursor = "wait";
	},
	EndLoading : function()
	{
		if(document.getElementById('Loading'))
		{
			var d = document.getElementById('Loading');
			document.body.removeChild(d);
			document.body.style.cursor = "default";
		}
	},
	errors : function(s)
	{
		alert(s);
	},
	ErrorView : function(t)
	{
		alert('Error ' + t.status + ' -- ' + t.statusText);
	},
	processResponse : function(req)
	{
		var i;
		if($('innerblock'))
			i = $('innerblock');
		else if($('inner'))
			i = $('inner');
		if(req.responseText)
		{
			if(i)
			{
				i.innerHTML = '';
				i.innerHTML = req.responseText;
			}
			/*else
				alert(req.responseText);*/
		}
		Loading.EndLoading();
	},
	close: function(name)
	{
		if($(name))
		{
			//Effect.Shrink($(name));
			document.body.removeChild($(name));
		}

		if($("MaskBody"))
		{
			document.body.removeChild($("MaskBody"));
		}
	}
}

Comments = {
	addAnswer : function(id_a)
	{
		if(id_a)
		{
			// Delete old form
			if($("#answer_add"))
			{
				var inp = $("answer_add")['answer_id'];
				var inp_val = $(inp).attr('value');

				if($('#insertaddform'+ inp_val)) $('insertaddform'+ inp_val).empty();
			}
			$('#tableaddcomm').hide("slow");
			if($('#insertaddform'+ id_a))
			{
				$('#insertaddform'+ id_a).empty();
				var cntn = '<table cellpadding="0" cellspacing="0" width="100%" border="0"><tr><td id="insansferform" style="display: none;">';
				cntn += '</td></tr></table>';
				$('#insertaddform'+ id_a).html(cntn);
				var dans = $('#insansferform');
				var fcontent = $('#comment_add').html();
				// Create new form
				var newform = "<form id='answer_add' action='"+$('#comment_add').attr("action")+"' method='"+$('#comment_add').attr("method")+"'>";
				newform += '<input type="hidden" name="answer_id" value="'+id_a+'"/>';
				newform += fcontent + '</form>';
				$('#insansferform').append(newform);
				$('#insansferform').show("slow");
			}
		}
	},
	ChangeView : function(elm,elmcl)
	{
		if($(elmcl))
			$(elmcl).hide("slow");

		if($(elm + ":hidden"))
		{
			$(elm).show("slow");
			//if(elm == '#tableaddcomm')
				//document.location='#info';
			//else
				//document.location='#MailFriend';
		}
		else $(elm).hide("slow");
	}
}


Cart = {
	AddToCart : function(tovarid, lightbox)
	{
		if(!tovarid)
		{
			//console.log("Ошибка! Не выбран товар!");
			return false;
		}

		Loading.StartLoading();
		$.post('/tools/cart/',
					{type: "json", field: "cart", val:  tovarid},
					function (data) {
							// console.log(data);

							 if(data.count)
							 {
								 $('#cart a').html($('#cart').attr("alt") + " " + data.count);
								 $.prompt('Ваш заказ принят!', {prefix: "jqi"}).corner();
							 }
					},
					"json"
			);
		Loading.EndLoading();
	}
}


Dogovor = {
	View : function(data)
	{
		$.prompt(data, {prefix: "jqi", callback: Dogovor.oks, buttons: { OK: true, Cancel: false } }).corner();
		$('.jqicontainer').css('font-weight', 'normal');
	},
	oks : function(v,m,f)
	{
		if(v)
		{
			$('#is_dogovor').attr('checked', true);
		}
		else
		{
			$('#is_dogovor').attr('checked', false);
		}
	}
}

