
		function addToCart(id) {
				JsHttpRequest.query(
					'/js_cart.php', // backend
					{
						// pass a text value 
						'a': 'add',
						'id':id	,
						'value':(document.getElementById("i"+id).checked)	
						},
					// Function is called when an answer arrives. 
					function(result, errors) {
						if (result["res"]==1 ){
							document.getElementById("cart_in_header").innerHTML=result["text"];
						}
					},
					false  // do not disable caching
				);
		}

		function mcartRecount() {
				JsHttpRequest.query(
					'/js_cart.php', // backend
					{
						// pass a text value 
						'a': 'mrecount',
						'form':	document.getElementById("cart_form")
						},
					// Function is called when an answer arrives. 
					function(result, errors) {
						if (result["res"]==1 ){
							document.getElementById("itogo").innerHTML=result["itogo"]+" руб.";
						}
					},
					false  // do not disable caching
				);


		}


		function addToMCart(id) {
				JsHttpRequest.query(
					'/js_cart.php', // backend
					{
						// pass a text value 
						'a': 'madd',
						'col': document.getElementById("cnt"+id).value,
						'id':id	,
						'value':(document.getElementById("i"+id).checked)	
						},
					// Function is called when an answer arrives. 
					function(result, errors) {
						if (result["res"]==1 ){
							document.getElementById("cart_in_header").innerHTML=result["text"];
							document.getElementById("cnt"+id).value=result["col"];

						}
					},
					false  // do not disable caching
				);
		}

		function delFromCart(id) {
				JsHttpRequest.query(
					'/js_cart.php', // backend
					{
						// pass a text value 
						'a': 'add',
						'id':id	,
						'value':0	
						},
					// Function is called when an answer arrives. 
					function(result, errors) {
						if (result["res"]==1 ){
							document.getElementById("t_analiz").deleteRow(document.getElementById('tr'+result["id"]).rowIndex);
							document.getElementById("itogo").innerHTML=result["itogo"]+" руб.";
							document.getElementById("sum_analizi").innerHTML=result["itogo"]+" руб.";
						}
					},
					false  // do not disable caching
				);
		}
		function delFromMCart(id) {
				JsHttpRequest.query(
					'/js_cart.php', // backend
					{
						// pass a text value 
						'a': 'madd',
						'id':id	,
						'value':0	
						},
					// Function is called when an answer arrives. 
					function(result, errors) {
						if (result["res"]==1 ){
							document.getElementById("t_analiz").deleteRow(document.getElementById('tr'+result["id"]).rowIndex);
//							document.getElementById("itogo").innerHTML=result["itogo"]+" руб.";
//							document.getElementById("cnt"+id).value=0;

						}
					},
					false  // do not disable caching
				);
		}
	
function askDoctor(atype){
	if (document.getElementById("get_advice").style.display=="none"){
		document.getElementById("get_advice").style.display="block";
		document.getElementById("ask_dockor").innerText="Скрыть форму";
	}
	else{
		document.getElementById("get_advice").style.display="none";
		if (atype==2)
			document.getElementById("ask_dockor").innerText="Задать вопрос врачу";
		else
			document.getElementById("ask_dockor").innerText="Оставить свой отзыв";

		document.forms['search_form'].reset();
	}
}

function sendQuestion(){
		if (document.forms['search_form'].elements['name'].value == "" || 
			document.forms['search_form'].elements['email'].value == "" || 
			document.forms['search_form'].elements['age'].value == "" ){
			alert("Не заполнены поля обязательные для заполнения!!");
			return false;
		}
		if (document.forms['search_form'].elements['code'] && document.forms['search_form'].elements['code'].value == ""){
			alert("Не заполнено поле кода проверки!!");
			return false;
		}
		JsHttpRequest.query(
			'/js_cart.php', // backend
			{
				// pass a text value 
				'a': 'getadvice',
				'type': 2,
				'form':document.getElementById("search_form")
			},
			// Function is called when an answer arrives. 
			function(result, errors) {
				if (result["res"]==1){
//					askDoctor();
					window.location.href="/advice/?st=1";
//					if (result["message"]!="")
//						document.getElementById("f_message").innerHTML=result["message"];
				}else if (result["res"]==2 ){
					alert(result["error"]);
				}
			},
			false  // do not disable caching
		);

}

