﻿/*
Global.js

This file includes all client-side functions which should be global (accessible to all).
*/

//checkForInnerTextFeature
//This function checks the DOM to see if the innerText property is available (it is for IE but not FireFox, for example)
//If the property is present, it returns true
//If the property is not present, it returns false
function checkForInnerTextFeature()
{
	var obj = (document.getElementsByTagName("body")[0].innerText != undefined) ? true : false;

	return obj;
}

//changeText
//This function sets the innerText/textContent property of the provided element. 
//Parameters:
//elem - object to set the text for
//changeVal - new text to set on the provided object
function changeText(elem, changeVal)
{
	if( elem != null )
	{
		if(!checkForInnerTextFeature())
		{
			elem.textContent = changeVal;
		}
		else
		{
			elem.innerText = changeVal;
		}
	}
}

function getTextContent(elem)
{
	if( elem != null )
	{
		if( !checkForInnerTextFeature() )
		{
			return elem.textContent;
		}
		else
		{
			return elem.innerText;
		}
	}
	return null;
}
//Custom Validator Javascript function for verifying XSS characters in the string
function CustomVerifyXssCharacters(sender, args)
{
    //var filteredPassword = password.value.charAt(0).replace(/\<|\>|\"|\'|\%|\;|\(|\)|\&|\+|\-/g,""); 
    var filteredInput = args.Value.replace(/\<|\>/g,""); 
    if(filteredInput.length != args.Value.length && args.Value)
    { 
    if(document.all)
    { 
      //for handling IE
      alert(sender.attributes["errormessage"].value);
      document.getElementById(sender.attributes["controltovalidate"].value).value="";
      
    }
    else
    {
    //For Firefox
    alert(sender.errormessage);
    document.getElementById(sender.controltovalidate).value="";
    }
    document.getElementById(sender.id).innerHTML="";
    args.IsValid= false;
    }
    else{
    args.IsValid= true;
    }
}