var EntryTypes = new Array("emailEntry","numberEntry","dateTimeEntry","selectEntry","checkBox","WebSite","multiSelectionListBox");
	var EMAIL_DATA_TYPE = EntryTypes[0];
	var NUMBER_DATA_TYPE = EntryTypes[1];
	var DATE_DATA_TYPE = EntryTypes[2];
	var COMBO_BOX_DATA_TYPE = EntryTypes[3];
	var CHECKBOX_DATA_TYPE = EntryTypes[4];    
	var WEB_SITE_URL_DATA_TYPE = EntryTypes[5]; 
	var MULTISELECT_LIST_BOX_DATA_TYPE = EntryTypes[6];

var ErrorMessages = new Array("wrong email","must be a number","wrong date formula","Can't take first choice","not a web site","must be longer than","must be less  than","must not contain these charachters","must be selected","can't be empty" , "must specify the search area" , "must select an item"); 
	var ERROR_NOT_VALID_EMAIL = ErrorMessages[0];
	var ERROR_NOT_VALID_NUMBER = ErrorMessages[1];
	var ERROR_NOT_VALID_DATE = ErrorMessages[2];
	var ERROR_FIRST_CHOICE_FORBIDDEN = ErrorMessages[3];
	var ERROR_NOT_VALID_WEB_SITE = ErrorMessages[4];
	var ERROR_LESS_THAN_REQUIRED = ErrorMessages[5];
	var ERROR_GREATER_THAN_REQUIRED = ErrorMessages[6];
	var ERROR_HAVE_INVALID_LETTERS = ErrorMessages[7];
	var ERROR_MUST_BE_CHECKED = ErrorMessages[8];
	var ERROR_CANNOT_BE_NULL = ErrorMessages[9];
	var ERROR_MUST_SELECT_SEARCH_CRITERIA = ErrorMessages[10];
	var ERROR_AT_LEAST_ONE_ITEM_SELECTED =  ErrorMessages[11];

var ValidDomainExtensions = new Array("com" ,"net","gov","org","edu","biz" ,"tv","us"); 

function CheckSubscription(FormObject)
{
  
	var obj = GetFormFieldByName(FormObject,"EmiratesCheckBox");
	var obj2 = GetFormFieldByName(FormObject,"AgreementsCheckBox");
	if (!obj.checked && obj2.checked)
	{
	alert("لا يمكن الاشتراك في المعاهدات فقط لانها عرض خاص");
	obj.focus();
	return false;
	} 
	 
	
	return true;
	  
	
  
}


function ClientResponse(obj,message){
	    alert(message);
		try
		{
			if ( obj.type != "hidden" ){
				obj.focus();
			}
			
			if (obj.type == "text" || obj.type == "textarea")
			{
				obj.select();
			}
		}
		catch(e)
		{
		}
}

function isNull(obj){
	if (!obj)
	{
		return true;
	}
	return false;
}

function isFirstSelected(obj){
	if(obj.value==0)
	{
		return true;
	}
	return false;
}

function isEmpty(obj)
{
str=obj.value;
str = str.replace(/^\s*|\s*$/g,"");
		if(str == "")
		{
			return true;
		}//end if
		return false;
}

function isNumber(obj){
		if(isNaN(obj.value))
		{
			return false;
		}
		return true;
}

function check_email(obj){

	
	if (obj.value.indexOf(" ") != -1)
	{
		return false;
	}
	
	var EmailPortions = obj.value.split("@");
	if (EmailPortions.length != 2)
	{
		return false;
	}

	if (EmailPortions[0] == "")
	{
		return false;
	}
	
	if (EmailPortions[1] == ""){
		return false;
	}
	
	EmailPortions = EmailPortions[1].split(".");
	if (EmailPortions.length < 2)
	{
		return false;
	}
	
	if(EmailPortions[0] == "")
	{
		return false;
	}
	
	//var validDomain = false;
	//Always Valid Domain
	var validDomain = true;
	for (i=0;i<ValidDomainExtensions.length;i++)
	{
		if(EmailPortions[1].toLowerCase() == ValidDomainExtensions[i].toLowerCase())
		{
			validDomain = true;
			break; 
		}
	}
	if (!validDomain)
	{
		return false;
	}
	return true;
}

function multipleValidation(FormObject,FieldsIndexes,RequiredArray,ValidationTypeArray,MinimumLengthArray,MaximumLengthArray,RubbishTextArray)
{
	for (i=0;i<FieldsIndexes.length;i++)
	{
			if (!ValidationTemplate(FormObject.item(FieldsIndexes[i]),RequiredArray[i],ValidationTypeArray[i],MinimumLengthArray[i],MaximumLengthArray[i],RubbishTextArray[i]) )
			{
				return false;
			}
	} 
	return true;
}

