/*
  ***********************************************************************************
  * Copyright Notice																*
  * (c) Blue Star InfoTech Limited													*
  * All rights reserved. The software and associated documentation					*
  * supplied hereunder are the confidential and proprietary information				*
  * of Blue Star Infotech Limited, India and are supplied							*
  * subject to licence terms. In no event may the Licensee reverse					*
  * engineer, decompile, or otherwise attempt to discover the						*
  * underlying source code or confidential information herein.						*
  *																					*
  ***********************************************************************************
-------------------------------------------------------------------------------------
 File Name         : DVCMN_CodeNav.js

 Description       : This script files is used by DVGND_Codenav.aspx page

 Author            :    BSIL

 Date Created      : 28 July 2003
-------------------------------------------------------------------------------------
 Version   Date Modified     Modified By     Brief Description
-------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------
*/

function SetFocus()
{
	window.document.MainForm.txtCodeNav.focus();
}

function ProcessCodeNav(eventObject)
{
    var codeValue = window.document.MainForm.txtCodeNav.value;

	if (navigator.appName == "Netscape")
	{
		if((eventObject.which==13) || (eventObject.which==1))
		{
			if(codeValue != "")
			{
				if (ValidateText(codeValue) == false)
				{
					CtlError(1, 1, ErrorMessage(1501));
					ShowError(ErrMsg);
					SetFocus();
					return false;
				}
				else
				{
					window.location.href = "/DVCMN_CodeNav.aspx?ReqType=PostBack&txtCodeNav=" + codeValue;
					return false;
				}
			}
			else
			{
				CtlError(1, 1, ErrorMessage(1500));
				ShowError(ErrMsg);
				SetFocus();
				return false;
			}
		}
	}
	if (navigator.appName == "Microsoft Internet Explorer")
	{
		if ((event.keyCode==13)||(event.keyCode==0))
		{
			if(codeValue != "")
			{
				if (ValidateText(codeValue) == false)
				{
					CtlError(1, 1, ErrorMessage(1501));
					ShowError(ErrMsg);
					SetFocus();
					return false;
				}
				else
				{
					window.location.href = "/DVCMN_CodeNav.aspx?ReqType=PostBack&txtCodeNav=" + codeValue;
					return false;
				}
			}
			else
			{
				CtlError(1, 1, ErrorMessage(1500));
				ShowError(ErrMsg);
				SetFocus();
				return false;
			}
		}
	}
	return true;
}

function ValidateText(strname)
{
	if (strname != "")
	{
		for (var i = 0; i < strname.length; i++)
		{
			var ch = strname.substring(i, i + 1);
			if ((ch == "&") || (ch == '<') || (ch == '>') || (ch == '/')  || (ch == '\\') || (ch == ';'))
			{
				return false;
			}
		}
	}
	else
	{
		return false;
	}
	return true;
}
