//AJAX OBJECT
function ajaxObject(url, callbackFunction) {
  var that=this;      
  this.updating = false;
  this.abort = function() {
    if (that.updating) {
      that.updating=false;
      that.AJAX.abort();
      that.AJAX=null;
    }
  }
  this.update = function(passData,postMethod) { 
    if (that.updating) { return false; }
    that.AJAX = null;
    var xmlHttp= null;	
  try
    {
    // Firefox, Opera 8.0+, Safari
    xmlHttp=new XMLHttpRequest();
    }
  catch (e)
    {
    // Internet Explorer
    try
      {
      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      }
    catch (e)
      {
      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
    }
if(!xmlHttp)
{
alert("Nu s-a putut crea obiectul XMLHttpRequest");
}else{
that.AJAX = xmlHttp;
}
    if (that.AJAX==null) {                             
      return false;                               
    } else {
      that.AJAX.onreadystatechange = function() {  
	  if (that.AJAX.readyState==3) {      
          that.callback(null,that.AJAX.readyState,null,null);                                             
        }   
        if (that.AJAX.readyState==4) {  	
          that.updating=false;                
          that.callback(that.AJAX.responseText,that.AJAX.readyState,that.AJAX.status,that.AJAX.responseXML);          that.AJAX=null;                                         
        }                                                      
      }                                                        
      that.updating = new Date();                              
      if (/post/i.test(postMethod)) {
        var uri=urlCall+'?'+that.updating.getTime();
        that.AJAX.open("POST", uri, true);
        that.AJAX.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
        that.AJAX.setRequestHeader("Content-Length", passData.length);
        that.AJAX.send(passData);
      } else {
	          if(urlCall.indexOf("?")== -1)
	            {
         uri=urlCall+'?'+passData+'&timestamp='+(that.updating.getTime()); 
	            }else{
		 uri=urlCall+'&'+passData+'&timestamp='+(that.updating.getTime()); 		
				}
        that.AJAX.open("GET", uri, true);                             
        that.AJAX.send(null);                                         
      }              
      return true;                                             
    }                                                                           
  }
  var urlCall = url;        
  this.callback = callbackFunction || function () { };
}

//AJAX FUNCTIONS
//Contor
function adresa()
{
var referinta = document.referrer;
myRequest = new ajaxObject("http://www.targuldemobila.ro/contor.php");
myRequest.callback = function(responseText,readyState,status)
{
if(readyState == 4)
  {
  //status 200 arata ca cererea a fost rezolvata cu succes
    if(status == 200)
	{
	//extragen rezultatul
	raspuns = responseText;
	//modificam div-ul rezultat cu rezultatul
	}
	//daca statusul este diferit avem o problema
	else
	  {
	  alert("Problema la accesare:");
	  }
  }
}
myRequest.update("referinta=" + referinta);
}
//Initializare cos
function loadcos(prodid)
{
var vizcos = document.getElementById('cos');
//preloader
vizcos.style.visibility = 'visible';
vizcos.innerHTML =
'<div style="display: block;overflow: hidden;position: relative;height: auto;width: 310px;">' +
'<form name="ccosmod" id="ccosmod" action="#" method="post" style="margin:0px">' +
'<table style="display: block;position: relative;margin: 0;padding: 0; width: 299px;border: 3px solid #555555;overflow: hidden;" cellspacing ="0" cellpadding="0">' +
'<tr>' +
'<td colspan="3" style="margin: 0; padding: 0; background-color: #44d8e5;width: 299px;"><center style="font-family: Arial; font-weight: bold; font-size: 15px; color: #F00000;">COS PRODUSE<img src="http://www.targuldemobila.ro/imagini/delc.gif" width="17" height="16" border="0" onmousedown="hidecos()" style="padding-left: 5px" alt="ascunde cos"/></center></td>' +
'</tr>' +
'<tr>' +
'<td style="margin: 0; padding: 0; border-bottom: 1px solid #44d8e5; background-color: #d6f2f4;"><center style="font-family: Arial; font-weight: bold; font-size: 11px; color: #083135;">Produs</center></td><td style=" margin: 0; padding: 0; border-bottom: 1px solid #44d8e5; background-color: #d6f2f4;"><center style="font-family: Arial; font-weight: bold; font-size: 11px; color: #083135;">Cantitate</center></td><td style=" margin: 0; padding: 0; border-bottom: 1px solid #44d8e5; background-color: #d6f2f4;"><center style="font-family: Arial; font-weight: bold; font-size: 11px; color: #083135;">Pret</center></td>' +
'</tr>' +
'<td colspan="3" style="margin: 0; padding: 0; background-color: #44d8e5;width: 299px;"><center style="font-family: Arial; font-weight: bold; font-size: 15px; color: #F00000;"><img src="http://www.targuldemobila.ro/imagini/ajax-loader.gif" alt="se incarca" /></center></td>' +
'<tr>' +
'<td colspan ="3" style=" margin: 0; padding: 0; background-color: #d6f2f4; border-bottom: 1px; solid #2b4041"><center style="font-family: Arial; font-weight: bold; font-size: 12px; color: #9e2404;">&nbsp;</center></td>' +
'</tr>' +
'<tr>' +
'<td style=" margin: 0; padding: 0;' + "background-image:url('http://www.targuldemobila.ro/imagini/cosbg.gif')" + '">&nbsp;</td><td style=" margin: 0; padding: 0;' + "background-image:url('http://www.targuldemobila.ro/imagini/cosbg.gif')" + '"><img src="http://www.targuldemobila.ro/imagini/shopbag1.gif" style="cursor: move;" alt="Muta cosul !" title= "Pentru a muta cosul titneti apasat butonul stanga al mouse-lui si trageti !"/></td><td style="margin: 0; padding: 0;' + "background-image:url('http://www.targuldemobila.ro/imagini/cosbg.gif')" + ';font-weight: bold;font-size: 12px;font-family: Arial"><a href="finalizeaza-comanda~1UK7tj66;1heL{W8;1Y9020188A;1XBcQ7n;1Ur7E8v0;1Tk96W056;~.html" class="cos"> FINALIZEAZA</a></td>' +
'</tr>' +
'</table>' +
'</form>' +
'</div>';
myRequest = new ajaxObject("http://www.targuldemobila.ro/cosload.php");
myRequest.callback = function(responseText,readyState,status)
{
if(readyState == 4)
  {
  //status 200 arata ca cererea a fost rezolvata cu succes
    if(status == 200)
	{
	//extragen rezultatul
	raspuns = responseText;
    vizcos = document.getElementById('cos');
vizcos.style.visibility = 'visible';
vizcos.innerHTML =
'<div style="display: block;overflow: hidden;position: relative;height: auto;width: 310px;">' +
'<form name="ccosmod" id="ccosmod" action="#" method="post" style="margin:0px">' + 
'<table style="display: block;position: relative;margin: 0;padding: 0; width: 299px;border: 3px solid #555555;overflow: hidden;" cellspacing ="0" cellpadding="0">' + 
'<tr>' + 
'<td colspan="3" style="margin: 0; padding: 0; background-color: #44d8e5;width: 299px;"><center style="font-family: Arial; font-weight: bold; font-size: 15px; color: #F00000;">COS PRODUSE<img src="http://www.targuldemobila.ro/imagini/delc.gif" width="17" height="16" border="0" onmousedown="hidecos()" style="padding-left: 5px" alt="ascunde cos"/></center></td>' +
'</tr>' + 
'<tr>' + 
'<td style="margin: 0; padding: 0; border-bottom: 1px solid #44d8e5; background-color: #d6f2f4;"><center style="font-family: Arial; font-weight: bold; font-size: 11px; color: #083135;">Produs</center></td><td style=" margin: 0; padding: 0; border-bottom: 1px solid #44d8e5; background-color: #d6f2f4;"><center style="font-family: Arial; font-weight: bold; font-size: 11px; color: #083135;">Cantitate</center></td><td style=" margin: 0; padding: 0; border-bottom: 1px solid #44d8e5; background-color: #d6f2f4;"><center style="font-family: Arial; font-weight: bold; font-size: 11px; color: #083135;">Pret</center></td>' + 	
'</tr>' + raspuns + 
'<tr>' + 
'<td colspan ="3" style=" margin: 0; padding: 0; background-color: #d6f2f4; border-bottom: 1px; solid #2b4041"><center style="font-family: Arial; font-weight: bold; font-size: 12px; color: #9e2404;">&nbsp;</center></td>' + 
'</tr>' + 
'<tr>' + 
'<td style=" margin: 0; padding: 0;cursor: move;' + "background-image:url('http://www.targuldemobila.ro/imagini/cosbg.gif')" + '"title= "Pentru a muta cosul tineti apasat butonul stanga al mouse-lui si trageti !" >&nbsp;</td><td style=" margin: 0; padding: 0;' + "background-image:url('http://www.targuldemobila.ro/imagini/cosbg.gif')" + '"><img src="http://www.targuldemobila.ro/imagini/shopbag1.gif" style="cursor: move;" alt="Muta cosul !" title= "Pentru a muta cosul titneti apasat butonul stanga al mouse-lui si trageti !" /></td><td style="margin: 0; padding: 0;' + "background-image:url('http://www.targuldemobila.ro/imagini/cosbg.gif')" + ';font-weight: bold;font-size: 12px;font-family: Arial"><a href="finalizeaza-comanda~1UK7tj66;1heL{W8;1Y9020188A;1XBcQ7n;1Ur7E8v0;1Tk96W056;~.html" class="cos"> FINALIZEAZA</a></td>' +
'</tr>' + 
'</table>' + 
'</form>' + 
'</div>';

	//modificam div-ul rezultat cu rezultatul
	}
	//daca statusul este diferit avem o problema
	else
	  {
	  alert("Problema la accesare !");

	  }
  }

}
myRequest.update("cosid=" + prodid);
}
//Modifica cos
function cantcosmodif(i)
{
var cantval = document.getElementById('ccant'+i).value;
//preloader
var vizcos = document.getElementById('cos');
vizcos.style.visibility = 'visible';
vizcos.innerHTML =
'<div style="display: block;overflow: hidden;position: relative;height: auto;width: 310px;">' +
'<form name="ccosmod" id="ccosmod" action="#" method="post" style="margin:0px">' +
'<table style="display: block;position: relative;margin: 0;padding: 0; width: 299px;border: 3px solid #555555;overflow: hidden;" cellspacing ="0" cellpadding="0">' +
'<tr>' +
'<td colspan="3" style="margin: 0; padding: 0; background-color: #44d8e5;width: 299px;"><center style="font-family: Arial; font-weight: bold; font-size: 15px; color: #F00000;">COS PRODUSE<img src="http://www.targuldemobila.ro/imagini/delc.gif" width="17" height="16" border="0" onmousedown="hidecos()" style="padding-left: 5px" alt="ascunde cos"/></center></td>' +
'</tr>' +
'<tr>' +
'<td style="margin: 0; padding: 0; border-bottom: 1px solid #44d8e5; background-color: #d6f2f4;"><center style="font-family: Arial; font-weight: bold; font-size: 11px; color: #083135;">Produs</center></td><td style=" margin: 0; padding: 0; border-bottom: 1px solid #44d8e5; background-color: #d6f2f4;"><center style="font-family: Arial; font-weight: bold; font-size: 11px; color: #083135;">Cantitate</center></td><td style=" margin: 0; padding: 0; border-bottom: 1px solid #44d8e5; background-color: #d6f2f4;"><center style="font-family: Arial; font-weight: bold; font-size: 11px; color: #083135;">Pret</center></td>' +
'</tr>' +
'<td colspan="3" style="margin: 0; padding: 0; background-color: #44d8e5;width: 299px;"><center style="font-family: Arial; font-weight: bold; font-size: 15px; color: #F00000;"><img src="http://www.targuldemobila.ro/imagini/ajax-loader.gif"></center></td>' +
'<tr>' +
'<td colspan ="3" style=" margin: 0; padding: 0; background-color: #d6f2f4; border-bottom: 1px; solid #2b4041"><center style="font-family: Arial; font-weight: bold; font-size: 12px; color: #9e2404;">&nbsp;</center></td>' +
'</tr>' +
'<tr>' +
'<td style=" margin: 0; padding: 0;' + "background-image:url('http://www.targuldemobila.ro/imagini/cosbg.gif')" + '">&nbsp;</td><td style=" margin: 0; padding: 0;' + "background-image:url('http://www.targuldemobila.ro/imagini/cosbg.gif')" + '"><img src="http://www.targuldemobila.ro/imagini/shopbag1.gif" style="cursor: move;" alt="Muta cosul !" title= "Pentru a muta cosul titneti apasat butonul stanga al mouse-lui si trageti !"/></td><td style="margin: 0; padding: 0;' + "background-image:url('http://www.targuldemobila.ro/imagini/cosbg.gif')" + ';font-weight: bold;font-size: 12px;font-family: Arial"><a href="finalizeaza-comanda~1UK7tj66;1heL{W8;1Y9020188A;1XBcQ7n;1Ur7E8v0;1Tk96W056;~.html" class="cos"> FINALIZEAZA</a></td>' +
'</tr>' +
'</table>' +
'</form>' +
'</div>';
myRequest = new ajaxObject("http://www.targuldemobila.ro/cosmodif.php");
myRequest.callback = function(responseText,readyState,status)
{
if(readyState == 4)
  {
  //status 200 arata ca cererea a fost rezolvata cu succes
    if(status == 200)
	{
	//extragen rezultatul
	raspuns = responseText;
	var vizcos = document.getElementById('cos');	
	if(raspuns != "hidden")
{	
vizcos.style.visibility = 'visible';
//modificam div-ul rezultat cu rezultatul
vizcos.innerHTML =
'<div style="display: block;overflow: hidden;position: relative;height: auto;width: 310px;">' +
'<form name="ccosmod" id="ccosmod" action="#" method="post" style="margin:0px">' + 
'<table style="display: block;position: relative;margin: 0;padding: 0; width: 299px;border: 3px solid #555555;overflow: hidden;" cellspacing ="0" cellpadding="0">' + 
'<tr>' + 
'<td colspan="3" style="margin: 0; padding: 0; background-color: #44d8e5;width: 299px;"><center style="font-family: Arial; font-weight: bold; font-size: 15px; color: #F00000;">COS PRODUSE<img src="http://www.targuldemobila.ro/imagini/delc.gif" width="17" height="16" border="0" onmousedown="hidecos()" style="padding-left: 5px" alt="ascunde cos"/></center></td>' +
'</tr>' + 
'<tr>' + 
'<td style="margin: 0; padding: 0; border-bottom: 1px solid #44d8e5; background-color: #d6f2f4;"><center style="font-family: Arial; font-weight: bold; font-size: 11px; color: #083135;">Produs</center></td><td style=" margin: 0; padding: 0; border-bottom: 1px solid #44d8e5; background-color: #d6f2f4;"><center style="font-family: Arial; font-weight: bold; font-size: 11px; color: #083135;">Cantitate</center></td><td style=" margin: 0; padding: 0; border-bottom: 1px solid #44d8e5; background-color: #d6f2f4;"><center style="font-family: Arial; font-weight: bold; font-size: 11px; color: #083135;">Pret</center></td>' + 	
'</tr>' + raspuns + 
'<tr>' + 
'<td colspan ="3" style=" margin: 0; padding: 0; background-color: #d6f2f4; border-bottom: 1px; solid #2b4041"><center style="font-family: Arial; font-weight: bold; font-size: 12px; color: #9e2404;">&nbsp;</center></td>' + 
'</tr>' + 
'<tr>' + 
'<td style=" margin: 0; padding: 0;cursor: move;' + "background-image:url('http://www.targuldemobila.ro/imagini/cosbg.gif')" + '">&nbsp;</td><td style=" margin: 0; padding: 0;' + "background-image:url('http://www.targuldemobila.ro/imagini/cosbg.gif')" + '" title= "Pentru a muta cosul tineti apasat butonul stanga al mouse-lui si trageti !" ><img src="http://www.targuldemobila.ro/imagini/shopbag1.gif" style="cursor: move;" alt="Muta cosul !" title= "Pentru a muta cosul titneti apasat butonul stanga al mouse-lui si trageti !"/></td><td style="margin: 0; padding: 0;' + "background-image:url('http://www.targuldemobila.ro/imagini/cosbg.gif')" + ';font-weight: bold;font-size: 12px;font-family: Arial"><a href="finalizeaza-comanda~1UK7tj66;1heL{W8;1Y9020188A;1XBcQ7n;1Ur7E8v0;1Tk96W056;~.html" class="cos"> FINALIZEAZA</a></td>' +
'</tr>' + 
'</table>' + 
'</form>' + 
'</div>';
}else{
vizcos.style.visibility = 'hidden';
}	
	}
	//daca statusul este diferit avem o problema
	else
	  {
	  alert("Problema la accesare:");
	  }
  }
}
myRequest.update("cantindice=" + i + "&cantval=" + cantval);
}
//Modifica cos la finalizare
function fcosmodif(i)
{
//preloader
var vizcos = document.getElementById('fcos');
var preloader = document.getElementById('ajaxloader');
preloader.style.display = 'block';
var cantval = document.getElementById('fcant'+i).value;
myRequest = new ajaxObject("http://www.targuldemobila.ro/fcosmodif.php");
myRequest.callback = function(responseText,readyState,status)
{
if(readyState == 4)
  {
  //status 200 arata ca cererea a fost rezolvata cu succes
    if(status == 200)
	{
	//extragen rezultatul
	raspuns = responseText;
	var vizcos = document.getElementById('fcos');
	if(raspuns != "hidden")
{	
vizcos.style.visibility = 'visible';
preloader.style.display = 'none';
//modificam div-ul rezultat cu rezultatul
vizcos.innerHTML = '<table style="width: 100%; position: relative; margin: 0; padding: 0;">' + 
'<tr><td colspan="5" style="height: 5px;">&nbsp;</td></tr>' + raspuns +  
'</table>';
}else{
vizcos.style.visibility = 'hidden';
}	
	}
	//daca statusul este diferit avem o problema
	else
	  {
	  alert("Problema la accesare:");
	  }
  }
}
myRequest.update("cantindice=" + i + "&cantval=" + cantval);
}
//lastprev
var v = 0;


function lastprev(i, j)
{
v = j;
var cantval = document.getElementById('fcant'+i).value;
//preloader
var vizcos = document.getElementById('lastprv');
vizcos.style.display = 'block';
vizcos.innerHTML ='<center><img src="http://www.targuldemobila.ro/imagini/ajax-loader.gif" alt="se incarca.." /></center>';
myRequest = new ajaxObject("http://www.targuldemobila.ro/lastprev.php");
myRequest.callback = function(responseText,readyState,status)
{
if(readyState == 4)
  {
  //status 200 arata ca cererea a fost rezolvata cu succes
    if(status == 200)
	{
	//extragen rezultatul
	raspuns = responseText;
	var vizcos = document.getElementById('lastprv');
	if(raspuns != "none")
{	
vizcos.style.display = 'block';
vizcos.style.left = posx+20+"px";
vizcos.style.top = posy + "px";  	 
//modificam div-ul rezultat cu rezultatul
vizcos.innerHTML = raspuns;
}else{
vizcos.style.visibility = 'hidden';
}	
	}
	//daca statusul este diferit avem o problema
	else
	  {
	  alert("Problema la accesare:");
	  }
  }
}
myRequest.update("cantindice=" + i);
}
//Adauga-Elimina produs
function addrem_produs(pid, mod)
{
var nrprod = document.getElementById('nrpprod').value;
var prodadd = "";
var pval = new Array();
for(i=0;i < nrprod;i++)
{
pval[i] = document.getElementById('pprod' + i).value;
prodadd += "&pprod" + i + "=" + pval[i];
}
//preloader
var vizcos = document.getElementById('parentprod');
vizcos.innerHTML ='<center><img src="http://www.targuldemobila.ro/imagini/ajax-loader.gif" alt="Se incarca" /></center>';
var myRequest = new ajaxObject("search_prod.php", cautaprod);
 //adauga produs
 myRequest.update("mod=" + mod + "&pid=" + pid + "&nrpprod=" + nrprod + prodadd);
}
function cautaprod(responseText,readyState,status)
{
if(readyState == 4)
  {
  //status 200 arata ca cererea a fost rezolvata cu succes
    if(status == 200)
	{
	//extragen rezultatul
	raspuns = responseText;
	var vizcos = document.getElementById('parentprod');	
//modificam div-ul rezultat cu rezultatul
vizcos.innerHTML = raspuns;
var pprodf = "";
var nrprod = document.getElementById('nrpprod').value;
var pval = new Array();
for(i=0;i < nrprod;i++)
{
pval[i] = document.getElementById('pprod' + i).value;
pprodf += pval[i] + "/";
}
document.getElementById('pprodf').value = pprodf;
	}
	//daca statusul este diferit avem o problema
	else
	  {
	  alert("Problema la accesare:");
	  }
  }
}
//NAVIGARE CATALOG
function prodselect(catid, prodid, tip, index, ptip)
{
//preloader 
var vizcos = document.getElementById('prodnav'); 
vizcos.style.display = 'block';
vizcos.innerHTML =
'<div style="display: block;overflow: hidden;position: relative;height: auto;width: 310px;"><center>' +
'<img src="http://www.targuldemobila.ro/imagini/ajax-loader.gif">' +
'</center></div>';
switch (tip)
{
 case "furnizor":
 myRequest = new ajaxObject("fcatnav.php");
 break;
 case "admin":
 document.getElementById('cpm').style.display="none";
 document.getElementById('cpd').style.display="none";
 myRequest = new ajaxObject("acatnav.php");
 break;
 case "factura":
 myRequest = new ajaxObject("catnav.php");
 break;
 case "newprod":
 myRequest = new ajaxObject("npcatnav.php");
 break;
}
myRequest.callback = function(responseText,readyState,status)
{
if(readyState == 4)
  {
  //status 200 arata ca cererea a fost rezolvata cu succes
    if(status == 200)
	{
	//extragen rezultatul
	raspuns = responseText;
	var vizcos = document.getElementById('prodnav');
vizcos.style.display = 'block';
vizcos.innerHTML = raspuns;

	//modificam div-ul rezultat cu rezultatul
	}
	//daca statusul este diferit avem o problema
	else
	  {
	  alert("Problema la accesare:");
	  }
  }
}
myRequest.update("cid=" + catid + "&pid=" + prodid + "&index=" + index + "&ptip=" + ptip);
selprd.length = 0;
}
var email = 1;
function emailver()
{
if(email){
var cemail = document.getElementById('cemail').value;
myRequest = new ajaxObject("http://www.targuldemobila.ro/emailver.php");
myRequest.callback = function(responseText,readyState,status)
{
if(readyState == 4)
  {
  //status 200 arata ca cererea a fost rezolvata cu succes
    if(status == 200)
	{
	//extragen rezultatul
	raspuns = responseText;
	var vizcos = document.getElementById('loghelp');
	switch (raspuns)
	{
	case '0':
    break;
    case '1':	
	vizcos.style.display = 'block';
    vizcos.innerHTML = '<p style="color: red"><b>Adresa email incorecta !</b></p>';
	break;
	default:
	vizcos.style.display = 'block';
    vizcos.innerHTML = raspuns;
	}
	//modificam div-ul rezultat cu rezultatul
	}
	//daca statusul este diferit avem o problema
	else
	  {
	  alert("Problema la accesare:");

	  }
  }

}
myRequest.update("cemail=" + cemail);
}
}
function passver()
{
var logp = document.getElementById('logp').value;
var cemail = document.getElementById('cemail').value;
var vizcos = document.getElementById('loghelp');
//preloader
vizcos.style.display = 'block';
vizcos.innerHTML ='<center><img src="http://www.targuldemobila.ro/imagini/ajax-loader.gif" alt="se incarca.." /></center>';
myRequest = new ajaxObject("http://www.targuldemobila.ro/passver.php");
myRequest.callback = function(responseText,readyState,status,responseXML)
{
if(readyState == 4)
  {
  //status 200 arata ca cererea a fost rezolvata cu succes
    if(status == 200)
	{	
	//extragen rezultatul
	raspuns = responseXML;   
    //procesare xml
	var aut_succes = raspuns.getElementsByTagName('aut_succes').item(0);
	if(aut_succes.firstChild.data == "1")
	{
	vizcos.style.display = 'none';
	document.getElementById('caddr').value = '0';
	var adrese = raspuns.getElementsByTagName('adrese').item(0);
	var prenume = raspuns.getElementsByTagName('prenume').item(0);
	var nume = raspuns.getElementsByTagName('nume').item(0);
	var telefon = raspuns.getElementsByTagName('telefon').item(0);
	var strada = raspuns.getElementsByTagName('strada').item(0);
	var numar = raspuns.getElementsByTagName('numar').item(0);
	var bloc = raspuns.getElementsByTagName('bloc').item(0);
	var scara = raspuns.getElementsByTagName('scara').item(0);
	var apartament = raspuns.getElementsByTagName('apartament').item(0);
    var localitate = raspuns.getElementsByTagName('localitate').item(0);
	var codp = raspuns.getElementsByTagName('codp').item(0);
	var judet = raspuns.getElementsByTagName('judet').item(0);
	var statut = raspuns.getElementsByTagName('statut').item(0);
	var numef = raspuns.getElementsByTagName('numef').item(0);
	var codf = raspuns.getElementsByTagName('codf').item(0);
	var regcom = raspuns.getElementsByTagName('regcom').item(0);
	var iban = raspuns.getElementsByTagName('iban').item(0);
	var banca = raspuns.getElementsByTagName('banca').item(0);	
	//Afisare adrese introduse(Adresa1, Adresa2,...)
	var a = adrese.firstChild.data;
	var ladrese = "";
	for(i=0;i<a;i++)
	{
	ladrese +=" <b onclick='seladr(\""+i+"\")' style='cursor: pointer;cursor: hand' >Adresa"+(i + 1)+"</b>";
	}
	document.getElementById('adrlist').innerHTML = "Adrese livrare: " + ladrese;
	document.getElementById('adrcr').innerHTML = "Adresa 1";
	document.getElementById('nadd').style.display = "block";
	if(nume.firstChild){
	document.getElementById('cnume').value = nume.firstChild.data; 
	}else{
	document.getElementById('cnume').value = "";	
	}
	if(prenume.firstChild){
	document.getElementById('cprenume').value = prenume.firstChild.data;
	}else{
	document.getElementById('cprenume').value = "";
	}
	if(telefon.firstChild){
    document.getElementById('ctel').value = telefon.firstChild.data;	
	}else{
	document.getElementById('ctel').value = "";
	}
	if(strada.firstChild){
    document.getElementById('cstrada').value = strada.firstChild.data; 
	}else{
	document.getElementById('cstrada').value = "";
	}	
	if(numar.firstChild){
    document.getElementById('cnumar').value = numar.firstChild.data;
	}else{
	document.getElementById('cnumar').value = "";
	}
	if(bloc.firstChild){
    document.getElementById('cbloc').value = bloc.firstChild.data;
	}else{
	document.getElementById('cbloc').value = "";
	}
	if(scara.firstChild){
    document.getElementById('cscara').value = scara.firstChild.data; 
	}else{
	document.getElementById('cscara').value = "";
	}
	if(apartament.firstChild){
    document.getElementById('capartament').value = apartament.firstChild.data;  
    }else{
    document.getElementById('capartament').value = "";
    }
    if(localitate.firstChild){	
    document.getElementById('clocalitate').value = localitate.firstChild.data;
	}else{
	document.getElementById('clocalitate').value = "";
	}
	if(codp.firstChild){
    document.getElementById('ccodp').value = codp.firstChild.data; 
    }else{
    document.getElementById('ccodp').value = "";
    }	
	if(judet.firstChild){
    document.getElementById('cjudet').value = judet.firstChild.data; 
    }else{
    document.getElementById('cjudet').value = "";
    }	
    //Afisare in functie de statut	
 	if(statut.firstChild.data == "fizic")
	{
	document.getElementById('sfizic').checked = true;
	changefstatus(1);
	}else if(statut.firstChild.data == "juridic"){
	document.getElementById('sjuridic').checked = true;
	changefstatus(0);
	}
	if(numef.firstChild){
	document.getElementById('firma').value = numef.firstChild.data;	
	}else{
	document.getElementById('firma').value = ""
	}
	if(codf.firstChild){
	document.getElementById('ccfisc').value = codf.firstChild.data;
	}else{
	document.getElementById('ccfisc').value = "";
	}
	if(regcom.firstChild){
	document.getElementById('regcom').value = regcom.firstChild.data;
	}else{
	document.getElementById('regcom').value = "";
	}
	if(iban.firstChild){
	document.getElementById('ciban').value = iban.firstChild.data;
    }else{
    document.getElementById('ciban').value = "";
    }
    if(banca.firstChild){	
	document.getElementById('banca').value = banca.firstChild.data;	
	}else{
	document.getElementById('banca').value = "";
	}
    }else{
    vizcos.innerHTML = '<p>Parola introdusa nu este corecta !</p><form id="logform" action="#" method="get" accept-charset="utf8_general_ci" onsubmit="return false"><b>Introduceti parola:</b> <input type="text" name="logp" id="logp" value="" /> <button onclick="passver()">Autentificare</button></form><br/><br/><p>Daca nu mai retineti parola sau doriti sa o schimbati</p><form id="rlogform" action="#" method="get" accept-charset="utf8_general_ci" onsubmit="return false"><b>Introduceti noua parola:</b> <input type="text" name="rlogp" id="rlogp" value="" /> <button onclick="passmodif()">Modifica</button></form>';
    }		
	//end procesare	
	email = 0;
	}
	//daca statusul este diferit avem o problema
	else
	  {
	  alert("Problema la accesare:");

	  }
  }

}
myRequest.update("logp=" + logp + "&cemail=" + cemail);
}
function passmodif()
{
var rlogp = document.getElementById('rlogp').value;
var cemail = document.getElementById('cemail').value;
var vizcos = document.getElementById('loghelp');
//preloader
vizcos.style.display = 'block';
vizcos.innerHTML ='<center><img src="http://www.targuldemobila.ro/imagini/ajax-loader.gif" alt="se incarca.." /></center>';
myRequest = new ajaxObject("http://www.targuldemobila.ro/passmodif.php");
myRequest.callback = function(responseText,readyState,status)
{
if(readyState == 4)
  {
  //status 200 arata ca cererea a fost rezolvata cu succes
    if(status == 200)
	{
	//end procesare	
	//modificam div-ul rezultat cu rezultatul
	raspuns = responseText;
	vizcos.innerHTML = raspuns;
	}	
	//daca statusul este diferit avem o problema
	else
	  {
	  alert("Problema la accesare:");

	  }
	}	
}
myRequest.update("rlogp=" + rlogp + "&cemail=" + cemail);
}


//navigare  prin adrese de livrare
function seladr(idadr)
{
var caddr = document.getElementById('caddr');
var vizcos = document.getElementById('adrcr');
//preloader
vizcos.innerHTML ='<center><img src="http://www.targuldemobila.ro/imagini/ajax-loader.gif" alt="se incarca.." /></center>';
document.getElementById('newadd').checked = false;
myRequest = new ajaxObject("http://www.targuldemobila.ro/seladr.php");
myRequest.callback = function(responseText,readyState,status,responseXML)
{
if(readyState == 4)
  {
  //status 200 arata ca cererea a fost rezolvata cu succes
    if(status == 200)
	{
	//extragen rezultatul
	raspuns = responseXML;   
    //procesare xml
	var adr_curenta = raspuns.getElementsByTagName('adr_curenta').item(0);
	var strada = raspuns.getElementsByTagName('strada').item(0);
	var numar = raspuns.getElementsByTagName('numar').item(0);
	var bloc = raspuns.getElementsByTagName('bloc').item(0);
	var scara = raspuns.getElementsByTagName('scara').item(0);
	var apartament = raspuns.getElementsByTagName('apartament').item(0);
    var localitate = raspuns.getElementsByTagName('localitate').item(0);
	var codp = raspuns.getElementsByTagName('codp').item(0);
	var judet = raspuns.getElementsByTagName('judet').item(0);
	var statut = raspuns.getElementsByTagName('statut').item(0);
	var cnp = raspuns.getElementsByTagName('cnp').item(0);
	var numef = raspuns.getElementsByTagName('numef').item(0);
	var codf = raspuns.getElementsByTagName('codf').item(0);
	var regcom = raspuns.getElementsByTagName('regcom').item(0);
	var iban = raspuns.getElementsByTagName('iban').item(0);
	var banca = raspuns.getElementsByTagName('banca').item(0);
	var crid = adr_curenta.firstChild.data;
	if(!isNaN(crid))
	{
	var vizcos = document.getElementById('adrcr');
    if(crid >= 0){
	var adnr = 1+crid*1;
	vizcos.innerHTML ='Adresa ' + adnr;
	caddr.value = crid;
	}
	} 
	if(strada.firstChild){
    document.getElementById('cstrada').value = strada.firstChild.data; 
	}else{
	document.getElementById('cstrada').value = "";
	}
	if(numar.firstChild){
    document.getElementById('cnumar').value = numar.firstChild.data;
	}else{
	document.getElementById('cnumar').value = "";
	}
	if(bloc.firstChild){
    document.getElementById('cbloc').value = bloc.firstChild.data; 
	}else{
	document.getElementById('cbloc').value = ""; 
	}
	if(scara.firstChild){
    document.getElementById('cscara').value = scara.firstChild.data;
	}else{
	document.getElementById('cscara').value = "";
	}
	if(apartament.firstChild){
    document.getElementById('capartament').value = apartament.firstChild.data;
	}else{
	document.getElementById('capartament').value = "";
	}
 	if(localitate.firstChild){
    document.getElementById('clocalitate').value = localitate.firstChild.data;
	}else{
	document.getElementById('clocalitate').value = "";
	}
	if(codp.firstChild){
    document.getElementById('ccodp').value = codp.firstChild.data; 
	}else{
	document.getElementById('ccodp').value = "";
	}
	if(judet.firstChild){
    document.getElementById('cjudet').value = judet.firstChild.data;  
	}else{
	document.getElementById('cjudet').value = "";
	}
    //Afisare in functie de statut	
 	if(statut.firstChild.data == "fizic")
	{
	document.getElementById('sfizic').checked = true;
	changefstatus(1);
	}else if(statut.firstChild.data == "juridic"){
	document.getElementById('sjuridic').checked = true;
	changefstatus(0);
	}
	if(cnp.firstChild){
	document.getElementById('ccnp').value = cnp.firstChild.data;	
	}else{
	document.getElementById('ccnp').value = "";
	}
	if(numef.firstChild){
	document.getElementById('firma').value = numef.firstChild.data;	
	}else{
	document.getElementById('firma').value = "";
	}
	if(codf.firstChild){
	document.getElementById('ccfisc').value = codf.firstChild.data;
	}else{
	document.getElementById('ccfisc').value = "";
	}
	if(regcom.firstChild){
	document.getElementById('regcom').value = regcom.firstChild.data;
	}else{
	document.getElementById('regcom').value = "";
	}
	if(iban.firstChild){
	document.getElementById('ciban').value = iban.firstChild.data;
	}else{
	document.getElementById('ciban').value = "";
	}
	if(banca.firstChild){
	document.getElementById('banca').value = banca.firstChild.data; 
  	}else{
	document.getElementById('banca').value = "";
	}
	//end procesare	
	email = 0;
	}
	//daca statusul este diferit avem o problema
	else
	  {
	  alert("Problema la accesare:");

	  }
  }

}
myRequest.update("idadr=" + idadr);
}
function newadress()
{
var vizcos = document.getElementById('adrcr');
var caddr = document.getElementById('caddr');
vizcos.innerHTML ='Adresa noua';	
caddr.value = -1;
    document.getElementById('cstrada').value = ""; 
    document.getElementById('cnumar').value = "";
    document.getElementById('cbloc').value = ""; 
    document.getElementById('cscara').value = "";
    document.getElementById('capartament').value = "";  	
    document.getElementById('clocalitate').value = "";
    document.getElementById('ccodp').value = "";  
    document.getElementById('cjudet').value = ""; 
    document.getElementById('ccnp').value = "";
	document.getElementById('firma').value = "";	
	document.getElementById('ccfisc').value = "";
	document.getElementById('regcom').value = "";
	document.getElementById('ciban').value = "";	
	document.getElementById('banca').value = "";  	
document.getElementById('sfizic').checked = true;
changefstatus(1);
}
//de mutat
//Completare date client in factura noua
function femailver(idadr)
{
var caddr = document.getElementById('caddr');
var vizcos = document.getElementById('adrcr');
var cemail = document.getElementById('cemail').value;
var ctel = document.getElementById('ctel').value;
var etsrc = document.getElementById('etsrc');
//preloader
etsrc.src = "http://www.targuldemobila.ro/imagini/ajax-loader.gif";
myRequest = new ajaxObject("femailver.php");
myRequest.callback = function(responseText,readyState,status,responseXML)
{
if(readyState == 4)
  {
 etsrc.src = "http://www.targuldemobila.ro/imagini/admpx.gif";
  //status 200 arata ca cererea a fost rezolvata cu succes
    if(status == 200)
	{
	//extragen rezultatul
	raspuns = responseXML;   
    //procesare xml
	var adr_curenta = raspuns.getElementsByTagName('adr_curenta').item(0);
	var adrese = raspuns.getElementsByTagName('adrese').item(0);
	var prenume = raspuns.getElementsByTagName('prenume').item(0);
	var nume = raspuns.getElementsByTagName('nume').item(0);
	var telefon = raspuns.getElementsByTagName('telefon').item(0);
	var strada = raspuns.getElementsByTagName('strada').item(0);
	var numar = raspuns.getElementsByTagName('numar').item(0);
	var bloc = raspuns.getElementsByTagName('bloc').item(0);
	var scara = raspuns.getElementsByTagName('scara').item(0);
	var apartament = raspuns.getElementsByTagName('apartament').item(0);
    var localitate = raspuns.getElementsByTagName('localitate').item(0);
	var codp = raspuns.getElementsByTagName('codp').item(0);
	var judet = raspuns.getElementsByTagName('judet').item(0);
	var statut = raspuns.getElementsByTagName('statut').item(0);		
	var numef = raspuns.getElementsByTagName('numef').item(0);
	var codf = raspuns.getElementsByTagName('codf').item(0);
	var regcom = raspuns.getElementsByTagName('regcom').item(0);
	var iban = raspuns.getElementsByTagName('iban').item(0);
	var banca = raspuns.getElementsByTagName('banca').item(0);	
	var crid = adr_curenta.firstChild.data;
	//Afisare adrese introduse(Adresa1, Adresa2,...)
	var a = adrese.firstChild.data;
	var ladrese = "";
	for(i=0;i<a;i++)
	{
	ladrese +=" <b onclick='femailver(\""+i+"\")' style='cursor: pointer;cursor: hand' >Adresa"+(i + 1)+"</b>";
	}
	document.getElementById('adrlist').innerHTML = "Adrese livrare: " + ladrese;
	document.getElementById('adrcr').innerHTML = "Adresa 1";
	document.getElementById('nadd').style.display = "block";
	if(!isNaN(crid))
	{
	var vizcos = document.getElementById('adrcr');
    if(crid >= 0){
	var adnr = 1+crid*1;
	vizcos.innerHTML ='Adresa ' + adnr;
	caddr.value = crid;
	}
	} 
	if(nume.firstChild){
	document.getElementById('cnume').value = nume.firstChild.data; 
	}else{
	document.getElementById('cnume').value = "";
	}
	if(prenume.firstChild){
	document.getElementById('cprenume').value = prenume.firstChild.data;
	}else{
	document.getElementById('cprenume').value = "";
	}
	if(strada.firstChild){
    document.getElementById('cstrada').value = strada.firstChild.data;
    }else{
	document.getElementById('cstrada').value = "";
	}
    if(numar.firstChild){	
    document.getElementById('cnumar').value = numar.firstChild.data; 
    }else{
	document.getElementById('cnumar').value = "";
	}
    if(localitate.firstChild){	
    document.getElementById('clocalitate').value = localitate.firstChild.data;
	}else{
	document.getElementById('clocalitate').value = "";
	}
	if(codp.firstChild){	
    document.getElementById('ccodp').value = codp.firstChild.data; 
    }else{
	document.getElementById('ccodp').value = "";
	}
	if(judet.firstChild){	
    document.getElementById('cjudet').value = judet.firstChild.data;
	}else{
	document.getElementById('cjudet').value = "";
	}
	if(telefon.firstChild){	
    document.getElementById('ctel').value = telefon.firstChild.data; 
    }else{
	document.getElementById('ctel').value = "";
	}
	if(bloc.firstChild){	
    document.getElementById('cbloc').value = bloc.firstChild.data;
    }else{
	document.getElementById('cbloc').value = "";
	}
	if(scara.firstChild){	
    document.getElementById('cscara').value = scara.firstChild.data; 
    }else{
	document.getElementById('cscara').value = "";
	}
	if(apartament.firstChild){	
    document.getElementById('capartament').value = apartament.firstChild.data;
	}else{
	document.getElementById('capartament').value = "";
	}
	if(iban.firstChild){	
	document.getElementById('ciban').value = iban.firstChild.data;
	}else{
	document.getElementById('ciban').value = "";
	}
	if(codf.firstChild){	
	document.getElementById('ccfisc').value = codf.firstChild.data;
	}else{
	document.getElementById('ccfisc').value = "";
	}
	if(numef.firstChild){	
	document.getElementById('firma').value = numef.firstChild.data;
	}else{
	document.getElementById('firma').value = "";
	}
	if(regcom.firstChild){	
	document.getElementById('regcom').value = regcom.firstChild.data;
	}else{
	document.getElementById('regcom').value = "";
	}
	if(banca.firstChild){	
	document.getElementById('cbanca').value = banca.firstChild.data;
	}else{
	document.getElementById('cbanca').value = "";
	}
	//Afisare in functie de statut	
 	if(statut.firstChild.data == "fizic")
	{
	document.getElementById('sfizic').checked = true;
	changefstatus(1);
	}else if(statut.firstChild.data == "juridic"){
	document.getElementById('sjuridic').checked = true;
	changefstatus(0);
	}  
	//end procesare	
	email = 0;
	}
	//daca statusul este diferit avem o problema
	else
	  {
	  alert("Problema la accesare:");

	  }
  }

}
myRequest.update("ctel=" + ctel + "&cemail=" + cemail + "&idadr=" + idadr);
}
//admin panou administrare 
var selprd = new Array();
var ctrl = 0;
function detectspecialkeys(e){
var evt = window.event?event:e;
if (evt.ctrlKey){
ctrl = 1;
}else{
ctrl = 0;
}
}
function resetctrl(){
ctrl = 0;
}
document.onkeydown=detectspecialkeys
document.onkeyup=resetctrl

function cpnav(idsel)
{

var n = selprd.length;
  if(ctrl == 1)
  {
  var duplicat = 0;
  //se cauta elemente duplicate
   for(i=0;i < n;i++)
    {
      if(selprd[i] == idsel)
	  { 
	  document.getElementById(idsel).src="http://www.targuldemobila.ro/imagini/icon_info.gif";
	  selprd.splice(i,1);
	  duplicat = 1;
	  }
    }
	if(!duplicat)
	{
	selprd[n] = idsel;
	document.getElementById(idsel).src="http://www.targuldemobila.ro/imagini/arrow_right.gif";
	}
	
  }else if(ctrl == 0){
  if(selprd.length)
  {
   for(i=0;i < selprd.length;i++)
    {
	  document.getElementById(selprd[i]).src="http://www.targuldemobila.ro/imagini/icon_info.gif";
    }
    selprd.splice(0,n);
   }
    selprd[0] = idsel;
    document.getElementById(idsel).src="http://www.targuldemobila.ro/imagini/arrow_right.gif";
  }
var prsl = selprd.join(";") + ";";
cpedit(prsl)
}
function cpedit(prsl)
{
var vizcos = document.getElementById('cpedit');
//preloader
vizcos.innerHTML ='<center><img src="http://www.targuldemobila.ro/imagini/ajax-loader.gif" alt="Va rog asteptati se incarca !" /></center>';
myRequest = new ajaxObject("cpedit.php");
myRequest.callback = function(responseText,readyState,status)
{
if(readyState == 4)
  {
  //status 200 arata ca cererea a fost rezolvata cu succes
    if(status == 200)
	{
	//end procesare	
	//modificam div-ul rezultat cu rezultatul
	raspuns = responseText;
	vizcos.innerHTML = raspuns;
	}	
	//daca statusul este diferit avem o problema
	else
	  {
	  alert("Problema la accesare:");

	  }
	}	
}
myRequest.update("prsl=" + prsl);
}
function dmpc(prsl, tipo)
{
var prodnav = document.getElementById('prodnav');
//preloader
prodnav.innerHTML ='<center><img src="http://www.targuldemobila.ro/imagini/ajax-loader.gif" alt="se incarca" /><center>';
if(tipo == 'move'){
var catsel = document.getElementById('cpm');
document.getElementById('cpd').style.display="none";
}
if(tipo == 'del'){
var catsel = document.getElementById('cpd');
document.getElementById('cpm').style.display="none";
}
var vprsl = document.getElementById('prsl');
myRequest = new ajaxObject("dmpc.php");
myRequest.callback = function(responseText,readyState,status)
{
if(readyState == 4)
  {
  //status 200 arata ca cererea a fost rezolvata cu succes
    if(status == 200)
	{
	//end procesare	
	//modificam div-ul rezultat cu rezultatul
	catsel.style.display = "block";
	vprsl.value = prsl;
	raspuns = responseText;
	prodnav.innerHTML = raspuns;
	}	
	//daca statusul este diferit avem o problema
	else
	  {
	  alert("Problema la accesare:");

	  }
	}	
}
myRequest.update("prsl=" + prsl + "&tipo=" + tipo);
}
function formcatSubmit(tipo)
{
var pcmove = document.getElementById('prodmove').value;
if(tipo == 'move')
var catsel = document.getElementById('cpm');
if(tipo == 'del')
{
var catsel = document.getElementById('cpd');
}
var vprsl = document.getElementById('prsl').value;
var prodnav = document.getElementById('prodnav');
//preloader
prodnav.innerHTML ='<center><img src="http://www.targuldemobila.ro/imagini/ajax-loader.gif" alt="se incarca" /></center>';
myRequest = new ajaxObject("dmpcex.php");
myRequest.callback = function(responseText,readyState,status)
{
if(readyState == 4)
  {
  //status 200 arata ca cererea a fost rezolvata cu succes
    if(status == 200)
	{
	//end procesare	
	//modificam div-ul rezultat cu rezultatul
	catsel.style.display = "none";
	raspuns = responseText;
	prodnav.innerHTML = raspuns;
	}	
	//daca statusul este diferit avem o problema
	else
	  {
	  alert("Problema la accesare:");

	  }
	}	
}
myRequest.update("prsl=" + vprsl + "&pcmove=" + pcmove + "&tipo=" + tipo);

}
//END AJAX

function formcmdSubmit()
{
document.getElementById("comanda").submit();
}
function cchange(i, j)
{
if(j>0)
{
document.getElementById('ccant'+i).focus();
document.getElementById('ccant'+i).value++;
cantcosmodif(i);
document.getElementById('ccant'+i).blur();
}else{
document.getElementById('ccant'+i).focus();
document.getElementById('ccant'+i).value--;
cantcosmodif(i);
document.getElementById('ccant'+i).blur();
}
}

function cantminus(i, j)
{
if(j>0)
{
document.getElementById('fcant'+i).focus();
document.getElementById('fcant'+i).value++;
fcosmodif(i);
document.getElementById('fcant'+i).blur();
}else{
document.getElementById('fcant'+i).focus();
document.getElementById('fcant'+i).value--;
fcosmodif(i);
document.getElementById('fcant'+i).blur();
}
}

function catbg(i, j) {
switch (j)
{
case '0':
document.getElementById("ct" + i).style.backgroundColor='#F4F4E8';
break;
case '1':
document.getElementById("ct" + i).style.backgroundColor='#FBFBF7';
break;
}
}

function catbgda(i) {
document.getElementById(i).style.backgroundColor='#F4F4E8';
}

function catbgdb(i) {
document.getElementById(i).style.backgroundColor='#FBFBF7';
}

function bimgWin(i, w, h)
{	
 //myWin= open("bigimg.php?bigsrc=big_images/" + i, "displayWindow", "status=no,toolbar=no,menubar=no,left=200,top=250"); 
 if(w)
 {
 var Detprod = document.getElementById("detaliu");
 var Detimg = document.getElementById("bishow");
 Detprod.style.display= "block";
 Detimg.innerHTML="<img src='http://www.targuldemobila.ro/" + i +"' alt='Detaliu produs se incarca ->' title='Detaliu produs' />";
 Detshadow = document.getElementById("detshadow");
 Detshadow.style.width= w + "px";
 Detshadow.style.height= h + "px";
 Detshadow.style.display= "block";
 }else{
 alert("Imagine Indisponibila !");
 }
}	

function bbimgWin(i)
{	
 myWin= open("bigimg.php?bigsrc=" + i, "displayWindow", "status=no,toolbar=no,menubar=no,left=200,top=250");
}

function hidedet(detaliu)
{
 document.getElementById("detshadow").style.display = "none";
 document.getElementById(detaliu).style.display = "none";
}	

function msEdit(ascund)
{
document.getElementById(ascund).style.display= "block";	
}

function canceledit(ascund)
{
document.getElementById(ascund).style.display= "none";	
}		

function msRaspuns(i)
{
var mesaj;
mesaj = "mspr"+i;
document.getElementById(mesaj).style.display= "table-cell";
}

function cancelRaspuns(i)
{
var mesaj;
mesaj = "mspr"+i;	
document.getElementById(mesaj).style.display= "none";
}

/*
function adresa(){
var referinta = document.referrer
window.document.form.refer.value = referinta;
window.document.form.submit();

}
*/

function formdenySubmit()
{
alert('Nu puteti raspunde propriului mesaj!');	
}

function formdenybSubmit()
{
alert('Nu puteti introduce mesje la propriul anunt, doar raspunsuri!');	
}

function formdenySubmit()
{
alert('Pentru a putea edita mesaje trebuie sa fii inregistrat!');	
}

function formfacturaSubmit()
{
document.getElementById("factura").submit();	
}	

function formmseditSubmit()
{
document.getElementById("msedit").submit();	
}

function bestsellSubmit()
{
document.getElementById("bsell").submit();	
}

function formprmspSubmit(i)	
{
var nume;
nume = "mpraspuns"+i;
document.getElementById(nume).submit();
}

function formcmdSubmit()
{
document.getElementById("comanda").submit();
}
function formadmSubmit()
{
document.getElementById("admenter").submit();
}

function formadmrnSubmit()
{
document.getElementById("admrenew").submit();
}

function formprodSubmit()
{
document.getElementById("prodadd").submit();
}

function mobil_validation(tel){
		if (!tel.toString().match(/^(072|073|074|075|078|076|077|079|021|023|024|025|031|033|034|035)[0-9]{7}$/)) {
		alert("Numarul de telefon furnizat este incorect!");
		return false;
	}
	else {
		return true;
	}
}

function newaccSubmit()
{
var send;
var acnicname;
var acpass;
var acpassc;
var acemail;
var actel;
var acconditii;
var spam;
send = 1;
acnicname = document.getElementById("acnicname").value;
acpass = document.getElementById("acpass").value;
acpassc = document.getElementById("acpassc").value;
acemail = document.getElementById("acemail").value;
actel = document.getElementById("actelefon").value;
spam = document.getElementById("spam").value;
acconditii = document.getElementById("acconditii").value;
if(!acnicname){
alert("Introduceti numele de utilizator !");
send = 0; 
}
if((!acpass) || (acpass.length < 4)){
alert("Introduceti o parola din minim 4 caractere!");
send = 0; 
return false;
}

if(!acpassc){
alert("Reintroduceti parola");
send = 0; 
return false;
}

if(!acemail){
alert("Introduceti adresa email !");
send = 0; 
return false;
}

if(!mobil_validation(actel)){
send = 0; 
return false;
}

if(acpass != acpassc){
alert("Parola introdusa in campul de confirmare este diferita!");
send = 0; 
return false;
}

if(!spam){
alert("Introduceti codul anti-spam !");
send = 0; 
return false;
}

if(!acconditii){
alert("Trebuie sa fiti de acord cu conditiile de utilizare pentru a putea continua inregistrarrea !");
send = 0; 
return false;
}
document.getElementById("newacc").submit();
}

function bazarSubmit()
{
var send;
var tipanunt;
var titlu;
var pret;
var moneda;
var localitate;
var spam;
send = 1;
tipanunt = document.getElementById("btipanunt").value;
titlu = document.getElementById("btitlu").value;
pret = document.getElementById("bpret").value;
moneda = document.getElementById("bmoneda").value;
localitate = document.getElementById("blocalitate").value;
spam = document.getElementById("spam").value;
document.getElementById("bazar").submit();
}

function bzeditSubmit()
{
document.getElementById("bzedit").submit();
}

function casaSubmit()
{
var send;
var tipanunt;
var titlu;
var pret;
var moneda;
var localitate;
var spam;
send = 1;
titlu = document.getElementById("ctitlu").value;
pret = document.getElementById("pretp").value;
moneda = document.getElementById("moneda").value;
localitate = document.getElementById("clocalitate").value;
spam = document.getElementById("spam").value;
document.getElementById("casa").submit();
}

function hidecos()
{
document.getElementById("cos").style.visibility = 'hidden';
}

function showcos()
{
document.getElementById("cos").style.visibility = 'visible';
}
var posx = 0;
var posy = 0;
document.onmousemove = getMousePos;

function getMousePos(e)
{
// get mouse cursor XY
if (document.all) {
    posx = event.clientX + document.documentElement.scrollLeft;
    posy = event.clientY + document.documentElement.scrollTop;
  } else {
    posx = e.pageX;
    posy = e.pageY;
  }
  if (posx < 0){posx = 0}
  if (posy < 0){posy = 0}

	// alert(posy); 

}

function ShowPreview2(divid, prodsrc, prodname, pwidth, pheight) {
var PreviewPanel = document.getElementById(divid);
PreviewPanel.innerHTML = '<img src="http://www.targuldemobila.ro/preview_images/'+prodsrc+'" border="0" align="top" alt="'+prodname+' se incarca ..." style="display: block; width: '+pwidth+'px; height: '+pheight+'px; overflow: visible" />';
PreviewPanel.style.visibility = 'visible';
PreviewPanel.style.left = posx+20+"px";
PreviewPanel.style.top = posy + "px";  	      
}

function HidePreview(divid) {
var PreviewPanel = document.getElementById(divid);
PreviewPanel.innerHTML = ' ';
PreviewPanel.style.visibility = 'hidden';
}





function MovePreview(divid)
{
var PreviewPanel = document.getElementById(divid);
PreviewPanel.style.left = (20 + posx) + "px";
PreviewPanel.style.top = posy + "px";
}


function trim(stringToTrim) {
return stringToTrim.replace(/^\s+|\s+$/g,"");
}

function judsec()
{
var comandloc = document.getElementById("clocalitate").value;
var smolloc = trim(comandloc).toLowerCase();
if((smolloc == "bucuresti") || (smolloc == "bucure�ti") || (smolloc == "buc"))
{
document.getElementById("cmdsec").style.display = "block";
document.getElementById("cmdjud").style.display = "none";
}
}

function acolor(i)
{
var csdet = "casa"+i;
document.getElementById(csdet).style.color = "#bf4d00";
}

function bcolor(i)
{
var csdet = "casa"+i;
document.getElementById(csdet).style.color = "#494927";
}

function insert_anunt()
{
var anunt = document.getElementById('tiplic').value;
switch (anunt)
{

case 'bazar':
document.getElementById('pretf').style.display = "block";
document.getElementById('pretp').style.display = "none";
document.getElementById('pretb').style.display = "none";
document.getElementById('pretr').style.display = "none";
break;
case 'standard':
document.getElementById('pretf').style.display = "none";
document.getElementById('pretp').style.display = "block";
document.getElementById('pretb').style.display = "block";
document.getElementById('pretr').style.display = "block";
break;
case 'olandeza':
document.getElementById('pretf').style.display = "none";
document.getElementById('pretp').style.display = "block";
document.getElementById('pretb').style.display = "none";
document.getElementById('pretr').style.display = "block";
break;
}
}

function uformsubmit(i)
{
document.getElementById(i).submit();
}

function avertisment(i, detid)
{
var fmdelete = document.getElementById("antdel");
if(i)
{
var where_to= confirm("Exista licitatii pentru acest anunt, stergerea lui va aduce penalizari!");
if (where_to== true)
 {

document.getElementById("antdel").submit();
 }
else
 {
 }
}else{
var where_to= confirm("Sunteti sigur ca doriti stergerea anuntului?");


if (where_to== true)


 {


 document.getElementById("antdel").submit();


 }


else


 {


  


  }


}  


}


function changefstatus(fstatus)


{


if(fstatus){


document.getElementById("ffacturare").style.display="block";


document.getElementById("pfacturare").style.display="none";


}else{


document.getElementById("ffacturare").style.display="none";


document.getElementById("pfacturare").style.display="block";


}


}


function PDFopen(i)


{	





myWin = open("pdfopen.php?pdfsrc=" + i, "display Window", "width= 100%, height= 100%, status= no, toolbar= no, menubar= no, left= 200, top= 250");			





}





function hidelastprv(i)


{


if(i)


{


document.getElementById("lastprv").style.display = "none";


v = 0;


}else{


if(!v) 


   {


   document.getElementById("lastprv").style.display = "none";


   }


}


}


function ccntmdf(pid)
{
document.getElementById(pid).blur();
}


function trmdf(pidm)


{


if (document.all) {


document.getElementById(pidm).style.display="inline";


}else{


document.getElementById(pidm).style.display="table-row";


}


}





//inserare produs


function accesviz(i)
{
if(i > 0)
{
document.getElementById("accesoriu").style.display= "block";
switch (i)
{
case 1:
document.getElementById("tipa").style.display= "block";
document.getElementById("tips").style.display= "none";
break;
case 2:
document.getElementById("tips").style.display= "block";
document.getElementById("tipa").style.display= "none";
break;
}
}else{
document.getElementById("accesoriu").style.display= "none";
document.getElementById("tipa").style.display= "none";
document.getElementById("tips").style.display= "none";
}
}

function open_url(url, opt){
  if (opt == 0) // current window
    window.location = url;
  else if (opt == 1) // new window
    window.open(url);
  else if (opt == 2) // background window
    {window.open(url); self.focus();}
}
//Discount Grid
function discgrid(mod,d,c)
{
var discgval = document.getElementById('discgval');
var discgrid = document.getElementById('discgrid').value;
var param = null;
var dgd = document.getElementById('dgd');
var dgc = document.getElementById('dgc');
switch(mod)
{
    case '0':
//stergere
param = "&mod=0&dgd="+d+"&dgc="+c;
    break;
    case '1':
 //adaugare
 d = dgd.value;
 c = dgc.value;
 param = "&mod=1&dgd="+d+"&dgc="+c;
    break;
}
myRequest = new ajaxObject("http://www.targuldemobila.ro/discgrid.php");
myRequest.callback = function(responseText,readyState,status)
{
if(readyState == 4)
  {
  //status 200 arata ca cererea a fost rezolvata cu succes
    if(status == 200)
	{
	//extragen rezultatul
	raspuns = responseText;
	var dgg = document.getElementById('dgg');
    dgg.innerHTML = raspuns;
    discgval.value = document.getElementById('discgrid').value;
	//modificam div-ul rezultat cu rezultatul
    dgd.value = "";
    dgc.value = "";
	}
	//daca statusul este diferit avem o problema
	else
	  {
	  alert("Problema la accesare:");

	  }
  }

}
myRequest.update("discgrid="+ discgrid + param);
}