/**************************************************
The file contains the following funtions

1. validateWholeNumber
2. validateAlphaNumeric
3. CheckDate
4. isValidDateWithoutAlerts
5. TrimString
6. CheckNum
7. isValidDate
8. PrintWindow
9. OpenWindow
***************************************************/
//ValidationExpression="\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"

var objFirstField
var blnHasError
var strErrorMessage
var strErrorSeparator

blnHasError=false
strErrorSeparator="\n - "
strFirstField=""
strErrorMessage ="The following error(s) were found :";

function ShowErrorAndResetValues()
	{		
		try
		{
			if (objFirstField)
			{
				alert(strErrorMessage );
				objFirstField.focus();
				strErrorMessage ="The following error(s) were found :";
				objFirstField="";
				return false;
			}	
			else
			{
				return true;
			}
		}
		catch(e)
		{
			
		}
	}

function SendMail(objEmail,url)
{
	/*validates and is valid sends mail*/
	
	var objText=document.getElementById(objEmail)
	
	if(validateEmail(objText))
	{
		strNewUrl = url + "?MailTo="+ TrimString(objText.value)
		mailWindow=window.open(strNewUrl,"MailWindow","status=no,resize=no,toolbar=no,scrollbars=no,width=300,height=120,maximize=null")
	}
	
}
function validateEmail(objTextBox)
{
	try
	{
		var str;
		var str = new String(TrimString(objTextBox.value));
		var objRegExp =/^[\w-\.]{1,}\@([\da-zA-Z-]{1,}\.){1,}[\da-zA-Z-]{2,3}$/;   // /\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/;
		var flag = str.match(objRegExp);
		
		if (flag == null)
		{
			return false; // invalid string
		}
		else 
		{
			return true; // valid string
		}
	}
	catch (exception){}
}

function validateWholeNumber(source, arguments)
{
	try
	{
		var str;
		var str = new String(arguments.Value);
		
		var objRegExp = /^\d*$/;
		var flag = str.match(objRegExp);
		
		if (flag == null)
		{
			arguments.IsValid = false;
			return ; // invalid string
		}
		else 
		{
			arguments.IsValid = true;
			return ; // valid string
		}
	}
	catch (exception){}
}


function validateAlphaNumeric(source, arguments)
{
	try
	{
		var str;
		var str = new String(arguments.Value);
		
		var objRegExp = /^[a-zA-Z0-9\s]+$/;
		var flag = str.match(objRegExp);
		
		if (flag == null)
		{
			arguments.IsValid = false;
			return ; // invalid string
		}
		else 
		{
			arguments.IsValid = true;
			return ; // valid string
		}
	}
	catch (exception){}
}

function CheckDate(source, arguments)
{
	try
	{
		var dateStr 
		dateStr = new String(arguments.Value);
		//if (isValidDateWithoutAlerts(dateStr)==true) 
		isValidDateWithoutAlerts(dateStr)
		if(strErrMsg=="")
		{
			arguments.IsValid = true;
			return ; // valid string
		}
		else
		{
			source.errormessage= strErrMsg
			arguments.IsValid = false;
			return ; // invalid string
		}		
	}
	catch (exception){}
}


/*
'*****************************************************************
'Function :isValidDateWithoutAlerts
'Purpose  :Checks for valid date but does not alert any message
'Algorithm:
'Input    :Date
'Output   :True/False
'Author   :Rajesh Srivastava
'Created On: 15th January 2005
'*****************************************************************
*/
//stores the error message
var strErrMsg
function isValidDateWithoutAlerts(dateStr) 
{
	try
	{
		strErrMsg=""
		var datePat = /^(\d{1,2})(\/|-)(\d{1,2})\2(\d{4})$/;
		var matchArray = dateStr.match(datePat); 
		var strMonth;
		if (matchArray == null) 
		{
			strErrMsg="Date is not in a valid format."
			return false;
		}
		month = matchArray[1]; 
		day = matchArray[3];
		year = matchArray[4];
		switch(month)
		{
			
			case "4":
			case "04":
						strMonth="April";
						break;
			case "6":
			case "06":
						strMonth="June"; 
						break;
			case "9":
			case "09":	
						strMonth="September"; 
						break;
			case "11":	
						strMonth="November";
						break;
			
			
		}
		if(year < 1800)
		{
			strErrMsg="Year cannot be less than 1800."
			return false;
		}
		if (year > 2078)
		{
			strErrMsg="Year cannot be greater than 2078";
			return false;
		} 
		if (month < 1 || month > 12) 
		{ 
			strErrMsg="Month must be between 1 and 12."
			return false;
		}
		if (day < 1 || day > 31) 
		{
			strErrMsg="Day must be between 1 and 31."
			return false;
		}
		if ((month==4 || month==6 || month==9 || month==11) && day==31) 
		{
			strErrMsg=strMonth+" "+"does not have 31 days."
			return false;
		}
		if (month == 2) 
		{ 
			var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
			if (day>29 || (day==29 && !isleap)) 
			{
				strErrMsg="February does not have " + day + " days in the year " + year + "."
				return false;
			}
		}
		return true;
	}
	catch (exception){}
}


