function checkCount(max) 
{ 
	var count=max-document.guestbookForm.message.value.length;
	if(count>=0){
		document.guestbookForm.count.value = count; 
	}else
	{	
		if(window.event.type=="keyup")
			alert("You can not enter more that 100 words");
		document.guestbookForm.message.value = document.guestbookForm.message.value.substring(0,max);		
	}  
	return true;
}

function onSubmit()
{
	if(validateData())
	{
	    document.getElementById("firstName").disabled=true;
		document.getElementById("e_mail").disabled=true;
		document.getElementById("message").disabled=true;
		
		
       //window.open("/services/QgeneratedCode/CaptchaImage/JoinConversation.aspx",null,"height=425,width=415,status=yes,toolbar=no,menubar=no,location=no");
       window.open("/services/QgeneratedCode/CaptchaImage/SecureImageMed.htm",null,"height=425,width=415,status=yes,toolbar=no,menubar=no,location=no");
       
       return false;
	   //document.getElementById("guestbookForm").submit();
	}
}	

function validateData()
{
	if (trim(document.getElementById("firstName").value) == "")
	{
	  alert("الرجاء ادخال الإسم");
	  document.getElementById("firstName").focus();
	  return false;
	}
	
	parametersChecking(document.getElementById('firstName').value,"##;##<##>##--##/*##\*##'##!",document.getElementById('firstName').id);
		if (trim(InvalidChars) != "")
		{
			alert("لا يمكنك استخدام هذه الرموز" + InvalidChars + " في حقل الاســم");
			document.getElementById("firstName").focus();
			return false;
		}
	
	if (isValidEmail(document.getElementById("e_mail").value) == "")
	{
	  alert("الرجاء إدخال بريد إلكتروني صحيح");
	  document.getElementById("e_mail").focus();
	  return false;
	}
	
	if (trim(document.getElementById("message").value) == "")
	{
	  alert("الرجاء إدخال رسالة");
	  document.getElementById("message").focus();
	  return false;
	}
	
	parametersChecking(document.getElementById('message').value,"##;##<##>##--##/*##\*##'##!",document.getElementById('message').id);
		if (trim(InvalidChars) != "")
		{
			alert("لا يمكنك استخدام هذه الرموز" + InvalidChars + " في حقل الرسالة");
			document.getElementById("message").focus();
			return false;
		}
	
	return true;
}

function SearchOnMonth()
{
	var pagenO    = parseInt(document.getElementById("PageNo").value);
	var currantdate = new Date();
	//var currYear = parseInt(document.getElementById("search_date_year").value);
	var currYear = document.getElementById("SrhyearList").options[document.getElementById("SrhyearList").selectedIndex].value;
	var Smonth=document.getElementById("SrhMonthList").options[document.getElementById("SrhMonthList").selectedIndex].value ;
	var valTemp;
	document.location.href ="/guestbook/preview.asp?search_date_month=" + Smonth +"&search_date_year=" + currYear + "&cu_no=" + document.getElementById("cu_no").value;
}

//@Mohammad Fathi 09-02-2008.
//function to check for special character.
function parametersChecking(Str,SpecialCheck,ControlId) // Seperate Between Chars With ##
{
	var SpecialCharsCheck =new Array()
	var SpecialCharsCheck=SpecialCheck.split('##')
	var Invalid
	Invalid=false;
	InvalidChars=''
	try
	{
		if (Str!='')
		{
			for(var I=0;I<SpecialCharsCheck.length;I++)
			{
				if (SpecialCharsCheck[I]!='')
				{
					if (Str.indexOf(SpecialCharsCheck[I])!=-1)
					{
						Invalid=true
						InvalidChars = InvalidChars + ' ' + SpecialCharsCheck[I]
					}
				}
			}
			if (Str.indexOf("'")!=-1)
			{
				Invalid=true
				InvalidChars = InvalidChars + ' ' + "'"
				if (document.getElementById(ControlId))
				{
					document.getElementById(ControlId).focus();
				}
			}
		}
		if (Invalid)
		{
			if (document.getElementById(ControlId))
			{
				document.getElementById(ControlId).focus();
			}
			//alert("you can't use these symbols" + InvalidChars);
			//return false;
			return InvalidChars
		}
		else
		{
			return null
		}
	}
	catch(Err)
	{
		return InvalidChars
	}
	
}