// JavaScript Document

function checkForm(frm){
	var t = 0;	
	setDVstyle("inpPass2", "stFormCellText");	
	setDVstyle("inpPass3", "stFormCellText");
	t+=checkItem(frm.password, 'inpPass');
	t+=checkItem(frm.password2, 'inpPass2');
	t+=checkItem(frm.password3, 'inpPass3');
	if (frm.password2.value == frm.password3.value) t++;
		else {
			setDVstyle("inpPass2", "stFormCellTextError");	
			setDVstyle("inpPass3", "stFormCellTextError");
		}
	
	if (t == 4) 
		frm.submit();
	return false;
}

function checkComanda(frm){
	var t = 0;	

	t+=checkItemC(frm.nume, 'inpNume');
	t+=checkItemC(frm.email, 'inpEmail');
	if (frm.email.value != ""){
		if (echeck(frm.email.value)) t++;
			else setDVstyle("inpEmail", "stFormCellTextErrorC");	
	}
	if (t == 3) 
		return frm.submit();
	return false;
}

function checkFormPages(frm){
	var t = 0;	
	t+=checkItem(frm.title_page, 'inpTitel');
		
	if (t == 1) 
		frm.submit();
	return false;
}

function checkFormShop(frm){
	var t = 0;	
	t+=checkItem(frm.name, 'nume');
		
	if (t == 1) 
		frm.submit();
	return false;
}

function checkFormMenu(frm){
	var t = 0;	
	setDVstyle("inpOrd", "stFormCellText");
	t+=checkItem(frm.name, 'inpName');
	if ((frm.ordinea.value != "") && (isNumeric(frm.ordinea.value))) t++;
		else setDVstyle("inpOrd", "stFormCellTextError");
	if (t == 2) 
		frm.submit();
	return false;
}

function checkFormRecomand(frm){
	var t = 0;	
	var u = 0;
	var er = 0;
	setDVstyle("pentru", "stFormCellText");
	t+=checkItem(frm.myname, 'dela');
	t+=checkItem(frm.myEmail, 'adr_mea');
	if (frm.myEmail.value != ""){
		if (echeck(frm.myEmail.value)) t++;
			else setDVstyle("adr_mea", "stFormCellTextError");	
	}
	if (frm.sendTo1.value != ""){
		if (echeck(frm.sendTo1.value)) u++;
			else {
				er++;
				setDVstyle("pentru", "stFormCellTextError");
			}
	}
	if (frm.sendTo2.value != ""){
		if (echeck(frm.sendTo2.value)) u++;
			else  {
				er++;
				setDVstyle("pentru", "stFormCellTextError");
			}
	}	
	if (frm.sendTo3.value != ""){
		if (echeck(frm.sendTo3.value)) u++;
			else {
				er++;
				setDVstyle("pentru", "stFormCellTextError");
			}
	}	
	if (frm.sendTo4.value != ""){
		if (echeck(frm.sendTo4.value)) u++;
			else {
				er++;
				setDVstyle("pentru", "stFormCellTextError");
			}
	}	
	if (frm.sendTo5.value != ""){
		if (echeck(frm.sendTo5.value)) u++;
			else {
				er++;
				setDVstyle("pentru", "stFormCellTextError");	
			}
	}	
	if (frm.sendTo6.value != ""){
		if (echeck(frm.sendTo6.value)) u++;
			else {
				er++;
				setDVstyle("pentru", "stFormCellTextError");	
			}
	}	
	if (frm.sendTo7.value != ""){
		if (echeck(frm.sendTo7.value)) u++;
			else  {
				er++;
				setDVstyle("pentru", "stFormCellTextError");	
			}
	}	
	if (u == 0) setDVstyle("pentru", "stFormCellTextError");
	if (er > 0) setDVstyle("pentru", "stFormCellTextError");
	if ((t == 3) && (u > 0) && (er == 0))
		frm.submit();
	return false;
}

function checkFormContact(frm){
	var t = 0;	
	setDVstyle("email", "stFormCellText");
	t+=checkItem(frm.fname, 'nume');
	t+=checkItem(frm.lname, 'prenume');
	t+=checkItem(frm.email, 'email');
	if (frm.email.value != ""){
		if (echeck(frm.email.value)) t++;
			else setDVstyle("email", "stFormCellTextError");	
	}
	
	if (t == 4)
		frm.submit();
	return false;
}

function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}

function ignoreEvent(e) {
	if (!e || !e.stopPropagation)
		window.event.cancelBubble = true;
	else
		e.stopPropagation();
}

function CheckDelFormAndSubmit() {
if(confirm("Esti sigur ca vrei sa stergi randurile selectate ? \n ATENTIUNE: ACEASTA OPERATIUNE ESTE IREVERSIBILA !!!"))
 document.frmDelete.submit();
}

