

function add_compare(id, mark)	{





//	alert (mark);

	var url = '/';



	if (document.getElementById('cottage'+id))	{

		ajaxSend(url + 'ajax/add_compare.php', 'add='+id+'&mark='+mark, 'compare');  



		if (mark == 'cottage')	{

			var comparelink = ' | <a href="/comparecottage">Сравнить</a>';

		}

		if (mark == 'sanatoriums')	{

			var comparelink = ' | <a href="/comparesan">Сравнить</a>';

		}

		if (mark == 'tcentre')	{

			var comparelink = ' | <a href="/comparetcentre">Сравнить</a>';

		}
        if (mark == 'bani')	{

			var comparelink = ' | <a href="/comparebani">Сравнить</a>';

		}
		document.getElementById('cottage'+id).innerHTML = '<div class="compare2"><a href="#" onClick="del_compare(\'' + id + '\', \'' + mark + '\');  return false;">Удалить из сравнения</a>' + comparelink + '</div>';

		

	}



}



function del_compare(id, mark)	{



	var url = '/';



	if (document.getElementById('cottage'+id))	{

		ajaxSend(url + 'ajax/del_compare.php', 'del='+id, 'compare');  

		if (mark != 'no')	{

			document.getElementById('cottage' + id).innerHTML = '<div class="compare"><a href="#" onClick="add_compare(\'' + id + '\', \'' + mark + '\');  return false;">Добавить для сравнения</a></div>';

		}

	}



}



function add_compare2(id)	{



	var url = '/';



	if (document.getElementById('cottage'+id))	{

		ajaxSend(url + 'ajax/add_compare.php', 'add='+id, 'compare');  



		document.getElementById('cottage' + id).innerHTML = '<img src="'+url+'img/ico-del.gif" width="11" height="9" alt="" title="" /><a href="#" onClick="del_compare2('+id+');">Удалить из сравнения</a>';

	}



}



function del_compare2(id)	{



	var url = '/';



	if (document.getElementById('cottage'+id))	{

		ajaxSend(url + 'ajax/del_compare.php', 'del='+id, 'compare');  

		document.getElementById('cottage' + id).innerHTML = '<img src="'+url+'img/ico-add.gif" width="11" height="9" alt="" title="" /><a href="#" onClick="add_compare2('+id+');">Добавить для сравнения</a>';

	}



}







function set_cottage_filtr_price_user()		{



	var name_check = document.getElementById('cottage_filtr_price_check');

	var name_text = document.getElementById('cottage_filtr_price_user');

	var name_submit = document.getElementById('cottage_filtr_price_submit');



	if (name_check.checked == true)	{

		name_text.focus();

		name_text.value = '40';

		name_submit.style.display = 'block';

		name_submit.disabled= false;

		name_submit.enabled = 'enabled';

	}	else	{

		name_text.value = '';

		name_submit.disabled = 'disabled';

	}



}



function NewWindow(url, winWidth, winHeight, name) {

		if (!name) name = 'popupWin';

		if (!winWidth) winWidth = 550;

		if (!winHeight) winHeight = 500;

		var  PopupWin = window.open(url, name, 'width='+winWidth+', height='+winHeight+',menubar=no,status=no,toolbar=no,location=no,resizable=yes,scrollbars=no');

PopupWin.focus(); return false;

}





function check_form(f, url, div_id)	{

		var id;

		var name_id;

		var message;



		var string;



		if (!div_id)	{

			div_id = 'form_panel';

		}



		message = '';



  		for(var i=0; i<f.elements.length; i++ )	{

			id = f.elements[i].id;



			if ( (id.substr(0,4) == 'text') || (id.substr(0,5) == 'email') || (id.substr(0,8) == 'textarea') || (id.substr(0,6) == '_email') )		{

				var new_id = 'for_'+id;

				var name_id = document.getElementById(new_id);

//				alert (name_id.innerHTML);



				if (id.substr(0,4) == 'text')	{

					if (document.getElementById(id).value == '')	{

						message += "Не заполнено поле '" + name_id.innerHTML + "' \n";

					}

				}

				if (id.substr(0,6) == '_email')	{

					if (document.getElementById(id).value == '')	{

						message += "Не заполнено поле '" + name_id.innerHTML + "' \n";

					}

				}

				if ( (id.substr(0,5) == 'email') || (id.substr(0,6) == '_email') )	{

					if (document.getElementById(id).value != '')	{

						if (!document.getElementById(id).value.match(/^[\w\.\-]+@[\w\.\-]+\.[a-zA-Z]{2,}$/i, ""))		{

							message += "Поле '" + name_id.innerHTML + "' заполнено неправильно \n";					

						}

					}

				}

			}





			if (f.elements[i].name.value != '')		{

				if (f.elements[i].type == 'checkbox')	{

					if (f.elements[i].checked == true)		{

						string += '&' + f.elements[i].name + '=' + f.elements[i].value;

					}

				}	else	{

					string += '&' + f.elements[i].name + '=' + f.elements[i].value;

				}

			}

		}





		//message = '';



		if (message != '')	{

			message = "Ошибки при заполнении полей формы: \n" + message;

			alert (message);

			return false;

		}	else	{

			ajaxSend(url, string, div_id);

			return false;

		}



	return false;

}



//специально для отзывов

function report_check()	{



	var message;

	message = '';

	if (document.data.send_name.value == '')	{

		message += "Поле 'Ваше имя' не заполнено \n";					

	}

	if (document.data.send_text.value == '')	{

		message += "Поле 'Ваш отзыв' не заполнено \n";					

	}







		if (message != '')	{

			message = "Ошибки при заполнении полей формы: \n" + message;

			alert (message);

			return false;

		}	else	{

			return true;

		}





}

