function check(){
  var check = 0;
  var empty = 0;
  if (document.getElementById ('searchid').value!="#") {
  	if (isNaN(document.getElementById ('searchid').value)) {
  		document.getElementById ('searchid').className = 'heed'
  		check = 1
  	}
  } else {
  	empty++
  }
	if (document.getElementById ('searchmin').value!="min метраж") {
	  if (isNaN(document.getElementById ('searchmin').value)) {
	  	document.getElementById ('searchmin').className = 'heed'
  		check = 1
  	}
  } else {
  	empty++
  }
  if (document.getElementById ('searchmax').value!="max метраж") {
  	if (isNaN(document.getElementById ('searchmax').value)) {
	  	document.getElementById ('searchmax').className = 'heed'
  		check = 1
  	}
  } else {
  	empty++
  }
  if ((check==0)&&(empty<3)) {return true;
  } else {return false;}
}

/*********************/

function InputPlaceholder (input, value)
{
	var thisCopy = this
	
	this.Input = input
	this.Value = value
	this.SaveOriginal = (input.value == value)
	this.CssFilled = ''
	this.CssEmpty = 'emptySearch'
	this.CssAttention = 'heed'

	this.setupEvent (this.Input, 'focus', function() {return thisCopy.onFocus()})
	this.setupEvent (this.Input, 'blur',  function() {return thisCopy.onBlur()})
	this.setupEvent (this.Input, 'keyup', function() {return thisCopy.onKeyUp()})

	if (input.value == '') this.onBlur();

	return this
}

InputPlaceholder.prototype.setupEvent = function (elem, eventType, handler) {
	if (elem.attachEvent)	{
		elem.attachEvent ('on' + eventType, handler)
	}

	if (elem.addEventListener) {
		elem.addEventListener (eventType, handler, false)
	}
}

InputPlaceholder.prototype.onFocus = function() {
	if (!this.SaveOriginal &&  this.Input.value == this.Value) {
		this.Input.value = ''
	}	else {
		if (this.Input.className != this.CssAttention) {this.Input.className = ''}
	}
}

InputPlaceholder.prototype.onKeyUp = function() {
	if (isNaN(this.Input.value)) {
		this.Input.className = this.CssAttention
	} else {
		this.Input.className = ''
	}
	if ((this.Input==document.getElementById ('searchmin'))||(this.Input==document.getElementById ('searchmax'))) {
		document.getElementById ('searchid').value="#";
		document.getElementById ('searchid').className=this.CssEmpty;
	}
	if (this.Input==document.getElementById ('searchid')) {
		document.getElementById ('searchmin').value="min метраж";
		document.getElementById ('searchmin').className=this.CssEmpty;
		document.getElementById ('searchmax').value="max метраж";
		document.getElementById ('searchmax').className=this.CssEmpty;
	}
}

InputPlaceholder.prototype.onBlur = function() {
	if (this.Input.value == '' || this.Input.value == this.Value) {
		this.Input.value = this.Value
		this.Input.className = this.CssEmpty
	}	else {
		if (this.Input.className != this.CssAttention) {this.Input.className = this.CssFilled}
	}
}

