//-----------
function confirmare(data, id_local)	{
	var confirma = confirm(data);
	if (confirma==true)
	{
	navigate("admin_delete.php?id="+id_local);
	}
	else ;	
}

function confirmare2(data, id_local, prod)	{
	var confirma = confirm(data);
	if (confirma==true)
	{
	navigate("admin_pret.php?del=1&id="+id_local+"&prod="+prod);
	}
	else ;	
}
//-----------
<!--
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];}
}
//--


// This function will verify all controls from a given form
function checkSubmitError(theForm) {

	var theElements = theForm.elements;
	var theKey;
	var theError,goDown;
	var tempobj;

	var winObject;
	
	theError="";
	for (k=1;k<=theElements.length;k++) {
		theKey=theElements[k-1].name+"_JS";
		goDown=false;
		if (theForm[theKey] !=null) {
			theArray=theForm[theKey].value.split("}");
			// if the field is empty and is Mandatory 
			if (theArray[0].toLowerCase()=="ma" && theElements[k-1].value=="") {
				goDown=true;
				theError=theError+"Campul "+theForm[theElements[k-1].name].name+" nu poate fi gol !\n";
			}
			// if the field is empty and is optional
			if ((theArray[0].toLowerCase()=="op" && theElements[k-1].value=="") && goDown==false) 
				goDown=true;
			// if the field is number then is verified like a string with 0..9 and ,.
			if (theArray[1].toLowerCase()=="integer" && goDown==false) {
				goDownNumber=true;
				for (i=1;i<=theElements[k-1].value.length;i++) {
					if ((theElements[k-1].value.charAt(i-1)<"0" || theElements[k-1].value.charAt(i-1)>"9") && theElements[k-1].value.charAt(i-1)!="." && theElements[k-1].value.charAt(i-1)!=",") {
						goDown=true;
						goDownNumber=false;
						theError=theError+"Campul "+theForm[theElements[k-1].name].name+" trebuie sa fie un numar !\n";
						break;
					}
				}
				if (goDownNumber=true) {
					/*if (theElements[k-1].value.charAt(0)=="." || theElements[k-1].value.charAt(0)==",") {
						theError=theError+"The field "+theForm[theElements[k-1].name].name+" must be a number !"+String.fromCharCode(13);
						goDownNumber=false;
					}*/
					/*if (goDownNumber==true) {
						if (theElements[k-1].value.charAt(theElements[k-1].value.length-1)=="." || theElements[k-1].value.charAt(theElements[k-1].value.length-1)==",") {
							theError=theError+"The field "+theForm[theElements[k-1].name].name+" must be a number !"+String.fromCharCode(13);
							goDownNumber=false;
						}
					}*/
					/*theNumberArray1=theElements[k-1].value.split(".");
					theNumberArray2=theElements[k-1].value.split(",");
					if ((theNumberArray1.length>2 || theNumberArray2.length>2) && goDownNumber==true) {
						goDownNumber=false;
						goDown=true;
						theError=theError+"The field "+theForm[theElements[k-1].name].name+" must be a number !"+String.fromCharCode(13);
					}
					if (goDownNumber==true && theNumberArray1.length==2 && theNumberArray2.length==2) {
						goDown=true;
						theError=theError+"The field "+theForm[theElements[k-1].name].name+" must be a number !"+String.fromCharCode(13);
					}*/
				}
			}
			/*if ((theArray[1].toLowerCase()=="integer" && isNaN(theElements[k-1].value)==true) && goDown==false) {
				goDown=true;
				theError=theError+"The field "+theForm[theElements[k-1].name].name+" must be an number !"+String.fromCharCode(13);
			}*/
			// if the field is a date then is verified only the format:mm/dd/yyyy
			if ((theArray[1].toLowerCase()=="date") && goDown==false) {
				goDown=true;
				//goDownDate=false;
				/*if ((theElements[k-1].value.charAt(2)!="/") || (theElements[k-1].value.charAt(5)!="/")) {
					goDownDate=true;
					theError=theError+"The field "+theForm[theElements[k-1].name].name+" contain an invalid date !"+String.fromCharCode(13);
				}*/
				var splitDate=theElements[k-1].value.split("/");
				if (splitDate.length!=3) {
					splitDate=theElements[k-1].value.split(".");
					if (splitDate.length!=3) {
						splitDate=theElements[k-1].value.split("-");
					}
				}
				if (splitDate.length!=3) {
					theError=theError+"Campul "+theForm[theElements[k-1].name].name+" contine o data invalida !\n";
				}
				else {
					if ((isNaN(splitDate[0])==true) || (isNaN(splitDate[1])==true) || (isNaN(splitDate[2])==true))
						theError=theError+"Campul "+theForm[theElements[k-1].name].name+" contine o data invalida !\n";
				}
			}
			// if the field is an email then it must include '@' and '.'
			if ((theArray[1].toLowerCase()=="email") && goDown==false) {
				goDown=true;

				goDownEmail=false;
				var theEmailArray=theElements[k-1].value.split(",")
				for (i=1;i<=theEmailArray.length;i++) {
					// test if exists "@" and "."
					if ((theEmailArray[i-1].indexOf("@")==-1) || (theEmailArray[i-1].indexOf(".")==-1)) {
						goDownEmail=true;
						theError=theError+"Campul "+theForm[theElements[k-1].name].name+" contine un e-mail invalid !\n";
						break;
					}
					// test if the first char is "@" or "."
					if (((theEmailArray[i-1].charAt(0)=="@") || (theEmailArray[i-1].charAt(0)==".")) && goDownEmail==false) {
						goDownEmail=true;
						theError=theError+"Campul "+theForm[theElements[k-1].name].name+" contine un e-mail invalid !\n";
						break;
					}
					// test if the last char is "@" or "."					
					if (((theEmailArray[i-1].charAt(theEmailArray[i-1].length-1)=="@") || (theEmailArray[i-1].charAt(theEmailArray[i-1].length-1)==".")) && goDownEmail==false) {
						goDownEmail=true;
						theError=theError+"Campul "+theForm[theElements[k-1].name].name+" contine un e-mail invalid !\n";
						break;
					}
					// test if numbers of '@' is 1 on the string
					theEmail=theEmailArray[i-1].split("@");
					if ((theEmail.length!=2) && goDownEmail==false) {
						goDownEmail=true;
						theError=theError+"Campul "+theForm[theElements[k-1].name].name+" contains un e-mail invalid !\n";
						break;
					}
					//test if index of "." <> index of "@" + 1 and <>index of "@" -1
					if (goDownEmail==false) {
						if ((theEmailArray[i-1].indexOf("@")==theEmailArray[i-1].indexOf(".")-1) || (theEmailArray[i-1].indexOf("@")==theEmailArray[i-1].indexOf(".")+1)) {
							goDownEmail=true;
							theError=theError+"Campul "+theForm[theElements[k-1].name].name+" contine un e-mail invalid !\n";
							break;
						}
					}
					// test if index of "." <> index of "." + 1
					if ((theEmailArray[i-1].charAt((theEmailArray[i-1].indexOf(".")))==theEmailArray[i-1].charAt((theEmailArray[i-1].indexOf(".")+1))) && goDownEmail==false) {
						theError=theError+"Campul "+theForm[theElements[k-1].name].name+" contine un e-mail invalid !\n";
						break;
					}
				}
			}
			// if the field is a credit card...
			// if the field is string and must test the min numbers or chars and the max numbers of chars
			if ((theArray[1].toLowerCase()=="string") && goDown==false) {
				goDown=true;
				if (theArray.length>=3) {
					if (theArray[2]!="") {
						// must test the min numbers of chars
						if (theElements[k-1].value.length<theArray[2])
							theError=theError+"Campul "+theForm[theElements[k-1].name].name+" trebuie sa aiba min "+theArray[2]+" caractere !\n";
					}
					if (theArray[3]!="") {
						// must test the min numbers of chars
						if (theElements[k-1].value.length>theArray[3])
							theError=theError+"Campul "+theForm[theElements[k-1].name].name+" trebuie max "+theArray[3]+" caractere !\n";
					}					
				}
			}
		}
	}
	if (theError !="") {
		alert (theError);
		return false;
	} else{

for (i = 0; i < theForm.length; i++) {
var tempobj = theForm.elements[i];
if (tempobj.type.toLowerCase() == "submit" || tempobj.type.toLowerCase() == "reset")
tempobj.disabled = true;             }


		return true;
	}
}
//--

function ff(adr, w, h){
	var t = Math.floor((screen.availWidth-w)/2);
	var l = Math.floor((screen.availHeight-h)/2);
	window.open(adr, '', 'resizable=yes,width='+w+',height='+h+',top='+t+',left='+l+',location=no,menubar=no,scrollbars=auto,status=no,toolbar=no');
}
