﻿function disableEnterKey(e)
{
     var key;      
     if(window.event)
          key = window.event.keyCode; //IE
     else
          key = e.which; //firefox      

     return (key != 13);
}

function checkForm()
{
   var cname, cprovince, num ;
   with(window.document.form1)
   {
      cname    = SearchString;
      cprovince   = province;
   }
   

   if(trim(cname.value) =='')
   {
      alert('الرجاء ادخال اسم الشركة');
      cname.focus();
      return false;
   }
   
   else if(trim(cprovince.value) == '')
   {
      alert('الرجاء اختيار محافظة');
      cprovince.focus();
      return false;
   }
      
   else
   {
      cname.value    = trim(cname.value);
      cprovince.value   = trim(cprovince.value);
	  if(lengthRestriction(cname, 3, 30)){
      return true;
	  }else{
		return false;
	  }
   }
}

function trim(str)
{
   return str.replace(/^\s+|\s+$/g,'');
}

function lengthRestriction(elem, min, max){
	var cname = elem.value;
	if(cname.length >= min && cname.length <= max){
		return true;
	}else{
		alert("عدد الاحرف لاسم الشركة يجب ان يكون بين " +min+" و "+max+" حرف ");
		elem.focus();
		return false;
	}
}


<!-- EYAD -->

function checkForm2()
{
   var val1 ;
   var val4 ;
   
   with(window.document.f1)
   {
      val1   = name;
	  val4   = cat.options[cat.options.selectedIndex];
   }
   

   if((trim(val1.value) =='') && (val4.value =='') )
   {
      alert('الرجاء كتابة اسم او اختيار تصنيف');
      val1.focus();
      return false;
   }
   
   else
   {
   	  if(val4.value == ''){
      val1.value    = trim(val1.value);
	  if(lengthRestriction(val1, 3, 30)){
      return true;
	  }else{
		return false;
	  }
	  }
   }
}

function trim(str)
{
   return str.replace(/^\s+|\s+$/g,'');
}

function lengthRestriction(elem, min, max){
	var val1 = elem.value;
	if(val1.length >= min && val1.length <= max){
		return true;
	}else{
		alert("عدد الاحرف لاسم الشركة يجب ان يكون بين " +min+" و "+max+" حرف ");
		elem.focus();
		return false;
	}
}




<!-- EYAD -->



function reload1(form)
{

	if(f1.typ[0].checked == true){
		var val5 = f1.typ[0].value;

	}else if(f1.typ[1].checked == true){
		var val5 = f1.typ[1].value;

	}else {
		alert("الرجاء اختيار نوع البحث");
		return false;
	}

var val1=form.name.value;
var val=form.province.options[form.province.options.selectedIndex].value; 
var val2='';
var val3='';
var val4=form.cat.options[form.cat.options.selectedIndex].value;
var val6=form.scat.options[form.scat.options.selectedIndex].value;	
self.location='index.php?var=advancedsearch&typ=' + val5 + '&name=' + val1 + '&province=' + val + '&city=' + val2 + '&area=' + val3 + '&cat=' + val4 + '&scat=' + val6;


}

function reload2(form)
{

	if(f1.typ[0].checked == true){
		var val5 = f1.typ[0].value;

	}else if(f1.typ[1].checked == true){
		var val5 = f1.typ[1].value;

	}else {
		alert("الرجاء اختيار نوع البحث");
		return false;
	}

var val1=form.name.value;
var val=form.province.options[form.province.options.selectedIndex].value; 
var val2=form.city.options[form.city.options.selectedIndex].value; 
var val3='';
var val4=form.cat.options[form.cat.options.selectedIndex].value;
var val6=form.scat.options[form.scat.options.selectedIndex].value;	
self.location='index.php?var=advancedsearch&typ=' + val5 + '&name=' + val1 + '&province=' + val + '&city=' + val2 + '&area=' + val3 + '&cat=' + val4 + '&scat=' + val6;

}

function reload3(form)
{

	if(f1.typ[0].checked == true){
		var val5 = f1.typ[0].value;

	}else if(f1.typ[1].checked == true){
		var val5 = f1.typ[1].value;

	}else {
		alert("الرجاء اختيار نوع البحث");
		return false;
	}

var val1=form.name.value;
var val=form.province.options[form.province.options.selectedIndex].value; 
var val2=form.city.options[form.city.options.selectedIndex].value; 
var val3=form.area.options[form.area.options.selectedIndex].value; 
var val4=form.cat.options[form.cat.options.selectedIndex].value;
var val6=form.scat.options[form.scat.options.selectedIndex].value;	
self.location='index.php?var=advancedsearch&typ=' + val5 + '&name=' + val1 + '&province=' + val + '&city=' + val2 + '&area=' + val3 + '&cat=' + val4 + '&scat=' + val6;


}

function reload4(form)
{

	if(f1.typ[0].checked == true){
		var val5 = f1.typ[0].value;

	}else if(f1.typ[1].checked == true){
		var val5 = f1.typ[1].value;

	}else {
		alert("الرجاء اختيار نوع البحث");
		return false;
	}

var val1=form.name.value;
var val=form.province.options[form.province.options.selectedIndex].value; 
var val2=form.city.options[form.city.options.selectedIndex].value; 
var val3=form.area.options[form.area.options.selectedIndex].value; 
var val4=form.cat.options[form.cat.options.selectedIndex].value;
var val6='';
self.location='index.php?var=advancedsearch&typ=' + val5 + '&name=' + val1 + '&province=' + val + '&city=' + val2 + '&area=' + val3 + '&cat=' + val4 + '&scat=' + val6;


}

function reload5(form)
{

	if(f1.typ[0].checked == true){
		var val5 = f1.typ[0].value;

	}else if(f1.typ[1].checked == true){
		var val5 = f1.typ[1].value;

	}else {
		alert("الرجاء اختيار نوع البحث");
		return false;
	}

var val1=form.name.value;
var val=form.province.options[form.province.options.selectedIndex].value; 
var val2=form.city.options[form.city.options.selectedIndex].value; 
var val3=form.area.options[form.area.options.selectedIndex].value; 
var val4=form.cat.options[form.cat.options.selectedIndex].value;
var val6=form.scat.options[form.scat.options.selectedIndex].value; 
self.location='index.php?var=advancedsearch&typ=' + val5 + '&name=' + val1 + '&province=' + val + '&city=' + val2 + '&area=' + val3 + '&cat=' + val4 + '&scat=' + val6;


}
