
/*===================================================Numarul de vizitatori=====================
===============================================================================================
===============================================================================================
===============================================================================================
*/
/*function nr_vizitatori()
{
	 var http = getRul();
  var myurl = 'php/nr_vizitatori.php';
  myRand = parseInt(Math.random()*999999999999999);
  var modurl = myurl+"?rand="+myRand;
    
  http.open("GET", modurl, true);
  
  http.onreadystatechange = function rand_dev()
    {
     if (http.readyState == 4)
	 {
     if(http.status == 200) 
	  {
		   document.getElementById('vizite').innerHTML = " chriissis 2009 | Vizitatori: "+http.responseText + " | <span id='cauta_dev_span' onclick=\"parola_holder()\"> Cauta </span>";
	  } 
	 else {document.getElementById('vizite').innerHTML = " chriissis 2009 | Vizitatori: Se incarca... | <span id='cauta_dev_span' onclick=\"cauta_dev()\"> Cauta </span>" }
  }
 }
  http.send(null);
}

*/

/*===================================================================Intoarce Orase============
===============================================================================================
===============================================================================================
===============================================================================================
*/
function getOrase(litera) {
  var http = getRul();
  var myurl = 'php/orase_return.php';
  myRand = parseInt(Math.random()*999999999999999);
  var modurl = myurl+"?rand="+myRand+"&litera="+litera;
  http.open("GET", modurl, true);
  http.onreadystatechange = function putOrase()
  {
   {
     if (http.readyState == 4)
	 {
     if(http.status == 200) 
	  {
      
	  orasele_lista = new Array();
	  
	  var orasele = new Array();
	  orasele = http.responseText.split("|");
	 	  
	  document.getElementById('Main_Holder').innerHTML = "";
	  
	  for(var i = 0;i<orasele.length;i++)
	  {
		document.getElementById('Main_Holder').innerHTML += "<div class='bloc_exterior'><div class='bloc_nume' id='bloc_nume_"+i+"'>"+orasele[i]+"</div><div class='bloc_interior' id='bloc_interior_"+i+"'></div></div>"; 
		getUseri(i,orasele[i],0);
	    orasele_lista.push(orasele[i]);
		
	  }
	  
	  document.title = orasele_lista;
	  }
     } 
	 else { document.getElementById('orase').innerHTML = "Se incarca..." }
  }
 }
  http.send(null);
}


/*===========================================================Intoarce toate orasele============
===============================================================================================
===============================================================================================
===============================================================================================
*/
function getToateOrasele() {
  var http = getRul();
  var myurl = 'php/orase_return.php';
  myRand = parseInt(Math.random()*999999999999999);
  var modurl = myurl+"?rand="+myRand+"&litera=#";
  http.open("GET", modurl, true);
  http.onreadystatechange = function()
   {
     if (http.readyState == 4)
	 {
     if(http.status == 200) 
	  {
	   orasele_toate = http.responseText.split("|");
	}
 }
}
  http.send(null);
}


/*=====================================================Intoarce userii din baza de date========
===============================================================================================
===============================================================================================
===============================================================================================
*/
function getUseri(nr,orasul,cauta_string) {
  var http = getRul();
  var myurl = 'php/useri_return.php';
  myRand = parseInt(Math.random()*999999999999999);
  var modurl = myurl+"?rand="+myRand+"&oras="+orasul;
  if(cauta_string!=0) modurl+="&cauta="+cauta_string;
  
  http.open("GET", modurl);
  http.onreadystatechange = function putUseri()
  {
   {
     if (http.readyState == 4)
	 {
     if(http.status == 200) 
	  {
      var userii = new Array();
	  userii = http.responseText.split("|"); 
	  var userii_text ="";
	 
	  var intermediar = 0;
	  for (var i=0;i<userii.length;i++)
	  {
		if(intermediar==0)
		{
	       userii_text += "<span class='u'><a href='http://www."+userii[i]+".deviantart.com' target='_blank'>"+userii[i]+"</a></span> ";
		   intermediar = 1;
		}
		else if(intermediar==1)
		{
		   userii_text += "<span class='u2'><a href='http://www."+userii[i]+".deviantart.com' target='_blank'>"+userii[i]+"</a></span> ";
		   intermediar = 2;
		}
		else if(intermediar==2)
		{
		   userii_text += "<span class='u3'><a href='http://www."+userii[i]+".deviantart.com' target='_blank'>"+userii[i]+"</a></span> ";
		   intermediar = 0;
		}
	  }
	 
	 
	 document.getElementById('bloc_interior_'+nr).innerHTML = userii_text;
	  
      }
     } else { document.getElementById('bloc_interior_'+nr).innerHTML = "Se incarca ... "; }
  }
 }
  http.send(null);
 }
 
 /*==========================================Intoarce numarul deviantilor + in asteptare========
===============================================================================================
===============================================================================================
===============================================================================================
*/
function getNrDevianti() {
  var http = getRul();
  var myurl = 'php/numara_deviantii_toti.php';
  myRand = parseInt(Math.random()*999999999999999);
  var modurl = myurl+"?rand="+myRand;
  
  http.open("GET", modurl);
  http.onreadystatechange = function getNr()
  {
     if (http.readyState == 4)
	 {
     if(http.status == 200) 
	  {
	   
       document.getElementById('numar_devianti').innerHTML = "# deviantilor: "+http.responseText;
     }
	 }
	 else {  }
 }
  http.send(null);
 }

