function InputHint(el,hint){
	this.hint = hint;
	this.el = el;
	this.el.style.color = '#ccc';
	this.el.style.fontStyle = 'italic';
	this.el.value = hint;
	this.el.onfocus = function(){
		el.value = '';
		el.style.color = '#36c';el.style.fontWeight = 'bold';el.style.fontStyle = 'normal';
	}
	this.el.onblur = function(){
		if (el.value == ''){
			el.style.color = '#aaa';el.style.fontStyle = 'italic';el.style.fontWeight = 'normal';
			el.value = hint;
		}else{
			el.onfocus = null;
			el.onblur = null;
		}
	
	}
}


function kd(e)
{
	intKey = (window.Event) ? e.which : e.keyCode;
	return intKey;
}



var xmlhttp;
function showHint(str,event)
{
c=kd(event);
c1=String.fromCharCode(c);
//document.getElementById("rez").innerHTML=c;return;
goods = "0123456789"+String.fromCharCode(46)+String.fromCharCode(8)+String.fromCharCode(96)
+String.fromCharCode(97)
+String.fromCharCode(98)
+String.fromCharCode(99)
+String.fromCharCode(100)
+String.fromCharCode(101)
+String.fromCharCode(102)
+String.fromCharCode(103)
+String.fromCharCode(104)
+String.fromCharCode(105)
;
if (goods.indexOf(c1) == -1)
{
	return;
}





if (str.length<2)
  {
  document.getElementById("rez").innerHTML="";
  return;
  }

document.getElementById("goog").style.display="block";
document.getElementById("rez").innerHTML='Cauta..... <img src="imagini/progress_bar.gif">';
xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
  {
  alert ("Your browser does not support XMLHTTP!");
  return;
  } 
var url="search.php";
url=url+"?q="+str;
url=url+"&sid="+Math.random();
xmlhttp.onreadystatechange=stateChanged;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}

function GetXmlHttpObject()
{
if (window.XMLHttpRequest)
  {
  // code for IE7+, Firefox, Chrome, Opera, Safari
  return new XMLHttpRequest();
  }
if (window.ActiveXObject)
  {
  // code for IE6, IE5
  return new ActiveXObject("Microsoft.XMLHTTP");
  }
return null;
}

function stateChanged()
{
if (xmlhttp.readyState==4)
  {
  document.getElementById("rez").innerHTML=xmlhttp.responseText;
  }
}


function ow(id) {
	window.open('compara.php?id='+id,'','scrollbars=yes,resizable=yes');
}

function testform()
{
	if (document.cauta.cod.value.length <2) 
	{
		window.alert("introduceti minim 2 caractere pentru a putea cauta");
		document.cauta.cod.focus();		
		return false;
	}
	
	if (document.cauta.ci[0].checked==false && document.cauta.ci[1].checked==false && document.cauta.ci[2].checked==false) 
	{
		window.alert("alegeti un criteriu de cautare");
		//document.cauta.cod.focus();		
		return false;
	}


	return true;
}

function mark()
{
document.cauta.cod.focus();		
}

function goodchars(e, goods)
{
var key, keychar;
key = getkey(e);
if (key == null) return true;

// get character
keychar = String.fromCharCode(key);
keychar = keychar.toLowerCase();
goods = goods.toLowerCase();

// check goodkeys
if (goods.indexOf(keychar) != -1)
	return true;

// control keys
if ( key==null || key==0 || key==8 || key==9 || key==13 || key==27  || key==46 || key==37 || key==38 || key==39 || key==40)
   return true;


// else return false
return false;
}

function getkey(e)
{
if (window.event)
   return window.event.keyCode;
else if (e)
   return e.which;
else
   return null;
}