function checkFormNewsList(frm){
	var t = 0;	
	setDVstyle("email", "stFormCellText");
	setDVstyle("telefon", "stFormCellText");
	setDVstyle("mobil", "stFormCellText");
	t+=checkItem(frm.email, 'email');
	if (frm.email.value != ""){
		if (echeck(frm.email.value)) t++;
			else setDVstyle("email", "stFormCellTextError");	
	}
	var i=0;j=0;
	if (frm.telefon.value != ""){
			i=1;
			if (isNumeric(frm.telefon.value)) i=0;
			else setDVstyle("telefon", "stFormCellTextError");
	}
	if (frm.mobil.value != ""){
			j=1;
			if (isNumeric(frm.mobil.value)) j=0;
			else setDVstyle("mobil", "stFormCellTextError");
	}
	if ((i == 0) && (j == 0)){
		if (t == 2)
			frm.submit();
	}
	return false;
}

function submitForm(pg){
	document.search.action="newslist.php?pg=" + pg;
	document.search.submit();
}

function checkFormAccount(frm){
	var t = 0;	u = 0;
	
	for (i=0;i<frm.rights.length;i++) {
		if (frm.rights[i].checked) {
			u = 1;
		}
	}
	setDVstyle("inpRight", "stFormCellText");
	if (u == 0) {
		setDVstyle("inpRight", "stFormCellTextError");
	}
	else t++;
	setDVstyle("inpPass", "stFormCellText");
	setDVstyle("inpPass2", "stFormCellText");
	setDVstyle("telefon", "stFormCellText");
	setDVstyle("inpEmail", "stFormCellText");
	setDVstyle("fax", "stFormCellText");
	t+=checkItem(frm.username, 'inpName');
	t+=checkItem(frm.email, 'inpEmail');
	if (echeck(frm.email.value)) t++;
			else setDVstyle("inpEmail", "stFormCellTextError");	
	t+=checkItem(frm.parola, 'inpPass');
	t+=checkItem(frm.parola2, 'inpPass2');
	if (frm.parola.value != frm.parola2.value){
			setDVstyle("inpPass", "stFormCellTextError");
			setDVstyle("inpPass2", "stFormCellTextError");
	}
	else t++;
	var i=0;j=0;
	if (frm.telefon.value != ""){
			i=1;
			if (isNumeric(frm.telefon.value)) i=0;
			else setDVstyle("telefon", "stFormCellTextError");
	}
	if (frm.fax.value != ""){
			j=1;
			if (isNumeric(frm.fax.value)) j=0;
			else setDVstyle("fax", "stFormCellTextError");
	}
	
	if ((i == 0) && (j == 0)){
		if (t == 7)
			frm.submit();
	}
	return false;
}

function checkFormModifyAccount(frm){
	var t = 0;	
	setDVstyle("inpPass", "stFormCellText");
	setDVstyle("inpPass2", "stFormCellText");
	setDVstyle("telefon", "stFormCellText");
	setDVstyle("fax", "stFormCellText");
	setDVstyle("inpEmail", "stFormCellText");
	t+=checkItem(frm.email, 'inpEmail');
	if (echeck(frm.email.value)) t++;
			else setDVstyle("inpEmail", "stFormCellTextError");	
	if (frm.parola.value != frm.parola2.value){
			setDVstyle("inpPass", "stFormCellTextError");
			setDVstyle("inpPass2", "stFormCellTextError");
	}
	else t++;
	var i=0;j=0;
	if (frm.telefon.value != ""){
			i=1;
			if (isNumeric(frm.telefon.value)) i=0;
			else setDVstyle("telefon", "stFormCellTextError");
	}
	if (frm.fax.value != ""){
			j=1;
			if (isNumeric(frm.fax.value)) j=0;
			else setDVstyle("fax", "stFormCellTextError");
	}
	
	if ((i == 0) && (j == 0)){
		if (t == 3)
			frm.submit();
	}
	return false;
}

function CheckGolire() {
if(confirm("Esti sigur ca vrei sa golesti baze de date ? \n ATENTIUNE: ACEASTA OPERATIUNE ESTE IREVERSIBILA !!!"))
	MM_goToURL('parent','act/act_participanti_delete.php');
}

function checkLogin(frm){
	var t = 0;

	t+=checkItemL(frm.username, 'inpName');
	t+=checkItemL(frm.password, 'inpPass');
	if (t == 2)
		frm.submit();
	return false;
}

function checkReparola(frm){
	var t = 0;	
	setDVstyle("inpEmailRe", "stFormCellText");	
	t+=checkItem(frm.email, 'inpEmailRe');
	if (echeck(frm.email.value)) t++;
			else setDVstyle("inpEmailRe", "stFormCellTextError");	
	if (t == 2)
		frm.submit();
	return false;
}

function checkChangeLogin(frm){
	var t=0;
	t+=checkItem(frm.password1, 'inpPass_1');
	t+=checkItem(frm.password2, 'inpPass_2');
	t+=checkItem(frm.password3, 'inpPass_3');
	if (frm.password3.value == frm.password2.value) t++;
	
	if (t==4)
		frm.submit();
	return false;
}

function checkNewsletter(frm){
	if ((frm.newsletter.value != "" ) && (echeck(frm.newsletter.value))) return true;
		else {
			showDiv('newslerror');
			return false;
		}
}