// JavaScript Document
//jump to page
function selecturl(site,s) 
{
  var gourl = s.options[s.selectedIndex].value;
  
  var jump = site + '?action=publica&cat='+ gourl;
    
  if ((gourl != null) && (gourl != '') )
  {
    window.top.location.href = jump;
  }
}

//make jud visible
function showjud(){
  var s = document.getElementById("lista_judet").style.visibility;
  
  if(s == "hidden" || s == ""){
    document.getElementById("lista_judet").style.visibility = "visible";
  }
  else{
    document.getElementById("lista_judet").style.visibility = "hidden";
  }
}

//preview anunt
function preview(dvx,anunt,txt)
{  
  document.public.previewtitle.value = anunt;
  document.public.previewtext.value = txt;
}

//check form publish if susubcat exist
function form_check(){
  sc = document.getElementById("subcat");
  ssc = document.getElementById("subsubcat");
  
  if(sc.options[sc.selectedIndex].value == "" || ssc.options[ssc.selectedIndex].value == "")alert("Va rugam selectati categoria si subcategoria anuntului.");
  else document.public.submit();
}

//check form publish if susubcat don't exist
function form_check2(){
  sc = document.getElementById("subcat");
  
  if(sc.options[sc.selectedIndex].value == "")alert("Va rugam selectati categoria si subcategoria anuntului.");
  else document.public.submit();
}

//hide adult warning
function hide_adult()
{
  document.getElementById("adult").style.visibility = "hidden";
  document.getElementById("adult").style.position = "absolute";
}
//------------------------------------------------------------------------------ajax
function ajaxFunction(dvx,url,param1,param2,param3,param4,param5)
{  
  if (url == "anunturi-list")urlx = "anunturi-list.php?p1="+param1+"&p2="+param2+"&p3="+param3+"&p4="+param4;
  if (url == "nume")urlx = "datelemele.php?p1="+param1+"&p2="+param2+"&p3="+param3;
  if (url == "foto-view")urlx = param2 + "view_image.php?p1="+param1+"&p2="+param2+"&p3="+param3+"&p4="+param4+"&p5="+param5;
  if (url == "remind-pass")urlx = param2 + "remind-pass.php?p1="+param1;
  if (url == "promo_close")urlx = param2 + "promo_close.php?p1="+param1;
  //alert(urlx);
  var xmlHttp;
  try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
  catch (e)
    {
    // Internet Explorer
    try
      {
      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      }
    catch (e)
      {
      try
        {
        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
      catch (e)
        {
        alert("Your browser does not support AJAX!");
        return false;
        }
      }
    }
    
    xmlHttp.onreadystatechange=function()
    {
      if(xmlHttp.readyState==4)
      {
        if (document.getElementById(dvx)){document.getElementById(dvx).innerHTML=xmlHttp.responseText;}
      }
      if(xmlHttp.readyState < 4)
      {
        if (document.getElementById(dvx))
        {
          if (url != "foto-view" & url != "remind-pass")document.getElementById(dvx).innerHTML = "<br><img src=\'img/loading.gif\' border=\'0\'>";
          if (url == "foto-view" || url == "remind-pass")document.getElementById(dvx).innerHTML = "<br><img src=\'" + param2 + "img/loading.gif\' border=\'0\'>";
        }
      }
    }   
    xmlHttp.open("GET",urlx,true);
    xmlHttp.send(null);
}
//------------------------------------------------------------------------------end ajax function
