
'Moved to JSMiscNew.js
'function vbsIsDate(date1)
'	vbsIsDate = isDate(date1) 
'end function

'------------------------------------------------------------------------------------'
function vbs_replace(val, rep, withi)
	vbs_replace = replace(val, rep, withi)
end function

'------------------------------------------------------------------------------------'
'Moved to JSMiscNew.js
'sub GetDate(sFieldName)
'	GetDate_diri "", sFieldName
'end sub	

'------------------------------------------------------------------------------------'
'Moved to JSMiscNew.js
'sub GetDate_diri(diri, sFieldName)
'	dim sParam	
'	arrIndex = -1
'	sParam = ""
'	sParam = window.showModalDialog(diri & "Util/Behavior_date/Calendar.htm","", "dialogHeight:225px;dialogWidth=300px;help=no;status=no;")	
'	document.all(sFieldName).value = sParam	
'end sub 

'------------------------------------------------------------------------------------'
function validDate(s)

	dim tempi
	
	dateError = false
	tempi = split(s,"/")
	
	if ubound(tempi) >= 0 then 
		if IsNumeric(tempi(0)) then
			if tempi(0) > 31 then dateError = true
			if tempi(0) > 30 and (tempi(1)= 6 or tempi(1)= 06 or tempi(1)= 4 or tempi(1)= 04 or tempi(1)= 9 or tempi(1)= 09 or tempi(1)= 11) then dateError = true	
			if tempi(0) > 29 and (tempi(1)= 2 or tempi(1)= 02) then dateError = true
		else
			dateError = true	
		end if
	end if	
	
	if ubound(tempi) >= 1 then 
		if IsNumeric(tempi(1)) then
			if tempi(1) > 12 then dateError = true
		else
			dateError = true	
		end if
	end if

	if ubound(tempi) >= 2 then 
		if IsNumeric(tempi(2)) then
			if not (len(tempi(2))=2 or len(tempi(2))=4) then dateError = true
		else
			dateError = true	
		end if
	end if
	
	if not isdate(s) or dateError then
		alert(WorngDate)
		alert_an_error = true	
	end if
	
end function


'---------------------------------------------------------------'
function check_ISPhone(this_, bool) 
	
	if this_.value = "" then exit function
	this_.value = replace(replace(this_.value,"-","")," ", "")
	if len(this_.value) >3 then
		this_.value = left(this_.value, 3) & "-" & right(this_.value, len(this_.value) - 3)
	end if	
	
	if bool and this_.value = "" then
		alert(WorngCellNum1)
		this_.focus()
	else
		if this_.value <> "" then
			ret_val = (ISPhone(this_.value, false, true, this_))
		end if 
	end if 
	
end function

'---------------------------------------------------------------'
Function ISPhone (byval Phone, byval  MustHaveLine, byval CellPhoneInNEwFormat, byref obj) 
	
	dim ErrStr
	dim i
	Dim LineSpace
	Dim ketomet 
	Dim GoodKetomotarray 
	'Dim PhoneLen
	Dim CellPhoneLen 
	LineSpace = instr(1,phone,"-") 
	
	'defing the len per 
	'IF LineSpace = 0 then 
	'	PhoneLen = 9
	'	CellPhoneLen = 10
	'else
	'	PhoneLen = 10 
		CellPhoneLen = 11
	'end if 
	
	select case true 
	
	case len(Phone) <> CellPhoneLen		' and  len(Phone) <> PhoneLen 
		ErrStr = WorngCellNum2
		ISPhone  = false 
		   
	'case LineSpace <> 3 and LineSpace <> 4 and MustHaveLine 
	'	ErrStr = WorngCellNum5
	'	ISPhone  = false 
		    
	case else    
	 
		'checking their are no only numbers
		for i = 1 to len(Phone)
			if instr(1,"1234567890-",mid(Phone,i,1)) = 0 then
			 'msgbox("here")
			 ISPhone  = false 
			 ErrStr = WorngCellNum3
			 alert(ErrStr)
			 obj.select()
			 obj.focus()
			 exit function  
			end if  
		next 
			
		'chekcing the ketomot 
		 isphone = false
		 GoodKetomotarray = array("02","03","04","08","09","050","052","054","057")    
		 ketomet = mid(phone,1,LineSpace - 1 )
		    ErrStr  = WorngCellNum4
			for i = 0 to ubound(GoodKetomotarray) 
			   if ketomet = GoodKetomotarray(i) then 
					
					IF i >=5 and CellPhoneInNEwFormat and len(Phone) <> CellPhoneLen then
					  ErrStr = WorngCellNum3			 
					 else 
					   ErrStr = ""
					   isphone = true  
					end if 
					exit for 
			   end if 
			next 	
	 end select 
	
	if ErrStr <> "" then 
		alert(ErrStr)
		obj.select()
		obj.focus()
	end if 
	
end function 