function submitForm(form, action)
{
	document.forms[form].action = action;
	document.forms[form].submit();
}

function confirmAction(form,action)
{
	var mconfirm = confirm("Are you sure you want to delete this record?");
	if (mconfirm)
	{
		submitForm(form,action);
		return true;
	}
	else
	{

		return false;
	}
}

function clearForm()
{
	for(i=0; i < document.forms[0].elements.length; i++)
	{
		switch(document.forms[0].elements[i].type)
		{
			case "file":
			case "hidden":
			case "password":
			case "text":
			case "select-multiple":
			case "textarea":
			document.forms[0].elements[i].value = "";
			case "select":
			case "select-one":
			document.forms[0].elements[i].selectedIndex = -1;
		}

	}
}

function rollIn(el)
{
	var ms = navigator.appVersion.indexOf("MSIE")
	ie4 = (ms>0) && (parseInt(navigator.appVersion.substring(ms+5, ms+6)) >= 4)
	if(ie4)
	{
		el.initstyle=el.style.cssText;
		var newStyle=el.style.cssText+";"+el.fprolloverstyle;
		el.style.cssText=newStyle
	}
}

function confirmDelete(action)
{
	var mconfirm = confirm("هل انت متأكد انك تريد حذف هذا الموضوع");
	if (mconfirm) {
		window.location = action;
		return true;
	} else {
		return false;
	}
}

function testemail(obj) {
	if(obj){
		var emailForm = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/
		if (emailForm.test(obj.value)){
			return true;
		}
	}

	return false;
}

function addNewsletter(Obj){
	if(!testemail(Obj)){
		alert("الرجاء التأكدّ من البريد الإلكتروني");	
	} else{
		AJAXPost("addNewsLetter.php?email="+Obj.value, new Function("response","addNewsLetterHandler(response)"));
	}
}

function addNewsLetterHandler(reponseTEXT){
	alert(reponseTEXT);
}