// JavaScript Document
function a_showcateg()
{
	var str = document.getElementById("a_rubrica").value;
	if (str==0)
     { 
     document.getElementById("categ").innerHTML="";
     return;
     }
     		
	 
xmlHttp = GetXmlHttpObject();
xmlHttp.onreadystatechange = function()
 {
	if(xmlHttp.readyState == 1)
	    {
			document.getElementById("categ").innerHTML = "<img src='../img/loaded.gif' />";
		}
	if(xmlHttp.readyState == 4)
	    {
			document.getElementById("categ").innerHTML = xmlHttp.responseText;
			
			//alert (xmlHttp.responseText);
			if(xmlHttp.status == 200) {
            // alert("The server said: " + xmlHttp.responseText);
             } else {
            // issue an error message for
            // any other HTTP response
            //alert("An error has occurred: " + xmlHttp.statusText);
            }

		}
	
 }
	var url="http://www.anunturi-in-bucuresti.ro/include/script_ajax.php";
    url=url+"?rubr="+str;
    xmlHttp.open("GET",url,true);
    xmlHttp.send(null);
}

//--------------------------------------------------------------------------
function contact()
{

var titlu_contact = document.getElementById("titlu_contact").value;
if(titlu_contact == '')
  {
	  document.getElementById("error_contact_sus").style.display='';
	  document.getElementById("error_contact_mijloc").style.display='';
	  document.getElementById("error_contact_jos").style.display='';
	  document.getElementById("error_contact_mijloc").innerHTML="- TITLU!";
	  return false; 
  }

var email_contact = document.getElementById("email_contact").value;
if(email_contact == '')
  {
	  document.getElementById("error_contact_sus").style.display='';
	  document.getElementById("error_contact_mijloc").style.display='';
	  document.getElementById("error_contact_jos").style.display='';
	  document.getElementById("error_contact_mijloc").innerHTML="- E-MAIL !";
	  return false; 
  }

var mesaj_contact = document.getElementById("mesaj_contact").value;
if(mesaj_contact == '')
  {
	  document.getElementById("error_contact_sus").style.display='';
	  document.getElementById("error_contact_mijloc").style.display='';
	  document.getElementById("error_contact_jos").style.display='';
	  document.getElementById("error_contact_mijloc").innerHTML="- MESAJ !";
	  return false; 
  }


var cod_sesiune = document.getElementById("sesiune_cod").value;
var cod_verif = document.getElementById("user_text").value;
if(cod_sesiune!=cod_verif)
  {
	  document.getElementById("error_contact_sus").style.display='';
	  document.getElementById("error_contact_mijloc").style.display='';
	  document.getElementById("error_contact_jos").style.display='';
	  document.getElementById("error_contact_mijloc").innerHTML="- Nu ai introdus codul corect !";
	  return false; 
  }

return true;
}
//---------------------------------------------------------------------------------