function TrimString(str)
{
	var stringInput = new String(str)	//variable to store input string 
	startPosition=0;	//variable to store the postion where the first Non Blank character comes
	stringLength = stringInput.length;	//stores string length
	endPosition = stringLength-1;			//stores the position where the last non blank character comes
		
	while(startPosition<stringLength)	//starts finding first non blank character from begining of the string
	{
		if(stringInput.substr(startPosition,1)!=' ' && stringInput.charCodeAt(startPosition)!=13 && stringInput.charCodeAt(startPosition)!=10)	
		{
			break;
		}
		startPosition=startPosition+1;	//if non blank character is found then the position is stored and loop breaks
	}
		
		
	while(endPosition>=startPosition)
	{
		if(stringInput.substr(endPosition,1)!=' ' && stringInput.charCodeAt(endPosition)!=13 && stringInput.charCodeAt(endPosition)!=10)
		{
			break;
		}
		endPosition=endPosition-1;
	}
	var stringReturn = stringInput.substring(startPosition,endPosition+1);	//gets the string between 2 postions
	
	return stringReturn;
}

/*
Function to allow numeric entry 
Input:	(1)obj - Object for Textbox
		(2)SubmitOnEnter - Set the Enter Key active for submitting form. Set 0 for making Inactive and Set 1 to make active
	
*/
function CheckNum(eventObject)
{
	try
	{
		if(navigator.family=="IE")
		{	
			if( ((eventObject.keyCode >= 96) && (eventObject.keyCode <= 105)) ||
				((eventObject.keyCode >= 48) && (eventObject.keyCode <= 57)) ||
				(eventObject.keyCode == 8)|| 
				(eventObject.keyCode == 9) ||
				(eventObject.keyCode == 46) || 
				(eventObject.keyCode == 35) || 
				(eventObject.keyCode == 36))
				return true;
			else
				return false;
		}
		else
		{
			alert(window.captureEvents(Event.KEYPRESS));
			if(eventObject.which!=13 && !(eventObject.which>47&&eventObject.which<58||eventObject.which==8||eventObject.which==0)) 
				return false;
		}
	}
	catch (exception)
	{
		alert(exception);
	}
}

function CheckNum(obj,evt)
{
	evt = (evt) ? evt : ((event) ? event : null);
						
	var charCode = (evt.charCode) ? evt.charCode : evt.keyCode

	if( ((charCode >= 48) && (charCode <= 57)) ||
		(charCode == 8)|| (charCode == 13)|| 
		(charCode == 9))
		return true;
	else
		return false;
	
}

//Function checks for valid date and returns true/false accordingly by Dinesh Thakan Used in Messaging Search Page.
/*
'*****************************************************************
'Function :isValidDate
'Purpose  :Checks for valid date
'Algorithm:
'Input    :Date
'Output   :True/False
'Author   :Rajesh Srivastava
'Created On: 15th January 2005
'*****************************************************************
*/

