jQuery.fn.replaceText = function(a, b) {
	return this.html(this.html().replace(new RegExp(a,'g'), b));
}

var price;
$(document).ready(function() {
	$('#price').height(Math.max($('body').height() - 4, $('#menu_container').height(), $('#posl_container').height()));
	price = document.getElementById('price').innerHTML;
	$("#button_skach").fancybox({
		'scrolling': 'no',
		'titleShow': false
	});
});
$(window).resize(function() {
	$('#price').height(Math.max($('body').height() - 4, $('#menu_container').height(), $('#posl_container').height()));
});
function searchPromt() {
	var textToFind = window.prompt("Введите слово для поиска:", "");
	document.getElementById('price').innerHTML = price;
	textToFind = textToFind.replace(/^\s+/, ''); 
	textToFind = textToFind.replace(/\s+$/, ''); 
	$("#texttofind").attr('value', textToFind);
	if (textToFind == "") {
		return;
	}
	var a = new RegExp(textToFind,'gi');
	var b = '<span class="highlight">' + textToFind + '</span>';
	var td = document.getElementsByTagName('td');
	var l = td.length;
	for(var i = 0; i < l; i++) {
//		if (td[i].className == 'toSearch') {
		if ($(td[i]).hasClass('toSearch')) {
			td[i].innerHTML = td[i].innerHTML.replace(a, b);
		}
	}
	$("span.highlight").parentsUntil('tr').parent().addClass('highlight_row');
	if ($('tr.highlight_row').size() == 0) {
		alert('Ничего не найдено');
	} else {
		alert('Найдено ' + $('tr.highlight_row').size() + ' строк');
	}
}
function submit_form() {
	$('#hiddenform').submit();
}
