	function IsWildcard(aTextField)
	{
		var len = aTextField.value.length;
		//var iChars = "!@#$%^&*()+=-[]\\\';,./{}|\":<>?";
		var iChars = "!@#$%^&*()+=-[]\\\;,/{}|\":<>";

		for (var i = 0; i < len; i++) 
		{
			if (iChars.indexOf(aTextField.value.charAt(i)) != -1) 
			{
				return true;
			}
		}
		return false;
	}

	function numbersonly(str)
	{
		//var i;
		/*for (i = 0; i < str.length; i++)
		{
			var ch=str.charAt(i);*/

			if(isNaN(str))
		{
				return false;
		}
		var str = str + "";
		if(str.indexOf('+') != -1)
		{file:///var/www/kendasampige/js/common.js
			return false;
		}
		if(str.indexOf('.') != -1)
		{
			return false;
		}
		if(str.indexOf('-') != -1)
		{
			return false;
		}

			/* if(!((ch >= 0) && (ch <= 9)))
				 {
					return false;
				 }
		}*/
		return true;
	}
	
	function Trim(txt)
    {	
          if(txt.split(" ").join("").length == 0)
          return true;
          else
          return false;           
    }
	
	function alphaonly(str)
	{
		var i;		
		for (i = 0; i < str.length; i++)
		{
			var ch=str.charCodeAt(i);
			if(!(((ch >= 65) && (ch <= 90)) || ((ch >= 97) && (ch <= 122)) ||(ch == 95)))
				 {
					return false;
				 }
		}
		return true;
	}

	function alphaNames(str)
	{
		var i;		
		for (i = 0; i < str.length; i++)
		{
			var ch=str.charCodeAt(i);
			if(!(((ch >= 65) && (ch <= 90)) || ((ch >= 97) && (ch <= 122)) ||(ch == 95) ||(ch == 46) ||(ch == 32)))
				 {
					return false;
				 }
		}
		return true;
	}

	/*********************************************************************
	Added By: Bhavani.G
	Date Created: 28-Jan-2008
	Module: Comments
	Description: To show the comments form
	**********************************************************************/

	function showCommentsForm(article_id, parent_id, theDiv)
	{
		//alert("i am here");
		var theFormTxt = "<form id=\"frmComments_" + article_id + "_" + parent_id + "\" name=\"frmComments_" + article_id + "_" + parent_id + "\" method=\"post\" action=\"comments.php\" onSubmit=\"javascript:return addComment(this);\" >";
		
		theFormTxt += document.getElementById('FormComments').innerHTML;
		theFormTxt += "</form>";
		//alert(theDiv);
		document.getElementById(theDiv).innerHTML = theFormTxt;
		//alert("TEST");
		theForm = document.getElementById("frmComments_" + article_id + "_" + parent_id);
		//alert('test1');
		theForm.article_id.value = article_id;
		theForm.parent_id.value = parent_id;
		theForm.container_id.value = "CommentForm_"+article_id+"_"+parent_id;//alert('bhavani');
	}

	/*********************************************************************
	Added By: Bhavani.G
	Date Created: 28-Jan-2008
	Module: Comments
	Description: To add a new comment
	**********************************************************************/

	function addComment(theForm)
	{	
		/*if(theForm.subject.value=='')
		{
			alert('Enter subject');
			return false;
		}*/
		
		if(theForm.description.value=='')
		{
			alert('Enter comments');
			return false;
		}
		
		var theDiv = 'Comment'+theForm.article_id.value;
		
		var status = AjaxRequest.submit(
		theForm
		,{	
			'onSuccess':function(req){
				alert("Comment successfully added. You can view your comment once approved by the admin."); 
				document.getElementById(theDiv).innerHTML = req.responseText;
		 }
			,'onError':function(req){ alert('Error!\nStatusText='+req.statusText+'\nContents='+req.responseText);}
		}
			);
		return false;
	}

	/*********************************************************************
	Added By: Bhavani.G
	Date Created: 28-Jan-2008
	Module: Comments
	Description: To display the comments
	**********************************************************************/

	function showComments(mode,article_id, theDiv,page)
	{
		if(mode=='view' || mode=='view1')mode1 = 'view';else mode1='add';
		var pageURL = "comments.php?article_id="+article_id+"&page="+page+"&mode="+mode1;

		//alert(pageURL);
		var status = AjaxRequest.get(
		{
			'url':pageURL
			,'onSuccess':function(req)
				{
					//alert(theDiv+"theDiv");
					var objDiv = document.getElementById(theDiv);
					//alert(objDiv+" objDiv");
					if(objDiv.style.display=='none')
						objDiv.style.display='block';
					
					//document.getElementById('topcomments').style.display = 'none';
					document.getElementById(theDiv).innerHTML = req.responseText;
	
					if(mode=='add')
					showCommentsForm(article_id,  0, 'CommentForm_'+article_id+'_0');
					else if(mode=='view1'){
						alert("Please Login");
						document.login_user_form.name.focus();
					}
				}
			,'onError':function(req){ alert(req.statusText+'\nContents='+req.responseText); }
		}
		);
		return false;
	}
	
	/*********************************************************************
	Added By: Bhavani.G
	Date Created: 28-Jan-2008
	Module: Comments
	Description: To display the comments
	**********************************************************************/

	function hideComments(theDiv)
	{

		var objDiv = document.getElementById(theDiv);
	
		if(objDiv.style.display=='block')
		{
			objDiv.style.display='none';
		}
	}
	
/*********************************************************************
	Added By: Bhavani.G
	Date Created: 28-Jan-2008
	Module: Comments
	Description: To display the top 5 comments
	**********************************************************************/

	function showTopComments(mode,article_id, theDiv,page)
	{	
		var pageURL = "comments.php?article_id="+article_id+"&flag=top5&page="+page;

		//alert(pageURL);
		var status = AjaxRequest.get(
		{
			'url':pageURL
			,'onSuccess':function(req)
				{
					
					var objDiv = document.getElementById(theDiv);
					//alert(objDiv+" objDiv");
					if(objDiv.style.display=='none')
						objDiv.style.display='block';

					document.getElementById(theDiv).innerHTML = req.responseText;

					

				}
			,'onError':function(req){ alert(req.statusText+'\nContents='+req.responseText); }
		}
		);
		return false;
	}

	
	/*********************************************************************
	Added By: Bhavani.G
	Date Created: 28-Jan-2008
	Module: Comments
	Description: To approve the comments
	**********************************************************************/

	function approve_comment(id, article_id, cat_id)
	{	//alert('testing');
		var pageURL = "approve_comments.php?cid="+id +"&article_id="+article_id+"&cat_id="+cat_id;
		//alert(pageURL);
		var status = AjaxRequest.get(
		{
			'url':pageURL
			,'onSuccess':function(req)
				{
					response = req.responseText;
					alert(response);
					//document.location = document.location;
					document.location = "manage_comments.php?article_id="+article_id+"&cat_id="+cat_id;
				}
			,'onError':function(req){ alert(req.statusText+'\nContents='+req.responseText); }
		}
		);
		return false;				
	}

	
