//  22-Mar-2005 ST          [002]      add Product in my favorite option list 
//  31-mar-2005 Rk			[003]      date format mm/dd/yyyy
function textAreaMaxLength(field, maxlimit)
{
	if (field.value.length > maxlimit) // if too long...trim it!
	field.value = field.value.substring(0, maxlimit);
}

function resizeWindow(Width,Height)
{
	window.resizeTo(Width,Height);
	centreWindow(Width,Height);
}

function moveWindow(X,Y)
{
	window.moveTo(X,Y);
}

function centreWindow(Width,Height)
{
	var X;
	var Y;
	X= (screen.width - Width) /2 ;
	Y= (screen.height - Height) /2 ;
	window.moveTo(X,Y);
}
function IsDecimal(element)
{
var decimalRE = "^(\\+|-)?[0-9][0-9]*(\\.[0-9]*)?$";
return RegExTest(element,decimalRE);
}
function RegExTest(element,expression)
{
return element.value.match(expression) != null;
}

function fnIsVal(r_strMsg,r_strVal)
{
    var l_intFlag
    var l_intPrevFlag
    var l_strCtrlValue
    var l_inti

    l_intFlag=0
    l_intPrevFlag = 0
    l_strCtrlValue = " "

    if (r_strVal.length > 0)
    {
        if (r_strVal != "0")
        {
            for (l_inti=0;l_inti<r_strVal.length;l_inti++)
            {
                l_strCtrlValue = r_strVal.substring(l_inti,l_inti+1)
                if (l_strCtrlValue != "0")
                {
                    if ((parseInt(r_strVal.substring(l_inti,l_inti+1))==0) || (isNaN(parseInt(r_strVal.substring(l_inti,l_inti+1)))))
                    {
                        l_intFlag= 1
                        break
                    }
                }
            }
            if (l_intFlag == 1 )
            {
                var l_strErr

                l_strErr = r_strMsg + " has to be numeric"
                alert(l_strErr)
                return false
            }
        }
    }
    return true
}
//---------FOR mm/dd/yyyy format -----------------------[003] starts
//date function to test date in dd/mm/yyyy format
function fnIsDate(r_strMsg,r_varCtrl)
{
    if (r_varCtrl.value == "") return true

    if (r_varCtrl.value.length > 10)
    {
        alert("Date length cannot exceed 10 characters");
        r_varCtrl.focus()
        return true
    } 
    
    if (r_varCtrl.value.charAt(1) == "/")
		r_varCtrl.value = "0" + r_varCtrl.value;
	//alert(r_varCtrl.value.substring(3, 10));

    if (r_varCtrl.value.charAt(4) == "/")
		r_varCtrl.value = r_varCtrl.value.substring(0, 3) + "0" + r_varCtrl.value.substring(3, 10);
		
    if ((r_varCtrl.value.charAt(2) != "/") || (r_varCtrl.value.charAt(5) != "/"))
    {
        //alert("Enter Date in (DD/MM/YYYY) format");
        alert("Enter Date in (MM/DD/YYYY) format");
        r_varCtrl.focus()
        return true
    }
	
    var l_intDay
    var l_intMonth
    var l_intYear
	//l_intDay = r_varCtrl.value.charAt(0)+r_varCtrl.value.charAt(1)
	l_intDay = r_varCtrl.value.charAt(3)+r_varCtrl.value.charAt(4)
    //l_intMonth = r_varCtrl.value.charAt(3)+r_varCtrl.value.charAt(4) 
    l_intMonth = r_varCtrl.value.charAt(0)+r_varCtrl.value.charAt(1) 
    l_intYear = r_varCtrl.value.charAt(6)+r_varCtrl.value.charAt(7) + r_varCtrl.value.charAt(8)+r_varCtrl.value.charAt(9)
	
    if (l_intYear.length < 4)
    {
        alert("Year format is YYYY")
        r_varCtrl.focus()
        return true
    }
	
    if (!fnIsVal("Day value in date",l_intDay))
    {
        r_varCtrl.focus()
        return true
    }

    if (!fnIsVal("Month value in date",l_intMonth))
    {
        r_varCtrl.focus()
        return true
    }

    if (!fnIsVal("Year value in date",l_intYear))
    {
        r_varCtrl.focus()
        return true
    }

    
	
    if ((l_intDay < 0) || (l_intMonth < 0) || (l_intYear < 0))
    {
        alert("Invalid character in Date");
        r_varCtrl.focus()
        return true
    }

    if ((l_intDay == 0) || (l_intMonth == 0) || (l_intYear == 0))
    {
        alert("Invalid Date");
        r_varCtrl.focus()
        return true
    }

    if (l_intMonth > 12)
    {
        alert("Month can not be greater than 12");
        r_varCtrl.focus()
        return true
    }
	
    if (l_intDay > 31 )
    {
        alert("Day can not be greater than 31")
        r_varCtrl.focus()
        return true
    }
    if ((l_intMonth==4)||(l_intMonth==6)||(l_intMonth==9)||(l_intMonth==11))
    {
        if (l_intDay > 30 )
        {
            alert("Day can not be greater than 30")
            r_varCtrl.focus()
            return true;
        }
    }
    if (l_intMonth==2)
    {
        if  ((l_intYear % 4 == 0) && ( (!(l_intYear % 100 == 0)) || (l_intYear % 400 == 0) ) )
        {
            if (l_intDay > 29)
            {
                alert("Day can not be greater than 29 for a Leap Year")
                r_varCtrl.focus()
                return true;
            }
        }
        else
        {
            if (l_intDay > 28)
            {
                alert("Day can not be greater than 28 for a non-leap year")
                r_varCtrl.focus()
                return true;
            }
        }
    }
    return false
}

//[003] ends

///new date function


function isAlphaSpace(val)
{
	var str=new String();
	str=''+val;
	if(str.indexOf('0')!=-1) { return false;}
	if(str.indexOf('1')!=-1) { return false;}
	if(str.indexOf('2')!=-1) { return false;}
	if(str.indexOf('3')!=-1) { return false;}
	if(str.indexOf('4')!=-1) { return false;}
	if(str.indexOf('5')!=-1) { return false;}
	if(str.indexOf('6')!=-1) { return false;}
	if(str.indexOf('7')!=-1) { return false;}
	if(str.indexOf('8')!=-1) { return false;}
	if(str.indexOf('9')!=-1) { return false;}
	return true;
}

/*for numeric test*/
function fnIsNumeric(strInteger)
{
   if (fnTrim(strInteger)=='')
   {
    return true;
   }
	var regExp = /^[\-\+]{0,1}\d{0,100}\.{0,1}\d{1,100}$/
	strInteger = fnTrim(strInteger); //Remove leading and trailing spaces
	if (regExp.test(strInteger)) //Validate Integer
	{
		return true;
	}
	return false; //Not a valid integer
}

/*+++++++++++++++++++++++++ function that accepte only integer that is 0 to 9 by chaman ++++++++++++++++++++++ */
function isInteger(s)
		{
			var i;
			for (i = 0; i < s.length; i++)
			{
				// Check that current character is number.
				var c = s.charAt(i) ;
				if (((c < "0") || (c > "9"))) return false;
			}
			// All characters are numbers.
			return true;
		}
/*++++++++++++++++  End  ++++++++++++++++++++++++++++++++++++++++*/