function isValidDate(dateStr) 
{
	try
	{
		//var dateStr = obj.value;
		if(TrimString(dateStr)!="")
		{
			var datePat = /^(\d{1,2})(\/|-)(\d{1,2})\2(\d{4})$/;
			var matchArray = dateStr.match(datePat);
			var strMonth; 
			if (matchArray == null) 
			{
				alert("Date is not in a valid format. (mm/dd/yyyy)")
				return false;
			}
			month = matchArray[1]; 
			day = matchArray[3];
			year = matchArray[4];
			switch(month)
			{
				
				case "4":
				case "04":
							strMonth="April";
							break;
				case "6":
				case "06":
							strMonth="June"; 
							break;
				case "9":
				case "09":	
							strMonth="September"; 
							break;
				case "11":	
							strMonth="November";
							break;
				
				
			}
			if(year < 1800)
			{
				alert("Year cannot be less than 1800.");
				return false;
			}
			if (year > 2078)
			{
				alert("Year cannot be greater than 2078");
				return false;
			} 
			if (month < 1 || month > 12) 
			{ 
				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(strMonth +" does not have 31 days!")
				return false;
			}
			if (month == 2) 
			{ 
				var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
				if (day>29 || (day==29 && !isleap)) 
				{
					alert("February does not have " + day + " days!");
					return false;
				}
			}
		}
		return true;
	}
	catch (exception){}
}

//Function checks for valid date and returns true/false accordingly by Dinesh Thakan Used in Messaging Search Page.
/*
'*****************************************************************
'Function :PrintWindow
'Purpose  :Prints the window
'Algorithm:
'Input    :
'Output   :
'Author   :Rajesh Srivastava
'Created On: 15th January 2005
'*****************************************************************
*/
function PrintWindow()
{
	try
	{
		if (window.print) 
			self.print();
		setTimeout('self.close()',2000);
	}
	catch (exception){}
}

//Function checks for valid date and returns true/false accordingly by Dinesh Thakan Used in Messaging Search Page.
/*
'*****************************************************************
'Function :OpenWindow
'Purpose  :Opens the window for print/word/excel
'Algorithm:
'Input    : Filename, WindowName, ShowMenuBar (0 to hide, 1 to show. this is for menu for Word/Excel output)
'Output   :
'Author   :Rajesh Srivastava
'Created On: 15th January 2005
'*****************************************************************
*/
function OpenWindow(FileName, WindowName, ScrollBar, MenuBar, Resizable,width,height)
{
	try
	{	
		
		var intTop;
		var intLeft;
		var strWindowStatus;
		
		if (window.screen.availWidth > 750)
		{
		//800 x 600 or better
		if (window.screen.availHeight>710)
			{
				intTop = (window.screen.availHeight-500)/2;
				intLeft = (window.screen.availWidth-750)/2
			}
		else
			{
				intTop = (window.screen.availHeight-450)/2;
				intLeft = (window.screen.availWidth-720)/2
			}
		}
		else
		{
			//small screen
			intTop = 5;
			intLeft = 5;
			
		}
		
		if (navigator.family=="gecko")
			height = height+200;
		
		strWindowStatus = "width=" + width + ",height=" + height +",left=" + intLeft + ",top=" + intTop + ",resizable=" + Resizable + ",scrollbars=" + ScrollBar + ",menubar=" + MenuBar 
		
		
		return window.open(FileName,WindowName,strWindowStatus);
	}
	catch(exception){}
}


function HideLayer(pLayer, bCascade) {
	for (var i=0; i<pLayer.length; i++) {
		pLayer[i].visibility = "hide";
		if (bCascade)
			HideLayer(pLayer[i].document.layers, true);
	}
}
		
function HideDivTags() {
	var pDivs  = "";
	var sDivNm = ""		;
	if (navigator.family == "IE") 
		pDivs  = document.all.tags("div");	
	else
		pDivs  = document.getElementsByTagName("div");	

	for (var i=0; i<pDivs.length; i++) {
		sDivNm = pDivs[i].id;
		if (sDivNm.substr(0,3) == "mnu")
			pDivs[i].className = "hide";
	}
}
		
function Toggle(pAnkr, pDivLyr) {
							
	var nArgs = arguments.length;
	var pLayer = document.layers;
	switch (navigator.family) {
		case "IE":
			HideDivTags();
			//alert(document.all["mnuDropA"].id);
		break;
		case "nn":
			HideLayer(pLayer, true);
			//alert(document.layers["mnuDropA"]);
		break;
		case "gecko":
			HideDivTags();
			pDivLyr = document.getElementById(pDivLyr);
		break;
		default:
		break;
	}
	if (nArgs != 0) {				
		// check which browser we are
		var pDynElem = (pLayer ? pDivLyr.visibility : pDivLyr.className);
		
		// be smart about namimg display classes
		pDynElem = (pDynElem = "hide" ? "show" : "hide");
		
		// make the changes to the style or class
		switch(navigator.family) {
			case "nn":
				pDivLyr.visibility = pDynElem;
				if (pDynElem == "show") {
					pDivLyr.left = pAnkr.x;
					pDivLyr.top  = pAnkr.y + 15;
				}
			break;
			default:
				pDivLyr.className = pDynElem;
			break;
		}
	}
	return(false);
}