/*====================================================Intoarce literele oraselor valide========
===============================================================================================
===============================================================================================
===============================================================================================
*/
function facatorDeLitere()
{
  var http = getRul();
  var myurl = 'php/orase_return.php';
  myRand = parseInt(Math.random()*999999999999999);
  var modurl = myurl+"?rand="+myRand+"&orasul=#";
  http.open("GET", modurl, true);
  http.onreadystatechange = function getLitere()
  {
	  if (http.readyState == 4) {
        if(http.status == 200) {
          var orase = new Array();
		  orase = http.responseText.split("|");
		  for( var i =0;i<orase.length;i++)
		   orase[i] = orase[i].charAt(0);
		   orase = unique(orase);
		   
		 	 document.getElementById('menuLitere').innerHTML = "";	  
		  for(var i=0;i<orase.length-1;i++)
		     document.getElementById('menuLitere').innerHTML += "<li onclick=\"getOrase('"+orase[i]+"')\">"+orase[i]+"</li>";
		  
      }
    } else {
		    document.getElementById('menuLitere').innerHTML = "<li> Se Incarca </li>";
	       }
  }
  http.send(null);
}






/*===================================================================Random deviant============
===============================================================================================
===============================================================================================
===============================================================================================
*/
function randdev()
{
  var http = getRul();
  var myurl = 'php/random_deviant.php';
  myRand = parseInt(Math.random()*999999999999999);
  var modurl = myurl+"?rand="+myRand;
  http.open("GET", modurl, true);
  http.onreadystatechange = function rand_dev()
    {
     if (http.readyState == 4)
	 {
     if(http.status == 200) 
	  {
 	   document.getElementById('rand_dev').innerHTML = "<a onmouseout='randdev();' href='http://www."+http.responseText+".deviantart.com' target='_blank'>"+http.responseText+"</a>";
	   rand_user = http.responseText;
	   poza_feature();
	  } 
	 else {}
  }
 }
  http.send(null);

	
}

/*========================================Functie ce face un array unic========================
===============================================================================================
===============================================================================================
===============================================================================================
*/
function unique(a) // face o array unica
{
   var r = new Array();
   o:for(var i = 0, n = a.length; i < n; i++) {
      for(var x = i + 1 ; x < n; x++)
      {
         if(a[x]==a[i]) continue o;
      }
      r[r.length] = a[i];
   }
   return r;
}




/*=================================================================== Parola===================
===============================================================================================
===============================================================================================
===============================================================================================
*/
function trimite_parola(x,ce)
{
  document.title = ce;
  var http = getRul();
  var myurl = 'php/check_pass.php';
  myRand = parseInt(Math.random()*999999999999999);
  var modurl = myurl+"?rand="+myRand;
  var params = "parola="+x;

  
  http.open("POST", modurl, true);
  
  http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  http.setRequestHeader("Content-length", params.length);
  http.setRequestHeader("Connection", "close");


  http.onreadystatechange = function()
    {
     if (http.readyState == 4)
	 {
     if(http.status == 200) 
	  {
 	   if(http.responseText == "1")
	  {
	    pass_v = 1;
		if(ce=="asteptare")
				  document.getElementById('unde_e_loginu').style.backgroundColor = "green";
		else
	    	if(ce=="cauta")
		{
		  document.getElementById('parola_asteptare').style.backgroundColor = "green";
		   cauta_deviantii();
		}
	  }
	   else 
	     pass_v = 0;
	  } 
	 else {}
  }
 }
  http.send(params);

	
}