function fnIsReal(strInteger,intScale,intPrecision,intRange)
{
/******************************************************************************
Function name:	function fnIsReal(strInteger,intScale,intPrecision,intRange)
Description  :  This  function is used for validating integer under given parameters.
				Maximum digit in the integer must be less than max length passed as 
				parameter and integer must lie between the range specified in Third parameter.
				function used : 1) fnTrim(strValue) 
								
Assumption	 :  1)intMaxLength must contain value ( >=0 )
					if (intMaxLength = 0) means input value can have any number of digits 
				2)There should be no space between sign and digit
				3)intRange should contain permissible value given below
				4)4.0 is not treated as interger with value 4

Input		 :	1) Pass value to be validated
				2) Pass integer value.
				3) Pass valid range
					Valid Range are :
						1)	0  -> Any Input
						2)	2  -> only +ve ( *zero not included)
						3)	8  -> only  -ve ( * zero not included)
						4)	16 -> >= 0
						5)  32 -> <= 0
						6)  64 -> only 0 

Output       :	If Valid Integer (Check Against each parameter)
					Return True
				Else
					Return False

*******************************************************************************/

	//Mandatory check for parameters
	if ((!fnMandatory(strInteger))||(!fnMandatory(intScale))||(!fnMandatory(intPrecision))) 
	{
		alert ("Invalid Parameters");
		return false;
	}
	if (intPrecision == 0)
	{
		intPrecision = 999; //Assume that max. length of any number befor decimal is less than 999 digit
	}
	if (intScale == 0)
	{
		intScale = 999; //Assume that max. length of any number after decimal is less than 999 digit
	}
	
	/*Generate Regular expression which will check 
	1) First character must be (+,- or any valid digit)
	2) Input value is a valid interger
	3) Reg. Exp checks No. of digit before decimal in first parameter must be less than equal 
	to Scale
	4) Reg. Exp also checks No. of digit after decimal in first parameter must be less than equal 
	to the precision.
	*/
	var regExp = new RegExp("\^\[\\-\\+\]{0,1}\\d{0," + intScale+ "}$\|\^\[\\-\\+\]{0,1}\\d{0," + intScale+ "}\\.{1,1}\\d{1," + intPrecision+ "}$");
	strInteger = fnTrim(strInteger); //Remove leading and trailing spaces
	if (regExp.test(strInteger)) //Validate Integer
	{
		strInteger = strInteger.valueOf(Number)//Convert to numeric value
		switch (parseInt(intRange,10)) //Match Range 
		{
			case 0:
				alert("Valid Number");
				return true;
			case 2:
				if (strInteger > 0)
				{
					alert("Valid Number");
					return true;
				}
				alert("InValid Number");
				return false;
			case 8:
				if (strInteger < 0)
				{
					alert("Valid Number");
					return true;
				}
				alert("InValid Number");
				return false;
			case 16:
				if (strInteger >= 0)
				{
					alert("Valid Number");
					return true;
				}
				alert("InValid Number");
				return false;
			case 32:
				if (strInteger <= 0)
				{
					alert("Valid Number");
					return true;
				}
				alert("InValid Number");
				return false;
			case 64:
				if (strInteger == 0)
				{
					alert("Valid Number");
					return true;
				}
				alert("InValid Number");
				return false;
			default:
				alert ("Incorrect Range format")
				return false;	// Not a Valid Range
		}
	}
	return false; //Not a valid integer
}
//********************************************************************
function ValidateData(obj,objname,str)
{
	var validationStr=str.toLowerCase();
	var len="20"
	obj.value=fnTrim(obj.value);
	/*for mandatory- DONE*/
	if(validationStr.indexOf('mand')!=-1)
	{
		if(!fnMandatory(obj.value))
		{
			alert(objname+' is mandatory.');
			if (obj.type!="hidden")
			{
			obj.focus();
			obj.select();
			}
			return false;
		}
	}
	/*for numeric- DONE*/
   	if(validationStr.indexOf('numeric')!=-1)
	{
		if(!fnIsNumeric(obj.value))
		{
			alert(objname+' should be numeric.');
			obj.focus();
			obj.select();
			return false;
		}
	}
	/*for float- DONE*/
	if(validationStr.indexOf('float')!=-1)
	{
		if(!isFloat(obj.value))
		{
			alert(objname+' should be a Numeric Value [999.99]');
			obj.focus();
			obj.select();
			return false;
		}
	}
	/*for alpha chars with space- DONE*/
	if(validationStr.indexOf('alphaspace')!=-1)
	{
		
		if(!isAlphaSpace(fnTrim(obj.value)))
		{
			alert(objname+' should be text only');
			obj.focus();
			obj.select();
			return false;			
		}
	}
	/*for alpha chars without space- DONE*/
	if(validationStr.indexOf('alpha')!=-1)
	{
		if(validationStr.indexOf('alphaspace')==-1)
		{
		if(!IsAlpha(fnTrim(obj.value)))
		{
			alert(objname+' should be text only');
			obj.focus();
			obj.select();
			return false;			
		}
		}
	}
	/*for alpha chars without space but with blank space- DONE created by CHAMAN*/
	if(validationStr.indexOf('test')!=-1)
	{
		if(validationStr.indexOf('alphaspace')==-1)
		{
		if(!IsAlphaWBlank(fnTrim(obj.value)))
		{
			alert(objname+' should be text only');
			obj.focus();
			obj.select();
			return false;			
		}
		}
	}
	/*for alpha with number and chars - DONE*/
	if(validationStr.indexOf('alphn')!=-1)
	{
		if(!IsAlphaNumeric(obj.value))
		{
			alert(objname+' should be Alpha Numeric only');
			obj.focus();
			obj.select();
			return false;
		}
	}
	/*for alpha with space and number and chars- DONE*/
	if(validationStr.indexOf('alphsn')!=-1)
	{
		if(!IsAlphaNumericSpace(obj.value))
		{
			alert(objname+' should be Alpha Numeric only');
			obj.focus();
			obj.select();
			return false;
		}
	}
	/*for length match*/
	
	if(validationStr.indexOf('length')!=-1)
	{
		lenPos=validationStr.indexOf('length');
		fieldLength=validationStr.substring(lenPos+6);
		fieldLengthNum=parseInt(fieldLength);
		len=validationStr.substring(lenPos+5);
		if(obj.value.length>fieldLengthNum)
		{
			alert(objname+' length should not be greater than '+fieldLengthNum);
			obj.focus();
			obj.select();
			return false;
		}
	}
	/*for exact length match*/
	if(validationStr.indexOf('exact')!=-1)
	{
		lenPos=validationStr.indexOf('exact');
		fieldLength=validationStr.substring(lenPos+5);
		len=validationStr.substring(lenPos+5);
		fieldLengthNum=parseInt(fieldLength);
        if (fnTrim(obj.value)!="")
        {
		if(obj.value.length!=fieldLengthNum)
		{
			alert(objname+' length should be '+fieldLengthNum);
			obj.focus();
			obj.select();
			return false;
		}
	   }
	 }
	/*for date validation -DONE*/
	if(validationStr.indexOf('date')!=-1)
	{
		if (fnIsDate("",obj))
		{
			obj.focus();
			obj.select();
			return false;
		}
	}
	/*for email validation -DONE*/
	if(validationStr.indexOf('email')!=-1)
	{
	    len=parseInt(len)
	  	if (fnEmailValidation(obj.value,"",60) == false)
		{
			alert("Invalid "+ objname)
			obj.focus();
			obj.select();
			return false;
		}	
	}
	/*for time validation -DONE*/
	if(validationStr.indexOf('time')!=-1)
	{
		if(!convert_time(obj))
		{
			obj.focus();
			obj.select();
			return false;
		}
	}
	return true;
}
function fnMandatory(strTxtCtrlValue)
{
	if (strTxtCtrlValue == "")
        return false
    
    strTxtCtrlValue = fnTrim(strTxtCtrlValue)
    if (strTxtCtrlValue.length == 0)
       return false
    
	return true
}

function fnTrim(strString)
{
// white space consist of (blank,tab,newline)
	var intLeftIndex = 0; //Store position of first non-white space from leftmost side
	var intRightIndex = 0; //Store position of first non-white space from rightmost side
	var blnFound = false; //Check for any non-white space character
	var regExp = /\S+/; 
	var intCount;
	if (strString.search(regExp) == -1) //Check for non-white space character
	{
		strString = ""; //Valid character not found then return empty string
		return(strString);
	}

	//If  atleast one non-white space character found.
	for (intCount=0;intCount < strString.length; intCount++)
	{
		if (strString.charAt(intCount) != " ") // Checking for first non-white spaces 
											// from left side
		{
			intLeftIndex = intCount - 1;
			break;
		}
	}
	for (intCount=strString.length - 1;intCount >= 0; intCount--)
	{
		if (strString.charAt(intCount) != " ") // Checking for first non-white spaces 
											// from Right most side
		{
			intRightIndex = intCount + 1;
			break;
		}
	}

	strString=strString.substring(intLeftIndex+1,intRightIndex); //Remove leading and trailing
														// spaces
	return (strString);
}
function fnEmailValidation(strTxtCtrlValue,strDelimiter,strMaxLength)
{
	var strAtSym
	var strPeriod
	var strSpace
	var strLength

	if (fnMandatory(strTxtCtrlValue) == false) // This includes Null and Space check
		return false;
	if (strTxtCtrlValue.length > strMaxLength)
		return false;

	strTxtCtrlValue = fnTrim(strTxtCtrlValue);
	var regExpression = /[^0-9a-zA-Z][^0-9a-zA-Z]/;


	
	if (regExpression.test(strTxtCtrlValue))
		return false;
	
	var arrEmailIds = new Array(); 
	var strFieldValue = strTxtCtrlValue;
	if (strDelimiter == "")
	{
		arrEmailIds[0] = strTxtCtrlValue
	}
	else
	{
		arrEmailIds = strFieldValue.split(strDelimiter); // Split to get individual email ids using the Delimiter 
	}	
	for (intk = 0;intk < arrEmailIds.length;intk++ )
	{
		if (arrEmailIds[intk] == "") // Null check
			return false;
			
		arrEmailIds[intk] = fnTrim(arrEmailIds[intk]);
		if (arrEmailIds[intk].length == 0 )			 // Spaces Check
			return false;
				
		if (arrEmailIds[intk].search(/\s+/) != -1 ) // checking space in between email id
			return false;
			
		var arrSplit = new Array();
		
		arrSplit = 	arrEmailIds[intk].split("@");
		if ( arrSplit.length != 2) 				 // Only one @ is allowed in an email id
			return false;
	
		// Call Function for Alphanumeric Check along with special character (. - _) 
		// for the string before @ and pass 0 in maxlength as maxlength check not required
		
		if (fnIsAlphaNumeric(arrSplit[0],"M","0",".-_") == false)
			return false;
		
		//Check whether first charater is in a-z /A-Z
		var strValidchar = arrSplit[0].substring(0,1)
		if (!((strValidchar >= "A") && (strValidchar <= "Z")) &&  !((strValidchar >= "a") && (strValidchar <= "z"))&&  !((strValidchar >= "0") && (strValidchar <= "1")))
		 return false
		
		// Call Function for IsAlpha Check along with special character (.) 
		// for the string after @ and pass 0 in maxlength as maxlength check not required
		if (fnIsAlphaNumeric(arrSplit[1],"M","0",".-_")== false)
			return false;
		
		//Check whether first charater is in a-z /A-Z
		strValidchar = arrSplit[1].substring(0,1)
		if (!((strValidchar >= "A") && (strValidchar <= "Z")) &&  !((strValidchar >= "a") && (strValidchar <= "z"))&&  !((strValidchar >= "0") && (strValidchar <= "1")))
			return false
		//Check whether last character is in a-z /A-Z
		strValidchar = arrSplit[1].substring(arrSplit[1].length-1,arrSplit[1].length)
		
		if (!((strValidchar >= "A") && (strValidchar <= "Z")) &&  !((strValidchar >= "a") && (strValidchar <= "z"))&&  !((strValidchar >= "0") && (strValidchar <= "1")))
			return false
		
		//Every portion of the email address after @ must be of <= 2 characters
		var arrEmails
		arrEmails = arrSplit[1].split("."); 
			
		for (intm = 0;intm < arrEmails.length;intm++ )
		{
			if (arrEmails[intm].length < 2)
				return false;
		}
					
		strAtSym=arrEmailIds[intk].indexOf('@')
		strPeriod=arrEmailIds[intk].lastIndexOf('.')
		strSpace=arrEmailIds[intk].indexOf(' ')
		strLength=arrEmailIds[intk].length-1
		if ((strAtSym < 1) ||(strPeriod <= strAtSym+1)|| (strPeriod==strLength) ||(strSpace!=-1))
			return false;
		
	}
			
	return true;
}