function ValidationTemplate(obj,Required,dataType,LengthGreaterThan,LengthLessThan,DoNotContain)
{
	var k=0;
	
	if ( !isNull(obj)  )
	{
		
		var FieldCaption = obj.name;
		if (ValidationTemplate.arguments.length > 6) 
		{
			FieldCaption = ValidationTemplate.arguments[6];
		}
		
		if (Required == true)
		{
			switch(obj.type)
			{
				
				case "checkbox":
					if(obj.checked == false)
					{
						ClientResponse(obj,FieldCaption+" "+ERROR_MUST_BE_CHECKED); 
						return false;
					}
				case "select-multiple":
					if(isEmpty(obj))
					{
						ClientResponse(obj,ERROR_AT_LEAST_ONE_ITEM_SELECTED+" "+FieldCaption); 
						return false;
					}
					break;
				default:
					if(isEmpty( obj ) )
					{
						ClientResponse(obj,FieldCaption+" "+ERROR_CANNOT_BE_NULL); 
						return false;
					}
					break;
			}
		}
		else
		{
			switch(obj.type)
			{
				
				case "checkbox":
					if(obj.checked == false)
					{
						return true;
					}
				default:
					if(isEmpty( obj ) )
					{
						return true;					
					}
					break;
		    }
		}
		
		switch( dataType )
		{
			
			case EntryTypes[0] :
				
				if (obj.value.indexOf(" ") != -1)
				{
					ClientResponse(obj,FieldCaption+" "+ERROR_NOT_VALID_EMAIL);
					return false;
				}
				if( !( check_email(obj) )  )
				{
					ClientResponse(obj,FieldCaption+" "+ERROR_NOT_VALID_EMAIL); 
					return false;
				}
				break;
			
			case EntryTypes[1]:
				if( !isNumber( obj )  )
				{
					ClientResponse(obj,FieldCaption+" "+ERROR_NOT_VALID_NUMBER); 
					return false;
				}
				break;
			
			case EntryTypes[2]:
				if( !check_date( obj ,dateFormat )  )
				{
					ClientResponse(obj,FieldCaption+" "+ERROR_NOT_VALID_DATE); 
					return false;
				}
				break;
			
			case EntryTypes[3]:
				if( isFirstSelected( obj)  )
				{
					ClientResponse(obj,FieldCaption+" "+ERROR_FIRST_CHOICE_FORBIDDEN); 
					return false;
				}
				break;
			
			case EntryTypes[5]:
				if( !check_WebSite(obj)  )
				{
					ClientResponse(obj,FieldCaption+" "+ERROR_NOT_VALID_WEB_SITE); 
					return false;
				}
				break;
			
			case EntryTypes[6]:
				var isValidListBox = false;
				for(i=0 ; i<obj.options.length;i++)
				{
					if(obj.options[i].selected)
					{
						isValidListBox = true;
						break;
					}
				}
				if(!isValidListBox)
				{
					ClientResponse(obj,ERROR_AT_LEAST_ONE_ITEM_SELECTED+" "+FieldCaption); 
					return false;
				}
				break; 
		}
		if ( LengthGreaterThan != -1 )
		{
			if(	isLengthLessThanExpected(obj,LengthGreaterThan ))
			{
				ClientResponse(obj,FieldCaption+" "+ERROR_LESS_THAN_REQUIRED+" "+LengthGreaterThan); 
				return false;
			}
		}
		
		if ( LengthLessThan != -1 )
		{
			if(	isLengthGreaterThanExpected (obj,LengthLessThan ))
			{
				ClientResponse(obj,FieldCaption+" "+ERROR_GREATER_THAN_REQUIRED+" "+LengthLessThan); 
				return false;
			}
		}
	
	   for (k = 0; k < DoNotContain.length; k++) 
	   {
			if (  contains(obj,DoNotContain.substr(k,1) )  ) 
			{
				ClientResponse(obj,FieldCaption+" "+ERROR_HAVE_INVALID_LETTERS+" ("+DoNotContain+")"  ); 
				return false;
			}
		}
		return true;		
	}
	else
	{
		return true;
	}
}

function isLengthLessThanExpected(obj,leastLength){
		if(obj.value.length < leastLength )
		{
			return true;
		}//end if
		return false;
}

function contains(obj,stringToSearch){
		if( obj.value.toUpperCase().indexOf(stringToSearch.toUpperCase()) != -1  )
		{
			return true;
		}//end if
		return false;
}
function isLengthGreaterThanExpected(obj,MaximumLength){
		if(obj.value.length > MaximumLength )
		{
			return true;
		}//end if
		return false;
}
function GetFormFieldByName(FormObject,FieldName)
{

		var i = 0;
		try{

			
			while (FormObject.elements.item(i) != null)
			{
			
				//if a field with name contains field name return this field
				if( FormObject.elements.item(i).name.toUpperCase().indexOf(FieldName.toUpperCase()) != -1  )
				{
				
					return FormObject.elements.item(i);
				}//end if
				i++;
			}
		}
		catch(e){}
		return null;
}

//---------------------------------------------------------
function ValidateFolderFormForm(FormObject)
{
    var obj = GetFormFieldByName(FormObject,"txtFolderName");
    if(!ValidationTemplate(obj,true,"text",2,250,"<>","folder name"))
	{
	   
		return false;
	}
	
	  var obj = GetFormFieldByName(FormObject,"txtOder");
     if(!ValidationTemplate(obj,true,EntryTypes[1],-1,250,"'?%&@(*=/\!~.,-);,<>[]+^$#","order "))
	{
	   
		return false;
	}
	
}


function ValidatePageFormForm(FormObject)
{
   // var obj  = GetFormFieldByName(FormObject,"txtPage");
   // if(!ValidationTemplate(obj,true,EntryTypes[1],-1,250,"'?%&@(*=/\!~.,-);,<>[]+^$#","رقم الصفحة  "))
	//{
	   
	//	return false;
	//}
	
	  var obj = GetFormFieldByName(FormObject,"txtContent");
     if(!ValidationTemplate(obj,true,"text",2,50000,"","page content "))
	{
	   
		return false;
	}
	
}

function ValidateSimpleFileForm(FormObject)
{
    var obj = GetFormFieldByName(FormObject,"txtFileName");
    if(!ValidationTemplate(obj,true,"text",2,500,"<>","document name    "))
	{
	   
		return false;
	}
	
	obj = GetFormFieldByName(FormObject,"txtSummary");
    if(!ValidationTemplate(obj,true,"text",2,500,"<>","document summary   "))
	{
	   
		return false;
	}
	
	
	obj = GetFormFieldByName(FormObject,"txtContent");
    if(!ValidationTemplate(obj,true,"text",2,50000,"'<>","document content   "))
	{
	   
		return false;
	}
	
	
	
	
	   obj = GetFormFieldByName(FormObject,"txtOrder");
     if(!ValidationTemplate(obj,true,EntryTypes[1],-1,250,"'?%&@(*=/\!~.,-);,<>[]+^$#","document order  "))
	{
	   
		return false;
	}
	
}


