// JavaScript Document
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_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_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];}
}

function numeralsOnly(evt)
{
	evt = (evt) ? evt : event;
	var charCode = (evt.charCode) ? evt.charCode : ((evt.keyCode) ? evt.keyCode : ((evt.which) ? evt.which : 0));
	if(charCode > 31 && (charCode < 48 || charCode > 57)){
		alert("Eroare: Trebuie sa introduceti doar cifre!");
		return false;
	}
	return true;
}

function MM_validateForm() { //v4.0
  if (document.getElementById){
    var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
    for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=document.getElementById(args[i]);
      if (val) { nm=val.name; if(nm=='utilizator') nm='nume utilizator'; if(nm=='parola1') nm='parola'; if(nm=='parola2') nm='reintroducerea parolei'; if(nm=='email1') nm='adresa de e-mail'; if(nm=='email2') nm='reintroducerea adresei de e-mail'; if(nm=='cod') nm='cod postal'; if(nm=='mail') nm='adresa de e-mail'; if(nm=='nume_amway') nm='ID-ul AMWAY'; if(nm=='denfirm') nm='denumirea firmei'; if(nm=='codfisc') nm='codul fiscal'; if(nm=='regcom') nm='numarul registrul comertului'; if(nm=='contbanc') nm='contul bancar'; if(nm=='capsoc') nm='capitalul social'; if(nm=='pozfirm') nm='pozitia in cadrul firmei'; if(nm=='numeb') nm='nume beneficiar'; if(nm=='prenumeb') nm='prenume beneficiar'; if(nm=='judetb') nm='judet beneficiar'; if(nm=='orasb') nm='oras beneficiar'; if(nm=='adresab') nm='adresa beneficiar'; if(nm=='codb') nm='cod postal beneficiar'; if(nm=='mailb') nm='adresa de e-mail beneficiar'; if(nm=='telefonb') nm='telefon beneficiar'; if(nm=='numee') nm='nume expeditie'; if(nm=='prenumee') nm='prenume expeditie'; if(nm=='judete') nm='judet expeditie'; if(nm=='orase') nm='oras expeditie'; if(nm=='adresae') nm='adresa expeditie'; if(nm=='code') nm='cod postal expeditie'; if(nm=='maile') nm='adresa de e-mail expeditie'; if(nm=='telefone') nm='telefon expeditie'; if(nm=='numep') nm='numele prietenului'; if(nm=='prenumep') nm='prenumele prietenului'; if(nm=='tsem') nm='telefonul sau e-mail-ul'; if ((val=val.value)!="") {
        if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
          if (p<1 || p==(val.length-1)) errors+='- '+nm+' nu este valida.\n';
        } else if (test!='R') { num = parseFloat(val);
          if (isNaN(val)) errors+='- '+nm+' trebuie sa fie numeric.\n';
          if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
            min=test.substring(8,p); max=test.substring(p+1);
            if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
      } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' este obligatoriu de completat.\n'; }
    } if (errors) alert('Aveti urmatoarele erori:\n'+errors);
    document.MM_returnValue = (errors == '');
} }

function verificare(){
	var pass1 = document.crearecont.parola1.value;
	var pass2 = document.crearecont.parola2.value;
	var mail1 = document.crearecont.email1.value;
	var mail2 = document.crearecont.email2.value;
	if(pass1!=pass2) {
		alert('Cele doua campuri pentru parola nu coincid!');
		return false;
	}
	if(mail1!=mail2) {
		alert('Cele doua campuri pentru adresa de e-mail nu coincid!');
		return false;
	}
	if(document.crearecont.judet.value=="nimic"){
		alert('EROARE! Va rugam selectati judetul');
		return false;
	}
	if(document.crarecont.cnp.value.length<13||document.crearecont.cnp.value.charAt(0)<1||document.crearecont.cnp.value.charAt(0)>2){
		alert('EROARE! CNP invalid');
		return false;
	}
	return true;
}


