// JavaScript Document
<!-- 


	function validateTestimonial(){
		if (validate_fullname()==false || validate_email()==false || validate_comments()==false){
			return false;
		}else{
			return true;
		}	
	}
	
	function validateInquiryForm(){
		if (validate_fullname()==false || validate_phone()==false || validate_email()==false || validate_comments()==false){
			return false;
		}else{
			return true;
		}	
	}
	function validateContactForm(){
		if (validate_fullname()==false || validate_phone()==false || validate_email()==false || validate_comments()==false){
			return false;
		}else{
			return true;
		}	
	}
	
	
	
//=====================================================================================================================================================
	
	function validate_card_title(){
			var str = document.frmRegister.card_title.value;
			var regExp = / /g;
			var tmp = document.frmRegister.card_title.value;
			tmp = tmp.replace(regExp,'');
			if (tmp.length <= 0) {
				alert("عنوان البطاقة غير موجود الرجاء كتابة عنوان البطاقة");
				document.frmRegister.card_title.focus();
			return false;
			}
		return true;
	}
	
	function validate_ad_category(){
			var str = document.frmRegister.category.value;
			var regExp = / /g;
			var tmp = document.frmRegister.category.value;
			tmp = tmp.replace(regExp,'');
			if (tmp.length <= 0) {
				alert("لم يتم تحديد التصنيف الرجاء أختيار التصنيف المناسب");
				document.frmRegister.category.focus();
			return false;
			}
		return true;
	}
	
	function validate_terms(){			
			if (document.frmRegister.is_agreed.checked==true){
				return true;
			}else{				
				alert("Please agree to terms and conditions");
				return false;
			}
			
	}
	
	function validate_ad_title(){
			var str = document.frmRegister.ad_title.value;
			var regExp = / /g;
			var tmp = document.frmRegister.ad_title.value;
			tmp = tmp.replace(regExp,'');
			if (tmp.length <= 0) {
				alert("عنوان الإعلان غير موجود الرجاء كتابة عنوان الإعلان");
				document.frmRegister.ad_title.select();
				document.frmRegister.ad_title.focus();
			return false;
			}
		return true;
	}
	
	function validate_ad_description(){
		
		var str = nicEditors.findEditor("textarea1").getContent();
	
		var regExp = /&nbsp;/g;
		str = str.replace(regExp,'');
		if (str.length <= 0) {
			alert("Description is blank, Please write Description.");
			//nicEditors.findEditor("textarea1").setContent('');
			return false;
		}
	}
	function validate_image1(){
		str = document.frmRegister.image1.value;
		if (str == ""){
			return true;
		}else{
			str = new String(document.frmRegister.image1.value)		
			var len = str.length-3;
			str = str.substring(len,len+3);
			str = str.toLowerCase();
			if(str=="peg"){ str="jpeg";}
			if(str=="jpg" || str=="gif" || str=="jpeg" || str=="png" ){
				//alert("I am here uploaded!");
			}else{
				alert("صيغة  الصورة رقم 1 التي قم باختيارها لاحقة غير معروفة الرجاء اختيار الصيغة الصحيحة مثل : JPG, GIF أو PNG");
				return false;		
			}
		}
	}
	function validate_image2(){
		str = document.frmRegister.image2.value;
		if (str == ""){
			return true;
		}else{
			str = new String(document.frmRegister.image2.value)		
			var len = str.length-3;
			str = str.substring(len,len+3);
			str = str.toLowerCase();
			if(str=="peg"){ str="jpeg";}
			if(str=="jpg" || str=="gif" || str=="jpeg" || str=="png" ){
				//alert("I am here uploaded!");
			}else{
				alert("صيغة  الصورة رقم 2 التي قم باختيارها لاحقة غير معروفة الرجاء اختيار الصيغة الصحيحة مثل : JPG, GIF أو PNG");
				return false;		
			}
		}
	}
	function validate_image3(){
		str = document.frmRegister.image3.value;
		if (str == ""){
			return true;
		}else{
			str = new String(document.frmRegister.image3.value)		
			var len = str.length-3;
			str = str.substring(len,len+3);
			str = str.toLowerCase();
			if(str=="peg"){ str="jpeg";}
			if(str=="jpg" || str=="gif" || str=="jpeg" || str=="png" ){
				//alert("I am here uploaded!");
			}else{
				alert("صيغة  الصورة رقم 3 التي قم باختيارها لاحقة غير معروفة الرجاء اختيار الصيغة الصحيحة مثل : JPG, GIF أو PNG");
				return false;		
			}
		}
	}
	function validate_image4(){
		str = document.frmRegister.image4.value;
		if (str == ""){
			return true;
		}else{
			str = new String(document.frmRegister.image4.value)		
			var len = str.length-3;
			str = str.substring(len,len+3);
			str = str.toLowerCase();
			if(str=="peg"){ str="jpeg";}
			if(str=="jpg" || str=="gif" || str=="jpeg" || str=="png" ){
				//alert("I am here uploaded!");
			}else{
				alert("صيغة  الصورة رقم 4 التي قم باختيارها لاحقة غير معروفة الرجاء اختيار الصيغة الصحيحة مثل : JPG, GIF أو PNG");
				return false;		
			}
		}
	}
	function validate_image5(){
		str = document.frmRegister.image5.value;
		if (str == ""){
			return true;
		}else{
			str = new String(document.frmRegister.image5.value)		
			var len = str.length-3;
			str = str.substring(len,len+3);
			str = str.toLowerCase();
			if(str=="peg"){ str="jpeg";}
			if(str=="jpg" || str=="gif" || str=="jpeg" || str=="png" ){
				//alert("I am here uploaded!");
			}else{
				alert("صيغة  الصورة رقم 5 التي قم باختيارها لاحقة غير معروفة الرجاء اختيار الصيغة الصحيحة مثل : JPG, GIF أو PNG");
				return false;		
			}
		}
	}
	
	
	
	
	
	
	
	
	
	
	
			
	
	
	function validate_username(){
			/*var str = document.frmRegister.username.value;
			var regExp = / /g;
			var tmp = document.frmRegister.username.value;
			tmp = tmp.replace(regExp,'');
			if (tmp.length <= 0) {
				alert("اسم المستخدم فارغ ,الرجاء كتابة اسم المستخدم");
				document.frmRegister.username.select();
				document.frmRegister.username.focus();
			return false;
			}
		return true;*/
		var str = document.frmRegister.username.value;
			var regExp = / /g;
			var RegExpCharsNumOnly = /^[A-z0-9]+$/; 
			var tmp = document.frmRegister.username.value;
			tmp = tmp.replace(regExp,'');
			if (tmp.length <= 0) {
				alert("اسم المستخدم غير موجود الرجاء كتابة اسم المستخدم");
				document.frmRegister.username.select();
				document.frmRegister.username.focus();
				return false;
			}
			if (tmp.length > 0) {
				if(!RegExpCharsNumOnly.test(str)){
					alert("الحروف والأرقام فقط مسموحة الفراغات غير مسموحة");
					document.frmRegister.username.select();
					document.frmRegister.username.focus();
					return false;
				}
			}
		return true;
	}
	
	function validate_password(){
			
			var str = document.frmRegister.password.value;
			var regExp = / /g;
			var RegExpCharsNumOnly = /^[A-z0-9]+$/; 
			var tmp = document.frmRegister.password.value;
			tmp = tmp.replace(regExp,'');
			if (tmp.length <= 0) {
				alert("كلمة المرور فارغة ,الرجاء كتابة كلمة المرور");
				document.frmRegister.password.select();
				document.frmRegister.password.focus();
				return false;
			}
			if (tmp.length > 0) {
				if(!RegExpCharsNumOnly.test(str)){
					alert("الحروف والأرقام فقط مسموحة الفراغات غير مسموحة");
					document.frmRegister.password.select();
					document.frmRegister.password.focus();
					return false;
				}
			}
		return true;
	}
	
	function validate_old_password(){
			var str = document.frmRegister.old_password.value;
			var regExp = / /g;
			var tmp = document.frmRegister.old_password.value;
			tmp = tmp.replace(regExp,'');
			if (tmp.length <= 0) {
				alert("كلمة المرور السابقة فارغة الرجاء كتابة كلمة المرور السابقة");
				document.frmRegister.old_password.select();
				document.frmRegister.old_password.focus();
			return false;
			}
		return true;
	}
	
	function validate_confirm_password(){
			
			var str = document.frmRegister.confirm_password.value;
			var regExp = / /g;
			var RegExpCharsNumOnly = /^[A-z0-9]+$/; 
			var tmp = document.frmRegister.confirm_password.value;
			tmp = tmp.replace(regExp,'');
			if (tmp.length <= 0) {
				alert("تأكيد كلمة المرور فارغ الرجاء تأكيد كلمة المرور");
				document.frmRegister.confirm_password.select();
				document.frmRegister.confirm_password.focus();
				return false;
			}
			if (tmp.length > 0) {
				if(!RegExpCharsNumOnly.test(str)){
					alert("الحروف والأرقام فقط مسموحة الفراغات غير مسموحة");
					document.frmRegister.confirm_password.select();
					document.frmRegister.confirm_password.focus();
					return false;
				}
			}
		return true;
	}
	
	function validate_ispassword_same(){
			var str1 = document.frmRegister.password.value;
			var str2 = document.frmRegister.confirm_password.value;
			
			if (str1 != str2) {
				alert("عدم تطابق في كلمة المرور الرجاء كتابة نفس كلمة المرور في كلا الحقلين");
				document.frmRegister.confirm_password.select();
				document.frmRegister.confirm_password.focus();
			return false;
			}
		return true;
	}
	
	function validate_email(){
		var str = document.frmRegister.email.value;
		if (str == "") {
			alert("Email address is blank. Please write your email address.");
			document.frmRegister.email.select();
			document.frmRegister.email.focus();
		return false;
		}else{
			var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
			var address = document.frmRegister.email.value;
			if(reg.test(address) == false) {
				alert('Invalid email address. Please write correct email address.');
				document.frmRegister.email.select();
				document.frmRegister.email.focus();
			return false;
			}
		}
	}
	function validate_phone(){
			var str = document.frmRegister.phone.value;
			var regExp = / /g;
			var tmp = document.frmRegister.phone.value;
			tmp = tmp.replace(regExp,'');
			if (tmp.length <= 0) {
				alert("Phone number is blank. Please write phone number.");
				document.frmRegister.phone.select();
				document.frmRegister.phone.focus();
			return false;
			}
		return true;
	}
	
	function validate_comments(){
			var str = document.frmRegister.comments.value;
			var regExp = / /g;
			var tmp = document.frmRegister.comments.value;
			tmp = tmp.replace(regExp,'');
			if (tmp.length <= 0) {
				alert("Comments are blank. Please write comments.");
				document.frmRegister.comments.select();
				document.frmRegister.comments.focus();
			return false;
			}
		return true;
	}
	
	
	// =========================== ================================================
	
	function validate_job_title(){
			var str = document.frmRegister.job_title.value;
			var regExp = / /g;
			var tmp = document.frmRegister.job_title.value;
			tmp = tmp.replace(regExp,'');
			if (tmp.length <= 0) {
				alert("المسمى الوظيفي غير موجود الرجاء كتابة المسمى الوظيفي");
				document.frmRegister.job_title.select();
				document.frmRegister.job_title.focus();
			return false;
			}
		return true;
	}

	function validate_fullname(){
			var str = document.frmRegister.fullname.value;
			var regExp = / /g;
			var tmp = document.frmRegister.fullname.value;
			tmp = tmp.replace(regExp,'');
			if (tmp.length <= 0) {
				alert("Fullname is blank. Please write your fullname.");
				document.frmRegister.fullname.select();
				document.frmRegister.fullname.focus();
			return false;
			}
		return true;
	}
		
	
	// =========================== VALIDATION FOR CONTACT US FORM ==========================================

	function validate_contact_name(){
		
			var str = document.frmContactUsForm.name.value;
			var regExp = / /g;
			var RegExpCharsOnly = /^[A-z ]+$/; 
			var tmp = document.frmContactUsForm.name.value;
			tmp = tmp.replace(regExp,'');
			if (tmp.length <= 0) {
				alert("الاسم الكامل غير موجود الرجاء كتابة الاسم الكامل ");
				document.frmContactUsForm.name.select();
				document.frmContactUsForm.name.focus();
				return false;
			}
			if (tmp.length > 0) {
				if(!RegExpCharsOnly.test(str)){
					alert("الحروف فقط مسموحة ");
					document.frmContactUsForm.name.select();
					document.frmContactUsForm.name.focus();
					return false;
				}
			}
		return true;
	}
	
	function validate_contact_subject(){
			var str = document.frmContactUsForm.subject.value;
			var regExp = / /g;
			var tmp = document.frmContactUsForm.subject.value;
			tmp = tmp.replace(regExp,'');
			if (tmp.length <= 0) {
				alert("الموضوع غير موجود ,الرجاء إضافة الموضوع");
				document.frmContactUsForm.subject.select();
				document.frmContactUsForm.subject.focus();
			return false;
			}
		return true;
	}
	function validate_contact_comments(){
			var str = document.frmContactUsForm.comments.value;
			var regExp = / /g;
			var tmp = document.frmContactUsForm.comments.value;
			tmp = tmp.replace(regExp,'');
			if (tmp.length <= 0) {
				alert("التعليق غير موجود الرجاء إضافة تعليقك");
				document.frmContactUsForm.comments.select();
				document.frmContactUsForm.comments.focus();
			return false;
			}
		return true;
	}
	
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}



//=====================================================================================




// =========================== VALIDATION FOR CONTACT AD OWNER FORM ==========================================
	
	
	




	
-->