function ValidateNewsFileForm(FormObject)
{
    var obj = GetFormFieldByName(FormObject,"txtName");
    if(!ValidationTemplate(obj,true,"text",2,500,"<>","document name   "))
	{
	   
		return false;
	}
	
	obj = GetFormFieldByName(FormObject,"txtSummary");
    if(!ValidationTemplate(obj,true,"text",2,500,"<>","documnet summary  "))
	{
	   
		return false;
	}
	
	
	obj = GetFormFieldByName(FormObject,"txtNumber");
    if(!ValidationTemplate(obj,true,EntryTypes[1],-1,250,"'?%&@(*=/\!~.,-);,<>[]+^$#","issue number  "))
	{
	   
		return false;
	}
	
	obj = GetFormFieldByName(FormObject,"txtPublishDate");
    if(!ValidationTemplate(obj,true,"text",2,250,"<>"," date"))
	{
	   
		return false;
	}
	
	
	
	
}


function ValidateJudgmentFileForm(FormObject)
{
    var obj = GetFormFieldByName(FormObject,"txtTitle");
    if(!ValidationTemplate(obj,true,"text",1,10000,"<>","document name    "))
	{
	   
		return false;
	}
	
	obj = GetFormFieldByName(FormObject,"txtSummary");
    if(!ValidationTemplate(obj,true,"text",2,10000,"<>","document summary  "))
	{
	   
		return false;
	}
	
	
	obj = GetFormFieldByName(FormObject,"txtNumber");
    if(!ValidationTemplate(obj,true,EntryTypes[1],-1,250,"'?%&@(*=/\!~.,-);,<>[]+^$#","issue number  "))
	{
	   
		return false;
	}
	  	obj = GetFormFieldByName(FormObject,"cmbEmirates");
   
	if( !ValidationTemplate(obj,true,"selectEntry",1,-1,"","select Circle please")  )
	{
		return false;
	}
	 	obj = GetFormFieldByName(FormObject,"cmbJudements");
   
	if( !ValidationTemplate(obj,true,"selectEntry",1,-1,"","select court please")  )
	{
		return false;
	}
	
	obj = GetFormFieldByName(FormObject,"cmbCircles");
   
	if( !ValidationTemplate(obj,true,"selectEntry",1,-1,"","select circle please")  )
	{
		return false;
	}
	obj = GetFormFieldByName(FormObject,"cmbYear");
   
	if( !ValidationTemplate(obj,true,"selectEntry",1,-1,"","Select year please")  )
	{
		return false;
	}
	obj = GetFormFieldByName(FormObject,"txtContent");
    if(!ValidationTemplate(obj,true,"text",2,50000,"<>","content   "))
	{
	   
		return false;
	}
	
	
	
}


function ValidateLeglisationFileForm(FormObject)
{
    var obj = GetFormFieldByName(FormObject,"txtName");
    if(!ValidationTemplate(obj,true,"text",2,500,"<>","document name    "))
	{
	   
		return false;
	}
	
	obj = GetFormFieldByName(FormObject,"txtSummary");
    if(!ValidationTemplate(obj,true,"text",2,500,"<>","documnet summary  "))
	{
	   
		return false;
	}
	
	obj = GetFormFieldByName(FormObject,"cmbEmirates");
   
	if( !ValidationTemplate(obj,true,"selectEntry",1,-1,"","Select Circle please")  )
	{
		return false;
	}
	obj = GetFormFieldByName(FormObject,"cmblegisations");
   
	if( !ValidationTemplate(obj,true,"selectEntry",1,-1,"","Select legalisation  please")  )
	{
		return false;
	}
	
	
	obj = GetFormFieldByName(FormObject,"txtNumber");
	if (obj.value=="")
	{
	return true;
	}
     if(isNaN(obj.value))
		{
		 alert("Enter number please");
			return false;
		}
		return true;
  
  
}


function ValidateFormItemsForm(FormObject)
{
    var obj = GetFormFieldByName(FormObject,"txtFormTitle");
    if(!ValidationTemplate(obj,true,"text",2,250,"<>","form item title    "))
	{
	   
		return false;
	}
	obj = GetFormFieldByName(FormObject,"txtFormName");
    if(!ValidationTemplate(obj,true,"text",2,250,"<>"," form item name   "))
	{
	   
		return false;
	}
	obj = GetFormFieldByName(FormObject,"txtFormCaption");
    if(!ValidationTemplate(obj,true,"text",2,250,"<>"," form item caption    "))
	{
	   
		return false;
	}
	obj = GetFormFieldByName(FormObject,"txtFormOrder");
	if(!ValidationTemplate(obj,true,EntryTypes[1],-1,250,"'?%&@(*=/\!~.,-);,<>[]+^$#","order   "))
	{
	   
		return false;
	}
	
	
	
}
function ValidateUserType(FormObject)
{
    var obj = GetFormFieldByName(FormObject,"txtUserType");
    if(!ValidationTemplate(obj,true,"text",2,250,"<>","user type"))
	{
	   obj.focus();
		return false;
	}

	
}

function ValidateCountry(FormObject)
{
    var obj = GetFormFieldByName(FormObject,"txtCountryName");
    if(!ValidationTemplate(obj,true,"text",2,250,"<>","country name "))
	{
	   obj.focus();
		return false;
	}

	
}

//txtEmirateName