function verificarej(){
	var pass1 = document.crearecont.parola1.value;
	var pass2 = document.crearecont.parola2.value;
	var mail1 = document.crearecont.email1.value;
	var mail2 = document.crearecont.email2.value;
	if(pass1!=pass2) {
		alert('Cele doua campuri pentru parola nu coincid!');
		return false;
	}
	if(mail1!=mail2) {
		alert('Cele doua campuri pentru adresa de e-mail nu coincid!');
		return false;
	}
	if(document.crearecont.judet.value=="nimic"){
		alert('EROARE! Va rugam selectati judetul');
		return false;
	}
	return true;
}

var flag=0;

function docheck()
{
		MM_validateForm('numeb','','R','prenumeb','','R','cnp','','RisNum','orasb','','R','adresab','','R','codb','','RisNum','telefonb','','R','mailb','','RisEmail','numee','','R','prenumee','','R','orase','','R','adresae','','R','code','','RisNum');
}

function orasver(){
	if(document.frmForm.orase.value=="nimic"){
		alert('EROARE! Va rugam selectati orasul pentru expediere!\n Expedierea se face doar in anumite orase din tara!');
		return false;
	}
	if(document.frmForm.judetb.value=="nimic"){
		alert('EROARE! Va rugam selectati judetul de la datele de beneficiar!');
		return false;
	}
	if(document.frmForm.judete.value=="nimic"){
		alert('EROARE! Va rugam selectati judetul pentru expediere');
		return false;
	}
	if(document.frmForm.plata.value<3){
		document.frmForm.action="trimite_comanda.php";	
	}
	else{
		document.getElementById('BILL_LNAME').value=document.getElementById('numeb').value;
		document.getElementById('BILL_FNAME').value=document.getElementById('prenumeb').value;
		document.getElementById('BILL_CNP').value=document.getElementById('cnp').value;
		document.getElementById('BILL_CITY').value=document.getElementById('orasb').value;
		document.getElementById('BILL_STATE').value=document.getElementById('judetb').value;
		document.getElementById('BILL_ADDRESS').value=document.getElementById('adresab').value;
		document.getElementById('BILL_ZIPCODE').value=document.getElementById('codb').value;
		document.getElementById('BILL_PHONE').value=document.getElementById('telefonb').value;
		document.getElementById('BILL_EMAIL').value=document.getElementById('mailb').value;
		document.getElementById('DELIVERY_LNAME').value=document.getElementById('numee').value;
		document.getElementById('DELIVERY_FNAME').value=document.getElementById('prenumee').value;
		document.getElementById('DELIVERY_ADDRESS').value=document.getElementById('adresae').value;
		document.getElementById('DELIVERY_ZIPCODE').value=document.getElementById('code').value;
		document.frmForm.action="https://secure.epayment.ro/order/lu.php";
	}
	return true;
}

