function checkSpecialChars()
{	
	var arrTextArea;
	var arrInput;
	var txtAreaHasSplChar;
	var inputHasSplChar;
	var inputHasSplChar1;

	arrTextArea = document.getElementsByTagName("textarea");
	arrInput = document.getElementsByTagName("input");
	
	txtAreaLen = arrTextArea.length;
	inputLen = arrInput.length;
	for (var i=0; i < txtAreaLen; i++)
	{
		eleName = arrTextArea[i].name;
		eleClass = arrTextArea[i].className;

				
		if(removeSplChar4Text(arrTextArea[i]) == false)
		{
			txtAreaHasSplChar = false;
		}
		else if(removeSplChar4Text(arrTextArea[i]) == null)
		{
			txtAreaHasSplChar = null;
		}
	}
	
	for (j=0; j < inputLen; j++)
	{
		if(arrInput[j].type == "text")
		{
			if(arrInput[j].className == "textBoxStyleForLocal" || arrInput[j].className == "textBoxStyle")
			{
				eleName = arrInput[j].name;
				eleClass = arrInput[j].className;

				if(removeSplChar4Text(arrInput[j]) == false)
				{
					inputHasSplChar = false;
				}
				if(removeSplChar4Text(arrInput[j]) == null)
				{
					inputHasSplChar = null;
				}				
			}
			else
			{
				if(detechFieldType(arrInput[j]) == false)
				{
					inputHasSplChar = false;
				}
				if(detechFieldType(arrInput[j]) == null)
				{
					inputHasSplChar = null;
				}
			}
			
		}
		if(arrInput[j].type == "password")
		{
			removeSplChar4Password(arrInput[j]);
		}
	}
	if(txtAreaHasSplChar == false || inputHasSplChar == false)
	{
		alert("Some special characters were found and were removed from the data you have entered. Please review and resubmit the form.\nYou can visit Learning Center for details on Special Characters and Restrictions");
		return false;
	}
	if(txtAreaHasSplChar == "null" || inputHasSplChar == "null")
	{
		alert("Some technical issues have happenend while checking for Special Characters");
		return false;
	}
	else
	{
		return true;
	}
}

function detechFieldType(fieldObj)
{
	var inputHasSplChar;
	try
	{
	
		if(fieldObj.className == "passwordStyle")
		{
			inputHasSplChar = removeSplChar4Password(fieldObj);
		}
		else if(fieldObj.className == "emailStyle")
		{
			inputHasSplChar = removeSplChar4Email(fieldObj);
		}
		else if(fieldObj.className == "urlStyle")
		{
			inputHasSplChar = removeSplChar4URL(fieldObj);
		}
		else
		{		
			inputHasSplChar = removeSplChar4Text(fieldObj);
		}

	}
	catch (error)
	{
		inputHasSplChar = null;
	}

	return inputHasSplChar;
}

function removeSplChar4Text(fieldObj)
{
	var count = 0;
	var str1 = fieldObj.value;
	var str2 = "";
	var hasSplChar = false;
	try
	{	
	
		for(i = 0; i < str1.length; i++)
		{
			if((str1.charCodeAt(i) >= 44 && str1.charCodeAt(i) <= 58) || (str1.charCodeAt(i) >= 64 && str1.charCodeAt(i) <= 91) || 
				(str1.charCodeAt(i) >= 97 && str1.charCodeAt(i) <= 122) || str1.charCodeAt(i) == 32 || str1.charCodeAt(i) == 93 || str1.charCodeAt(i) == 95)
			{
				str2 = str2 + str1.charAt(i);
			}
			else if(str1.charCodeAt(i) == 10 || str1.charCodeAt(i)==13)
			{ 
				str2 = str2 + "   ";
				hasSplChar = true;
			}
			else
			{
				str2 = str2 + "  ";
				hasSplChar = true;
			}
		}
		  
		fieldObj.value = str2;

		if(hasSplChar)
		{
			return false;
		}
	}
	catch(error)
	{
		return null;
	}
    
	return true;
}
function removeSplChar4URL(fieldObj)
{
	var count = 0;
	var str1 = fieldObj.value;
	var str2 = "";
	var hasSplChar = false;
	try
	{
		for(i = 0; i < str1.length; i++)
		{
			if((str1.charCodeAt(i) >= 45 && str1.charCodeAt(i) <= 58) || (str1.charCodeAt(i) >= 65 && str1.charCodeAt(i) <= 90) || (str1.charCodeAt(i) >= 97 && str1.charCodeAt(i) <= 122))
			{
				str2 = str2 + str1.charAt(i);
			}
			else if(str1.charCodeAt(i) == 10 || str1.charCodeAt(i)==13)
			{ 
				str2 = str2 + "  ";
				hasSplChar = true;
			}
			else
			{
				hasSplChar = true;
			}
		}
		  
		fieldObj.value = str2;

		if(hasSplChar)
		{
			return false;
		}
	}
	catch(error)
	{
		return null;
	}
    
	return true;
}
function removeSplChar4Email(fieldObj)
{
	var count = 0;
	var str1 = fieldObj.value;
	var str2 = "";
	var hasSplChar = false;
	try
	{
		for(i = 0; i < str1.length; i++)
		{
			if((str1.charCodeAt(i) >= 48 && str1.charCodeAt(i) <= 57) || (str1.charCodeAt(i) >= 65 && str1.charCodeAt(i) <= 90) || (str1.charCodeAt(i) >= 97 && str1.charCodeAt(i) <= 122) || str1.charCodeAt(i) == 45 || str1.charCodeAt(i) == 46 || str1.charCodeAt(i) == 64 || str1.charCodeAt(i) == 95)
			{
				str2 = str2 + str1.charAt(i);
			}
			else if(str1.charCodeAt(i) == 10 || str1.charCodeAt(i)==13)
			{ 
				str2 = str2 + "";
				hasSplChar = true;
			}
			else
			{
				hasSplChar = true;
			}
		}
		  
		fieldObj.value = str2;

		if(hasSplChar)
		{
			return false;
		}
	}
	catch(error)
	{
		return null;
	}
	
	return true;
}
function removeSplChar4Password(fieldObj)
{
	var count = 0;
	var str1 = fieldObj.value;
	var str2 = "";
	var hasSplChar = false;
	try
	{			
		for(i = 0; i < str1.length; i++)
		{
			if((str1.charCodeAt(i) >= 48 && str1.charCodeAt(i) <= 57) || (str1.charCodeAt(i) >= 65 && str1.charCodeAt(i) <= 90) || (str1.charCodeAt(i) >= 97 && str1.charCodeAt(i) <= 122) || str1.charCodeAt(i) == 32 || str1.charCodeAt(i) == 95)
			{
				str2 = str2 + str1.charAt(i);
			}
			else if(str1.charCodeAt(i) == 10 || str1.charCodeAt(i)==13)
			{ 
				str2 = str2 + "";
				hasSplChar = true;
			}
			else
			{
				str2 = str2 + str1.charAt(i);
				hasSplChar = true;
			}
		}
		  
		fieldObj.value = str2;

		if(hasSplChar)
		{
			return false;
		}
	}
	catch(error)
	{
		return null;
	}
    
	return true;
}
function removeSpecialChars(str1)
{
	var str2;var i;
	str2='';
	for(i=0;i<str1.length;i++)
	{
		if(str1.charCodeAt(i)!=10 && str1.charCodeAt(i)!=13){str2=str2 + str1.charAt(i);}
	}
	alert(str2);
	return str2;
}
