//functia pt meniu
var current_id;
var idzx;
//onload="chosen_menu('l1')" onmouseover="chosen_menu('l1')"
function chosen_menu(liid)
{
	current_id=liid;
	document.getElementById('l1').className='';
	document.getElementById('l1').style.color='#333';
	document.getElementById('l2').className='';
	document.getElementById('l2').style.color='#333';
	document.getElementById('l3').className='';	
	document.getElementById('l3').style.color='#333';
	document.getElementById('l4').className='';
	document.getElementById('l4').style.color='#333';
	document.getElementById('l5').className='';
	document.getElementById('l5').style.color='#333';	
	document.getElementById('l6').className='';
	document.getElementById('l6').style.color='#333';
	document.getElementById('l7').className='';	
	document.getElementById('l7').style.color='#333';
	document.getElementById(liid).className='current';
	document.getElementById(current_id).style.color='#FFF';
	document.getElementById("u"+liid).style.zIndex=0;	
	document.getElementById("u"+current_id).style.zIndex=2;
}

function undermenu_display(idz)
{	
	document.getElementById(idz.substring(1)).className='current';
	idzx=idz;
	document.getElementById('ul1').style.zIndex=-1;
	document.getElementById('ul2').style.zIndex=-1;
	document.getElementById('ul3').style.zIndex=-1;
	document.getElementById('ul4').style.zIndex=-1;
	document.getElementById('ul5').style.zIndex=-1;	
	document.getElementById('ul6').style.zIndex=-1;
	document.getElementById('ul7').style.zIndex=-1;		
	document.getElementById(idz).style.zIndex=1;
	document.getElementById(idz.substring(1)).style.color='#FFF'
}


function return_display()
{
	document.getElementById("u"+current_id).style.zIndex=2;
	document.getElementById(idzx.substring(1)).style.color='#333'
	document.getElementById(idzx.substring(1)).className='';
	document.getElementById(current_id).className='current';
	document.getElementById(current_id).style.color='#FFF';
}



//functie ajax pt judete,orase,zone SI pentru verificare cod
var xmlHttp;
var url;
var is_ok;
function showLoc(tip)
{ 
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request");
 return
 }

value=document.getElementById(tip).value;
	
	if(tip=='judet'||tip=='oras')
	{
	if(tip=='judet')
	url="?judete="+value;
	if(tip=='oras')
	url+="&orase="+value;
	
	xmlHttp.onreadystatechange=stateChanged;
	xmlHttp.open("GET","http://www.anunturiapartamente.ro/judete_orase_zone.php"+url,true);
	xmlHttp.send(null);
	
	
	if(tip=='oras')
	null;
	} else
	if(value=='Adauga anunt'||value=='Creaza cont')
	{		 
		if((nr_a=document.getElementById('numere').value)!="")
		{
		is_ok="";
	    url="?numere="+nr_a;	
	    xmlHttp.onreadystatechange=stateChanged_code;
	    xmlHttp.open("GET","http://www.anunturiapartamente.ro/img_code.php"+url,false);
		xmlHttp.send(null);
		}
		else
		{
		is_ok="zero";
		alert('Introduceti codul din imagine.');
		document.getElementById('numere').focus();
		}
	}
}

function stateChanged() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 
 document.getElementById("locatie").innerHTML=xmlHttp.responseText; 
 } 
}

function stateChanged_code() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 
 is_ok=xmlHttp.responseText; 
 } 
}