function dodisable()
{
	if(flag==0){
		document.frmForm.numee.value=document.frmForm.numeb.value;
		document.frmForm.prenumee.value=document.frmForm.prenumeb.value;
		document.frmForm.adresae.value=document.frmForm.adresab.value;
		document.frmForm.code.value=document.frmForm.codb.value;
		flag=1;
	}
	else if(flag==1){
		flag=0;
	}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function MM_jumpMenu(targ,selObj){ //v3.0
	var plata=document.getElementById('plata').value;
	var exped=document.getElementById('expediere').value;
	var prenumeben=document.getElementById('prenumeb').value;
	var numeben=document.getElementById('numeb').value;
	var cnp=document.getElementById('cnp').value;
	var orasben=document.getElementById('orasb').value;
	var judetben=document.getElementById('judetb').value;
	var adresaben=document.getElementById('adresab').value;
	var codben=document.getElementById('codb').value;
	var telben=document.getElementById('telefonb').value;
	var emailben=document.getElementById('mailb').value;
	var prenumeexp=document.getElementById('prenumee').value;
	var numeexp=document.getElementById('numee').value;
	var judetexp=document.getElementById('judete').value;
	var adresaexp=document.getElementById('adresae').value;
	var codexp=document.getElementById('code').value;
  	eval(targ+".location='finalizare_comanda.php?pl="+plata+"&exped="+exped+"&oe="+selObj.options[selObj.selectedIndex].value+"&pb="+prenumeben+"&nb="+numeben+"&cnp="+cnp+"&ob="+orasben+"&jb="+judetben+"&ab="+adresaben+"&cb="+codben+"&tb="+telben+"&eb="+emailben+"&pe="+prenumeexp+"&ne="+numeexp+"&je="+judetexp+"&ae="+adresaexp+"&ce="+codexp+"'");
  //	if (restore) selObj.selectedIndex=0;
}

function MM_jumpMenu_m(targ,selObj){ //v3.0
	var plata=document.getElementById('plata').value;
	var prenumeexp=document.getElementById('prenumee').value;
	var numeexp=document.getElementById('numee').value;
	var judetexp=document.getElementById('judete').value;
	var adresaexp=document.getElementById('adresae').value;
	var codexp=document.getElementById('code').value;
  	eval(targ+".location='finalizare_comanda.php?pl="+plata+"&oe="+selObj.options[selObj.selectedIndex].value+"&pe="+prenumeexp+"&ne="+numeexp+"&je="+judetexp+"&ae="+adresaexp+"&ce="+codexp+"'");
  //	if (restore) selObj.selectedIndex=0;
}

function MM_jumpMenu_m_jur(targ,selObj){ //v3.0
	var plata=document.getElementById('plata').value;
	var numeexp=document.getElementById('numee').value;
	var judetexp=document.getElementById('judete').value;
	var adresaexp=document.getElementById('adresae').value;
	var codexp=document.getElementById('code').value;
  	eval(targ+".location='finalizare_comanda.php?pl="+plata+"&oe="+selObj.options[selObj.selectedIndex].value+"&ne="+numeexp+"&je="+judetexp+"&ae="+adresaexp+"&ce="+codexp+"'");
  //	if (restore) selObj.selectedIndex=0;
}

function MM_jumpMenu_j(targ,selObj){ //v3.0
	var plata=document.getElementById('plata').value;
	var exped=document.getElementById('expediere').value;
	var prenumeben=document.getElementById('prenumeb').value;
	var numeben=document.getElementById('numeb').value;
	var cnp=document.getElementById('cnp').value;
	var orasben=document.getElementById('orasb').value;
	var judetben=document.getElementById('judetb').value;
	var adresaben=document.getElementById('adresab').value;
	var codben=document.getElementById('codb').value;
	var telben=document.getElementById('telefonb').value;
	var emailben=document.getElementById('mailb').value;
	var prenumeexp=document.getElementById('prenumee').value;
	var numeexp=document.getElementById('numee').value;
	var orasexp=document.getElementById('orase').value;
	var adresaexp=document.getElementById('adresae').value;
	var codexp=document.getElementById('code').value;
  	eval(targ+".location='finalizare_comanda.php?pl="+plata+"&exped="+exped+"&je="+selObj.options[selObj.selectedIndex].value+"&pb="+prenumeben+"&nb="+numeben+"&cnp="+cnp+"&ob="+orasben+"&jb="+judetben+"&ab="+adresaben+"&cb="+codben+"&tb="+telben+"&eb="+emailben+"&pe="+prenumeexp+"&ne="+numeexp+"&oe="+orasexp+"&ae="+adresaexp+"&ce="+codexp+"'");
  //	if (restore) selObj.selectedIndex=0;
}

function MM_jumpMenu_j_m(targ,selObj){ //v3.0
	var plata=document.getElementById('plata').value;
	var exped=document.getElementById('expediere').value;
	var prenumeexp=document.getElementById('prenumee').value;
	var numeexp=document.getElementById('numee').value;
	var orasexp=document.getElementById('orase').value;
	var adresaexp=document.getElementById('adresae').value;
	var codexp=document.getElementById('code').value;
  	eval(targ+".location='finalizare_comanda.php?pl="+plata+"&exped="+exped+"&je="+selObj.options[selObj.selectedIndex].value+"&pe="+prenumeexp+"&ne="+numeexp+"&oe="+orasexp+"&ae="+adresaexp+"&ce="+codexp+"'");
  //	if (restore) selObj.selectedIndex=0;
}

function MM_jumpMenu_j_m_jur(targ,selObj){ //v3.0
	var plata=document.getElementById('plata').value;
	var exped=document.getElementById('expediere').value;
	var numeexp=document.getElementById('numee').value;
	var orasexp=document.getElementById('orase').value;
	var adresaexp=document.getElementById('adresae').value;
	var codexp=document.getElementById('code').value;
  	eval(targ+".location='finalizare_comanda.php?pl="+plata+"&exped="+exped+"&je="+selObj.options[selObj.selectedIndex].value+"&ne="+numeexp+"&oe="+orasexp+"&ae="+adresaexp+"&ce="+codexp+"'");
  //	if (restore) selObj.selectedIndex=0;
}

function MM_jumpMenu_e(targ,selObj){ //v3.0
	var plata=document.getElementById('plata').value;
	var prenumeben=document.getElementById('prenumeb').value;
	var numeben=document.getElementById('numeb').value;
	var cnp=document.getElementById('cnp').value;
	var orasben=document.getElementById('orasb').value;
	var judetben=document.getElementById('judetb').value;
	var adresaben=document.getElementById('adresab').value;
	var codben=document.getElementById('codb').value;
	var telben=document.getElementById('telefonb').value;
	var emailben=document.getElementById('mailb').value;
	var prenumeexp=document.getElementById('prenumee').value;
	var numeexp=document.getElementById('numee').value;
	var judetexp=document.getElementById('judete').value;
	var adresaexp=document.getElementById('adresae').value;
	var codexp=document.getElementById('code').value;
  	eval(targ+".location='finalizare_comanda.php?pl="+plata+"&exped="+selObj.options[selObj.selectedIndex].value+"&je="+judetexp+"&pb="+prenumeben+"&nb="+numeben+"&cnp="+cnp+"&ob="+orasben+"&jb="+judetben+"&ab="+adresaben+"&cb="+codben+"&tb="+telben+"&eb="+emailben+"&pe="+prenumeexp+"&ne="+numeexp+"&ae="+adresaexp+"&ce="+codexp+"'");
  //	if (restore) selObj.selectedIndex=0;
}

function MM_jumpMenu_e_m(targ,selObj){ //v3.0
	var plata=document.getElementById('plata').value;
	var prenumeexp=document.getElementById('prenumee').value;
	var numeexp=document.getElementById('numee').value;
	var judetexp=document.getElementById('judete').value;
	var adresaexp=document.getElementById('adresae').value;
	var codexp=document.getElementById('code').value;
  	eval(targ+".location='finalizare_comanda.php?pl="+plata+"&exped="+selObj.options[selObj.selectedIndex].value+"&je="+judetexp+"&pe="+prenumeexp+"&ne="+numeexp+"&ae="+adresaexp+"&ce="+codexp+"'");
  //	if (restore) selObj.selectedIndex=0;
}

function MM_jumpMenu_e_m_jur(targ,selObj){ //v3.0
	var plata=document.getElementById('plata').value;
	var numeexp=document.getElementById('numee').value;
	var judetexp=document.getElementById('judete').value;
	var adresaexp=document.getElementById('adresae').value;
	var codexp=document.getElementById('code').value;
  	eval(targ+".location='finalizare_comanda.php?pl="+plata+"&exped="+selObj.options[selObj.selectedIndex].value+"&je="+judetexp+"&ne="+numeexp+"&ae="+adresaexp+"&ce="+codexp+"'");
  //	if (restore) selObj.selectedIndex=0;
}

function inchide(){
	document.getElementById("splash").style.visibility = "hidden";
	document.getElementById("splash").style.top = "-1000px";
	document.getElementById("splash").style.left = "-1000px";
}