function ValidateEmirate(FormObject)
{
    var obj = GetFormFieldByName(FormObject,"txtEmirateName");
    if(!ValidationTemplate(obj,true,"text",2,250,"<>","emarah name "))
	{
	   obj.focus();
		return false;
	}

	
}


function ValidateQuestions(FormObject)
{
    var obj = GetFormFieldByName(FormObject,"txtQuestion");
    if(!ValidationTemplate(obj,true,"text",2,250,"'?%&@(*=/\!~.,-);,<>[]+^$#","question "))
	{
	   obj.focus();
		return false;
	}

	
}



function ValidateAdminUserForm(FormObject)
{
    
  

   var obj = GetFormFieldByName(FormObject,"cmbTypes");
  
   if(!ValidationTemplate(obj,true,EntryTypes[3],1,250,"'?%&@(*=/\!~.,-);,<>[]+^$#","user type"))
	{
	   obj.focus();
		return false;
	}
	
	
	    obj = GetFormFieldByName(FormObject,"cmbYears");
	    
       if(!ValidationTemplate(obj,true,EntryTypes[3],1,250,"'?%&@(*=/\!~.,-);,<>[]+^$#"," "))
	   {
	   obj.focus();
		     return false;
	   }

	
	
	    var obj = GetFormFieldByName(FormObject,"cmbFormDays");
	   
        if(!ValidationTemplate(obj,true,EntryTypes[3],1,250,"'?%&@(*=/\!~.,-);,<>[]+^$#","from day "))
	    {
	   obj.focus();
		    return false;
	    }
	
	   var obj = GetFormFieldByName(FormObject,"cmbFromMonth");
	  
       if(!ValidationTemplate(obj,true,EntryTypes[3],1,250,"'?%&@(*=/\!~.,-);,<>[]+^$#","from month "))
	   {
	   obj.focus();
		   return false;
	   }
	
	 
	
	  var obj = GetFormFieldByName(FormObject,"cmbToDays");
	  
      if(!ValidationTemplate(obj,true,EntryTypes[3],1,250,"'?%&@(*=/\!~.,-);,<>[]+^$#","to day "))
	  {
	   obj.focus();
		   return false;
	   }
	
	   var obj = GetFormFieldByName(FormObject,"cmbToMonth");
	   
       if(!ValidationTemplate(obj,true,EntryTypes[3],1,250,"'?%&@(*=/\!~.,-);,<>[]+^$#","to month "))
	   {
	   obj.focus();
		   return false;
	   } 
	   
	    
	
	 obj = GetFormFieldByName(FormObject,"txtUseName");
	
    if(!ValidationTemplate(obj,true,"text",2,250,"'?%&@(*=/\!~.,-);,<>[]+^$#"," user name     "))
	{
	   obj.focus();
		return false;
	}
	obj = GetFormFieldByName(FormObject,"txtPassword");
	
    if(!ValidationTemplate(obj,true,"text",2,250,"'?%&@(*=/\!~.,-);,<>[]+^$#"," Password    "))
	{
	   obj.focus();
		return false;
	}
	obj = GetFormFieldByName(FormObject,"txtConfrimPassword");
	
	if(!ValidationTemplate(obj,true,"text",-1,250,"'?%&@(*=/\!~.,-);,<>[]+^$#","Password confirmation   "))
	{
	   obj.focus();
		return false;
	}
	
	var Password=GetFormFieldByName(FormObject,"txtPassword");
	var ConfirmPassword =GetFormFieldByName(FormObject,"txtConfrimPassword");
	
	try
	{
   if (Password.value!=ConfirmPassword.value)
	{
	 alert("Password and its confirmation are not identical");
	 obj.focus();
	return false;
	}
	}
	catch(ex)
	{
	}
	
	obj = GetFormFieldByName(FormObject,"txtEmail");
	
	if(!ValidationTemplate(obj,true,EntryTypes[0],-1,250,"<>","email   "))
	{
	   obj.focus();
		return false;
	}
	
	obj = GetFormFieldByName(FormObject,"txtAltEmail");
	 
	if(!ValidationTemplate(obj,false,EntryTypes[0],-1,250,"<>","Alter email   "))
	{
	   obj.focus();
		return false;
	}
	
	obj = GetFormFieldByName(FormObject,"CmbQuestions");
	
   if(!ValidationTemplate(obj,false,EntryTypes[3],1,250,"'?%&@(*=/\!~.,-);,<>[]+^$#","reminding question "))
	{
	   obj.focus();
		return false;
	}
	
	obj = GetFormFieldByName(FormObject,"txtReplay");
	 
	if(!ValidationTemplate(obj,false,"text",-1,250,"'?%&@(*=/\!~.,-);,<>[]+^$#","replay     "))
	{
	   obj.focus();
		return false;
	}
	
	obj = GetFormFieldByName(FormObject,"txtLastName");
	 
	 if(!ValidationTemplate(obj,false,"text",2,250,"'?%&@(*=/\!~.,-);,<>[]+^$#"," last name     "))
	{
	   obj.focus();
		return false;
	}
	
	obj = GetFormFieldByName(FormObject,"txtFullName");
	 
	 if(!ValidationTemplate(obj,true,"text",2,250,"'?%&@(*=/\!~.,-);,<>[]+^$#"," full name     "))
	{
	   obj.focus();
		return false;
	}
	
	
	obj = GetFormFieldByName(FormObject,"txtAddress");
	
	 if(!ValidationTemplate(obj,false,"text",2,250,"'?%&@(*=/\!~.,-);,<>[]+^$#"," Address     "))
	{
	   obj.focus();
		return false;
	}
	
	
	obj = GetFormFieldByName(FormObject,"txtMobile");
	
	if(!ValidationTemplate(obj,false,EntryTypes[1],-1,250,"'?%&@(*=/\!~.,-);,<>[]+^$#","Mobile   "))
	{
	   obj.focus();
		return false;
	}
	
	obj = GetFormFieldByName(FormObject,"cmbCountries");
	
   if(!ValidationTemplate(obj,true,EntryTypes[3],1,250,"'?%&@(*=/\!~.,-);,<>[]+^$#","Country"))
	{
	   obj.focus();
		return false;
	}
	
	
	
	obj = GetFormFieldByName(FormObject,"cmbManager");
	 
   if(!ValidationTemplate(obj,true,EntryTypes[3],1,250,"'?%&@(*=/\!~.,-);,<>[]+^$#","Marketing manager"))
	{
	   obj.focus();
		return false;
	}
	
	obj = GetFormFieldByName(FormObject,"txtUserNo");
	 
	if(!ValidationTemplate(obj,true,EntryTypes[1],-1,250,"'?%&@(*=/\!~.,-);,<>[]+^$#","number of users authorized to activate"))
	{
	   obj.focus();
		return false;
	}
	
	try
	{
	 var objToYear = GetFormFieldByName(FormObject,"cmbToYear");
     var objFormYear = GetFormFieldByName(FormObject,"CmbFromYear");

      if (objToYear.selectedIndex ==objFormYear.selectedIndex )
         {
 
             var objToMonth = GetFormFieldByName(FormObject,"cmbToMonth");
             var objFormMonth = GetFormFieldByName(FormObject,"cmbFromMonth");
           
            if (objToMonth.selectedIndex >objFormMonth.selectedIndex)
            {
                 return true
            }
            else if (objToMonth.selectedIndex == objFormMonth.selectedIndex)
            {
                  var objToDay = GetFormFieldByName(FormObject,"cmbToDays");
                  var objFormDay= GetFormFieldByName(FormObject,"cmbFormDays");
        
                  if(objToDay.selectedIndex >objFormDay.selectedIndex)
                  {
                       return true;
                  }
                  else
                  {
                       alert ("Please enter correct date");
                        return false;
                  }
             }
             else
             {
                  alert ("Please enter correct date");
                  return false;
             }
    
         }
   else  if (objToYear.selectedIndex <objFormYear.selectedIndex )
  {
    alert ("Please enter correct date");
      return false;
  }
  }
  catch(ex)
  {
  }
}

