function cauta_select(x,l)
{
    var x, l;
	!l ? l = '' : '';
    tip_v = document.getElementById('tip_v'+l).value;

    for (o=1; o<12; o++)
	{
	  if(document.getElementById('a'+x+o))
	  {
	  document.getElementById('a'+x+o).style.display = 'none';
      document.getElementById('b'+x+o).style.display = 'none';
	  }
	}

   	document.getElementById(tip_v+x+(document.getElementById('tip_c'+l).value)).style.display='block';
	document.getElementById('tip_l'+l).value = document.getElementById(tip_v+x+(document.getElementById('tip_c'+l).value)).value;
}


function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_swapImage() { //v3.0
var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function MM_swapImgRestore() { //v3.0
var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}


startList = function() {

	//code only for IE
	if(!document.body.currentStyle) return;
	var subs = document.getElementsByName('submenu');
	for(var i=0; i<subs.length; i++) {
		var li = subs[i].parentNode;
		if(li && li.lastChild.style) {
			li.onmouseover = function() {
				this.lastChild.style.visibility = 'visible';
			}
			li.onmouseout = function() {
				this.lastChild.style.visibility = 'hidden';
			}
		}
	}
}
window.onload=startList;


function emailCheck (emailStr) {
var emailPat=/^(.+)@(.+)$/
var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
var validChars="\[^\\s" + specialChars + "\]"
var quotedUser="(\"[^\"]*\")"
var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
var atom=validChars + '+'
var word="(" + atom + "|" + quotedUser + ")"
var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")
var matchArray=emailStr.match(emailPat)
if (matchArray==null) {
	alert("Adresa email incorecta !")
	return false
}
var user=matchArray[1]
var domain=matchArray[2]


if (user.match(userPat)==null) {
    alert("Username invalid.")
    return false
}

var IPArray=domain.match(ipDomainPat)
if (IPArray!=null) {
    // this is an IP address
	  for (var i=1;i<=4;i++) {
	    if (IPArray[i]>255) {
	        alert("Destinatie IP incorecta !")
		return false
	    }
    }
    return true
}
var domainArray=domain.match(domainPat)
if (domainArray==null) {
	alert("Numele domeniului e invalid !")
    return false
}

var atomPat=new RegExp(atom,"g")
var domArr=domain.match(atomPat)
var len=domArr.length
if (domArr[domArr.length-1].length<2 || 
    domArr[domArr.length-1].length>3) {
   alert("The address must end in a three-letter domain, or two letter country.")
   return false
}

if (len<2) {
   var errStr="This address is missing a hostname!"
   alert(errStr)
   return false
}


return true;
}


var texte = new Array();
texte[1] = " id";
texte[2] = "e-mail";
texte[3] = "telefon";
texte[4] = "doresc sa fiu contactat pentru a afla mai multe informatii legate de acest imobil";
texte[5] = "nume";
texte[6] = "adresa imobilului";
function fillIt(obiect,nr)
{

	if (obiect.value == '')
	{
		obiect.value = texte[nr];
	}
}

function clearIt(obiect,nr)
{
	if (obiect.value == texte[nr])
	{
		obiect.value = '';
	}
}

function set_hover(the_row)
{
		the_row.style.backgroundColor = '#f1dbb4';
}
function remove_hover(the_row)
{
			the_row.style.backgroundColor = '#fdfee2';
}
function formsubmit()
{
 if((document.getElementById('sorteaza').value != '---------'))
	document.getElementById('activ').submit('submit');
}

var good;
function sendOff(){
  good = false
   nmcheck = document.TheForm.nm.value
   if (nmcheck.length<1 || nmcheck=='nume') {
      alert('Va rugam sa introduceti numele dumneavoastra.')
      document.TheForm.nm.focus();
   	document.TheForm.nm.select();
		good = true
      return false
   }
   tel = document.TheForm.telefon.value
   if (tel.length <5 || tel=='telefon') {
      alert('Va rugam sa introduceti telefonul dumneavoastra.')
      document.TheForm.telefon.focus();
   	document.TheForm.telefon.select();
		good = true
      return false
   }
	


	
	if (good)
	{
		return false
	}
 return true
}

var newwindow;
function cenwin(mypage) {

myname='asd';
w=910;
h=600;
var winl = (screen.width-w)/2;
var wint = (screen.height-h)/2+40;
var settings ='height='+h+',';
settings +='width='+w+',';
settings +='top='+wint+',';
settings +='left='+winl+',';
settings +='scrollbars=yes,';
settings +='status='+1+',';
settings +='resizable=0';
win=window.open(mypage,myname,settings);
if(parseInt(navigator.appVersion) >= 4){win.window.focus();}
}

