//***---  This function is used to check if the date is correct  ---***//
//Parameters of the function
//day   : Specify the value of the day
//month : Specify the value of the month
//year  : Specify the value of the year
//Code Example:
//isDate(1,5,1990)
	function isDate(day,month,year) 
	{
		if (day < 1 || day > 31) 
		{
		    return false;
		}
		if (month < 1 || month > 12) 
		{ 
		    return false;
		}
		if ((month==4 || month==6 || month==9 || month==11) && day==31) 
		{
		    return false;
		}
		if (month == 2) 
		{ 
		    var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
		    if (day > 29 || (day==29 && !isleap)) 
		    {
		        return false;
		    }
		}
		if (year < 1) 
		{ 
		    return false;
		}
		return true; 
	}
	
	//***---  This function is used to display the validation Messages  ---***//
//Parameters of the function
//MessageType   : Specify the type of message(alert or confirm)
//LanguageIndex : Specify the type of message to be displayed
//EnglishMessage: English Message to be displayed
//ArabicMessage : Arabic Message to be displayed
//Code Example:
//Message(0,0,"Enter the First Name","أدخل الأسم الأول")
function Message(MessageType,LanguageIndex,EnglishMessage,ArabicMessage)
{
	
	if(MessageType==0) 
	{
			if	(LanguageIndex==0)
				{
					alert(EnglishMessage)
					return 1
					
				}
			if	(LanguageIndex==1)
				{
					alert(ArabicMessage)
					return 1
				}	
	}
	
	if(MessageType==1) 
	{
			if	(LanguageIndex==0)
				{
					if(confirm(EnglishMessage))
					return 1
				}
			if	(LanguageIndex==1)
				{
					if(confirm(ArabicMessage))
					return 1
				}	
	}
	
	
}

//***---  This function is used to check the date interval is correct  ---***//
//Parameters of the function
//start    : Specify the Starting Date
//end      : Specify the Starting Date
//interval : Specify the type of the interval (Days,Hours,Minutes or Seconds)
//rounding : Specify if the rounding is avaliable or not
//Code Example:
//ntemp = getDateDiff(objStartDate,objEndDate,'d',true);
	function getDateDiff(start,end,interval,rounding) 
	{
	    var iOut = 0;
	    var bufferA = Date.parse( start ) ;
	    var bufferB = Date.parse( end ) ;
	    // check that the start parameter is a valid Date. 
	    if ( isNaN (bufferA) || isNaN (bufferB) ) 
	    {
	        return null ;
	    }
		// check that an interval parameter was not numeric. 
	    if ( interval.charAt == 'undefined' ) 
	    {
	        // the user specified an incorrect interval, handle the error. 
	        return null ;
	    }
	    var number = bufferB-bufferA ;
	    // what kind of add to do? 
	    switch (interval.charAt(0))
	    {
	        case 'd': case 'D': 
	            iOut = parseInt(number / 86400000) ;
	            if(rounding) iOut += parseInt((number % 86400000)/43200001) ;
	            break ;
	        case 'h': case 'H':
	            iOut = parseInt(number / 3600000 ) ;
	            if(rounding) iOut += parseInt((number % 3600000)/1800001) ;
	            break ;
	        case 'm': case 'M':
	            iOut = parseInt(number / 60000 ) ;
	            if(rounding) iOut += parseInt((number % 60000)/30001) ;
	            break ;
	        case 's': case 'S':
	            iOut = parseInt(number / 1000 ) ;
	            if(rounding) iOut += parseInt((number % 1000)/501) ;
	            break ;
	        default:
			   return null ;
	    }
	    return iOut ;
	}
	