function fnIsAlphaNumeric(strString,chrFormat,intMaxLength,strSpecialChar)
{
	var regExp;
	// Check for mandatory parameters
	if ((!fnMandatory(strString)) || (!fnMandatory(intMaxLength))) //Mandatory check for parameters
	{
		alert ("Invalid Parameters");	
		return false;
	}
	strString = fnTrim(strString); //Remove leading and trailing spaces
	var regSpChar = /([\$\@\#\%\^\&\*\(\)\[\]\+\_\{\}\`\|\-\\])/g;
	strSpecialChar = strSpecialChar.replace(regSpChar,"\\$1") //Take care of special character in RegExp
	if (intMaxLength > 0) 
	{
		if (strString.length > intMaxLength)
		{
			alert ("Invalid Maxlength") //Return False if no. of  characters are greater than 
			return false				//specified max length
			
		}
	}

	switch(chrFormat) //Validate character against Format passed as parameter.
	{
		case "U": //All Upper case
			regExp = new RegExp("\[\^A-Z0-9" + strSpecialChar + "\]");
			if (regExp.test(strString)) 
			{
				alert ("Invalid Characters");
				return false;
			}
			break;
		case "L": // All Lower Case
			regExp = new RegExp("\[\^a-z0-9" + strSpecialChar + "\]");
			if (regExp.test(strString)) 
			{
				alert ("Invalid Characters");
				return false;
			}
			break;
		case "M": //Mixed Case
			regExp = new RegExp("\[\^a-zA-Z0-9" + strSpecialChar + "\]");
			if (regExp.test(strString)) 
			{
				alert ("Invalid Characters");
				return false;
			}
			break;
		case "P": //Proper Case
			var arrWords;
			arrWords = strString.split(/\s+/) //Split string in words
			for (var i=0 ;i<arrWords.length; i++)
			{
				if (arrWords[i].search(/^[^A-Z]|\S[A-Z]/) != -1)//Check first letter of each word 
				{										// must be Capital Letter
					alert ("Invalid Characters");
					return false;
				}
			}
			regExp = new RegExp("\[\^a-zA-Z0-9" + strSpecialChar + "\]");
			if (regExp.test(strString)) 
			{
				alert ("Invalid Characters");
				return false;
			}
			break
		default:
			
			return false;
	}
			
	return true; //Valid Character
}


function IsNumeric(s)
{
	if(s=="") return true;
	patern=/^[[0-9][0-9]*$/;
	var OK = s.match(patern)
	if (!OK)
		return false;
	else
		return true;
}

function Iscommalp(s)
{
   
	if(isBlank(s)) return true;
	var i;
	var ind;
	var len;
		
	//length of input string
	 len=s.length;
	
	//indexof comma in string
	 ind = s.indexOf(',');
	 
	 
	 
	  
	if(s.indexOf(',')!=-1)
	  {
	    //comma should not be at starting or end of the string
	    if(s.charCodeAt(len-1)==44 || s.charCodeAt(0)==44)
		   return false;
	   }		
	
    for (i = 0; i < s.length; i++)   
      {    
        // Check that current character is alphabet or a comma only and nothing else.
           var c = s.charCodeAt(i);
           if (!(((65 <= c )&& (c <= 90)) || ((97 <= c) && (c <= 122)) || (c==44) )) 
			  return false;
	  }
    
    return true;
}

////Code Amended by NK on 25-jun-03 End/////////////////

function isBlank(s)
{

	if(s==null)
		return false;
	if(s=="")
		return false;
		
	if ((s.charAt(0)==" ") || (s.charAt(0)=="\t")) {return false;}

 return true;

}
function isAlphaNumericBlank(s)
{

	if(s==null)
		return false;
	if(s=="")
		return false;
		
	if ((s.charAt(0)==" ") || (s.charAt(0)=="\t")) {return false;}


   if (/^[a-z\s\d]*$/i.test(s))   
    { 
        return true ;
      }
    else    { 
       return false;
   } 

}

function IsAlpha(s)
{
	if(s=="") return true;


	s=s.toLowerCase();
	patern=/^[[a-z]*$/;
	var OK2 = s.match(patern)

	if (!OK2)

		return false;
	else
		return true;


}
////////////////  function that accepts char along with blank space by CHAMAN ///////////////////////////

function IsAlphaWBlank(s)
{
	if(s=="") return true;


	s=s.toLowerCase();
	patern=/^[[a-z, ]*$/;
	var OK2 = s.match(patern)

	if (!OK2)

		return false;
	else
		return true;


}


/////////////// End //////////////////////////////////////////////////////////

function IsAlphaNumeric(s)
{
	if(isBlank(s)) return true;
	var i;
    for (i = 0; i < s.length; i++){   
        // Check that current character is alphabet.
        var c = s.charCodeAt(i);
        //alert(c);
        if (!(((65 <= c )&& (c <= 90)) || ((97 <= c) && (c <= 122)) || ((48 <= c) && (c <= 57)) )) 
			{
			return false;
			}
    }
    // All characters are alphabets.
    return true;
}

function IsAlphaNumericSpace(s)
{
	if(isBlank(s)) return true;
	var i;
    for (i = 0; i < s.length; i++){   
        // Check that current character is alphabet.
        var c = s.charCodeAt(i);
        //alert(c);
        if (!(((65 <= c )&& (c <= 90)) || ((97 <= c) && (c <= 122)) || ((48 <= c) && (c <= 57)) || (c = 255) || (c = 44) )) 
			{
			return false;
			}
    }
    // All characters are alphabets.
    return true;
}


function isInteger(s){
	var i;
    for (i = 0; i < s.length; i++){   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

////Code Amended by CHAMAN on 30-Dec-05 End/////////////////
function matchfolderpath(folderpath)
{
	var i;
	var j;
	for(i = 0;i < folderpath.length;i++)
	{
		if(folderpath.charAt(i)==':'||folderpath.charAt(i)=='/')
		{
		j="True";
		 return true;
		}
		else
		{
		
		}
	}
	if(j=="True")
	{
	
	}
	else
	{
	return false;
	}
	
}
function ValidateDate(strDate)
{

var dt;
var mn;
var yy;
var up=19;
var low=20;
 strDate=strDate.toUpperCase();
 dt=strDate.substr(0,2)
 mn=strDate.substr(2,3)
 yy=strDate.substr(5,2);
 
 if (strDate == "")
 {
		alert("Date cannot be left blank");
		return false
 }
 if (strDate.length > 7)
 {
		alert("Date length cannot exceed 7 characters");
		return false
 }
 if (strDate.length < 7)
 {
		alert("Date length should be of 7 characters");
		return false
 }

 if (dt.length < 2)
	{
		alert("Day format is DD")
		return false
	}

	if (mn.length < 3)
	{
		alert("Month format is MMM")
		return false
	}

	if (yy.length < 2)
	{
		alert("Year format is YY")
		return false
	} 	
 if (parseInt(yy) > 0 && parseInt(yy) < 74)  
 {
   yy="20"+ yy; 
 }
 else if (parseInt(yy) > 75) 
  {
     yy="19"+ yy; 
  }
  if (mn=="JAN")
  {
     mn="01"
  }
  else if (mn=="FEB")
  {
   mn="02"
  }
  else if (mn=="MAR")
  {
   mn="03"
  } 
  else if (mn=="APR")
  {
   mn="04"
  } 
  else if (mn=="MAY")
  {
   mn="05"
  }
  else if (mn=="JUN")
  {
   mn="06"
  }
  else if (mn=="JUL")
  {
   mn="07"
  }
  else if (mn=="Aug")
  {
   mn="08"
  }
  else if (mn=="SEP")
  {
   mn="09"
  } 
  else if (mn=="OCT")
  {
   mn="10"
  }
  else if (mn=="NOV")
  {
   mn="11"
  }
  else if (mn=="DEC")
  {
   mn="12"
  }
  else
  {
  	alert("Month format is MMM")
	return false
  }
  var dat=dt+"/"+mn+"/"+yy
 
  
return fnValidate(dat);
}

function fnValidate(strDate)
{
	//First part is to remove any Leading and Trailing spaces

    if ((strDate.charAt(2) != "/") || (strDate.charAt(5) != "/"))
	{
		alert("Enter Date in DDMMMYY format");
		return false
	}

	var l_intDay
	var l_intMonth
	var l_intYear

	l_intDay = strDate.charAt(0)+strDate.charAt(1)
	l_intMonth  = strDate.charAt(3)+strDate.charAt(4)
 	l_intYear = strDate.charAt(6)+strDate.charAt(7) +
    strDate.charAt(8)+strDate.charAt(9)
	l_intDay = parseInt(l_intDay,10)
	l_intMonth = parseInt(l_intMonth,10)
	l_intYear = parseInt(l_intYear,10)

	if (isNaN(l_intDay) || isNaN(l_intMonth) || isNaN(l_intYear))
	{
		alert("Invalid Date");
		return false
	}

	if ((l_intDay < 0) || (l_intMonth < 0) || (l_intYear < 0))
	{
		alert("Invalid Date");
		return false
	}

	if(l_intYear<=1752)
	{
		alert("Year should be greater than 1752");
		return false
	}

	if ((l_intDay == 0) || (l_intMonth == 0) || (l_intYear == 0))
	{
		alert("Invalid Date");
		return false
	}

	if (l_intMonth > 12)
	{
		alert("Month can not be greater than 12");
		return false
	}

	if (l_intDay > 31 )
	{
		alert("Day can not be greater than 31")
		return false
	}

	if ((l_intMonth==4)||(l_intMonth==6)||(l_intMonth==9)||(l_intMonth==11))
	{
		if (l_intDay > 30 )
		{
			alert("Day can not be greater than 30")
			return false
		}
	}
	else if (l_intMonth==2)
	{
		if  ((l_intYear % 4 == 0) && ( (!(l_intYear % 100 == 0)) || (l_intYear %
400 == 0) ) )
		{
			if (l_intDay > 29)
			{
				alert("Day can not be greater than 29 for a Leap Year")
				return false;
			}
		}
		else if (l_intDay > 28)
		{
			alert('Day cannot be greater than 28 for a Non-Leap Year')
			return false;
		}
     }

	return true;
}

function stripCharsInBag(s, bag){
	var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++){   
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function daysInFebruary (year){
	// February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
function DaysArray(n) {
	for (var i = 1; i <= n; i++) {
		this[i] = 31
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
		if (i==2) {this[i] = 29}
   } 
   return this
}

function isDate(dtStr){
	var daysInMonth = DaysArray(12)
	alert(dtCh);
	var pos1=dtStr.indexOf(dtCh)
	var pos2=dtStr.indexOf(dtCh,pos1+1)
	var strDay=dtStr.substring(0,pos1)
	var strMonth=dtStr.substring(pos1+1,pos2)
	var strYear=dtStr.substring(pos2+1)
	strYr=strYear
	if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
	if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
	for (var i = 1; i <= 3; i++) {
		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
	}
	month=parseInt(strMonth)
	day=parseInt(strDay)
	year=parseInt(strYr)
	if (pos1==-1 || pos2==-1){
		alert("The date format should be : mm/dd/yyyy")
		return false
	}
	if (strMonth.length<1 || month<1 || month>12){
		alert("Please enter a valid month")
		return false
	}
	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
		alert("Please enter a valid day")
		return false
	}
	if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
		alert("Please enter a valid 4 digit year between "+minYear+" and "+maxYear)
		return false
	}
	if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
		alert("Please enter a valid date")
		return false
	}
return true
}


function isNull(control,message)
{
	if(control.value == null ||control.value == '' )
	{
		alert(message+ " cannot be blank");
		return true;
	}
	else
	{
		return false;
	}
}
function isValidLength(control,len,message)
{
	if(control.value.length != len )
	{
		alert(message+ " should be of length " + len);
		return false;
	}
	else
	{
		return true;
	}
}
function isValid(control,len,message)
{
	if(control.value.length > len )
	{
		alert(message+ " should be <= " + len+" characters");
		return false;
	}
	else
	{
		return true;
	}
}
function isNullValue(control)
{
	if(fnTrim(control.value) == null || fnTrim(control.value) == '' )
	{
		return true;
	}
	else
	{
		return false;
	}
}

function fnTrim(strString)
{
	// white space consist of (blank,tab,newline)
	var intLeftIndex = 0; //Store position of first non-white space from leftmost side
	var intRightIndex = 0; //Store position of first non-white space from rightmost side
	var blnFound = false; //Check for any non-white space character
	var regExp = /\S+/; 
	var intCount;
	if (strString.search(regExp) == -1) //Check for non-white space character
	{
		//Valid character not found then return empty string
		strString = ""; 
		return(strString);
	}
	//If  atleast one non-white space character found.
	for (intCount=0;intCount < strString.length; intCount++)
	{
		// Checking for first non-white spaces from left side
		if (strString.charAt(intCount) != " ") 
		{
			intLeftIndex = intCount - 1;
			break;
		}
	}
	for (intCount=strString.length - 1;intCount >= 0; intCount--)
	{
		// Checking for first non-white spaces from Right most side
		if (strString.charAt(intCount) != " ") 
		{
			intRightIndex = intCount + 1;
			break;
		}
	}
	
	//Remove leading and trailing spaces
	strString=strString.substring(intLeftIndex+1,intRightIndex); 
	return (strString);
}



function fnDateCompare(strFromDate,strToDate)
{
	
	var regExp = /\s+|[\s\,\-\.]/g; //Reg Exp Use to identify Date seperator.
	var arrDate  // This variable is used to store Date(dd,mm,yyyy) as an array element
	strFromDate = fnTrim(strFromDate); // Remove Leading and Trailing Spaces
	strToDate = fnTrim(strToDate); // Remove Leading and Trailing Spaces
	strFromDate = strFromDate.replace(regExp,"/"); //Replace Date seperator by "/"
	strToDate = strToDate.replace(regExp,"/"); //Replace Date seperator by "/"
	arrDate = strFromDate.split("/");
	var dtmFromDate = new Date(arrDate[2],eval(arrDate[1])-1,arrDate[0]) //Create Date object with input Date as parameter
	arrDate = strToDate.split("/");
	var dtmToDate = new Date(arrDate[2],eval(arrDate[1])-1,arrDate[0]) //Create Date object with input Date as parameter
	if (dtmFromDate < dtmToDate) 
	{
		return 1
	}
	else if (dtmFromDate > dtmToDate) 
	{
		return -1
	}
	else
	{
		return 0
	}
}
function convert_time(field1)
{
if(isBlank(field1.value)) return true;
if(field1.value==null) return true;
field1.value = fnTrim(field1.value);
if (field1.value.length !=5)
{
	alert("The value " + field1.value + " is not a valid time.\n\r"+
		"Please enter a valid time in the format HH:MM");
		field1.focus();
		field1.select();
	return false;
}
var s = String(field1.value); // supplied time value variable.
var sh = s.substring(0,2);
var ss = s.substring(3,5);
var tot=sh+ss
if (field1.value.indexOf(':')=='-1')
{
alert("The value " + field1.value + " is not a valid time.\n\r"+
		"Please enter a valid time in the format HH:MM");
		field1.focus();
		field1.select();
	return false;
}
if(isInteger(tot))
{
	if((parseInt(sh) >= 0) && (parseInt(sh) <= 23) && (parseInt(ss) >= 0) && (parseInt(ss) <= 59))
	{
		return true;
	}
	else
	{
		alert("The value " + field1.value + " is not a valid time.\n\r"+
			"Please enter a valid time in the format HH:MM");
			field1.focus();
			field1.select();
		return false;
		//alert("It is not a valid time.");
	}
}
else
{
	alert("The value " + field1.value + " is not a valid time.\n\r"+
		"Please enter a valid time in the format HH:MM");
		field1.focus();
		field1.select();
	return false;
	//alert("It is not a valid time.");
}
return true;
}

function convert_date(field1)
{
if(isBlank(field1.value)) return true;
if(field1.value==null) return true;
var fLength = field1.value.length; // Length of supplied field in characters.
var divider_values = new Array ('-','.','/',' ',':','_',','); // Array to hold permitted date seperators.  Add in '\' value
var array_elements = 7; // Number of elements in the array - divider_values.
var day1 = new String(null); // day value holder
var month1 = new String(null); // month value holder
var year1 = new String(null); // year value holder
var divider1 = null; // divider holder
var outdate1 = null; // formatted date to send back to calling field holder
var counter1 = 0; // counter for divider looping
var divider_holder = new Array ('0','0','0'); // array to hold positions of dividers in dates
var s = String(field1.value); // supplied date value variable
if(isBlank(field1.value)) return false;
//If field is empty do nothing
if ( fLength == 0 ) {
   return true;
}

// Deal with today or now
if ( field1.value.toUpperCase() == 'NOW' || field1.value.toUpperCase() == 'TODAY' ) {

	var newDate1 = new Date();

  		if (navigator.appName == "Netscape") {
    		var myYear1 = newDate1.getYear() + 1900;
  		}
  		else {
  			var myYear1 =newDate1.getYear();
  		}

	var myMonth1 = newDate1.getMonth()+1;
	var myDay1 = newDate1.getDate();
	field1.value = myDay1 + "/" + myMonth1 + "/" + myYear1;
	fLength = field1.value.length;//re-evaluate string length.
	s = String(field1.value)//re-evaluate the string value.
}

//Check the date is the required length
if ( fLength != 0 && (fLength < 6 || fLength > 11) ) {
	invalid_date(field1);
	return false;
	}

// Find position and type of divider in the date
for ( var i=0; i<3; i++ ) {
	for ( var x=0; x<array_elements; x++ ) {
		if ( s.indexOf(divider_values[x], counter1) != -1 ) {
			divider1 = divider_values[x];
			divider_holder[i] = s.indexOf(divider_values[x], counter1);
		   //alert(i + " divider1 = " + divider_holder[i]);
			counter1 = divider_holder[i] + 1;
			//alert(i + " counter1 = " + counter1);
			break;
		}
 	}
 }

// if element 2 is not 0 then more than 2 dividers have been found so date is invalid.
if ( divider_holder[2] != 0 ) {
   invalid_date(field1);
	return false;
}

// See if no dividers are present in the date string.
if ( divider_holder[0] == 0 && divider_holder[1] == 0 ) {

		//continue processing
		if ( fLength == 6 ) {//ddmmyy
   		day1 = field1.value.substring(0,2);
     		month1 = field1.value.substring(2,4);
  			year1 = field1.value.substring(4,6);
  			if ( (year1 = validate_year(year1)) == false ) {
   			invalid_date(field1);
				return false;
				}
			}

		else if ( fLength == 7 ) {//ddmmmy
   		day1 = field1.value.substring(0,2);
  			month1 = field1.value.substring(2,5);
  			year1 = field1.value.substring(5,7);
  			if ( (month1 = convert_month(month1)) == false ) {
   			invalid_date(field1);
				return false;
				}
  			if ( (year1 = validate_year(year1)) == false ) {
   			invalid_date(field1);
				return false;
				}
			}
		else if ( fLength == 8 ) {//ddmmyyyy
   		day1 = field1.value.substring(0,2);
  			month1 = field1.value.substring(2,4);
  			year1 = field1.value.substring(4,8);
			}
		else if ( fLength == 9 ) {//ddmmmyyyy
   		day1 = field1.value.substring(0,2);
  			month1 = field1.value.substring(2,5);
  			year1 = field1.value.substring(5,9);
  			if ( (month1 = convert_month(month1)) == false ) {
   			invalid_date(field1);
				return false;
				}
			}

		if ( (outdate1 = validate_date(day1,month1,year1)) == false ) {
   		alert("The value " + field1.value + " is not a vaild date.\n\r" +
			"Please enter a valid date in the format ddMONyy");
			field1.focus();
			field1.select();
			return false;
			}

		field1.value = outdate1;
		return true;// All OK
		}

// 2 dividers are present so continue to process
if ( divider_holder[0] != 0 && divider_holder[1] != 0 ) {
  	day1 = field1.value.substring(0, divider_holder[0]);
  	month1 = field1.value.substring(divider_holder[0] + 1, divider_holder[1]);
  	//alert(month1);
  	year1 = field1.value.substring(divider_holder[1] + 1, field1.value.length);
	}

if ( isNaN(day1) && isNaN(year1) ) { // Check day and year are numeric
	invalid_date(field1);
	return false;
   }

if ( day1.length == 1 ) { //Make d day dd
   day1 = '0' + day1;
}

if ( month1.length == 1 ) {//Make m month mm
	month1 = '0' + month1;
}

if ( year1.length == 2 ) {//Make yy year yyyy
   if ( (year1 = validate_year(year1)) == false ) {
   	invalid_date(field1);
		return false;
		}
}

if ( month1.length == 3 || month1.length == 4 ) {//Make mmm month mm
   if ( (month1 = convert_month(month1)) == false) {
   	alert("month1" + month1);
   	invalid_date(field1);
   	return false;
   }
}

// Date components are OK
if ( (day1.length == 2 || month1.length == 2 || year1.length == 4) == false) {
   invalid_date(field1);
   return false;
}

//Validate the date
if ( (outdate1 = validate_date(day1, month1, year1)) == false ) {
   alert("The value " + field1.value + " is not a vaild date.\n\r" +
	"Please enter a valid date in the format ddMONyy");
	field1.focus();
	field1.select();
	return false;
}

// Redisplay the date in dd/mm/yyyy format
field1.value = outdate1;
return true;//All is well

}
/******************************************************************
   convert_month()

   Function to convert mmm month to mm month

   Called by convert_date()

   Author: Simon Kneafsey
   Date Created: 4/9/00
   Email: simonkneafsey@hotmail.com
   WebSite: www.simonkneafsey.co.uk

   Notes:P lease feel free to use/edit this script.  If you do please keep my comments and details
   intact and notify me via a quick Email to the address above.  Enjoy!
*******************************************************************/
function convert_month(monthIn) {

var month_values = new Array ("JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC");

monthIn = monthIn.toUpperCase();

if ( monthIn.length == 3 ) {
	for ( var i=0; i<12; i++ )
		{
   	if ( monthIn == month_values[i] )
   		{
			//alert(month_values[i]);
			monthIn = i + 1;
			if ( i != 10 && i != 11 && i != 12 )
				{
   			monthIn = '0' + monthIn;
				}
			if(monthIn=='010')	monthIn='10';
			/*alert(monthIn);	*/
			return monthIn;
			}
		}
	}

else if ( monthIn.length == 4 && monthIn == 'SEPT') {
   monthIn = '09';
   return monthIn;
	}

else {
	return false;
	}
}
/******************************************************************
   invalid_date()

   If an entered date is deemed to be invalid, invali
   d_date() is called to display a warning message to
   the user.  Also returns focus to the date  in que
   stion and selects the date for edit.

   Called by convert_date()

   Author: Simon Kneafsey
   Date Created: 4/9/00
   Email: simonkneafsey@hotmail.com
   WebSite: www.simonkneafsey.co.uk

   Notes: Please feel free to use/edit this script.  If you do please keep my comments and details
   intact and notify me via a quick Email to the address above.  Enjoy!
*******************************************************************/
function invalid_date(inField)
{
alert("The value " + inField.value + " is not in a vaild date format.\n\r" +
        "Please enter date in the format ddMONyy");
inField.focus();
inField.select();
return true
}
/******************************************************************
   validate_date()

   Validates date output from convert_date().  Checks
   day is valid for month, leap years, month !> 12,.

   Author: Simon Kneafsey
   Date Created: 4/9/00
   Email: simonkneafsey@hotmail.com
   WebSite: www.simonkneafsey.co.uk

   Notes: Please feel free to use/edit this script.  If you do please keep my comments and details
   intact and notify me via a quick Email to the address above.  Enjoy!
*******************************************************************/
function validate_date(day2, month2, year2)
{
var DayArray = new Array(31,28,31,30,31,30,31,31,30,31,30,31);
var MonthArray = new Array("01","02","03","04","05","06","07","08","09","10","11","12");

var inpDate = day2 + month2 + year2;
var filter=/^[0-9]{2}[0-9]{2}[0-9]{4}$/;

//Check ddmmyyyy date supplied
if (! filter.test(inpDate))
  {
  return false;
  }
/* Check Valid Month */
filter=/01|02|03|04|05|06|07|08|09|10|11|12/ ;

if (! filter.test(month2))
  {
  return false;
  }
/* Check For Leap Year */
var N = Number(year2);
if ( ( N%4==0 && N%100 !=0 ) || ( N%400==0 ) )
  	{
   DayArray[1]=29;
  	}
/* Check for valid days for month */
for(var ctr=0; ctr<=11; ctr++)
  	{
   if (MonthArray[ctr]==month2)
   	{
      if (day2<= DayArray[ctr] && day2 >0 )
        {
        //inpDate = day2 + '/' + month2 + '/' + year2;

        if(month2=='01') month2='JAN'
        if(month2=='02') month2='FEB'
        if(month2=='03') month2='MAR'
        if(month2=='04') month2='APR'
        if(month2=='05') month2='MAY'
        if(month2=='06') month2='JUN'
        if(month2=='07') month2='JUL'
        if(month2=='08') month2='AUG'
        if(month2=='09') month2='SEP'
        if(month2=='10') month2='OCT'
        if(month2=='11') month2='NOV'
        if(month2=='12') month2='DEC'
		year2=year2.substring(2,4);
        inpDate = day2 +   month2 + year2;
        return inpDate;
        }
      else
        {
        return false;
        }
   	}
   }
}
/******************************************************************
   validate_year()

   converts yy years to yyyy
   Uses a hinge date of 10
        < 10 = 20yy
        => 10 = 19yy.

   Called by convert_date() before validate_date().

   Author: Simon Kneafsey
   Date Created: 4/9/00
   Email: simonkneafsey@hotmail.com
   WebSite: www.simonkneafsey.co.uk

   Notes: Please feel free to use/edit this script.  If you do please keep my comments and details
   intact and notify me via a quick Email to the address above.  Enjoy!
*******************************************************************/
function validate_year(inYear)
{
if ( inYear < 10 )
	{
   inYear = "20" + inYear;
   return inYear;
	}
else if ( inYear >= 10 )
	{
   inYear = "19" + inYear;
   return inYear;
	}
else
	{
	return false;
	}
}

function GoToFirst()
{		
	if(document.forms[0]!=null){
		for(i=0;i<document.forms[0].elements.length;i++)
		{
			if(document.forms[0].elements[i].type=='text')
			{
				document.forms[0].elements[i].style.backgroundColor="#D8E7FC";
				document.forms[0].elements[i].focus();
				return;
			}
		}
		}
}
function isFloat(val)
{
	if(isBlank(val)) return true;
	return(parseFloat(val,10)==(val*1));
}



function LTrim(str){
	for(var i=0;str.charAt(i)==" ";i++);
	return str.substring(i,str.length);
	}
function RTrim(str){
	for(var i=str.length-1;str.charAt(i)==" ";i--);
	return str.substring(0,i+1);
	}
function Trim(str){return LTrim(RTrim(str));}

function isNull(val){return(val==null);}


/*function isInteger(val){
	if (isBlank(val)){return false;}
	for(var i=0;i<val.length;i++){
		if(!isDigit(val.charAt(i))){return false;}
		}
	return true;
	}
	*/

//function isNumeric(val){return(parseFloat(val,10)==(val*1));}

function isArray(obj){return(typeof(obj.length)=="undefined")?false:true;}

function isDigit(num) {
	if (num.length>1){return false;}
	var string="1234567890";
	if (string.indexOf(num)!=-1){return true;}
	return false;
	}

function setNullIfBlank(obj){if(isBlank(obj.value)){obj.value="";}}

function setFieldsToUpperCase(){
	for(var i=0;i<arguments.length;i++) {
		arguments[i].value = arguments[i].value.toUpperCase();
		}
	}

function disallowBlank(obj){
	var msg=(arguments.length>1)?arguments[1]:"";
	var dofocus=(arguments.length>2)?arguments[2]:false;
	if (isBlank(getInputValue(obj))){
		if(!isBlank(msg)){alert(msg);}
		if(dofocus){
			if (isArray(obj) && (typeof(obj.type)=="undefined")) {obj=obj[0];}
			if(obj.type=="text"||obj.type=="textarea"||obj.type=="password") { obj.select(); }
			obj.focus();
			}
		return true;
		}
	return false;
	}

function disallowModify(obj){
	var msg=(arguments.length>1)?arguments[1]:"";
	var dofocus=(arguments.length>2)?arguments[2]:false;
	if (getInputValue(obj)!=getInputDefaultValue(obj)){
		if(!isBlank(msg)){alert(msg);}
		if(dofocus){
			if (isArray(obj) && (typeof(obj.type)=="undefined")) {obj=obj[0];}
			if(obj.type=="text"||obj.type=="textarea"||obj.type=="password") { obj.select(); }
			obj.focus();
			}
		setInputValue(obj,getInputDefaultValue(obj));
		return true;
		}
	return false;
	}

function commifyArray(obj){
	var s="";
	if(obj==null||obj.length<=0){return s;}
	for(var i=0;i<obj.length;i++){
		s=s+((s=="")?"":",")+obj[i].toString();
		}
	return s;
	}

function getSingleInputValue(obj,use_default) {
	switch(obj.type){
		case 'radio': case 'checkbox': return(((use_default)?obj.defaultChecked:obj.checked)?obj.value:null);
		case 'text': case 'hidden': case 'textarea': return(use_default)?obj.defaultValue:obj.value;
		case 'password': return((use_default)?null:obj.value);
		case 'select-one':
			if(use_default){
				var o=obj.options;
				for(var i=0;i<o.length;i++){if(o[i].defaultSelected){return o[i].value;}}
				return o[0].value;
				}
			if (obj.selectedIndex<0){return null;}
			return(obj.options.length>0)?obj.options[obj.selectedIndex].value:null;
		case 'select-multiple':
			var values=new Array();
			for(var i=0;i<obj.options.length;i++) {
				if((use_default&&obj.options[i].defaultSelected)||(!use_default&&obj.options[i].selected)) {
					values[values.length]=obj.options[i].value;
					}
				}
			return (values.length==0)?null:commifyArray(values);
		}
	alert("FATAL ERROR: Field type "+obj.type+" is not supported for this function");
	return null;
	}

function getSingleInputText(obj,use_default) {
	switch(obj.type){
		case 'radio': case 'checkbox': 	return "";
		case 'text': case 'hidden': case 'textarea': return(use_default)?obj.defaultValue:obj.value;
		case 'password': return((use_default)?null:obj.value);
		case 'select-one':
			if(use_default){
				var o=obj.options;
				for(var i=0;i<o.length;i++){if(o[i].defaultSelected){return o[i].text;}}
				return o[0].text;
				}
			if (obj.selectedIndex<0){return null;}
			return(obj.options.length>0)?obj.options[obj.selectedIndex].text:null;
		case 'select-multiple':
			var values=new Array();
			for(var i=0;i<obj.options.length;i++) {
				if((use_default&&obj.options[i].defaultSelected)||(!use_default&&obj.options[i].selected)) {
					values[values.length]=obj.options[i].text;
					}
				}
			return (values.length==0)?null:commifyArray(values);
		}
	alert("FATAL ERROR: Field type "+obj.type+" is not supported for this function");
	return null;
	}

function setSingleInputValue(obj,value) {
    if(obj.type=='button') return true;
	switch(obj.type){
		case 'radio': case 'checkbox': if(obj.value==value){obj.checked=true;return true;}else{obj.checked=false;return false;}
		case 'text': case 'hidden': case 'textarea': case 'password': obj.value=value;return true;
		case 'select-one': case 'select-multiple':
			var o=obj.options;
			for(var i=0;i<o.length;i++){
				if(o[i].value==value){o[i].selected=true;}
				else{o[i].selected=false;}
				}
			return true;
		}
	//alert("FATAL ERROR: Field type "+obj.type+" is not supported for this function");
	return false;
	}

function getInputValue(obj) {
	var use_default=(arguments.length>1)?arguments[1]:false;
	if (isArray(obj) && (typeof(obj.type)=="undefined")) {
		var values=new Array();
		for(var i=0;i<obj.length;i++){
			var v=getSingleInputValue(obj[i],use_default);
			if(v!=null){values[values.length]=v;}
			}
		return commifyArray(values);
		}
	return getSingleInputValue(obj,use_default);
	}

function getInputText(obj) {
	var use_default=(arguments.length>1)?arguments[1]:false;
	if (isArray(obj) && (typeof(obj.type)=="undefined")) {
		var values=new Array();
		for(var i=0;i<obj.length;i++){
			var v=getSingleInputText(obj[i],use_default);
			if(v!=null){values[values.length]=v;}
			}
		return commifyArray(values);
		}
	return getSingleInputText(obj,use_default);
	}

function getInputDefaultValue(obj){return getInputValue(obj,true);}

function isChanged(obj){return(getInputValue(obj)!=getInputDefaultValue(obj));}

function setInputValue(obj,value) {
	var use_default=(arguments.length>1)?arguments[1]:false;
	if(isArray(obj)&&(typeof(obj.type)=="undefined")){
		for(var i=0;i<obj.length;i++){setSingleInputValue(obj[i],value);}
		}
	else{setSingleInputValue(obj,value);}
	}

function isFormModified(theform,hidden_fields,ignore_fields){
	if(hidden_fields==null){hidden_fields="";}
	if(ignore_fields==null){ignore_fields="";}
	var hiddenFields=new Object();
	var ignoreFields=new Object();
	var i,field;
	var hidden_fields_array=hidden_fields.split(',');
	for (i=0;i<hidden_fields_array.length;i++) {
		hiddenFields[Trim(hidden_fields_array[i])]=true;
		}
	var ignore_fields_array=ignore_fields.split(',');
	for (i=0;i<ignore_fields_array.length;i++) {
		ignoreFields[Trim(ignore_fields_array[i])]=true;
		}
	for (i=0;i<theform.elements.length;i++) {
		var changed=false;
		var name=theform.elements[i].name;
		if(theform.elements[i].type=='button')
		continue;
		if(!isBlank(name)){
			var type=theform[name].type;
			if(!ignoreFields[name]){
				if(type=="hidden"&&hiddenFields[name]){changed=isChanged(theform[name]);}
				else if(type=="hidden"){changed=false;}
				else {changed=isChanged(theform[name]);}
				}
			}
		if(changed){return true;}
		}
		return false;
	}

/**
Compare two date, MMDDYY
like 11/25/2003 12/25/2005
if ( Sdate - Fdate )
Return false < 0 else true
**/

////Code Amended by CHAMAN on 30-Dec-05 End/////////////////
function CompareTwoDate(Fsdate,Sedate)
{
    var Fdate = Fsdate;
    var Sdate = Sedate;
    
        
	var dateOne=new Date();
	str=Fdate;
	i=str.indexOf('/');
	month=str.substring(0,i);
	str=str.substring(i+1,str.length);
	i=str.indexOf('/');
	day=str.substring(0,i);
	str=str.substring(i+1,str.length);
	year=str;
	dateOne.setMonth( month-1 );
	dateOne.setDate(  day );
	dateOne.setYear(  year );

	var dateTwo=new Date();
	str=Sdate;
	i=str.indexOf('/');
	month=str.substring(0,i);
	str=str.substring(i+1,str.length);
	i=str.indexOf('/');
	day=str.substring(0,i);
	str=str.substring(i+1,str.length);
	year=str;
	dateTwo.setMonth( month-1 );
	dateTwo.setDate(  day );
	dateTwo.setYear(  year );
	var num=dateTwo.getTime()-dateOne.getTime();
	
	if(num<0)
	{
		alert('Start Date Cannot be Greater than End Date');
		
	}
	else
	{
	 return true;
	}
}

function CompareDate(Fsdate,Sedate)
{
    var Fdate = Fsdate.value;
    var Sdate = Sedate.value;
    
        
	var FirstDate = Fdate.substring(0,2) + '/' + RMonth(Fdate.substring(2,5).toUpperCase()) + '/' + Fdate.substring(5,7);
	var SecondDate = Sdate.substring(0,2) + '/' + RMonth(Sdate.substring(2,5).toUpperCase()) + '/' + Sdate.substring(5,7);

	var dateOne=new Date();
	str=FirstDate;
	i=str.indexOf('/');
	day=str.substring(0,i);
	str=str.substring(i+1,str.length);
	i=str.indexOf('/');
	month=str.substring(0,i);
	str=str.substring(i+1,str.length);
	year=str;
	dateOne.setMonth( month-1 );
	dateOne.setDate(  day );
	dateOne.setYear(  year );

	var dateTwo=new Date();
	str=SecondDate;
	i=str.indexOf('/');
	day=str.substring(0,i);
	str=str.substring(i+1,str.length);
	i=str.indexOf('/');
	month=str.substring(0,i);
	str=str.substring(i+1,str.length);
	year=str;
	dateTwo.setMonth( month-1 );
	dateTwo.setDate(  day );
	dateTwo.setYear(  year );
	var num=dateTwo.getTime()-dateOne.getTime();
	//alert('num='+num);
	if(num<0)
	{
		alert('Date Cannot be Greater than Current Date ['+ Sdate+']');
		Fsdate.focus();
		return false;
	}
	return true;
}

/*
Return month in integer,
input like JAN,FEB etc
call from CompareDate();
*/
function RMonth(cMonth)
{

   var nMonth;
        if(cMonth=='JAN') nMonth='01'
        if(cMonth=='FEB') nMonth='02'
        if(cMonth=='MAR') nMonth='03'
        if(cMonth=='APR') nMonth='04'
        if(cMonth=='MAY') nMonth='05'
        if(cMonth=='JUN') nMonth='06'
        if(cMonth=='JUL') nMonth='07'
        if(cMonth=='AUG') nMonth='08'
        if(cMonth=='SEP') nMonth='09'
        if(cMonth=='OCT') nMonth='10'
        if(cMonth=='NOV') nMonth='11'
        if(cMonth=='DEC') nMonth='12'

	return nMonth;
}

/*
To add zero upto tqwo decimal places
*/
function Addtwodecimal(strValue)
{
var len, pos
strValue=strValue+""
pos = strValue.indexOf('.');
if(pos == -1)
	{
	strValue = strValue + '.00';
	}
else
	{
	len = strValue.length;
	if ((len-pos) == 2)
		strValue = strValue + '0';
	}
return strValue;
}

/****************************************************************************
   'Function Name  : checkDecimalNumber
   'Parameters     : 
   'Return Type    : 
   'Functionality  : decimal value should not be greater than 1 decimal place 
   'Author         : Mihir Goyal
   'Creation Date  : 26-FEB-2004
   'Modified On		:
   'Modified By		:
   'Modifications	:
/****************************************************************************/
function checkDecimalNumber(strValue)
{
	 strValue = strValue + "";
	 var intPos = strValue.indexOf(".");
 	 if (intPos == -1) 
 		return true;
 		
	 if ((strValue.substring(intPos+1)).length > 1) 
	 {
		alert('GSM value should not be more than 1 decimal place');
		return false;
	}
	
	return true;
}

/****************************************************************************
   'Function Name  : addZero
   'Parameters     : 
   'Return Type    : 
   'Functionality  : adds zero in value upto 2 decimal places 
   'Author         : Mihir Goyal
   'Creation Date  : 04-MAR-2004
   'Modified On	   :
   'Modified By	   :
   'Modifications  :
/****************************************************************************/
function addZero(value)
{
	value = ''+value;
	intPos = value.indexOf(".")
	
	if (intPos == -1)
	{
		//value with any decimal
		value = value + ".00"
		return value;
	}
	
	intNo = parseInt(value);
	intDec = parseInt((parseInt(value) - intNo) * 100);
	if (intDec < 10)
		intDec = "0" + intDec;
	
	value=intNo+"."+intDec;
	return ''+value;
}

/*'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''  File Name:          Common.js
''  Original Author:    Arun
''  Created on:         01-Apr-2004 09:33:31
''  Description:        This moving data from a list to another list and vise-versa, so for following
						function are in used. 
						1. createListObjects(ListFrom, ListTo)
						2. AddToList(object)
						3. RemoveFromList(object)
						4. isValidAdd(lst1,msg)
						5. isValidRemove(lst2,msg)
						6. showSelected(frmName,ListTo)
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''  Modification history:
''  ---------------------------------------------------------------------------------------
''  Modify Date  Modify By   Comments
''  -----------  ---------   ---------------------------------------------------------------
''
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''*/				
	var selectedList;
	var availableList;
	function createListObjects(ListFrom, ListTo)
	{
		availableList = document.getElementById(ListFrom);
		//alert(availableList);
		selectedList = document.getElementById(ListTo);
	}
	function AddToList(object)
	{
		if(!isValidAdd(availableList,object)){
			return;
		}
		lst1len = availableList.length ;
		for ( i=0; i<lst1len ; i++){
			if (availableList.options[i].selected == true ) {
			lst2len = selectedList.length;
			selectedList.options[lst2len]= new Option(availableList.options[i].text,availableList.options[i].value);
			}
		}
		for ( i = (lst1len -1); i>=0; i--){
			if (availableList.options[i].selected == true ) {
			availableList.options[i] = null;
			}
		}
	}
	function RemoveFromList(object){
			if(!isValidRemove(selectedList,object)){
						return;
					}
		lst2len = selectedList.length ;
			for ( i=0; i<lst2len ; i++){
				if (selectedList.options[i].selected == true ) {
				lst1len = availableList.length;
				availableList.options[lst1len]= new Option(selectedList.options[i].text,selectedList.options[i].value);
				}
			}
			for ( i=(lst2len-1); i>=0; i--) {
				if (selectedList.options[i].selected == true ) {
				selectedList.options[i] = null;
				}
			}
	}

	function isValidAdd(lst1,msg)
	{
		if(lst1.selectedIndex==-1){
			alert("Please select "+msg+" !");
			return false;
		}
	return true;
	}
	
	function isValidRemove(lst2,msg)
	{
		if(lst2.selectedIndex == -1){
			alert("Please select "+msg+" !");
			return false;
		}
	return true;
	}
	function showSelected(frmName,ListTo)
	{
		var optionList = document.getElementById(ListTo).options;
		var data = '';
		var len = optionList.length;
			document.forms(frmName).hid_ListValues.value = len;
			//alert(len);
			for(i=0; i< len;i++){
				if (data == '')
				{
					data = optionList.item(i).value;
				}
				else
				{
					data = data + "," + optionList.item(i).value;
				}          
			        
					//alert(data);
				}
				document.forms(frmName).hid_ListValues.value =data;
			    
				return true;
			}
//----------------End List Box moving data ---------------------//
// Code Added by Vikas to get the calendar date
// [002] Following function commented  USE showCalender(from, formname) FUNCTION INSTEAD openCalender(textFieldName)
function openCalender(textFieldName)
{
//var strURl = 'width=235,height=200,left='+ (screen.width/2 - 170)+",top="+(screen.height/2 - 100)+"'";
var strURl = '../Reports/RFQ_CalendarPopUp.aspx?Date=' + textFieldName;
window.open(strURl,null,'left = 445, top = 150, width=235,height=200,status = no');
//window.open(strURl,null,'left='+ (screen.width/2 - 170)+",top="+(screen.height/2 - 100)+"'", width=235,height=200,status = no');
return false;
}
// Code Added by Arunender Singh  on 08-Apr-04 To manipulate the First list
function removeSelectedItemsFromList(ListFrom, ListTo)
{		
	var lst1lenSelected = 0;
	var lst1lenAvailable = 0;
	var strSelectedItem;
	var strAvailableItem;
	
	availableList = document.getElementById(ListFrom);		
	selectedList = document.getElementById(ListTo);

	lst1lenSelected = selectedList.length ;
	lst1lenAvailable = availableList.length ;
				
	if(lst1lenSelected > 0)
	{
		for ( i=0; i<lst1lenSelected ; i++)
		{
			strSelectedItem = selectedList.options[i].text;
			
			lst1lenAvailable = availableList.length ;
			for ( j=0; j<lst1lenAvailable ; j++)
			{
				strAvailableItem = availableList.options[j].text;
				
				if (strAvailableItem == strSelectedItem)
				{							
					availableList.options[j] = null;
					break;							
				}//End of if
			}//End of for				
		}//End of for
	}//End of if		
}//End Code Added by Arunender Singh  on 08-Apr-04 To manipulate the First list

// Code Added by Vikas to Compare fromDate to To date 
function fnReportDateCompare(strFromDate,strToDate,strDateFieldName)
{
	if((strFromDate == "" && strToDate != "") || (strFromDate != "" && strToDate == ""))
	{
		alert("Fill both " + strDateFieldName);
		return false;
	}
	
	var regExp = /\s+|[\s\,\-\.]/g; //Reg Exp Use to identify Date seperator.
	var arrDate  // This variable is used to store Date(dd,mm,yyyy) as an array element
	strFromDate = fnTrim(strFromDate); // Remove Leading and Trailing Spaces
	strToDate = fnTrim(strToDate); // Remove Leading and Trailing Spaces
	strFromDate = strFromDate.replace(regExp,"/"); //Replace Date seperator by "/"
	strToDate = strToDate.replace(regExp,"/"); //Replace Date seperator by "/"
	arrDate = strFromDate.split("/");
	var dtmFromDate = new Date(arrDate[2],eval(arrDate[1])-1,arrDate[0]) //Create Date object with input Date as parameter
	arrDate = strToDate.split("/");
	var dtmToDate = new Date(arrDate[2],eval(arrDate[1])-1,arrDate[0]) //Create Date object with input Date as parameter
	
	if (dtmFromDate < dtmToDate) 
	{
		return true;
	}
	else if (dtmFromDate > dtmToDate) 
	{
		alert(strDateFieldName + "(From) should be less than " +strDateFieldName + " (To)");
		return false;
	}
	return true;
}
// code added by Vikas  to check Mandatory Value 
function MandatoryCheck(strSelecetdPopUpData,strMessage)
{
	if ( strSelecetdPopUpData == "" )

		{
	  		alert(strMessage);
			return false ;
		}
	else 
	{
		return true;
	}
}

//[001] new method added
function showCalender(from, formname)
{
	var sFeature = 'width=235,height=200,left='+ (screen.width/2 - 170)+",top="+(screen.height/2 - 100)+"'";
	window.open("../UI/pupDate.aspx?frm="+formname+"&from="+from,"",sFeature);
}

//[002] New method for security access alert
function fnNoAccessAlert()
{
	alert('You are not authorised to access this module, Please contact System Administrator '); 
	fnBack();
}

//[002] New method back Function
function fnBack()
{
	history.back(-1);
}

//[003] Function added starts here
function FunctionKey()
{
	//alert('commonjs');
	if (window.event.ctrlKey)
	{
		var keycheck;
		keycheck=window.event.keyCode;
		switch(keycheck)
		{
			case 78:handleCtrlKey_N();break;// NEW
		}
	}
}

function handleCtrlKey_N()
{
		window.event.keyCode = 0;
		window.event.cancelBubble = true;
		window.event.returnValue = false;
}
//[003] Function added ends here

// Code Added by Vikas to get the DeclinedSupplier
function openDeclinedSupplierPopUp(strHiddenField,strTextField)
{
var strURl = '../Reports/RFQ_PopUpDeclinedSuppliers.aspx?Hid=' + strHiddenField +'&Text=' +strTextField;
window.open(strURl,null,'left = 445, top = 150, width=450,height=250,status=yes');
return false;
}

// Code Added by Arunender Singh  on 08-Apr-04 To manipulate the First list
function removeSelectedItemsFromList(ListFrom, ListTo)
{		
	var lst1lenSelected = 0;
	var lst1lenAvailable = 0;
	var strSelectedItem;
	var strAvailableItem;
	
	availableList = document.getElementById(ListFrom);		
	selectedList = document.getElementById(ListTo);

	lst1lenSelected = selectedList.length ;
	lst1lenAvailable = availableList.length ;
				
	if(lst1lenSelected > 0)
	{
		for ( i=0; i<lst1lenSelected ; i++)
		{
			strSelectedItem = selectedList.options[i].text;
			
			lst1lenAvailable = availableList.length ;
			for ( j=0; j<lst1lenAvailable ; j++)
			{
				strAvailableItem = availableList.options[j].text;
				
				if (strAvailableItem == strSelectedItem)
				{							
					availableList.options[j] = null;
					break;							
				}//End of if
			}//End of for				
		}//End of for
	}//End of if		
}//End Code Added by Arunender Singh  on 08-Apr-04 To manipulate the First list

// Code Added by Vikas to Compare fromDate to To date 
function fnReportDateCompare(strFromDate,strToDate,strDateFieldName)
{
	if((strFromDate == "" && strToDate != "") || (strFromDate != "" && strToDate == ""))
	{
		alert("Fill both " + strDateFieldName);
		return false;
	}
	
	var regExp = /\s+|[\s\,\-\.]/g; //Reg Exp Use to identify Date seperator.
	var arrDate  // This variable is used to store Date(dd,mm,yyyy) as an array element
	strFromDate = fnTrim(strFromDate); // Remove Leading and Trailing Spaces
	strToDate = fnTrim(strToDate); // Remove Leading and Trailing Spaces
	strFromDate = strFromDate.replace(regExp,"/"); //Replace Date seperator by "/"
	strToDate = strToDate.replace(regExp,"/"); //Replace Date seperator by "/"
	arrDate = strFromDate.split("/");
	var dtmFromDate = new Date(arrDate[2],eval(arrDate[1])-1,arrDate[0]) //Create Date object with input Date as parameter
	arrDate = strToDate.split("/");
	var dtmToDate = new Date(arrDate[2],eval(arrDate[1])-1,arrDate[0]) //Create Date object with input Date as parameter
	
	if (dtmFromDate < dtmToDate) 
	{
		return true;
	}
	else if (dtmFromDate > dtmToDate) 
	{
		alert(strDateFieldName + "(From) should be less than " +strDateFieldName + " (To)");
		return false;
	}
	return true;
}
// [004] Function added to compare text box values
function compareTextBox(strFrom, strTo, strMessageField)
{
	strValueFromName = document.getElementById(strFrom);
	strValueToName = document.getElementById(strTo);
	strValueFrom = strValueFromName.value;
	strValueTo = strValueToName.value;
	if(strValueFrom == "")
		strValueFrom = "0";
	if(strValueTo == "")
		strValueTo = "0";
	if(strMessageField != "Product code ")
	{
		if(strValueFrom == "0" && strValueTo == "0")
			return true;
		if (!isInteger(strValueFrom))
		{	
			alert(strMessageField + 'should be integer');
			strValueFromName.focus();
			return false;
		}
		if(!isInteger(strValueTo))
		{
			alert(strMessageField + 'should be integer');
			strValueToName.focus();
			return false;
		}
		if (strValueFrom != "0" && strValueTo != "0")
		{		
			if(parseInt(strValueTo) < parseInt(strValueFrom))
			{
				alert(strMessageField + "(From) should be less than " + strMessageField + "(To) ");
				return false;
			}
		}
	}

	if(strValueFrom == "0" && strValueTo == "0")
		return true;

	if(strValueFrom == "0" || strValueTo == "0")
	{
		alert("Fill both : " + strMessageField + "From and To");
		return false;
	}
	return true;
}

function compareComboBox(strValueFrom, strValueTo, strMessageField)
{
	if(strValueFrom == "" && strValueTo == "")
		return true;
	if(strValueFrom == "" || strValueTo == "")
	{
		alert("Fill both : " + strMessageField + "From and To");
		return false;
	}
	return true;
}


// Code Added by Vikas to get the Popup for Suppliercategorylocation
function openSupplierClientPopUp(strHiddenField,strTextField)
{
var strURl = '../Reports/RF_SupplierCategoryClientPopup.aspx?Hid=' + strHiddenField +'&Text=' +strTextField;
window.open(strURl,null,'left = 445, top = 150, width=450,height=250,status=yes');
return false;
}
// Function added ends hee

//[006] start
function showReportToolbar(boolShow)
{
	if (boolShow)
	{
		if (parent.frames[0].document.getElementById('divReportToolbar')!=null)
			parent.frames[0].document.getElementById('divReportToolbar').style.visibility='visible';	
	}
	else
	{
		parent.frames[0].divReportToolbar.style.visibility='hidden';	
	}
}
//[006] end
 /*--------------------------------------------------
	Auther:		Shravan Tembhre
	Date:		15-Mar-05
	Description:This function Image file(Name,Format,size)
 *--------------------------------------------------*/
function f_onChange(fileUpload,txtFile,txtSize){
	try {
		var objSize = new ActiveXObject("Scripting.FileSystemObject");
		var strFileName = objSize.getFile(document.getElementById(fileUpload).value);
		var SizeOfFile = strFileName.size;
		var strImageName = objSize.GetFileName(document.getElementById(fileUpload).value);
		document.getElementById(txtSize).value= (SizeOfFile/1024) + ' KB';
		document.getElementById(txtFile).value= strImageName
		}
	catch(e){
		
		if (e.number==-2146827859)
			alert('Please Enable ActiveX controls and plug-in browser setting for file and size \n\n  Goto Internet Option of IE browser and security setting');
	}
}
 /*--------------------------------------------------
	Auther:		Shravan Tembhre
	Date:		15-Mar-05
	Description:This function Image file(Name,Format,size)
 *--------------------------------------------------*/
function fn_onCnxtMenu(ProductTemplateId, FavouriteType){	
		if(ProductTemplateId!=''){			
				document.getElementById('hidProductTemplateId').value= ProductTemplateId;
				document.getElementById('hidFavouriteType').value= FavouriteType; //ST[002]
			}			
}


function chkSpecialCharacter(str, ctlName)
	{
		var iChars = "!@#$%^&*()+=-[]\\\';,./{}|\":<>?";

		for (var i = 0; i < str.length; i++) 
		{
  			if (iChars.indexOf(str.charAt(i)) != -1) 
  			{
  				alert (ctlName +" has special characters. \nThese are not allowed.\n Please remove them and try again.");
  				//str.substring(0,2).focus;
  				return false;
  			}
		}
		return true;
	}

function chkSpecialCharacter1(str, ctlName)
	{
		var iChars = "!#$%^&*()+=-[]\\\';,/{}|\":<>?";

		for (var i = 0; i < str.length; i++) 
		{
  			if (iChars.indexOf(str.charAt(i)) != -1) 
  			{
  				alert (ctlName +" has special characters. \nThese are not allowed.\n Please remove them and try again.");
  				//str.substring(0,2).focus;
  				return false;
  			}
		}
		return true;
	}

function CheckDecimal(sText)
{
   var ValidChars = "0123456789.";
   var IsNumber=true;
   var Char;

 
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;
   
   }

function isValidEmail(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid E-mail ID")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid E-mail ID")
		    return false
		 }


		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid E-mail ID")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }
		 if (str.charAt(lstr-1)=="."){
		    alert("Invalid E-mail ID")
		    return false
		 }
		 
		 return true;
	}
	
/*	function isValidURL(theUrl)
	{
	alert("address");
		if(theUrl.value.match(/^(http|ftp)\:\/\/\w+([\.\-]\w+)*\.\w{2,4}(\:\d+)*([\/\.\-\?\&\%\#]\w+)*\/?$/i) ||
		theUrl.value.match(/^mailto\:\w+([\.\-]\w+)*\@\w+([\.\-]\w+)*\.\w{2,4}$/i))
			{
			return true;
			} 
		else
		 {
			alert("Wrong address.");
			theUrl.select();
			theUrl.focus();
			return false;
		}
	} */
	
     function isValidURL(strUrl) 
      {
     	
		var urlText = strUrl;
		var httpText = urlText.substring(0,7);
		var strWwwtext = urlText.substring(0,4);
		
		if(httpText != 'http://' && strWwwtext != 'www.'   )
		{
			alert('invalid url');
			return false;
		}
		
		var dot="."
		var lstr=strUrl.length
		
		
		var ldot=strUrl.indexOf(dot)
				
		if (strUrl.indexOf(dot)==-1 || strUrl.indexOf(dot)==0 || strUrl.indexOf(dot)==lstr-1){
		    alert("Invalid URL")
		    return false
		}
         if (strUrl.indexOf(" ")!=-1){
		    alert("Invalid URL")
		    return false
		 }
		if (strUrl.charAt(lstr-1)=="."){
		    alert("Invalid URL....")
		    return false
		 }
		 if (strUrl.indexOf(",")!=-1){
		    alert("Invalid URL")
		    return false
		 }
 		 return true;					
	}