function GetXmlHttpObject()
{
var xmlHttp=null;
try
 {
 // Firefox, Opera 8.0+, Safari
 xmlHttp=new XMLHttpRequest();
 }
catch (e)
 {
 //Internet Explorer
 try
  {
  xmlHttp=new new ActiveXObject("Microsoft.XMLHTTP");
  }
 catch (e)
  {
  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
 }
return xmlHttp;
}



//functia se aplica la hotele, pensiuni si face sa apara un select list
function filter_camera()
{
stadiu=document.getElementById('tip_spatiu').value;
if(stadiu=='depozit'||stadiu=='hala')
{
	document.getElementById('pan1').style.display="none";
	document.getElementById('pan2').style.display="none";
	document.getElementById('panel_utilitati').style.display="none";
	document.getElementById('panel_utilitati_mic_shadow').style.display="block";
}	
else
{
	document.getElementById('pan1').style.display="block";
	document.getElementById('pan2').style.display="block";
	document.getElementById('panel_utilitati').style.display="block";
	document.getElementById('panel_utilitati_mic_shadow').style.display="none";
}
}

//functia se aplica la spatii comerciale, si pune niste campuri pe disabled
function filter()
{
stadiu=document.getElementById('tip_spatiu').value;
if(stadiu=='depozit'||stadiu=='hala')
{
	if(document.getElementById('pan1'))
	document.getElementById('pan1').style.display="none";
	if(document.getElementById('pan2'))
	document.getElementById('pan2').style.display="none";
	document.getElementById('panel_utilitati').style.display="none";
	document.getElementById('specs').style.display="none"; 
	if(document.getElementById('specs1'))
	document.getElementById('specs1').style.display="none"; 
	if(document.getElementById('specs2'))
	document.getElementById('specs2').style.display="none"; 
	document.getElementById('panel_utilitati_mic_shadow').style.display="block";
	document.getElementById('panel_utilitati_mic_shadow2').style.display="block";
}	
else
{
	document.getElementById('pan1').style.display="block";
	document.getElementById('pan2').style.display="block";
	document.getElementById('panel_utilitati').style.display="block";
	document.getElementById('specs').style.display="block";
	if(document.getElementById('specs1'))
	document.getElementById('specs1').style.display="block"; 
	if(document.getElementById('specs2'))
	document.getElementById('specs2').style.display="block"; 
	document.getElementById('panel_utilitati_mic_shadow').style.display="none";
	document.getElementById('panel_utilitati_mic_shadow2').style.display="none";
}
}



//functia de mai jos se aplica pt marirea panelului la "specificati suprafata pt fiecare camera"

nr=1;
cat=0;
x=60;

nr_bai=1;
cat_bai=0;
x_bai=60;

function marire_panel()
{ 
tipobj='specs';	
cat=document.getElementById('camere').value;
cat_bai=document.getElementById('bai').value;


htmladd="Suprafata Camera "+nr+"&nbsp;<input type=\"text\" id=\"cam"+nr+"\" name=\"cam"+nr+"\" size=\"5\" class=\"text_field\"> mp<br>";
htmladd_bai="Suprafata Baie "+nr_bai+"&nbsp;<input type=\"text\" id=\"baie"+nr_bai+"\" name=\"baie"+nr_bai+"\" size=\"5\" class=\"text_field\"> mp<br>";

htmlspec="<br><div class=\"specificati\"><u>Specificati suprafata pentru fiecare camera sau baie</u></div><br>";
delimiter="<Br><div class=\"despartitor_orizontal\"></div>";

objtip=document.all? document.all[tipobj] : document.getElementById? document.getElementById(tipobj) : "";

if(cat>1)
{
for(i=1;i<cat;i++)
{
x+=45;	
nr++;

htmladd_new="Suprafata Camera "+nr+"&nbsp;<input type=\"text\" id=\"cam"+nr+"\" name=\"cam"+nr+"\" size=\"5\" class=\"text_field\"> mp<br>";

htmladd+=htmladd_new;

}
}
else if(cat==0)
{
	x=70;
	htmladd="";
	
	if(cat_bai==0)
	{		
	if(nume_pagina=='apartament')			
	x=35;
	else
	x=75;
	
	htmlspec="<br><div class=\"specificati\"><u>Selectati o numar de camere</u></div><br>";	
	delimiter="";
	}
}



if(cat_bai>1)
{
for(i=1;i<cat_bai;i++)
{
x_bai+=45;	
nr_bai++;

htmladd_new_bai="Suprafata Baie "+nr_bai+"&nbsp;<input type=\"text\" id=\"baie"+nr_bai+"\" name=\"baie"+nr_bai+"\" size=\"5\" class=\"text_field\"> mp<br>";

htmladd_bai+=htmladd_new_bai;

}
}
else if(cat_bai==0)
{
	
	
	x_bai=70;
	htmladd_bai="";
	
	if(cat==0)	
	{		
	if(nume_pagina=='apartament')	
	x_bai=35;	
	else
	x_bai=75;
	
	htmlspec="<br><div class=\"specificati\"><u>Selectati un numar de camere.</u></div><br>";
	delimiter="";
	}
}
suprafata_totala="";
nume_pagina=document.getElementById('nume_pagina').value;
if(nume_pagina=='apartament')
suprafata_totala="Suprafata totala <input type=\"text\"  id=\"suprafata\" name=\"suprafata\" class=\"text_field\" size=\"5\"> mp";
else if(nume_pagina=='casa_vila'||nume_pagina=='pensiune')
{
suprafata_totala="Suprafata utila <input type=\"text\" class=\"text_field\" size=\"5\" name=\"suprafata\" id=\"suprafata\"> mp<br>Suprafata gradina <input type=\"text\" class=\"text_field\" size=\"5\" name=\"suprafata_gradina\" id=\"suprafata_gradina\"> mp<br>Suprafata totala <input type=\"text\" class=\"text_field\" size=\"5\" name=\"suprafata_totala\" id=\"suprafata_totala\"> mp";
}
else if(nume_pagina=='spatiu')
{
suprafata_totala="Suprafata utila <input type=\"text\" class=\"text_field\" size=\"5\" name=\"suprafata\" id=\"suprafata\"> mp<br>Suprafata curte <input type=\"text\" class=\"text_field\" size=\"5\" name=\"suprafata_curte\" id=\"suprafata_curte\"> mp<br>Suprafata totala <input type=\"text\" class=\"text_field\" size=\"5\" name=\"suprafata_totala\" id=\"suprafata_totala\"> mp";
}


heightx=x+x_bai;

c = document.getElementById('camere').value;
b = document.getElementById('bai').value;

if(((b>1)||(b<2))&&(c==0))
heightx+=60;

if(((c>1)||(c<6))&&(b==1))
{
heightx+=80;
if(heightx>400)
{
	heightx-=80;
}
}

if((c<4)&&(b==0))
{
heightx+=40;
}

if((c==4)&&(b>=2))
{
heightx+=60;
}

if((c==0)&&(b==0))
{
heightx=150;
}


if((c==2)&&(b>=2))
{
heightx+=60; 
}

if((c==1)&&(b<=5))
{
heightx+=60; 
}

if((c==3)&&((b>=2)||(b<=4)))
{
heightx+=60; 
}

if(heightx>700)
heightx-=100;

if(document.getElementById('nume_pagina').value=='apartament')
{
heightx-=70;
if((c==6)&&(b==1))
{
heightx+=20;
}
}
document.getElementById('specs').style.height =  heightx;

objtip.innerHTML=
htmlspec
+htmladd+
htmladd_bai+
delimiter+
suprafata_totala;

nr_bai=1;
x_bai=60;
x=60;
nr=1;
}