// JavaScript Document
/*#########################################
Author:Saurabh Ajmera
Date:02/16/2008
Description:This function does some security check, no special characters allowed!!
Please do not attempt to touch this code without my permission.

###########################################*/
//Check();
/*
function Check() {

    if (navigator.JavaEnabled()) {
        alert("The javascript is available .")
    }
    else {
        return false
    }

}
*/
function isInputSecure(value)
  {
	//lets trim the extra space
	//alert('I am in..');
	var re;
	re = new RegExp(document.getElementById('regex').value);
	//alert(value.match(re))?0:1);
	return (value.match(re))?0:1
		
  }
  
function securityCheck()
{
	//alert("checkin..");
	//alert(document.getElementById(id).value);
	//if(!isInputSecure(document.getElementById(id).value))
	//{
		//var inputCount = document.evaluate("count(//input)", document, null, XPathResult.ANY_TYPE, null).numberValue;
		//alert("This document contains " + inputCount + " input tags"); 
		
		var j = 0;
		
		while(document.getElementsByTagName('textarea')[j++])
		{	
			//alert(document.getElementsByTagName('textarea')[j-1].value);
			if(!isInputSecure(document.getElementsByTagName('textarea')[j-1].value))
			{
		//document.getElementsByTagName('input')[i]
				//alert(document.getElementsByTagName('textarea')[0].value);
   				document.getElementById('error').innerHTML = 'For security reasons, you cannot enter the following characters:\n ^$( )< >|\}{][*?%&+ \']';
				//alert("For security seasons, you cannot the following characters as input:\n ^ $ ( ) < > | \ } { ] [ * ? % & + ' @ ] ");
				return false;
			}                                                                                                                                                                                                                          
			//j++;
		}
		var i = 0;
		while(document.getElementsByTagName('input')[i])
		{
		//for(var i=0;i<=inputCount;i++)
		//{
			//alert(document.getElementsByTagName('input')[i].value);
			if((!isInputSecure(document.getElementsByTagName('input')[i].value)) && (document.getElementsByTagName('input')[i].type != 'hidden'))
			{
		//document.getElementsByTagName('input')[i]
			
   			document.getElementById('error').innerHTML = 'For security reasons, you cannot enter the following characters as input:\n ^ $ ( ) < > | \ } { ] [ * ? % & + \' ] ';
			//alert("For security seasons, you cannot the following characters as input:\n ^ $ ( ) < > | \ } { ] [ * ? % & + ' @ ] ");
			return false;
			}
			i++;
			
			
		}
		return true;
		
	
	
}  