// JavaScript Document

function Adauga_Oras()

{

  var oras=document.getElementById("nume_oras").value;

  var lista_orase=document.getElementById("orase");

   for(i=0;i<lista_orase.options.length;i++)

    if(lista_orase.options[i].value==oras) {alert("Orasul "+oras+" exista deja in lista de orase!");return false;}

  var dimensiune=lista_orase.options.length;

  lista_orase.options[dimensiune]=new Option(oras,oras);

  lista_orase.size+=1;

  document.getElementById("nume_oras").value="";

 }



function Deselect(id,sender)

{

  var receiver=document.getElementById(id);

  var sender=document.getElementById(sender);

  if(receiver.checked&&sender.checked) receiver.checked=false;

 }



function Sterge_Oras()

{

  var lista_orase=document.getElementById("orase");

  lista_orase.options[lista_orase.selectedIndex]=null;

  lista_orase.size-=1;

}





function Select()

{

var valoare=document.getElementById("hint").options[document.getElementById("hint").selectedIndex].value;

document.getElementById("nume_oras").value=valoare;

document.getElementById("hint").style.visibility="hidden";

}



var focus_oras=false,focus_lista=false;

function VerificaFocus()

{

if(focus_oras==false&&focus_lista==false) document.getElementById("hint").style.visibility="hidden";

setTimeout("VerificaFocus()",300);

}



setTimeout("VerificaFocus()",300);



function Inchide(id)

{

   if(id=="nume_oras") focus_oras=false;

   else focus_lista=false;



}



function Deschide(id)

{

  if(id=="nume_oras") focus_oras=true;

  else focus_lista=true;

}



var xmlHttp2;



function CheckUser()

{

xmlHttp2=GetXmlHttpObject(stateChange) 

var user=document.getElementById("user").value;

var url="checkuser.php?user="+user;

xmlHttp2.open("GET", url , true); 

xmlHttp2.send(null); 

}









function stateChange()

{

if (xmlHttp2.readyState==4 || xmlHttp2.readyState=="complete")

{ 

  

  if(xmlHttp2.responseText=="corect") document.getElementById("poza").src="imagini/ok.jpg";

									 

									  

  if(xmlHttp2.responseText=="incorect") document.getElementById("poza").src="imagini/not.png";

document.getElementById("poza").width=14;

document.getElementById("poza").height=14;

}

}





var xmlHttp;



function GetHint()

{

var oras=document.getElementById("nume_oras").value;

if(oras.length>0)

{

xmlHttp=GetXmlHttpObject(stateChanged) 

var url="gethint.php?oras="+oras;

xmlHttp.open("GET", url , true) 

xmlHttp.send(null) 

 }

else

  document.getElementById("hint").style.visibility="hidden";

}



function stateChanged()

{

if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")

{ 

//am primit raspunsul

var j=0;

var hint=document.getElementById("hint");

for(j=0;j<hint.options.length;j++)

hint.options[i]=null;

hint.options.length=0;

hint.size=0;

if(xmlHttp.responseText.length==0) { document.getElementById("hint").style.visibility="hidden";return false;}

var lista=xmlHttp.responseText.split(",");

if(lista.length>0) document.getElementById("hint").style.visibility="visible";

else  document.getElementById("hint").style.visibility="hidden";

var i=0;

for(i=0;i<lista.length;i++ )

{

 oras=lista[i];

 if(oras!="")

 document.getElementById("hint").options[i]=new Option(oras,oras);

 }

if(lista.length<=5)

           document.getElementById("hint").size=lista.length;

else

           document.getElementById("hint").size=5;		   

}

}





function Trimite_Datele()

{



var lista_orase=document.getElementById("orase");

if(lista_orase.options.length==0&& document.getElementById("nu").checked==true) {

                                     alert("Trebuie sa introduceti o lista de orase sau sa selectati 'magazin virtual' daca distribuiti oriunde in tara!");

                                      return false;

									  }

for(i=0;i<lista_orase.options.length;i++)

lista_orase.options[i].selected=true;







if(document.getElementById("utilizator").value=="") {

                                                alert("Trebuie sa alegeti un nume de utilizator!");

                                                 return false;}



if(document.getElementById("parola").value=="") {

                                                alert("Trebuie sa alegeti o parola!");

                                                 return false;}

if(document.getElementById("repeta_parola").value=="") {

                                                alert("Trebuie sa reintroduceti parola!");

                                                 return false;}

if(document.getElementById("email").value=="") {

                                                alert("Trebuie sa introduceti o adresa de email!");

                                                 return false;}

if(document.getElementById("telefon").value=="") {

                                                alert("Trebuie sa introduceti un numar de telefon!");

                                                 return false;}

if(document.getElementById("nume_firma").value=="") {

                                                alert("Trebuie sa introduceti numele firmei!");

                                                 return false;}

if(document.getElementById("descriere").value==""&&document.getElementById("descriere_eng").value=="") {

                                                alert("Trebuie sa faceti o descriere a firmei dumneavoastra, fie in romana, fie in engleza!");

                                                 return false;}



if(document.getElementById("adresa").value=="") {

                                                alert("Trebuie sa introduceti o adresa!");

                                                 return false;}

												 

if(document.getElementById("da").checked==false&& document.getElementById("nu").checked==false)

                                  {

								  alert("Selectati daca sunteti magazin virtual sau nu!");

								  return false;

								  }

if(document.getElementById("rochii_mireasa").checked==false&&document.getElementById("rochii_ocazie").checked==false&&document.getElementById("costume_femei").checked==false&&document.getElementById("confectii_femei").checked==false&&document.getElementById("rochii_inchiriat_mireasa").checked==false&&document.getElementById("rochii_inchiriat_ocazie").checked==false)

{

   alert("Trebuie sa selectati macar un domeniu din cele 6:rochii mireasa/rochii inchiriat/rochii ocazie/costume femei/confectii femei!");

   return false;

}





return true;

}





function GetXmlHttpObject(handler)

{ 

var objXmlHttp=null



if (navigator.userAgent.indexOf("Opera")>=0)

{

alert("Datorita faptului ca folositi Opera o parte din functionalitate este dezactivata!") 

return 

}



if (navigator.userAgent.indexOf("MSIE")>=0)

{ 

var strName="Msxml2.XMLHTTP"

if (navigator.appVersion.indexOf("MSIE 5.5")>=0)

{

strName="Microsoft.XMLHTTP"

} 

try

{ 

objXmlHttp=new ActiveXObject(strName)

objXmlHttp.onreadystatechange=handler 

return objXmlHttp

} 

catch(e)

{ 

alert("Eroare. Scripting-ul pentru ActiveX ar putea fi dezactivat!") 

return 

} 

} 

if (navigator.userAgent.indexOf("Mozilla")>=0)

{

objXmlHttp=new XMLHttpRequest()

objXmlHttp.onload=handler

objXmlHttp.onerror=handler 

return objXmlHttp

}

} 



function MM_preloadImages() { //v3.0

  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();

    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)

    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}

}



function MM_findObj(n, d) { //v4.01

  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {

    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}

  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];

  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);

  if(!x && d.getElementById) x=d.getElementById(n); return x;

}



function MM_swapImgRestore() { //v3.0

  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;

}



function MM_reloadPage(init) {  //reloads the window if Nav4 resized

  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {

    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}

  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();

}

MM_reloadPage(true);



function MM_swapImage() { //v3.0

  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)

   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}

}



