//START to show and hide the layers 
//variable to track the ecommerce status for the user
var ecomtrade;
function hide(id)
{
	ns4 = (document.layers)? true:false
	ie4 = (document.all)? true:false
	if (ns4) document.layers[id].visibility = "hide"
	else if (ie4) document.all[id].style.visibility = "hidden"	
	
	return
}


function fndatecomp(fromdate,todate)
{
	var today
	var sdate
	today= new Date(todate)
	sdate=new Date(fromdate)

	
	today = new Date(today.getFullYear(),today.getMonth(),today.getDate())
	sdate = new Date(sdate.getFullYear(),sdate.getMonth(),sdate.getDate())
	

	//alert("today = " + today + "   and    given date = " + sdate);
	//alert(sdate);
	//alert(today);	
	if(today < sdate)
	{
		return false;
		//alert("From date should be Lesser than or Equal to To Date")
	}
	else
	{
		return true;
	}
}


function isUpper(formelem)
{
 	formelem=new String(formelem)
	if(formelem != formelem.toUpperCase())
	{
		return false;
	}
	
	return true;	
} 
	

function show(id)
{
	ns4 = (document.layers)? true:false
	ie4 = (document.all)? true:false
	if (ns4) document.layers[id].visibility = "show"
	else if (ie4) document.all[id].style.visibility = "visible"	
	
	return
}
//END to show and hide the layers 

