function confirm_del() {
  var con=window.confirm("هل تريد إتمام عملية الحذف ؟"); 
  return con;
}

function confirm_del() {
  var con=window.confirm("هل تريد إتمام عملية الحذف ؟"); 
  return con;
}

function submitbutton(action,oF){
   	oF.operation.value = action;
	oF.submit();	
	oF.onsubmit = null; 	

}


function CheckAll(oF) {
	for(i=0; i<oF.length; i++) {
		e = oF.elements[i];
		if(e.type == 'checkbox' && e.name != 'allbox') {
			if(oF.allbox.checked)
				e.checked = true;
			else
				e.checked = false;
		}
	}
}

function CheckBox(oF, obj) {
	var count = 0;
	var len = 0;
	for(i = 0; i < oF.length; i++) {
		e = oF.elements[i];
		if(e.type == 'checkbox' && e.name != 'allbox' && e.checked)
			count++;
		if(e.type == 'checkbox' && e.name != 'allbox')
			len++;
	}
	if(oF.allbox.checked  && obj.checked == false)
		oF.allbox.checked = false;
	else if(oF.allbox.checked == false  && obj.checked == true && count == len)
		oF.allbox.checked = true;
}



function Check(oF) {
	for(i = 0; i < oF.length; i++) {
		e = oF.elements[i];
		if(e.type == 'checkbox' && e.name != 'allbox' && e.checked){
			
			return true;
			}		
	}
return false;
}
function DisplayDivs(aE) {
	var o = GEId(aE);
	//if(o) {
		if(o.style.display == 'block') {
			o.style.display = 'none';
		} else {
			o.style.display = 'block';
		}
	//}
}

function Delete(oF) {
	if(arguments.length > 1) {
		if(openModalWindow('confirm', MSG_DELETE_ITEMS)) {
			oF.method = 'POST';
			oF.iCMD.value = "delete";
			oF.iSubmit.click();
			oF.onsubmit = null;
			cat.operation2.value = "delete";

		}
	} else {
		var count = 0;
		var len = 0;
		for(i=0; i<oF.length; i++) {
			e = oF.elements[i];
			if(e.type == 'checkbox' && e.name != 'allbox' && e.checked)
				count++;
			if(e.type=='checkbox' && e.name != 'allbox')
				len++;
		}
		if(count == 0) {
			openModalWindow('alert', MSG_SELECT_ITEMS);
		} else if(count > 0 && count <= len) {
			if(openModalWindow('confirm', MSG_DELETE_ITEMS)) {
				oF.method = 'POST';
				oF.iCMD.value = "delete";
				oF.iSubmit.click();
				oF.onsubmit = null;
			}
		}
	}
}

function Print() {
	var sQuery = document.location.search;
	var sURL = 'print.php' + sQuery + ((sQuery.indexOf("?")==-1)? '?' : '&') + 'print=true';
	var sName = "printView";
	var sFeatures = "directories=0,height=550,left=0,location=0,menubar=0,resizable=0,scrollbars=1,status=0,toolbar=1,top=0,width=700";
	window.open(sURL, sName, sFeatures);
}
function isBlank(fieldValue) {
	var blankSpaces = / /g;
	fieldValue = fieldValue.replace(blankSpaces, "");
	return (fieldValue == "") ? true : false;
}


function isEmailValid(fieldValue) {
	var emailFilter = /^.+@.+\..{2,4}$/;
	var atSignFound = 0;
	for (var i = 0; i <= fieldValue.length; i++)
		if ( fieldValue.charAt(i) == "@" )
			atSignFound++;
	if ( atSignFound > 1 )
		return false;
	else
		return ( emailFilter.test(fieldValue) && !doesEmailHaveInvalidChar(fieldValue) ) ? true : false;
}

function validateEmail(form) {
	if(isBlank(form.email.value) || ! isEmailValid(form.email.value)) {
		form.email.style.border = "#FF0000 1px solid";
		if(thanksMsg.style.display == 'block') thanksMsg.style.display = 'none';
		errorMsg.style.display = 'block';
		return false;
	}
	return true;
}