function OnMouseOutCheck(pDiv) {
	
	switch(navigator.family) {
		case "IE":
			if (!pDiv.contains(event.toElement)) 
				Toggle();
			
		break;
		case "nn":
			Toggle();
		break;
		case "gecko":
			
			//var pDivTag = document.getElementById(pDiv);
					
			//alert(pDivTag.innerHTML)
			//if (pDivTag.innerHTML!="") 
			//	Toggle();
			
		break;
		default:
		break;
	}
}


/*
'*****************************************************************
'Function	:CheckGreaterThanZeroNonDecimal
'Purpose	:Check for values greater than 0 and non decimal
'Algorithm	:
'Input		:value
'Output		:True/False
'Author		:Rajesh Srivastava
'Created On: 15th January 2005
'*****************************************************************
*/
function CheckGreaterThanZeroNonDecimal(numValue)
{
	var Interval = numValue;

	if (isNaN(Interval))
	{
		return false;
	}
	if (Interval.indexOf(".") != -1)
	{
		return false;
	}
	if (Interval <= 0 )
	{
		return false;
	}	
	if (isexpo(Interval))
	{
		return false;
	}	
	return true;
}


/*
'*****************************************************************
'Function :isexpo
'Purpose  :Check for exponential values
'Algorithm:
'Input    :Source, Arguments
'Output   :True/False
'Author   :Rajesh Srivastava
'Created On: 15th January 2005
'*****************************************************************
*/
function isexpo(str)
{
	var strValue = new String(str)
	//Checks for exponensial values
	if (strValue.indexOf("e") >= 0 || strValue.indexOf("E") >= 0)
	{
		return true;
	}	
	else
	{
		return false;
	}
}
/******************************************************************
Function	: CheckAmount
Purpose		: Checks for valid amount text boxes
Input		: amount, allowDecimal, noOfDigitsAfterDecimal
Output		: Integer value  
			  0 : Valid value
			  1 : Empty value
			  2 : Invalid number
			  3 : More than two digits after decimal number
			  4 : Decimal is not allowed
			  5 : Zero is not allowed
			  6 : Negative value is not allowed
Author		: Rajesh Srivastava
'Created On: 15th January 2005
'******************************************************************/
function CheckAmount(amount, allowDecimal,noOfDigitsAfterDecimal)
{
	var intReturnValue;
	var intAfterDecimal;
		
	try
	{
		intReturnValue = -1;
		
		if (TrimString(amount)=='')
		{
			//Empty String
			intReturnValue = 1;
		}
		else if (isNaN(amount))
		{
			//Invalid Number
			intReturnValue = 2;
		}
		else if (isexpo(amount))
		{
			//Invalid Number
			intReturnValue = 2;
		}
		else if (amount.indexOf(".")>-1 && allowDecimal && amount.substr(amount.indexOf(".")+1,amount.length).length >noOfDigitsAfterDecimal)
		{
			//checks for digits after decimal
			intReturnValue =3
		}
		else if(amount.indexOf(".")>-1 && !allowDecimal)
		{
			//Decimal is not allowed
			intReturnValue =4;
		}
		else if(parseFloat(amount) == 0)
		{
			//Zero is not allowed
			intReturnValue =5;
		}
		else if(amount.indexOf("-")>-1)
		{
			intReturnValue = 6;
		}
		else if(parseFloat(amount) > 99999)
		{
			intReturnValue =7;
		}
		else
		{
			//valid number
			intReturnValue =0;
		}
		
		return intReturnValue;
	}
	
	catch(e){//alert(e.description)
			} 	
}
/******************************************************************
Function	: getMessage
Purpose		: returns message according to error condition
Input		: code
Output		: error message
Author		: Rajesh Srivastava
'Created On: 15th January 2005
'******************************************************************/
function getMessage(code)
{
	try
	{
		switch (code)
		{
			case 1:
				return "cannot be left blank.";
				break;
			
			case 2:
				return "is invalid.";
				break;
			
			case 3:
				return "cannot have more than two numbers after decimal.";
			
			case 4:
				return "cannot have decimal value.";
				break;
				
			case 5:
				return "cannot have zero value.";
				break;
				
			case 6:
					return "cannot have negative value.";
					break;
			case 7:
					return " cannot be greater than 99,999.";
					break;		
			
						
		}
	}
catch(e){}
}