function ValidateUserForm(FormObject)
{
   var obj = GetFormFieldByName(FormObject,"cmbTypes");
  
   if(!ValidationTemplate(obj,true,EntryTypes[3],1,250,"'?%&@(*=/\!~.,-);,<>[]+^$#","user type"))
	{
	   obj.focus();
		return false;
	}
	
	    obj = GetFormFieldByName(FormObject,"ckTrial");
	     obj2 = GetFormFieldByName(FormObject,"ckMultipleUsers");
	    if(obj.checked )
	    {
	     obj = GetFormFieldByName(FormObject,"txtTrial");
	     if(!ValidationTemplate(obj,true,EntryTypes[1],-1,250,"'?%&@(*=/\!~.,-);,<>[]+^$#","number of days   "))
	     {
	          obj.focus();
		     return false;
	      }
	       
	    }
	   
       else if(obj2.checked)
       {
          obj = GetFormFieldByName(FormObject,"txtMultipleUSers");
	     if(!ValidationTemplate(obj,true,EntryTypes[1],-1,250,"'?%&@(*=/\!~.,-);,<>[]+^$#"," number of users    "))
	     {
	          obj.focus();
		     return false;
	      }
       
       }
	
	    obj = GetFormFieldByName(FormObject,"cmbYears");
	   
       if(!ValidationTemplate(obj,true,EntryTypes[3],1,250,"'?%&@(*=/\!~.,-);,<>[]+^$#"," "))
	   {
	   obj.focus();
		     return false;
	   }

	
	
	    var obj = GetFormFieldByName(FormObject,"cmbFormDays");
	    
        if(!ValidationTemplate(obj,true,EntryTypes[3],1,250,"'?%&@(*=/\!~.,-);,<>[]+^$#","from day "))
	    {
	   obj.focus();
		    return false;
	    }
	
	   var obj = GetFormFieldByName(FormObject,"cmbFromMonth");
	  
       if(!ValidationTemplate(obj,true,EntryTypes[3],1,250,"'?%&@(*=/\!~.,-);,<>[]+^$#","from month "))
	   {obj.focus();
	   
		   return false;
	   }
	
	
	
	  var obj = GetFormFieldByName(FormObject,"cmbToDays");
	  
      if(!ValidationTemplate(obj,true,EntryTypes[3],1,250,"'?%&@(*=/\!~.,-);,<>[]+^$#","to day "))
	  {
	   obj.focus();
		   return false;
	   }
	
	   var obj = GetFormFieldByName(FormObject,"cmbToMonth");
	  
       if(!ValidationTemplate(obj,true,EntryTypes[3],1,250,"'?%&@(*=/\!~.,-);,<>[]+^$#","to month "))
	   {
	   obj.focus();
		   return false;
	   } 
	
	var objTrial=GetFormFieldByName(FormObject,"ckTrial");
	  obj = GetFormFieldByName(FormObject,"txtPayed");
	//  alert(objTrial.checked);
	if(!objTrial.checked) 
	{
		if(!ValidationTemplate(obj,true,EntryTypes[1],-1,250,"'?%&@(*=/\!~.,-);,<>[]+^$#","paid fee   "))
		{
		obj.focus();
			return false;
		}
	
		if (obj.value =="0")
		{
		alert ("paid fee must be more than zero");
		obj.focus();
		return false;
		}
	}
	
	
	 obj = GetFormFieldByName(FormObject,"txtUseName");
	
    if(!ValidationTemplate(obj,true,"text",2,250,"'?%&@(*=/\!~.,-);,<>[]+^$#"," user name     "))
	{
	   obj.focus();
		return false;
	}
	obj = GetFormFieldByName(FormObject,"txtPassword");
	
    if(!ValidationTemplate(obj,true,"text",2,250,"'?%&(*=/\!~,-);,<>[]+^$#"," Password    "))
	{
	   obj.focus();
		return false;
	}
	obj = GetFormFieldByName(FormObject,"txtConfrimPassword");
	
	if(!ValidationTemplate(obj,true,"text",-1,250,"'?%&(*=/\!~,-);,<>[]+^$#","Password confirmation   "))
	{
	   obj.focus();
		return false;
	}
	
	var Password=GetFormFieldByName(FormObject,"txtPassword");
	var ConfirmPassword =GetFormFieldByName(FormObject,"txtConfrimPassword");
	try
	{
	    if (Password.value!=ConfirmPassword.value)
	     {
	           alert("Password and its confirmation are not identical");
	           obj.focus();
	           return false;
	     }
	}
	catch(ex)
	{
	}
	
	obj = GetFormFieldByName(FormObject,"txtEmail");
	
	if(!ValidationTemplate(obj,true,EntryTypes[0],-1,250,"<>","email   "))
	{
	   obj.focus();
		return false;
	}
	
	obj = GetFormFieldByName(FormObject,"txtAltEmail");
	
	if(!ValidationTemplate(obj,false,EntryTypes[0],-1,250,"<>","Alter email   "))
	{
	   obj.focus();
		return false;
	}
	
	
	
	obj = GetFormFieldByName(FormObject,"txtLastName");
	
	 if(!ValidationTemplate(obj,false,"text",1,250,"'?%&@(*=/\!~.,-);,<>[]+^$#"," last name     "))
	{
	   obj.focus();
		return false;
	}
	
	obj = GetFormFieldByName(FormObject,"txtFullName");
	
	 if(!ValidationTemplate(obj,true,"text",1,250,"'?%&@(*=/\!~.,-);,<>[]+^$#"," full name     "))
	{
	   obj.focus();
		return false;
	}
	
	obj = GetFormFieldByName(FormObject,"txtcollage");
	
	 if(!ValidationTemplate(obj,false,"text",2,250,"'?%&@(*=/\!~.,-);,<>[]+^$#"," College    "))
	{
	   obj.focus();
		return false;
	}
	
	obj = GetFormFieldByName(FormObject,"txtUniversity");
	
	 if(!ValidationTemplate(obj,false,"text",2,250,"'?%&@(*=/\!~.,-);,<>[]+^$#"," Unevirsity     "))
	{
	   obj.focus();
		return false;
	}
	
	obj = GetFormFieldByName(FormObject,"txtNumber");
	
	if(!ValidationTemplate(obj,false,EntryTypes[1],-1,250,"'?%&@(*=/\!~.,-);,<>[]+^$#","College number   "))
	{
	   obj.focus();
		return false;
	}
	
	
	obj = GetFormFieldByName(FormObject,"txtAddress");
	
	 if(!ValidationTemplate(obj,false,"text",5,250,"'?%&@(*=/\!~.,-);,<>[]+^$#"," Address     "))
	{
	   obj.focus();
		return false;
	}
		
		obj = GetFormFieldByName(FormObject,"txtBox");
		
	if(!ValidationTemplate(obj,false,EntryTypes[1],-1,250,"'?%&@(*=/\!~.,-);,<>[]+^$#","postal code   "))
	{
	   obj.focus();
		return false;
	}
	
	var str =obj.value;
	if (str.length >= 10)
	{
	  alert("Mail box can't more than 10 ");
	  return false;
	}
		obj = GetFormFieldByName(FormObject,"txtTel");
		
	if(!ValidationTemplate(obj,false,EntryTypes[1],-1,250,"'?%&@(*=/\!~.,-);,<>[]+^$#","office phone   "))
	{
	   obj.focus();
		return false;
	}
		obj = GetFormFieldByName(FormObject,"txtFax");
		
	if(!ValidationTemplate(obj,false,EntryTypes[1],-1,250,"'?%&@(*=/\!~.,-);,<>[]+^$#","fax   "))
	{
	   obj.focus();
		return false;
	}
		
	
	obj = GetFormFieldByName(FormObject,"txtMobile");
	
	if(!ValidationTemplate(obj,false,EntryTypes[1],-1,250,"'?%&@(*=/\!~.,-);,<>[]+^$#","Mobile   "))
	{
	   obj.focus();
		return false;
	}
	
	obj = GetFormFieldByName(FormObject,"cmbCountries");
	
   if(!ValidationTemplate(obj,true,EntryTypes[3],1,250,"'?%&@(*=/\!~.,-);,<>[]+^$#","country  "))
	{
	   obj.focus();
		return false;
	}
	

	
	obj = GetFormFieldByName(FormObject,"cmbManagers");
	
   if(!ValidationTemplate(obj,true,EntryTypes[3],1,250,"'?%&@(*=/\!~.,-);,<>[]+^$#","marketing manager   "))
	{
	   obj.focus();
		return false;
	}
	
	obj = GetFormFieldByName(FormObject,"cmbMarkters");
	
   if(!ValidationTemplate(obj,true,EntryTypes[3],1,250,"'?%&@(*=/\!~.,-);,<>[]+^$#","marketer  "))
	{
	   obj.focus();
		return false;
	}
	
	
	
	
	obj = GetFormFieldByName(FormObject,"txtdiscount");
	
	if(!ValidationTemplate(obj,true,EntryTypes[1],-1,250,"'?%&@(*=/\!~.,-);,<>[]+^$#","  given discount "))
	{
	   obj.focus();
		return false;
	}
	try
	{
	
	var objToYear = GetFormFieldByName(FormObject,"cmbToYear");
     var objFormYear = GetFormFieldByName(FormObject,"CmbFromYear");

      if (objToYear.selectedIndex ==objFormYear.selectedIndex )
         {
        
 
             var objToMonth = GetFormFieldByName(FormObject,"cmbToMonth");
             var objFormMonth = GetFormFieldByName(FormObject,"cmbFromMonth");
             
            if (objToMonth.selectedIndex > objFormMonth.selectedIndex)
            {
            return true;
            }
            else if(objToMonth.selectedIndex == objFormMonth.selectedIndex)
            {
               var objToDay = GetFormFieldByName(FormObject,"cmbToDays");
                var objFormDay= GetFormFieldByName(FormObject,"cmbFormDays");
        
               if(objToDay.selectedIndex >objFormDay.selectedIndex)
                {
                 return true;
                 }
                 else
                 {
                       alert ("date not right");
                      return false;
                 }
             }
             else
             {
                  alert ("date not right");
                  return false;
             }
    
         }
   else if(objToYear.selectedIndex < objFormYear.selectedIndex)
  {
    alert ("date not right");
      return false;
  }
 }
  catch(ex)
  {
  }
	
	
}


