// JavaScript Document
function validare_comanda_legisdesktop() {
	rbml = document.getElementsByName("modlucru");
	modlucru = -1;
	for (i=rbml.length-1; i > -1; i--) {
	if (rbml[i].checked) {
	modlucru = i; i = -1;
	}
	}
	if (modlucru == -1) {
	alert("Trebuie sa selectati un mod de lucru!");
	return false;
	}
	
	rbma = document.getElementsByName("modactualizare");
	modactualizare = -1;
	for (i=rbma.length-1; i > -1; i--) {
	if (rbma[i].checked) {
	modactualizare = i; i = -1;
	}
	}
	if (modactualizare == -1) {
	alert("Trebuie sa selectati un mod de actualizare!");
	return false;
	}
	txt = document.getElementById("societate").value;
	var inputs = document.getElementsByTagName('input');
	for(var i=0; i<inputs.length; i++){
		if (inputs[i].type == "text") {
			if (inputs[i].value == "") {
				alert ("Campul "+ inputs[i].alt +" trebuie completat!");
				return false;
			}
		}
	}
		
   var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
   var address = document.getElementById("email").value;
   if(reg.test(address) == false) {
		alert ("Adresa email data nu este valida!");
		return false;
	}

	var tel = document.getElementById("tel");
    var reg = /(^[0-9\s\-\+]{10,})$/;
   
   if(reg.test(tel) == false) {
		alert ("Numarul de telefon nu este corect dat!");
		return false;
	}
   
	sc = document.getElementById("security_code").value;
	verificare = getSrvData("./html/test1.php?security_code="+sc);
	if (verificare ==0 ) {
		alert("Nu ati introdus corect codul de securizare!");
		// comanda('comanda_legisdesktop.php');
	} else {
		var param = "";
	rbml = document.getElementsByName("modlucru");
	modlucru = "";
	for (i=rbml.length-1; i > -1; i--) {
	if (rbml[i].checked) {
	modlucru = rbml[i].value;
	}
	}
		acteoficiale = document.getElementById("cmd_desktop_acteoficiale").checked;
		jurisprudenta = document.getElementById("cmd_desktop_jurisprudenta").checked;
		modelecontract = document.getElementById("cmd_desktop_modelecontract").checked;
		doctrine = document.getElementById("cmd_desktop_doctrine").checked;
		dictionare = document.getElementById("cmd_desktop_dictionare").checked;
		clasificari = document.getElementById("cmd_desktop_clasificari").checked;
		eurolegis = document.getElementById("cmd_desktop_eurolegis").checked;
		comentarii = document.getElementById("cmd_desktop_comentarii").checked;
		cedo = document.getElementById("cmd_desktop_cedo").checked;
		achizitii = document.getElementById("cmd_desktop_achizitiipublice").checked;
		definitii = document.getElementById("cmd_desktop_definitii").checked;
		sinteze = document.getElementById("cmd_desktop_sinteze").checked;
		autorizatii = document.getElementById("cmd_desktop_autorizatii").checked;
		acteinterne = document.getElementById("cmd_desktop_acteinterne").checked;
	rbma = document.getElementsByName("modactualizare");
	modactualizare = "";
	for (i=rbma.length-1; i > -1; i--) {
	if (rbma[i].checked) {
	modactualizare = rbma[i].value;
	}
	}
		soc = document.getElementById("societate").value;
		adr = document.getElementById("adresa").value;
		cf = document.getElementById("codfiscal").value;
		iban = document.getElementById("iban").value;
		tel = document.getElementById("tel").value;
		fax = document.getElementById("fax").value;
		email = document.getElementById("email").value;
		contact = document.getElementById("contact").value;
		param = param+ "modlucru="+modlucru+"&";
		param = param+ "acteoficiale="+acteoficiale+"&";
		param = param+ "jurisprudenta="+jurisprudenta+"&";
		param = param+ "modelecontract="+modelecontract+"&";
		param = param+ "doctrine="+doctrine+"&";
		param = param+ "dictionare="+dictionare+"&";
		param = param+ "clasificari="+clasificari+"&";		
		param = param+ "eurolegis="+eurolegis+"&";
		param = param+ "comentarii="+comentarii+"&";
		param = param+ "achizitii="+achizitii+"&";
		param = param+ "definitii="+definitii+"&";
		param = param+ "sinteze="+sinteze+"&";
		param = param+ "autorizatii="+autorizatii+"&";
		param = param+ "acteinterne="+acteinterne+"&";
		param = param+ "modactualizare="+modactualizare+"&";
		param = param+ "soc="+soc+"&";
		param = param+ "adr="+adr+"&";
		param = param+ "cf="+cef+"&";
		param = param+ "iban="+iban+"&";
		param = param+ "tel="+tel+"&";
		param = param+ "fax="+fax+"&";
		param = param+ "cf="+cef+"&";
		param = param+ "email="+email+"&";
		param = param+ "contact="+contact;
		postsjax("./html/sendcomandalegisdesktop.php", param, 'div_comanda');
		
		
		
		
		// comanda('comanda_legisdesktop.php');
	};
}
function comanda(fisier) {
	fisier = "./html/" + fisier;
	sjax(fisier,'div_comanda');
	
}
function loadmainpage() {
	//alert(document.body.page-height);
	//sjax('./html/principala.html','div_content');
	
}
function latime() {
 // var myWidth = 0, myHeight = 0;
/*  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
  }
  */
  
  if (parseInt(navigator.appVersion)>3) {
 if (navigator.appName=="Netscape") {
  winW = window.innerWidth;
  winH = window.innerHeight;
 }
 if (navigator.appName.indexOf("Microsoft")!=-1) {
  winW = document.body.offsetWidth;
  winH = document.body.offsetHeight;
 }
}

  return winW;
}
function inaltime() {
 /* var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myHeight = document.body.clientHeight;
  }
  */
  if (parseInt(navigator.appVersion)>3) {
 if (navigator.appName=="Netscape") {
  winW = window.innerWidth;
  winH = window.innerHeight;
 }
 if (navigator.appName.indexOf("Microsoft")!=-1) {
  winW = document.body.offsetWidth;
  winH = document.body.offsetHeight;
 }
}
  
return winH;
}