/*'*****************************************************************
'Function :CheckImage
'Purpose  :Check for Images
'Algorithm:
'Input    :Source-- > object whose image value has to be checked
'Output   :True/False
'Author   :Rajesh Srivastava
'Created On: 15th January 2005
'*****************************************************************
*/


function CheckImage(fileName)
{
		//Retrieves the file extension from the file name
		fileExtension = fileName.substr(fileName.lastIndexOf(".")+1);
		//Convert the file extension to lowercase to compare
		fileExtension = fileExtension.toLowerCase();
		
		if ( !(fileExtension=="jpg"	|| fileExtension=="jpeg" || fileExtension=="gif" || fileExtension=="bmp" || fileExtension=="png" ))
			return false;
		else
			return true;
}		
var objLCPopWindow;			// label company window
var objCusPopWindow;			// customer window
var objSPPopWindow;				// sales person window
var objLTPopWindow;				// label type window
var objPRPopWindow;				// process window
var objCLPopWindow;				// color window
var objMPopWindow;				// material window
var objSamplePopWindow;			// sample window
var objAdrPopWindow;			// address window
var objSPLPopWindow;			// samples added window
function ClosePopUpWindows()
{
	try
	{
		if(objLCPopWindow!=null)
			objLCPopWindow.close();
			
		if(objCusPopWindow!=null)
			objCusPopWindow.close();
			
		if(objSPPopWindow!=null)
			objSPPopWindow.close();
			
		if(objLTPopWindow != null)
			objLTPopWindow.close();
			
		if(objPRPopWindow!=null)
			objPRPopWindow.close();
			
		if(objCLPopWindow!=null)
			objCLPopWindow.close();
			
		if(objMPopWindow!=null)
			objMPopWindow.close();
			
		if(objSamplePopWindow!=null)
			objSamplePopWindow.close();
			
		if(objAdrPopWindow!=null)
			objAdrPopWindow.close();
			
		if(objSPLPopWindow != null)
			objSPLPopWindow.close();
	}
	catch(e){}
}	

/*
'*****************************************************************
'Function   :fResetTextarea 
'Purpose    :Resets the text area
'Algorithm  :
'Input      :Form object
'Output     :
'Author     :Rajesh Srivastava
'Created On: 15th January 2005
'*****************************************************************
*/

function fResetTextarea (oForm) 
{
	for (var i = 0; i < oForm.length; i++) 
	{
		if (oForm.elements[i].type == "textarea")
		oForm.elements[i].value = oForm.elements[i].defaultValue;
	}
}

/*****************************************************************
    Function : IsValidEmail
    Purpose  : To validate Email address
    Algorithm:
    Input    : string
    Output   :
    Author   : Rajesh Srivastava
    'Created On: 15th January 2005
 *****************************************************************/
function IsValidEmail(strEmail)
{

	// following line define a Regular Expression using pattering matching 
	// for validating Email Address.
	var objRegExp =/^[\w-\.]{1,}\@([\da-zA-Z-]{1,}\.){1,}[\da-zA-Z-]{2,6}$/;
 
	var flag=strEmail.match(objRegExp);//validate Email Address.
	
	if(flag==null)	//if not valid Email address.
		return false;
	else
		return true;
}

function CheckDecimal(obj,evt)
{
	try
	{
		var intIndex;
		evt = (evt) ? evt : ((event) ? event : null);
							
							
		var charCode = (evt.charCode) ? evt.charCode : evt.keyCode
		
		if( ((charCode >= 48) && (charCode <= 57)) ||(charCode == 8)|| (charCode == 9) || (charCode==46))
		{
			if(charCode == 46)
			{
				
				intIndex = obj.value.indexOf(".");
				
				if(intIndex!=-1)
					return false;
			}
			return true;
		}
		else
			return false;
		

	}
	catch(e){}
}