function sendFeedback(){
		if (document.forms['search_form'].elements['name'].value == ""){
			alert("Не заполнены поля обязательные для заполнения!!");
			return false;
		}
		if (document.forms['search_form'].elements['code'] && document.forms['search_form'].elements['code'].value == ""){
			alert("Не заполнено поле кода проверки!!");
			return false;
		}
		JsHttpRequest.query(
			'/js_cart.php', // backend
			{
				// pass a text value 
				'a': 'getfeedback',
				'type': 1,
				'form':document.getElementById("search_form")
			},
			// Function is called when an answer arrives. 
			function(result, errors) {
				if (result["res"]==1){
//					askDoctor();
					window.location.href="/feedbacks/?st=1";
//					if (result["message"]!="")
//						document.getElementById("f_message").innerHTML=result["message"];
				}else if (result["res"]==2 ){
					alert(result["error"]);
				}
			},
			false  // do not disable caching
		);

}


function sendCallOnHome(){
		if (document.forms['search_form'].elements['name'].value == "" || document.forms['search_form'].elements['email'].value == ""
|| document.forms['search_form'].elements['phone'].value == "" || document.forms['search_form'].elements['age'].value == ""){
			alert("Не заполнены поля обязательные для заполнения!!");
			return false;
		}
		if (document.forms['search_form'].elements['code'] && document.forms['search_form'].elements['code'].value == ""){
			alert("Не заполнено поле кода проверки!!");
			return false;
		}
		JsHttpRequest.query(
			'/js_cart.php', // backend
			{
				// pass a text value 
				'a': 'sendcallonhome',
				'form':document.getElementById("search_form")
			},
			// Function is called when an answer arrives. 
			function(result, errors) {
				if (result["res"]==1){
					callOnHome();
					document.getElementById("message").style.display="block";
//					window.location.href="/feedbacks/?st=1";
//					if (result["message"]!="")
//						document.getElementById("f_message").innerHTML=result["message"];
				}else if (result["res"]==2 ){
					alert(result["error"]);
				}
			},
			false  // do not disable caching
		);

}

function showDescription(id,x,y,iType){
	var x_p = (screen.availWidth - x)/2;	
	var y_p = (screen.availHeight - y)/2;	

	window.open('/showItem.php?id='+id+'&type='+iType,'changecat','height='+y+',width='+x+',top=100,left='+x_p+',toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=no,titlebar=no');
}
function printOrder(x,y){
	var x_p = (screen.availWidth - x)/2;	
	var y_p = (screen.availHeight - y)/2;	
	window.open('/printOrder.php','changecat','height='+y+',width='+x+',top=100,left='+x_p+',toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=no,titlebar=no');
}

		function checkOnHome(obj) {
			if (document.getElementById("onhome_div").style.display=="none")
				document.getElementById("onhome_div").style.display="block";
			else
				document.getElementById("onhome_div").style.display="none";

				JsHttpRequest.query(
					'/js_cart.php', // backend
					{
						// pass a text value 
						'a': 'callonhome',
						'value':(obj.checked)	
						},
					// Function is called when an answer arrives. 
					function(result, errors) {
						document.getElementById("itogo").innerHTML=result["itogo"]+" руб.";
					},
					false  // do not disable caching
				);
		}

		function checkOnHomeOrder(obj) {
		  if (obj.checked)
				document.getElementById("div_order").style.display="block";
		  else
				document.getElementById("div_order").style.display="none";
				JsHttpRequest.query(
					'/js_cart.php', // backend
					{
						// pass a text value 
						'a': 'callonhome',
						'value':(obj.checked)	
						},
					// Function is called when an answer arrives. 
					function(result, errors) {
					},
					false  // do not disable caching
				);



		}

function init_objects() {
	Calendar.setup(
		{
			inputField  : "date",      // ID of the input field
			ifFormat    : "dd-mm-y",    // the date format
			button      : "trigger",    // ID of the button
			mondayFirst : true
	//      daFormat    : "M d, y",    // the date format
	//			displayArea : displayDate

		}
	);
}


function callOnHome(){
	if (document.getElementById("call_form").style.display=="none"){
		document.getElementById("call_form").style.display="block";
		document.getElementById("ask_dockor").innerText="Скрыть форму";
	}
	else{
		document.getElementById("call_form").style.display="none";
		document.getElementById("ask_dockor").innerText="Заполнить форму вызова на дом";
		document.forms['search_form'].reset();
	}
}