function deletediv(id) {
div = document.getElementById(id);
document.body.removeChild(div);
}
function showdiv(divname) {
	dleft =50;
	dtop = 10;
	x= latime()-2*dleft;
	y= inaltime()-2*dtop;

	var div;
	if (document.createElement && (div = document.createElement('div'))) {
		/*div.setAttribute('name',divname);
		div.setAttribute('id',divname);
		div.setAttribute('border', '2px');
		div.innerHTML = mesaj;
		div.style.position = "absolute";
		div.style.top =top+"px";
		div.style.left = left+"px";
		div.style.width = x + "px";
		div.style.height =y -100 + "px";
		div.style.backgroundColor="#FFBB55";*/
		
		
		div.setAttribute('name',divname);
		div.setAttribute('class','divDetalii');
		div.setAttribute('className','divDetalii');
		div.setAttribute('id',divname);
	  mesaj = getSrvData(divname);		
		div.innerHTML =  mesaj;		

		div.style.position = "absolute";
		div.style.top =dtop+"px";
		div.style.left = dleft+"px";
		if (x > 1100) x=1100;
		if (x < 420) x=420;
		div.style.width = x + "px";
		div.style.height ="500px";
		document.body.appendChild(div);
		
		// document.getElementById(divname).innerHTML = getSrvData("wait.html") ;
	  	
		// document.getElementById(divname)
    }
}


function sendMail () {
  mName = document.getElementById("nume").value;
  mFrom = document.getElementById("email").value;
  mSubj = document.getElementById("subject").value;
  mMess = document.getElementById("mesaj").value;
  mCall = "./html/sendmail.php?subject="+mSubj+"&from="+mName+"&mesaj="+mMess+"&email="+mFrom+"&pagina=CONTACT";
  // alert (mCall);
  document.getElementById("teste").innerHTML = mCall;
  raspuns = getSrvData(mCall);
  alert (raspuns);


} 