function ValidateChangePassword(FormObject)
{
	var obj = GetFormFieldByName(FormObject,"txtoldPassword");
	 if(!ValidationTemplate(obj,true,"text",2,250,"'?%&@(*=/\!~.,-);,<>[]+^$#","old password"))
	{
	   obj.focus();
		return false;
	}
		
	obj = GetFormFieldByName(FormObject,"txtPassword");
	 if(!ValidationTemplate(obj,true,"text",2,250,"'?%&@(*=/\!~.,-);,<>[]+^$#"," password"))
	{
	   obj.focus();
		return false;
	}
		
	obj = GetFormFieldByName(FormObject,"txtConfirmPassword");
	 if(!ValidationTemplate(obj,true,"text",2,250,"'?%&@(*=/\!~.,-);,<>[]+^$#","Password confirmation"))
	{
	   obj.focus();
		return false;
	}
		
		var Password=GetFormFieldByName(FormObject,"txtPassword");
	var ConfirmPassword =GetFormFieldByName(FormObject,"txtConfirmPassword");
	if (Password.value!=ConfirmPassword.value)
	{
	 alert("Password and its confirmation are not identical");
	 obj.focus();
	return false;
	}

}

function ValidateLoginForm(FormObject)
{
   var obj = GetFormFieldByName(FormObject,"txtUserName");
	 if(!ValidationTemplate(obj,true,"text",2,250,"'?%&@(*=/\!~.,-);,<>[]+^$#","user name cell"))
	{
	   obj.focus();
		return false;
	}
	
	obj = GetFormFieldByName(FormObject,"txtPassword");
	 if(!ValidationTemplate(obj,true,"text",2,250,"'?%&@(*=/\!~.,-);,<>[]+^$#","password cell"))
	{
	   obj.focus();
		return false;
	}
  
}