function IsValidWebsite(strWebsite)
{

	/*
	Purpose: For validating website.
	Author: Rajesh Srivastava
	*/
	// following line define a Regular Expression using pattering matching 
	// for validating website.
	//var objRegExp =	/^(http|ftp|https):\/\/[\w]+(.[\w]+)([\w\-\.,@?^=%&amp;:/~\+#]*[\w\-\@?^=%&amp;/~\+#])?$/;
 	var objRegExp =	/^(http|ftp|https):\/\/[\w-\.]{1,}([\da-zA-Z-]{1,}\.){1,}[\da-zA-Z-]{2,6}$/;
	//var objRegExp =	/^(http|ftp|https):\/\/[\w](.[\w]{2,})([\w\-\.,@?^=%&amp;:/~\+#]*[\w\-\@?^=%&amp;/~\+#])?$/;

	//var objRegExp = /(?<http>(http:[/][/]|www.)([a-z]|[A-Z]|[0-9]|[/.]|[~])*)/;
 
	var flag=strWebsite.match(objRegExp); //validate website.
	
	if(flag==null)	//if not valid wegsite address.
		return false;
	else
		return true;
}
/*
 Functions for header */
function MM_swapImgRestore() { //v3.0
var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_findObj(n, d) { //v3.0
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); return x;
}
function MM_swapImage() { //v3.0
var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

/********************************************************/

/*
'*****************************************************************
'Function :CheckFileExtension
'Purpose  :Check for file extension & validate it against allowed file formats.
'Algorithm:Allow word, excel and pdf files only
'Input    :
'Output   :True/False
'Author   :Rajesh Srivastava
'Created On: 15th January 2005
'*****************************************************************
*/

function CheckFileExtension(objsource)
{
	var Str = new String(objsource.value);
	var fileName = Str.substr(Str.lastIndexOf(".")+1);
	fileName = fileName.toLowerCase();
	// valid for word, excel and pdf file only
	if ( !((fileName=="pdf") || (fileName=="doc") || (fileName=="xls") ) )
		{
		return false ; // invalid 
		}
	else
		{			
		return true ; // valid string
		}
}

/*
'*****************************************************************
'Function :CheckFileExtension
'Purpose  :Check for file extension & validate it against allowed file formats.
'Algorithm:Allow word, excel and pdf files only
'Input    :
'Output   :True/False
'Author   :Rajesh Srivastava
'Created On: 15th January 2005
'*****************************************************************
*/
function CheckNumericData(obj,evt)
{
	try
	{
		var intIndex;
		evt = (evt) ? evt : ((event) ? event : null);
							
							
		var charCode = (evt.charCode) ? evt.charCode : evt.keyCode
		
		if( ((charCode >= 48) && (charCode <= 57)) ||(charCode == 8)|| (charCode == 9) || (charCode==46) || (charCode==45))
		{
			if(charCode == 46)
			{
				
				intIndex = obj.value.indexOf(".");
				
				if(intIndex!=-1)
					return false;
			}
			if(charCode == 45)
			{
				
				intIndex = obj.value.indexOf("-");
				
				if(intIndex!=-1)
					return false;
				else
				{
					obj.value = "-" + obj.value;
					return false;
				}
			}
			
			return true;
		}
		else
			return false;
		

	}
	catch(e){}
}
var oPopup = window.createPopup();

function ShowHelp(arrHelpText,vPopupHeight,VClientX,VClientY)
{
	
	var oPopBody = oPopup.document.body;
	
	oPopBody.style.backgroundColor = "lightyellow";
	oPopBody.style.fontSize= "11px";
	oPopBody.style.fontFamily= "Tahoma";
	oPopBody.style.paddingLeft= "3px";
	oPopBody.style.border = "solid black 1px";

	oPopBody.innerText = arrHelpText;
	//oPopup.show(window.event.clientX + 5, window.event.clientY, 300,vPopupHeight, document.body);
	//oPopup.show(365,155, 300,vPopupHeight,document.body);
	oPopup.show(VClientX,VClientY, 300,vPopupHeight,document.body);
}

function HideHelp()
{
	oPopup.hide();
}

