
		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();
	}
}

function showDiv(divID){
	$(divID).show();
}
function closeDiv(divID){
	$(divID).hide();
}

function loginProject(pageurl,evt){
var clientY;

	clientY=evt.clientY;
					JsHttpRequest.query(
					'/include/js_back.php', // backend
					{
						// pass a text value 
						'a':'checkuser'
					},
					// Function is called when an answer arrives. 
					function(result, errors) {
						if (result["error"]==0){
							window.location.href=pageurl;
						}else{
							var y,x;
							x=300; y=180;
							document.getElementById("logindiv").style.display = 'none';
							if ((document.body.clientHeight - clientY) > y) {
								m_top = clientY + document.body.scrollTop - 5;
							} else {
								m_top = clientY + document.body.scrollTop - y + 5;
							}
					
					
							m_left = (document.body.clientWidth-x)/2;
					
							document.getElementById("logindiv").style.left = m_left;
							document.getElementById("logindiv").style.top = m_top;	
							document.getElementById("logindiv").style.display = 'block';

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


}

		function openPhoto(src,x,y){
			y=y+20;	
			var strQuery = '';
			$("picture").style.width = x;
			$("picture").style.height = y;
			$("picture").style.display = 'none';

			m_top = document.body.scrollTop+10;
	
	
			m_left = (document.body.clientWidth-x)/2;
	
			$("picture").style.left = m_left;
			$("picture").style.top = m_top;	
			$("picture-src").innerHTML = "<a href='#' onClick=\"closeDiv('picture');return false;\"><img src='"+src+"' width='"+x+"'></a>";
			$("picture").style.display = 'block';
			return false;
		}
		function openPhoto2(id){
			var strQuery = '';
			var x = (screen.availWidth - 1000)/2;	
			window.open('/photo.php?id='+id,'changecat','height=640,width=820,top=20,left='+x+',toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=no,titlebar=no');
			return false;
		}