function ValidateMailListMessageForm(FormObject)
{
   var obj = GetFormFieldByName(FormObject,"txtTitle");
	 if(!ValidationTemplate(obj,true,"text",2,250,"'?%&@(*=/\!~.,);,<>[]+^$#","address cell "))
	{
	   obj.focus();
		return false;
	}
	
	obj = GetFormFieldByName(FormObject,"txtUserTo");
	 if(!ValidationTemplate(obj,true,"text",2,1000000,"<>","to  "))
	{
	   obj.focus();
		return false;
	}
	
	//obj = GetFormFieldByName(FormObject,"FCKeditor1");
	/// if(!ValidationTemplate(obj,true,"text",5,250,"'?%&@(*=/\!~.,-);,<>[]+^$#","النص  "))
	//{
	  // obj.focus();
		//return false;
	//}
  
}


function ValidateMailListForm(FormObject)
{
   var obj = GetFormFieldByName(FormObject,"txtName");
	 if(!ValidationTemplate(obj,true,"text",2,250,"'?%&@(*=/\!~.,);,<>[]+^$#"," name cell"))
	{
	   obj.focus();
		return false;
	}
	
	obj = GetFormFieldByName(FormObject,"txtEmail");
	if(!ValidationTemplate(obj,true,EntryTypes[0],-1,10000000,"<>","email   "))
	{
	   obj.focus();
		return false;
	}
}

