function page_profil(id_pag,user_pag)
 {
	
     xmlHttp = GetXmlHttpObject();
     xmlHttp.onreadystatechange = function()
     {
	if(xmlHttp.readyState == 1)
	    {
			document.getElementById("rezult_pag").style.display=''; 
			document.getElementById("rezult_promo").style.display='';
			document.getElementById("rezult_pag").innerHTML = "<img src='../img/loaded.gif' />";	
			
			
		}
	if(xmlHttp.readyState == 4)
	    {
			document.getElementById("rezult_pag").style.display=''; 
			document.getElementById("rezult_promo").style.display='';
			document.getElementById("rezult_pag").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_profil.php";
    url=url+"?id_pag="+id_pag+"&user_pag="+user_pag;
    xmlHttp.open("GET",url,true);
    xmlHttp.send(null);

}

//modificare anunt
function m_showcateg()
{
	var m_rubrica = document.getElementById("m_rubrica").value;
	if (m_rubrica==0)
     { 
     document.getElementById("mcateg").innerHTML="";
     return;
     }
     		
	 
xmlHttp = GetXmlHttpObject();
xmlHttp.onreadystatechange = function()
 {
	if(xmlHttp.readyState == 1)
	    {
			document.getElementById("mcateg").innerHTML = "<img src='../img/loaded.gif' />";
		}
	if(xmlHttp.readyState == 4)
	    {
			document.getElementById("mcateg").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_profil.php";
    url=url+"?m_rubrica="+m_rubrica;
    xmlHttp.open("GET",url,true);
    xmlHttp.send(null);
}


//the end modificare anunt	
	
function promoveaza(id_promo, id_user)
 {
	if (id_promo==0)
     { 
     document.getElementById("rezult_promo").innerHTML="";
     return;
     }
     
     xmlHttp = GetXmlHttpObject();
     xmlHttp.onreadystatechange = function()
     {
	if(xmlHttp.readyState == 1)
	    {
			document.getElementById("rezult_promo").style.display=''; 
			document.getElementById("rezult_pag").style.display='none'; 
			document.getElementById("rezult_promo").innerHTML = "<img src='../img/loaded.gif' />";
		}
	if(xmlHttp.readyState == 4)
	    {
			document.getElementById("rezult_promo").style.display=''; 
			document.getElementById("rezult_pag").style.display='none'; 
			document.getElementById("rezult_promo").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_profil.php";
    url=url+"?promo_id="+id_promo+"&id_user="+id_user;
    xmlHttp.open("GET",url,true);
    xmlHttp.send(null);

}

 function check1(val)
      {	
	   document.getElementById("tip_promo1").value = val;
	   document.setAttribute("checked", "checked");
	   alert (val);
	  }

function check2(val)
      {	
	   document.getElementById("tip_promo2").value = val;
	   document.setAttribute("checked", "checked");
	   alert (val);
	  }





function date_promo()
 {

    
	if(document.prom.tip_promo1.value!='')
	    {
		var tip_promo = document.prom.tip_promo1.value; 
		}
	
	var id_prod = document.getElementById("id_prod").value;
	var id_user_f = document.getElementById("id_user_f").value;
	
	if (tip_promo==0)
     { 
     document.getElementById("rezult_promo").innerHTML="";
     return;
     }
     
     xmlHttp = GetXmlHttpObject();
     xmlHttp.onreadystatechange = function()
     {
	if(xmlHttp.readyState == 1)
	    {
			document.getElementById("rezult_promo").style.display=''; 
			document.getElementById("rezult_promo").innerHTML = "<img src='../img/loaded.gif' />";
		}
	if(xmlHttp.readyState == 4)
	    {
			document.getElementById("rezult_promo").style.display=''; 
			document.getElementById("rezult_promo").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_profil.php";
    url=url+"?tip_promo="+tip_promo+"&id_prod="+id_prod+"&id_user_f="+id_user_f;
    xmlHttp.open("GET",url,true);
    xmlHttp.send(null);

}

function modifica_result (id)
{
	if(id!='')
	{
		document.getElementById("rezult_promo").style.display=''; 
		document.getElementById("rezult_pag").style.display='none'; 
			
	}
}

function sterge_anunt(motiv, id)
 {
    if (motiv==0)
     { 
     document.getElementById("rezult_promo").innerHTML="";
     return;
     }
	 
     xmlHttp = GetXmlHttpObject();
     xmlHttp.onreadystatechange = function()
     {
	if(xmlHttp.readyState == 1)
	    {
			document.getElementById("rezult_promo").style.display=''; 
			document.getElementById("rezult_pag").style.display='none'; 
			document.getElementById("rezult_promo").innerHTML = "<img src='../img/loaded.gif' />";
		}
	if(xmlHttp.readyState == 4)
	    {
			document.getElementById("rezult_promo").style.display=''; 
			document.getElementById("rezult_pag").style.display='none'; 
			document.getElementById("rezult_promo").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_profil.php";
    url=url+"?motiv="+motiv+"&id="+id;
    xmlHttp.open("GET",url,true);
    xmlHttp.send(null);

}
	
	
	
function avert_anunt_ziar()
{
	 var an_ziar = document.getElementById("id_anunt_ziar").value;
	 if(an_ziar == '')
	  {
		   document.getElementById("error_anunt_ziar").style.display=''; 
		   document.getElementById("error_anunt_ziar").innerHTML = "Nu ai adaugat anuntul";
		   return false;
	  }
	
	var categ_ziar = document.getElementById("id_categ_ziar").value;
	 if(categ_ziar == ' ')
	  {
		   document.getElementById("error_anunt_ziar").style.display=''; 
		   document.getElementById("error_anunt_ziar").innerHTML = "Nu selectat categoria";
		   return false;
	  }
	
	
	return true;
}
	

function count_cuv()
{
	var cuv = document.getElementById("id_anunt_ziar").value;
	while(cuv.indexOf('  ')>-1)
	{cuv = cuv.replace('  ',' ');}
    
    var splitstring = cuv.split(' ');
	
	if(splitstring.length>=0)
	{
		document.getElementById("rezult_cuv").innerHTML = "Anuntul contine "+ splitstring.length +" cuvinte";
		return true;
		
	}
	
}

function avert_anut_ziarr()
{
	var nume_ziarr = document.getElementById("id_nume_ziarr").value;
	 if(nume_ziarr == '')
	  {
		   document.getElementById("error_anunt_ziarr").style.display=''; 
		   document.getElementById("error_anunt_ziarr").innerHTML = "Adauga numele !!!";
		   return false;
	  }
	
	var prenume_ziarr = document.getElementById("id_prenume_ziarr").value;
	 if(prenume_ziarr == '')
	  {
		   document.getElementById("error_anunt_ziarr").style.display=''; 
		   document.getElementById("error_anunt_ziarr").innerHTML = "Adauga Prenumele !!!";
		   return false;
	  }
	
    var tel_ziarr = document.getElementById("id_tel_ziarr").value;
	if(tel_ziarr == '')
	  {
		   document.getElementById("error_anunt_ziarr").style.display=''; 
		   document.getElementById("error_anunt_ziarr").innerHTML = "Adauga Telefonul !!!";
		   return false;
	  }
	
	var cnp_ziarr = document.getElementById("id_cnp_ziarr").value;
	if((cnp_ziarr.length <=12)||(cnp_ziarr.length >=14))
	  {
		   //alert(cnp_ziarr.length);
		   document.getElementById("error_anunt_ziarr").style.display=''; 
		   document.getElementById("error_anunt_ziarr").innerHTML = "CNP-ul nu este corect !!!";
		   return false;
	  }
	
	
	return true;
}