function checkspecialchar(formelem)
{
	var expisSpecialChar=/[\*\~|@\$\%\^\&\*\(\)\[\]\;\:\{\}\<\>\/\\\#\!\`\-\+\=\"\,\?]/
	return expisSpecialChar.test(formelem)
}




//This function returns the name of the Browser
// returns 'Microsoft Internet Explorer' or 'Netscape'
function getBrowserName()
{
	var l_strBrowserName
	l_strBrowserName = navigator.appName;
	return l_strBrowserName;	
}
//End of the function getBrowserName()




//To replace the given character by another given character
function replaceChars(entry,from,to)
{
out = from; // replace this
add = to; // with this
temp = "" + entry; // temporary holder

while (temp.indexOf(out)>-1) {
pos= temp.indexOf(out);
temp = "" + (temp.substring(0, pos) + add + 
temp.substring((pos + out.length), temp.length));
}
return temp;
}


//Checks whether the form input element is empty
function isEmpty(formelem)
{
	var expisEmpty=/[^ ]/
  	return ! expisEmpty.test(formelem);
}


//currency validation even if it has spaces 
function isCurrency(formelem)
{
  	if (formelem.indexOf(".")!=formelem.lastIndexOf("."))
	{
		return false;
	}
	if(formelem.indexOf(" ") > -1)
  	{
  		return false;
  	}
	var expisNumeric=/[0-9]/;
	if (expisNumeric.test(formelem))
	   {
  	     expisNumeric=/[a-zA-Z\*\~|@\$\%\^\&\*\(\)\/\#\!\`\-\+\;\:\<\>\{\}\|\\\\[\]\"\'\_\=\?]/
  	     return ! expisNumeric.test(formelem);
		}
	else 
	   {
	     return false;
	   }
}

function islimCurrency1(s)
{
	//var fl=true;
	var fl=false;
	var temp='';
	var i;
	var j=s.length;
	temp=s.charAt(j);
	if(temp!='.') 
	{
		if(!(isInteger(s)))
		{
			for (i=0;i<=j;i++)
			{
				var c=s.charAt(i);
				if((i==(j-3))||(i==(j-2))||(i==(j-4)))
				{
					if(!(isDigit(c)))
					{
						if(c!='.')
						{
												
							//fl=true;
							//return true;
							fl=false;	
							return false;
						}

						//else fl=false;
						else fl=true;
					}
				}
			}
			return fl;
		}
		else
		{
			//return false;
			return true;
		}
	}

	//else return true;
	else return false;
}

function islimCurrency(formelem)
{
  	if (formelem.indexOf(".")!=formelem.lastIndexOf("."))
	{
		return false;
	}
	if(formelem.indexOf(" ") > -1)
  	{
  		return false;
  	}
	
	if(formelem.indexOf(".") > -1)
	{
		strval=formelem.slice(parseInt(formelem.indexOf("."))+1,formelem.length)
		//alert(strval);
		if (strval.length > 2)
		{
		return false;
		}
	}	
	
	var expisNumeric=/[0-9]/;
	if (expisNumeric.test(formelem))
	   {
  	     expisNumeric=/[a-zA-Z\*\~|@\$\%\^\&\*\(\)\/\#\!\`\-\+\;\:\<\>\{\}\|\\\\[\]\"\'\_\=\?]/
  	     //alert("inside:"+! expisNumeric.test(formelem));
  	     return ! expisNumeric.test(formelem);
		}
	else 
	   {
	     return false;
	   }

	
}



//Checks whether the form input element is Numeric alone.
function isNumericOnly(formelem)
{
  	if (formelem.indexOf(".")!=formelem.lastIndexOf("."))
	{
		return false;
	}
	if(formelem.indexOf(" ") > -1)
  	{
  		return false;
  	}
	var expisNumeric=/[a-zA-Z\*\~|@\$\%\^\&\*\(\)\/\#\!\`\,\.\-\+\;\:\<\>\{\}\|\\\\[\]\"\'\_\=\?]/
  	return ! expisNumeric.test(formelem);
}



//Checks whether the form input element is numeric even if it has spaces 
function isNumeric(formelem)
{
  	if (formelem.indexOf(".")!=formelem.lastIndexOf("."))
	{
		return false;
	}
	if(formelem.indexOf(" ") > -1)
  	{
  		return false;
  	}
 	var expisNumeric=/[a-zA-Z\*\~|@\$\%\^\&\*\(\)\/\#\!\`\,\-\+\;\:\<\>\{\}\|\\\\[\]\"\'\_\=\?]/ 

  	return ! expisNumeric.test(formelem);
}



//Checks whether the form input element is a String
function isChar(formelem)
{
  	var expisChar=/[0-9]/;
  	return ! expisChar.test(formelem);
}


//Checks whether the form input element is Alphabets alone
function isAlpha(formelem)
{
var expisChar=/[\*\~\|\@\$\%\^\&\*\(\)\/\#\!\`\,\-\+\;\:\<\>\{\}\|\\\\[\]\"\'\_\.\=\?\0-9]/ ;
return ! expisChar.test(formelem);
}



//Checks whether the form input element is a validname
function isValidName(formelem)
{
	var expisValidName=/[\*\~|@\$\%\^\&\*\(\)\#\!\`\-\+\=\"\,\?]/
  	return ! expisValidName.test(formelem);
}


//Checks whether the form input element is a valid reference number(PO RFQ)
function isValidRefno(formelem)
{
var expisValidRefno=/[\*\~|@\$\%\^\*\(\)\!\`\+\=\.\'\"\,\ \?]/  	
return ! expisValidRefno.test(formelem);
}

//Checks whether the form input element is alphanumeric
function isAlphaNumeric(formelem)
{
 var expisChar=/[*\~|@\$\%\^\&\*\(\)\/\#\!\`\,\-\+\;\:\<\>\{\}\|\\\\[\]\"\'\_\.\=\?]/ ;
 return ! expisChar.test(formelem);
}




//Checks the validity of the Email Address
//function isEmail(formelem)
//{
//	var expisEmail=/^\w+@[a-zA-Z0-9]+\.\w{2,3}/
//	return expisEmail.test(formelem)
//}


function isEmail(emailStr) {

/* The following pattern is used to check if the entered e-mail address fits the user@domain format.  It also is used to separate the username from the domain. */

var emailPat=/^(.+)@(.+)$/

/* The following string represents the pattern for matching all special
   characters.  We don't want to allow special characters in the address. 
   These characters include ( ) < > @ , ; : \ " . [ ]    */

var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"

/* The following string represents the range of characters allowed in a 
   username or domainname.  It really states which chars aren't allowed. */

var validChars="\[^\\s" + specialChars + "\]"

/* The following pattern applies if the "user" is a quoted string (in
   which case, there are no rules about which characters are allowed
   and which aren't; anything goes).  E.g. "jiminy cricket"@disney.com
   is a legal e-mail address. */

var quotedUser="(\"[^\"]*\")"

/* The following pattern applies for domains that are IP addresses,
   rather than symbolic names.  E.g. joe@[123.124.233.4] is a legal
   e-mail address. NOTE: The square brackets are required. */

var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/

/* The following string represents an atom (basically a series of
   non-special characters.) */

var atom=validChars + '+'

/* The following string represents one word in the typical username.
   For example, in john.doe@somewhere.com, john and doe are words.
   Basically, a word is either an atom or quoted string. */

var word="(" + atom + "|" + quotedUser + ")"

// The following pattern describes the structure of the user

var userPat=new RegExp("^" + word + "(\\." + word + ")*$")

/* The following pattern describes the structure of a normal symbolic
   domain, as opposed to ipDomainPat, shown above. */

var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")


/* Finally, let's start trying to figure out if the supplied address is  valid. */

/* Begin with the coarse pattern to simply break up user@domain into
   different pieces that are easy to analyze. */
   
var matchArray=emailStr.match(emailPat)

if (matchArray==null) {
  /* Too many/few @'s or something; basically, this address doesn't
     even fit the general mould of a valid e-mail address. */
	return false
}

return true;
}







//Checks whether the form input element contains any Special Characters or not.
function isSpecialChar1(formelem)
{
	var expisSpecialChar=/[\!\`\'\"\,\?]/
	return expisSpecialChar.test(formelem)
}

//Checks whether the form input element contains any  limited Special Characters or not.
function islimSpecialChar(formelem)
{
//	var expisSpecialChar=/[\*\~|@\$\%\^\&\*\#\!\`\<\>\+\=\.\,\?]/
	var expisSpecialChar=/[\*\~|@\$\%\^\&\*\#\!\`\<\>\+\=\,\?]/
	return expisSpecialChar.test(formelem)
}


function isSpecialChar(formelem)
{
	var expisSpecialChar=/[\*\~|@\$\%\^\&\*\(\)\#\!\`\-\+\=\.\'\"\,\_\<\>\?]/
	return expisSpecialChar.test(formelem)
}
// This function Validates the Special Characters for the Spec ASP Page Remarks Field.

function isSpecialRemarks(formelem)
{
	var expisSpecialChar=/[\_\'\/\|\?]/
	return expisSpecialChar.test(formelem)
}



//checks onlyfor blank spaces for password
function nullcheck(tempval)
{
	tlen=tempval.length;
	var flag=true;
	for(k=0;k<=tlen-1;k++)
		{
		if(tempval.charAt(k)!=" ")
		{flag=false;}
		}
 
	if(flag)
	{  return false;}
	else
	{return true;}

}
//checks onlyfor blank spaces for password
function nullcheck1(tempval)
{
	tlen=tempval.length;
	var flag=true;
	for(k=0;k<=tlen-1;k++)
		{
		if(tempval.charAt(k)==" ")
		{flag=false;}
		}
 
	if(flag)
	{  return false;}
	else
	{return true;}

}

//checks only for the character ampersand for the username 
function checkampersand(tempval)
{
	tlen=tempval.length;
	var flag=true;
	for(k=0;k<=tlen-1;k++)
	{
		if(tempval.charAt(k)=="&")
		{
			flag=false;
		}
	}
 
 	
	if(flag)
	{  return false;}
	else
	{return true;}
}
//to turncate the leading and trailing blank spaces
function Trim(str)
 {
    return str.replace(/^\s+/g, '').replace(/\s+$/g, '');
 }


//checks whether the given date is lesser than the current date
function isdateless(seldate)
{
	var today
	var sdate
	today= new Date(strtodate)
	sdate=new Date(seldate)

	
	today = new Date(today.getFullYear(),today.getMonth(),today.getDate())
	sdate = new Date(sdate.getFullYear(),sdate.getMonth(),sdate.getDate())
	

	//alert("today = " + today + "   and    given date = " + sdate);

	if(sdate < today)
	{
		return true;
	}
	else
	{
		return false;
	}
}

function fndatecompare(fromdate,todate)
{
	var today
	var sdate
	today= new Date(todate)
	sdate=new Date(fromdate)

	
	today = new Date(today.getFullYear(),today.getMonth(),today.getDate())
	sdate = new Date(sdate.getFullYear(),sdate.getMonth(),sdate.getDate())
	

	//alert("today = " + today + "   and    given date = " + sdate);
	//alert(sdate);
	//alert(today);	
	if(sdate > today)
	{
		alert("From date should be Lesser than or Equal to To Date")
		return true;
	}
	else
	{
		
		return false;
	}
}

//checks whether the given string is a Valid date
function isValidDate(dateStr)
{
		if (isEmpty(dateStr) == true)
			return true;
			
		// Checks for the following valid date formats:
		// MM/DD/YY   MM/DD/YYYY   MM-DD-YY   MM-DD-YYYY
		// Also separates date into month, day, and year variables

		//var datePat = /^(\d{1,2})(\/|-)(\d{1,2})\2(\d{2}|\d{4})$/;

		// To require a 4 digit year entry, use this line instead:
		var datePat = /^(\d{1,2})(\/|-)(\d{1,2})\2(\d{4})$/;

		var matchArray = dateStr.match(datePat); // is the format ok?
		if (matchArray == null) {
		alert("Date is not in a  mm/dd/yyyy  format.")
		return false;
		}
		month = matchArray[1]; // parse date into variables
		day = matchArray[3];
		year = matchArray[4];
		if (month < 1 || month > 12) { // check month range
		alert("Month must be between 1 and 12.");
		return false;
		}
		if (day < 1 || day > 31) {
		alert("Day must be between 1 and 31.");
		return false;
		}
		if ((month==4 || month==6 || month==9 || month==11) && day==31) {
		alert("Month "+month+" doesn't have 31 days!")
		return false
		}
		if (month == 2) { // check for february 29th
		var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
		if (day>29 || (day==29 && !isleap)) {
		alert("February " + year + " doesn't have " + day + " days!");
		return false;
		   }
		}
		return true;  // date is valid
}

//checks whether the given string is a Valid date
function isValidDateBritish(dateStr)
{
		if (isEmpty(dateStr) == true)
			return true;
			
		// Checks for the following valid date formats:
		// MM/DD/YY   MM/DD/YYYY   MM-DD-YY   MM-DD-YYYY
		// Also separates date into month, day, and year variables

		//var datePat = /^(\d{1,2})(\/)(\d{1,2})\2(\d{2}|\d{4})$/;

		// To require a 4 digit year entry, use this line instead:
		var datePat = /^(\d{1,2})(\/)(\d{1,2})\2(\d{4})$/;

		var matchArray = dateStr.match(datePat); // is the format ok?
		if (matchArray == null) {
		alert("Date is not in a  DD/MM/YYYY  format.")
		return false;
		}
		day = matchArray[1]; // parse date into variables
		//alert(day);
		month = matchArray[3];
		//alert(month);
		year = matchArray[4];
		//alert(year);
		if (month < 1 || month > 12) { // check month range
		alert("Month must be between 1 and 12.");
		return false;
		}
		if (day < 1 || day > 31) {
		alert("Day must be between 1 and 31.");
		return false;
		}
		if ((month==4 || month==6 || month==9 || month==11) && day==31) {
		alert("Month "+month+" doesn't have 31 days!")
		return false
		}
		if (month == 2) { // check for february 29th
		var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
		if (day>29 || (day==29 && !isleap)) {
		alert("February " + year + " doesn't have " + day + " days!");
		return false;
		   }
		}
		return true;  // date is valid
}

//checks whether the given date is lesser than the current date
function chkdate(seldate)
		{ 
				var today = new Date();
    			var day   = today.getDate();
				var month = today.getMonth();
				var year  = today.getYear();
				stryear=new String(year)
				stryear=stryear.slice(2,5)
				//alert (stryear)
				month = month+1;
		
				var selcdate = new Date(seldate);
				var selday = selcdate.getDate();
				var selmonth = selcdate.getMonth();
				var selyear = selcdate.getYear();
				strselyear= new String(selyear)
				strselyear=strselyear.slice((strselyear.length)-2,(strselyear.length)+1)
				selmonth = selmonth+1;
		
				tmm = parseInt(month);
				smm = parseInt(selmonth);
				
				tyy = parseInt(stryear);
				syy = parseInt(strselyear);		
				tdd = parseInt(day);
				sdd = parseInt(selday);				
		
				if (syy > tyy)
				{
					flag=true;
					
				}	
				else
				{
					if (syy == tyy)
					{
						if (smm > tmm)
						{
							flag=true;
						}
						else
						{
							if (smm == tmm)
							{
								if (sdd >= tdd)
								{
									flag=true;
								}
								else
								{
									flag=false;
								}	
							}
							else
							{
								flag=false;
							}
						}
					}
					else
					{
						flag=false;
					}
					
				}
				if(flag)
				{
					return true;
				}
				else
				{
					return false;
				}
				 
			}
//Validates 5, 5+4 digit Zip Code
function validateZIP(field) {
var valid = "aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ0123456789-";
var hyphencount = 0;

if (field.length!=5 && field.length!=10) {
alert("Please enter your 5 digit or 5 digit+4 zip code.");
return false;
}
for (var i=0; i < field.length; i++) {
temp = "" + field.substring(i, i+1);
if (temp == "-") hyphencount++;
if (valid.indexOf(temp) == "-1") {
alert("Invalid characters in your zip code.  Please try again.");
return false;
}
if ((hyphencount > 1) || ((field.length==10) && ""+field.charAt(5)!="-")) {
alert("The hyphen character should be used with a properly formatted 5 digit+four zip code, like '12345-6789'.   Please try again.");
return false;
   }
}
return true;
}
//Validates 5, 5+4 digit Zip Code without comments
function validate1ZIP(field) {
var valid = "aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ0123456789-";
var hyphencount = 0;

if (field.length!=5 && field.length!=10) {
//alert("Please enter your 5 digit or 5 digit+4 zip code.");
return false;
}
for (var i=0; i < field.length; i++) {
temp = "" + field.substring(i, i+1);
if (temp == "-") hyphencount++;
if (valid.indexOf(temp) == "-1") {
//alert("Invalid characters in your zip code.  Please try again.");
return false;
}
if ((hyphencount > 1) || ((field.length==10) && ""+field.charAt(5)!="-")) {
//alert("The hyphen character should be used with a properly formatted 5 digit+four zip code, like '12345-6789'.   Please try again.");
return false;
   }
}
return true;
}


// Check all the form fields are empty
function isAllFieldsEmpty(input)
{
	var blnEmpty;
	var frm = eval("document." + input);

	blnEmpty = true;
	for(i=0;i<frm.length;i++)
	{
		if (frm.elements[i].type != "button" && frm.elements[i].type != "submit")
		{
			if (frm.elements[i].value != "" && frm.elements[i].value != null)
				blnEmpty = false;
		}
	}
	if (blnEmpty == true)
	{
		alert("All Fields are empty\nFill at least any one of the fields");
		frm.elements[0].focus();	
	}
	
	return blnEmpty;
}



// This Function displays the message on the status bar.

var strStatusMsg;
strStatusMsg = "  M c K e c h n i e    A e r o s p a c e";

timeID = 10;
stcnt = 16;
wmsg = new Array(39);
        wmsg[0]=strStatusMsg;
        blnk = "                                                               ";
        for (i=1; i<32; i++)
        {
                b = blnk.substring(0,i);
                wmsg[i]="";
                for (j=0; j<strStatusMsg.length; j++) wmsg[i]=wmsg[i]+strStatusMsg.charAt(j)+b;
        }

function wiper()
{
        if (stcnt > -1) str = wmsg[stcnt]; else str = wmsg[0];
        if (stcnt-- < -40) stcnt=31;
        status = str;
        clearTimeout(timeID);
        timeID = setTimeout("wiper()",100);
}

function isInteger (s)
{
	var i;
	for (i = 0; i < s.length; i++)
{
	var c = s.charAt(i);
	if (!isDigit(c)) return false;
}
return true;
}

function isDigit (c)
{
	return ((c >= '0') && (c <= '9'))
}

//Following Function is used to validate the values of Price Fields.
// Ramki - 12/Feb/02


function IsValidValue(ItemVal, MinLength, MaxLength, CapName )
{
	var l_blnDot
	var l_intIt 
	var l_strDecPart
	var l_strFirstPart
 
	l_blnDot = false;
	
	
	for (l_intIt=0;l_intIt<=ItemVal.length;l_intIt++)
	{
 		if ((ItemVal.charAt(l_intIt)=='.') && (l_blnDot == false))
		{
			l_blnDot = true;								
			break;
		}
	}
	
	if (l_blnDot==true)
	{				
	
		l_strDecPart = ItemVal.substring(l_intIt + 1,ItemVal.length);			
		if (l_strDecPart.length <= 2)
		{
			if (ItemVal.length <= MaxLength)
				return true;
			else
				alert('Length of ' + CapName + ' Should be ' + MaxLength + ' [with Integer Portion Minimum of Length ' + eval(MinLength-3) + ', Maximum of Length ' + eval(MaxLength-3) +   ' and 2 Decimal Places]'); 
				return false;
		}
		else
		{
			alert('Only Two characters allowed after the decimal point'); 
			return false;
		}	
	}
	else
	{
	
		if ((ItemVal.length >= (MinLength- 2)) && (ItemVal.length<=(MaxLength - 3)))
			return true;
		else
		{				
			alert('Length of Entered Value of ' + CapName + ' should be ' + (MinLength- 2) + ' of minimum and ' + (MaxLength - 3) + ' at maximum without Decimal'); 
			return false;
		}
	}	
}

//FUNCTION TO ADD 1900 TO YEAR IF BROWSER IS NETSCAPE
//HARI - 23/5/2002
function ChangeYearIfNetscape(pstrYear)
{
		var strBrowser=new String()
		var intYear;
		
		strBrowser=navigator.appName
		if (strBrowser.toLowerCase()=="netscape")
		{
			intYear=1900+parseInt(pstrYear);
		}
		else
		{
			intYear=parseInt(pstrYear);
		}
		return intYear
}
/*
	For valley module the following code is added
*/
	function checkTextbox(txtAlphaobj,dispMsg,allowSpecialchar,paramFieldName)
	{
		var itVar=0;
		var Cnt=0;
		txtAlphaobj=eval(txtAlphaobj);
		var mTxtboxvalue="";
/*		for(itVar=0;itVar<=txtAlphaobj.value.length-1;itVar++)
		{
			if(txtAlphaobj.value.substr(itVar,1)!=" ")
			{
				Cnt=1;
				break;
			}
		}*/
		mTxtboxvalue=txtAlphaobj.value;
		mTxtboxvalue=mTxtboxvalue.replace(/ /gi,"");
		if(mTxtboxvalue!="")
		{
			Cnt=1;
		}
		if(Cnt==1 && allowSpecialchar==0)
		{
			if(isSpecialChar(txtAlphaobj.value))
			{
				alert("Special Characters Are Not Allowed In " + paramFieldName);
				txtAlphaobj.focus();
				txtAlphaobj.select();
				return false;
			}
			return true;
			
		}
		if (Cnt==1 && allowSpecialchar!=0)
		{	
			return true;
		}
		
		
		alert(dispMsg);
		txtAlphaobj.focus();
		txtAlphaobj.select();
		return false;
	}
	function checkNumeric(txtNumericobj,dispMsg,zeroFlag,intPart,decPart)
	{
		if(checkNAN(txtNumericobj.value,dispMsg)==false)
		{
			txtNumericobj.focus();
			txtNumericobj.select();
			return false;
		}
		var realPart="";
		var imgPart="";
		var numericField;
		numericField=txtNumericobj.value.split(".");
		realPart=numericField[0];
		imgPart=numericField[1];
		if(zeroFlag=="0")
		{
			if(isNaN(txtNumericobj.value))
			{
				if(eval(parseFloat(decPart))>0)
				{
					dispMsg=dispMsg + "\n"+ "Data Should have Integer Portion of " + intPart + " And Decimal Portion of " + decPart;
				}
				else
				{
					dispMsg=dispMsg + "\n"+ "Data Should have Integer Portion of " + intPart + " And No Decimal Portion " ;
				}
				alert(dispMsg);
				txtNumericobj.focus();
				txtNumericobj.select();
				return false;
			}
			if(txtNumericobj.value!="" && eval(parseFloat(txtNumericobj.value))<0)
			{
				if(eval(parseFloat(decPart))>0)
				{
					dispMsg=dispMsg + "\n"+ "Data Should have Integer Portion of " + intPart + " And Decimal Portion of " + decPart;
				}
				else
				{
					dispMsg=dispMsg + "\n"+ "Data Should have Integer Portion of " + intPart + " And No Decimal Portion " ;
				}
				alert(dispMsg);
				txtNumericobj.focus();
				txtNumericobj.select();
				return false;
			}
		}
		if(zeroFlag!="0")
		{
			if(txtNumericobj.value=="")
			{
				if(eval(parseFloat(decPart))>0)
				{
					dispMsg=dispMsg + "\n"+ "Data Should have Integer Portion of " + intPart + " And Decimal Portion of " + decPart;
				}
				else
				{
					dispMsg=dispMsg + "\n"+ "Data Should have Integer Portion of " + intPart + " And No Decimal Portion " ;
				}
				alert(dispMsg);
				txtNumericobj.focus();
				txtNumericobj.select();
				return false;
			}
			if(txtNumericobj.value!="" && eval(parseFloat(txtNumericobj.value))<=0 || isNaN(txtNumericobj.value))
			{
				if(eval(parseFloat(decPart))>0)
				{
					dispMsg=dispMsg + "\n"+ "Data Should have Integer Portion of " + intPart + " And Decimal Portion of " + decPart;
				}
				else
				{
					dispMsg=dispMsg + "\n"+ "Data Should have Integer Portion of " + intPart + " And No Decimal Portion " ;
				}
				alert(dispMsg);
				txtNumericobj.focus();
				txtNumericobj.select();
				return false;
			}
		}
		if(txtNumericobj.value.indexOf(".")>0)
		{
/*			if(eval(parseFloat(realPart))<=0)
			{
				var dispMsg1=" - Decimal Portion Should be " + decPart + " Characters";
				if(eval(parseFloat(decPart))==0)
				{	
					dispMsg1=" - No Decimal Portion Allowed "
				}
				alert(dispMsg + dispMsg1);
				txtNumericobj.focus();
				txtNumericobj.select();
				return false;
			}*/
			if(eval(parseFloat(imgPart.length))>eval(parseFloat(decPart)) && eval(parseFloat(imgPart))>0)
			{
				var dispMsg1=" - Decimal Portion Should be " + decPart + " Characters";
				if(eval(parseFloat(decPart))==0)
				{	
					dispMsg1=""
				}
				alert(dispMsg + dispMsg1);
				txtNumericobj.focus();
				txtNumericobj.select();
				return false;
			}
		}
		if(eval(realPart.length)>eval(parseFloat(intPart)) && eval(parseFloat(realPart))>0)
		{
			var dispMsg1=" - Integer Portion Should be " + intPart + " Characters";
			alert(dispMsg + dispMsg1);
			txtNumericobj.focus();
			txtNumericobj.select();
			return false;
		}				
		return true;
	}
	function checkNAN(paramNumvalue,paramDispmsg)
	{
		if(paramNumvalue.toLowerCase().indexOf("e")>=0)
		{
			alert(paramDispmsg);
			return false;				
		}
		
	}
	function setObjfocus(focusObj)
	{
		focusObj=eval(focusObj);
		if(focusObj.type=="hidden")
		{
			return false;
		}
		focusObj.focus();
		if(focusObj.type=="text")
		{
			focusObj.select();
		}
	}
	function checkDate(txtBox,dispMsg)
	{
		if(txtBox.value=="")
		{
			alert(dispMsg)
			setObjfocus(txtBox);
			return false;
		}
		if(checkLength(txtBox)==false)
		{
			return false;
		}
		if(checkDateseparator(txtBox)==false)
		{
			return false;
		}
	}
	function checkLength(txtBox)
	{
/*		if(txtBox.value.length!=10)
		{
			alert("Invalid Date Format");
			txtBox.focus();
			txtBox.select();
			return false;
		}*/
	}
	function checkDateseparator(txtBox)
	{
		var dateSeparated="";
		dateSeparated=txtBox.value.split("/");
		if(dateSeparated.length!=3)
		{
			alert("Invalid Date Format");
			setObjfocus(txtBox);
			return false;
		}
		var mmValue="";
		var ddValue="";
		var yyValue="";
		if(dateFormat.toLowerCase()=="dd/mm/yyyy")
		{
			ddValue=dateSeparated[0];
			mmValue=dateSeparated[1];
			yyValue=dateSeparated[2];
		}
		else
		if(dateFormat.toLowerCase()=="mm/dd/yyyy")
		{
			mmValue=dateSeparated[0];
			ddValue=dateSeparated[1];
			yyValue=dateSeparated[2];
		}
		else
		if(dateFormat.toLowerCase()=="yyyy/mm/dd")
		{
			yyValue=dateSeparated[0];
			mmValue=dateSeparated[1];
			ddValue=dateSeparated[2];
		}
		else
		if(dateFormat.toLowerCase()=="yyyy/dd/mm")
		{
			yyValue=dateSeparated[0];
			ddValue=dateSeparated[1];
			mmValue=dateSeparated[2];
		}
		if(checkYear(txtBox,yyValue)==false)
		{
			return false;
		}
		if(checkMonth(txtBox,mmValue)==false)
		{
			return false;
		}
		if(checkDay(txtBox,mmValue,ddValue)==false)
		{
			return false;
		}
		if(eval(parseFloat(ddValue))<=9 && ddValue.length==1)
		{
			ddValue="0" + ddValue;
		}
		if(eval(parseFloat(mmValue))<=9 && mmValue.length==1)
		{
			mmValue="0" + mmValue;
		}
		dayPart=ddValue;
		monPart=mmValue;
		yearPart=yyValue;
	}
	function checkMonth(txtBox,mmValue)
	{
		if(isNaN(mmValue))
		{
			alert("Invalid Date - Month Should Be Valid Numeric Between 1-12");
			setObjfocus(txtBox);
			return false;
		}
		
		if(eval(parseFloat(mmValue))==0 || eval(parseFloat(mmValue))>12)
		{
			alert("Invalid Date - Month Should Be Valid Numeric Between 1-12");
			setObjfocus(txtBox);
			return false;
		}
	}
	function checkDay(txtBox,mmValue,ddValue,yyValue)
	{
		if(isNaN(ddValue))
		{
			alert("Invalid Date - Month Should Be Valid Numeric");
			setObjfocus(txtBox);
			return false;
		}
		if(eval(parseFloat(ddValue))==0)
		{
			alert("Invalid Date - Day Should Be Valid Numeric Between 1-31");
			setObjfocus(txtBox);
			return false;
		}
/* Check for 31 Days */
		if(eval(parseFloat(mmValue))==1 || eval(parseFloat(mmValue))==3 || eval(parseFloat(mmValue))==5 || eval(parseFloat(mmValue))==7 || eval(parseFloat(mmValue))==8 || eval(parseFloat(mmValue))==10 || eval(parseFloat(mmValue))==12)
		{
			if(eval(parseFloat(ddValue))>31)
			{
				alert("Invalid Date - Day Should Be Valid Numeric Between 1-31");
				setObjfocus(txtBox);
				return false;
			}
		}
/* Check for 30 Days */
		if(eval(parseFloat(mmValue))==4 || eval(parseFloat(mmValue))==6 || eval(parseFloat(mmValue))==9 || eval(parseFloat(mmValue))==11)
		{
			if(eval(parseFloat(ddValue))>30)
			{
				alert("Invalid Date - Day Should Be Valid Numeric Between 1-30");
				setObjfocus(txtBox);
				return false;
			}
		}
/* Check for Leap Year*/
		if(eval(parseFloat(mmValue))==2)
		{
			var mLeapyear=0;
			if(eval(parseFloat(yyValue)%4)==0)
			{
				mLeapyear=1;
				if(eval(parseFloat(yyValue)%100)==0 && eval(parseFloat(yyValue)%400)!=0)
				{
					mLeapyear=1;
				}
			}
			if(mLeapyear==0 && (eval(parseFloat(ddValue))==0 || eval(parseFloat(ddValue))>28))
			{
				alert("Invalid Date - Day Should Be Valid Numeric Between 1-28");
				setObjfocus(txtBox);
				return false;
			}
			if(mLeapyear==1 && (eval(parseFloat(ddValue))==0 || eval(parseFloat(ddValue))>29))
			{
				alert("Invalid Date - Day Should Be Valid Numeric Between 1-29");
				setObjfocus(txtBox);
				return false;
			}
		}
	}
	function checkYear(txtBox,yyValue)
	{
		if(isNaN(yyValue) || yyValue.length<4)
		{
			alert("Invalid Date - Year Part Should Be Valid Numeric Of Length 4 Digits");
			setObjfocus(txtBox);
			return false;
		}
		if(eval(parseFloat(yyValue))<=1900)
		{
			alert("Invalid Date - Year Should Not Be Less Than Or Equal To 1900 Below ");
			setObjfocus(txtBox);
			return false;
		}
		if(yyValue.length>4)
		{
			alert("Invalid Date - Year Part Should Be Valid Numeric Of Length 4 Digits");
			setObjfocus(txtBox);
			return false;

		}
	}
	function compareDate(txtFromdate,txtTodate,zeroFlag,focusObj,throwMsg)
	{
		var fromDate=""
		var toDate="";
		if(checkDate(txtFromdate,"Enter Required Date - Should Not Be Empty")==false)
		{
			return false;
		}
		fromDate=yearPart+monPart+dayPart;
		if(checkDate(txtTodate,"Enter Required Date - Should Not Be Empty")==false)
		{
			return false;
		}
		toDate=yearPart+monPart+dayPart;
		if(zeroFlag==0)
		{
			if(eval(parseFloat(fromDate))-eval(parseFloat(toDate))>0)
			{
				alert(throwMsg);
				setObjfocus(focusObj);
				return false;
			}
		}
		else
		if(zeroFlag==1)
		{
			if(eval(parseFloat(fromDate))-eval(parseFloat(toDate))>=0)
			{
				alert(throwMsg);
				setObjfocus(focusObj);
				return false;
			}
		}
	}

//functions added for VT - checkTextboxVT and isSpecialCharVT

	function checkTextboxVT(txtAlphaobj,dispMsg,allowSpecialchar,paramFieldName)
	{
		var itVar=0;
		var Cnt=0;
		txtAlphaobj=eval(txtAlphaobj);
		var mTxtboxvalue="";
/*		for(itVar=0;itVar<=txtAlphaobj.value.length-1;itVar++)
		{
			if(txtAlphaobj.value.substr(itVar,1)!=" ")
			{
				Cnt=1;
				break;
			}
		}*/
		mTxtboxvalue=txtAlphaobj.value;
		mTxtboxvalue=mTxtboxvalue.replace(/ /gi,"");
		if(mTxtboxvalue!="")
		{
			Cnt=1;
		}
		if(Cnt==1 && allowSpecialchar==0)
		{
			if(isSpecialCharVT(txtAlphaobj.value))
			{
				alert("Special Characters Are Not Allowed In " + paramFieldName);
				txtAlphaobj.focus();
				txtAlphaobj.select();
				return false;
			}
			return true;
			
		}
		if (Cnt==1 && allowSpecialchar!=0)
		{	
			return true;
		}
		
		
		alert(dispMsg);
		txtAlphaobj.focus();
		txtAlphaobj.select();
		return false;
	}



function isSpecialCharVT(formelem)
{
	var expisSpecialChar=/[\*\~|@\$\%\^\*\(\)\#\!\`\+\=\'\"\,\_\<\>\?]/
	return expisSpecialChar.test(formelem)
}
