/////////////////////////////////////////////////////////////
///isValidDate - 
///function gets date values of day, month and year.
///It returns true if it's a valid date, or false if it's not.
function isValidDate(day,month,year)
{
	var d = new Date(new String(month) + "/" + new String(day) + "/" + new String(year));
	return (d.getMonth() + 1 == month && d.getDate() == day && d.getFullYear() == year);
}

/////////////////////////////////////////////////////////////
///fnIsNumeric - 
///function returns true if the key that was pressed has 
///numeric value, or false if it hasn't.
// Modified by Sharon Segal. 18/07/2006
function fnIsNumeric(event)
{
       var KeyTyped
       var isExplorer
       isExplorer = 0
       if (navigator.userAgent.indexOf("Firefox") >= 0) 
	isExplorer = 0 
       else if (navigator.userAgent.indexOf("MSIE") >= 0)  
	isExplorer = 1

	if (isExplorer == 1)
		KeyTyped = String.fromCharCode(event.keyCode);
	else
		KeyTyped = String.fromCharCode(event.which);
	
       if(parseInt(KeyTyped.toString()) != KeyTyped.toString() && KeyTyped.toString()!="-" && event.keyCode!="8")
       {
               return false;
       }
       else
       {
               return true;
       }
}
	

/////////////////////////////////////////////////////////////
///foundSpecialChars - 
///function gets a string and returns true if it has any 
///special characters in it, or false if it hasn't 
///All special characters are written in the string 'iChars'.
function foundSpecialChars(inputStr)
{
  var iChars = "!@#$%^&*()+=-[]\\\';,./{}|\":<>?";
  for (var i = 0; i < inputStr.length; i++) 
  {
  	if (iChars.indexOf(inputStr.charAt(i)) != -1) 
	{
  	return true; //- FOUND SPECIAL CHARACTER
  	}
  }
  return false // - NO SPECIAL CHARACTER
}

/////////////////////////////////////////////////////////////
///checkMail - 
///function gets a string and returns 1 if it represents
///a valid email address, or 0 if it doesn't. 
function checkMail(mailAddress)
{
	var e = mailAddress;
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (filter.test(e)) 
	  return(1)
	else  
	  return(0)
}

/////////////////////////////////////////////////////////////
///setTextareaCharLimit - 
///function gets textarea object and a number - charLimit
///and it makes sure that there are no more than charLimit 
///characters in the textarea - it cuts from the end the text if needed.
function setTextareaCharLimit(textAreaObj, charLimit)
{
	if(textAreaObj.value.length>charLimit)
	{
		textAreaObj.value = textAreaObj.value.substring(0, charLimit);
	}
}



//////////////////////////////////////////////////////////////////////////////////////////////////////
// showDivAlert - 
// function displays div message for the user.
// divWidth: the width of the div message.
// divHeight: the height of the div message.
// divBgColor: the background color of the div.
// divBorderColor: the border color of the div (for no border make it the same as the divBgColor).
// divFontStyle: the style of the message text (HTML style format).
// divMessage: the message.
// divImage: path or link to an image that will be displayed on the right side of the div.
// objectIdToShowIn: ID of an HTML object that the div will be displayed in, if it's 
// 					 undefined or an empty string then the div will be displayed using document.write function.
// Example - 
// showDivAlert("280","20","silver","black","font-family:arial;font-size:12px;color:navy","הפרטים שהקלדת אינם נכונים","/Albums/images/errIcon.gif","errSpan")
// Written by Uri Sittan. 07/03/2006
function showDivAlert(divWidth,divHeight,divBgColor,divBorderColor,divFontStyle,divMessage,divImage,objectIdToShowIn)
{
	try
	{
			var htmStr = ''
			htmStr = '<div style="border:1px solid '+divBorderColor+';background-color:'+divBgColor+';width:'+divWidth+';height:'+divHeight+'">'
			htmStr += '<table align="center" dir="rtl" style="width:98%;'+divFontStyle+'">'
			htmStr += '<tr>'
			if (divImage!='')
			{
				// Getting the image width:
				var imgObj = new Image()
				imgObj.src = divImage
				var imgWidth = imgObj.width
				imgWidth += 10
				htmStr += '<td align="center"  style="width:'+imgWidth+'" valign="middle">'
				htmStr +=  '<img src="'+divImage+'">'
				htmStr += '</td>'
				htmStr += '<td  style="width:100%" valign="middle">'
				htmStr +=  divMessage
				htmStr += '</td>'		
			}
			else
			{
				htmStr += '<td dir="rtl" style="width:100%" valign="middle">'
				htmStr +=  divMessage
				htmStr += '</td>'	
			}
			htmStr += '</tr>'
			htmStr += '</table>'
			htmStr += '</div>'
			if(objectIdToShowIn==undefined ||objectIdToShowIn == '')
			{
				// No object to write the div into, writing the DIV to the page:
				document.write(htmStr)
			}
			else
			{
				// inserting the DIV into another HTML object on the page:
				if (document.getElementById(objectIdToShowIn))
					var objIn = document.getElementById(objectIdToShowIn)
				objIn.innerHTML = htmStr
			}
	}
	catch(e)
	{
		// If an error has occured then the message will be displayed 
		// in a standard alert:
		alert(divMessage)
	}
}