function ValidateRegisterForm(FormObject)
{ 


    
     var obj = GetFormFieldByName(FormObject,"txtUseName");
  
    
    if(obj!=null && !ValidationTemplate(obj,true,"text",2,250,"'?%&@(*=/\!~.,-);,<>[]+^$#","user name cell"))
	{
	   obj.focus();
		return false;
	}
    
    obj = GetFormFieldByName(FormObject,"txtRPassword");
     
   if(obj!=null && !ValidationTemplate(obj,true,"text",2,250,"'?%&@(*=/\!~.,-);,<>[]+^$#","password cell"))
	{
	   obj.focus();
		return false;
	}
	if(obj!=null )
	{
	str =obj.value;
	if (str.length>50)
	{
	alert("Please enter password less than or equal 50 charachter");
	 obj.focus();
	return false;
	}
	}
	
	 
	obj = GetFormFieldByName(FormObject,"txtConfrimPassword");
	if(obj!=null && !ValidationTemplate(obj,true,"text",-1,250,"'?%&@(*=/\!~.,-);,<>[]+^$#","password confirmation cell"))
	{
	   obj.focus();
		return false;
	}
	
	var Password=GetFormFieldByName(FormObject,"txtRPassword");
	var ConfirmPassword =GetFormFieldByName(FormObject,"txtConfrimPassword");
	if (Password!=null && ConfirmPassword!=null && Password.value!=ConfirmPassword.value)
	{
	 alert("Password and its confirmation are not identical");
	 obj.focus();
	 return false;
	}
	
	obj = GetFormFieldByName(FormObject,"txtREmail");
	if(obj!=null && !ValidationTemplate(obj,true,EntryTypes[0],-1,250,"<>","email cell"))
	{
	   obj.focus();
		return false;
	}
	
	
	
	obj = GetFormFieldByName(FormObject,"txtTel");
	if(obj!=null && obj.value!="" && !ValidationTemplate(obj,true,EntryTypes[1],-1,250,"'?%&@(*=/\!~.,-);,<>[]+^$#","phone number cell"))
	{
	   obj.focus();
		return false;
	}
	obj = GetFormFieldByName(FormObject,"txtFax");
	if(obj!=null && obj.value!="" && !ValidationTemplate(obj,true,EntryTypes[1],-1,250,"'?%&@(*=/\!~.,-);,<>[]+^$#","fax number cell"))
	{
	   obj.focus();
		return false;
	}
	
	
	obj = GetFormFieldByName(FormObject,"txtMobile");
	if(obj!=null && obj.value!="" && !ValidationTemplate(obj,true,EntryTypes[1],-1,250,"'?%&@(*=/\!~.,-);,<>[]+^$#","mobile cell"))
	{
	   obj.focus();
		return false;
	}
	
	obj = GetFormFieldByName(FormObject,"txtFullName");
	 if(obj!=null && !ValidationTemplate(obj,true,"text",2,250,"'?%&@(*=/\!~.,-);,<>[]+^$#","full name cell"))
	{
	   obj.focus();
		return false;
	}
	
	
	obj = GetFormFieldByName(FormObject,"cmbCountries");
   if(obj!=null && !ValidationTemplate(obj,true,EntryTypes[3],1,250,"'?%&@(*=/\!~.,-);,<>[]+^$#","country cell"))
	{
	   obj.focus();
		return false;
	}
   
     obj = GetFormFieldByName(FormObject,"cmbYears");
     if(obj!=null && !ValidationTemplate(obj,true,EntryTypes[3],1,250,"'?%&@(*=/\!~.,-);,<>[]+^$#"," "))
	   {
	         obj.focus();
		     return false;
	   }
	   obj = GetFormFieldByName(FormObject,"txtPayed");
	   if(obj!=null && !ValidationTemplate(obj,true,EntryTypes[1],-1,250,"'?%&@(*=/\!~.,-);,<>[]+^$#","paid fee cell"))
	   {
	        obj.focus();
		    return false;
	   }
	   
	  
	  obj = GetFormFieldByName(FormObject,"cmbMethods");
     if(obj!=null && !ValidationTemplate(obj,true,EntryTypes[3],1,250,"'?%&@(*=/\!~.,-);,<>[]+^$#","how to pay cell"))
	   {
	         obj.focus();
		     return false;
	   }
	    
	   obj = GetFormFieldByName(FormObject,"chkAgree");
	  
	  if (obj!=null && obj.checked==false)
	  {
	   alert("you must agree");
	    obj.focus();
	   return false;
	  }
	
	
}
function ValidateContactUSForm(FormObject)
{
   var obj = GetFormFieldByName(FormObject,"txtNameOFUser");
	 if(!ValidationTemplate(obj,true,"text",1,250,"'?%&@(*=/\!~.,-);,<>[]+^$#"," name cell "))
	{
	   obj.focus();
		return false;
	}
	
     str=obj.value;
    str = str.replace(/^\s*|\s*$/g,"");
    if (str=="" )
     {
     alert("can't be empty");
     return false;
    }
	
	obj = GetFormFieldByName(FormObject,"txtMailOFUser");
	if(!ValidationTemplate(obj,true,EntryTypes[0],-1,250,"<>","email cell"))
	{
	   obj.focus();
		return false;
	}
	obj = GetFormFieldByName(FormObject,"txtContent");
	 if(!ValidationTemplate(obj,true,"text",1,1000000,"<>", "content cell "))
	{
	   obj.focus();
		return false;
	}
}


function ValidateGlobaleSearchForm(FormObject)
{
   var obj = GetFormFieldByName(FormObject,"textSearchWord");
	if(!ValidationTemplate(obj,true,"text",1,250,"'?%&@(*=/\!~.,-);,<>[]+^$#"," search word "))
	{
	   obj.focus();
		return false;
	}
	
	
}
function  ValidateSubForm  (FormObject)
{

    var obj = GetFormFieldByName(FormObject,"cmbYears");
     if(obj!=null && !ValidationTemplate(obj,true,EntryTypes[3],1,250,"'?%&@(*=/\!~.,-);,<>[]+^$#"," subscription period"))
	   {
	         obj.focus();
		     return false;
	   }
	
	 obj = GetFormFieldByName(FormObject,"txtPayed");
	if(!ValidationTemplate(obj,true,"text",1,250,"'?%&@(*=/\!~.,-);,<>[]+^$#"," paid fee "))
	{
	   obj.focus();
		return false;
	}
	
	 obj = GetFormFieldByName(FormObject,"txtEPayed");
	if(!ValidationTemplate(obj,true,"text",1,250,"'?%&@(*=/\!~.,-);,<>[]+^$#"," required fee value "))
	{
	   obj.focus();
		return false;
	}
	    
	  obj = GetFormFieldByName(FormObject,"cmbMethods");
     if(obj!=null && !ValidationTemplate(obj,true,EntryTypes[3],1,250,"'?%&@(*=/\!~.,-);,<>[]+^$#"," how to pay"))
	   {
	         obj.focus();
		     return false;
	   }
}