function verific_an()
{

var email_an = document.getElementById("a_email").value;
if (email_an.indexOf("@")==-1)
  {
	  document.getElementById("sus_error_an").style.display='';
	  document.getElementById("mijloc_error_an").style.display='';
	  document.getElementById("jos_error_an").style.display='';
	  document.getElementById("mijloc_error_an").innerHTML="- E-mail-ul nu este corect !";
	  return false; 
  }  


var rubrica_an = document.getElementById("a_rubrica").value;
if(rubrica_an=='')
  {
	  document.getElementById("sus_error_an").style.display='';
	  document.getElementById("mijloc_error_an").style.display='';
	  document.getElementById("jos_error_an").style.display='';
	  document.getElementById("mijloc_error_an").innerHTML="- Nu ai selectat rubrica !";
	  return false; 
  }


// if(document.getElementById("a_rubrica").value!=0)
//  {
  var categria_an = document.getElementById("a_categ").value;
  if(categria_an=='')
     {
	  document.getElementById("error_an").style.display='';
	  document.getElementById("error_an").innerHTML="- Nu ai selectat categoria !";
	  return false; 
     }
//  }



var titlu_an = document.getElementById("a_titlu").value;

if((titlu_an.length<10)||(titlu_an.length>40))
  {
	  document.getElementById("sus_error_an").style.display='';
	  document.getElementById("mijloc_error_an").style.display='';
	  document.getElementById("jos_error_an").style.display='';
	  document.getElementById("mijloc_error_an").innerHTML="- Titlul trebuie sa aiba intre 10 si 40 de caractere in titlu sau nu trebuie sa contina caractere interzise !";
	return false;
  }
  
var anunt_an = document.getElementById("a_anunt").value;
if((anunt_an.length<50)||(anunt_an.length>300))
  {
	document.getElementById("sus_error_an").style.display='';
	  document.getElementById("mijloc_error_an").style.display='';
	  document.getElementById("jos_error_an").style.display='';
	  document.getElementById("mijloc_error_an").innerHTML="- Anuntul trebuie sa aiba intre 50 si 300 de caractere !";
	return false;
  }
  
var tel_an = document.getElementById("a_tel").value;
if (tel_an.length<5)
  {
	  document.getElementById("sus_error_an").style.display='';
	  document.getElementById("mijloc_error_an").style.display='';
	  document.getElementById("jos_error_an").style.display='';
	  document.getElementById("mijloc_error_an").innerHTML="- Numarul de telefon nu este corect !";
	  return false; 
  }  


var judet_an = document.getElementById("a_judet").value;
if(judet_an=='')
  {
	  document.getElementById("sus_error_an").style.display='';
	  document.getElementById("mijloc_error_an").style.display='';
	  document.getElementById("jos_error_an").style.display='';
	  document.getElementById("mijloc_error_an").innerHTML="- Selecteaza judetul !";
	  return false; 
  }

var localit_an = document.getElementById("a_localit").value;
if(localit_an=='')
  {
	  document.getElementById("sus_error_an").style.display='';
	  document.getElementById("mijloc_error_an").style.display='';
	  document.getElementById("jos_error_an").style.display='';
	  document.getElementById("mijloc_error_an").innerHTML="- Campul Localitate este gol !";
	  return false; 
  }

var cod_sesiune = document.getElementById("sesiune_cod").value;
var cod_verif = document.getElementById("user_text").value;
if(cod_sesiune!=cod_verif)
  {
	  document.getElementById("sus_error_an").style.display='';
	  document.getElementById("mijloc_error_an").style.display='';
	  document.getElementById("jos_error_an").style.display='';
	  document.getElementById("mijloc_error_an").innerHTML="- Nu ai introdus codul corect !";
	  return false; 
  }




return true;

}



function textCounter(field, countfield, maxlimit) {
if (field.value.length > maxlimit) // if too long...trim it!
field.value = field.value.substring(0, maxlimit);
// otherwise, update 'characters left' counter
else 
countfield.value = maxlimit - field.value.length;
}

function titluCounter(field, countfield, maxlimit) {
if (field.value.length > maxlimit) // if too long...trim it!
field.value = field.value.substring(0, maxlimit);
// otherwise, update 'characters left' counter
else 
countfield.value = maxlimit - field.value.length;
}




function anulare_cont()
{

var email_a_user = document.getElementById("id_anul_cont").value;
if(email_a_user == '')
  {
	  document.getElementById("sus_error_anulare_cont").style.display='';
	  document.getElementById("mijloc_error_anulare_cont").style.display='';
	  document.getElementById("jos_error_anulare_cont").style.display='';
	  document.getElementById("mijloc_error_anulare_cont").innerHTML="- Adresa de email !";
	  return false; 
  }


var cod_sesiune = document.getElementById("sesiune_cod").value;
var cod_verif = document.getElementById("user_text").value;
if(cod_sesiune!=cod_verif)
  {
	  document.getElementById("sus_error_anulare_cont").style.display='';
	  document.getElementById("mijloc_error_anulare_cont").style.display='';
	  document.getElementById("jos_error_anulare_cont").style.display='';
	  document.getElementById("mijloc_error_anulare_cont").innerHTML="- Nu ai introdus codul corect !";
	  return false; 
  }


return true;
 
}

