<!--
/////////////////////////////////////////////////////////////////////////////
//	To check for null values in a Text box call the function 			  	/	
//	_checforNull(th,ty,msg), where th = field name, ty =type for text,int, 	/	
//	radio, checkbox or date or float etc, and msg= message to be displayed.	/
//	if invalid data is passed to the method.								/
//	To check for date as well as null values in a date field , then use 	/
//	the function _checkforNull(th,ty,msg). To check only for date values 	/
//	then use _dateCheck(dat).
/////////////////////////////////////////////////////////////////////////////
	function _checkforNull(th,ty,mesg){
		
		//alert("inside .js" + th );
		if(ty == "TEXT")
		 {	
			if (th.value.length == "")
				{
					alert(mesg);
					th.focus();
					return false;
				}
		}
		
		if(ty == "Radio")
			{
			
				//alert(th.length);
				for(i=0;i<th.length;i++)
					{
						if (th[i].checked == true)
							return true;
					}
					alert(mesg);
				return false;
			}
		
		if(ty =="INT")
			{
			
				if(th.value.length =="")
					{
						alert(mesg);
						th.focus();
						return false;
					}
				else
					{
						if (isNaN(th.value))
							{
								alert(mesg);
								th.select();
								th.focus();
								return false;
							}
					}
				
				return true;
			}
		
		if(ty == "Date")
			{
				if(th.value.length=="")
					{
						alert(mesg);
						th.focus();
						return false;
					}
				else
					{
						//check for date validity
						//alert("Date Check");
						if( _dateCheck(th) == false)
							return false;
						else
							return true;
					}
			}
			
		if(ty == "DateofSelect")
			{
				if(th.options[th.selectedIndex].value=="")
					{
						alert(mesg);
						th.focus();
						return false;
					}
				else
					{
						//check for date validity
						//alert("Date Check");
						if( _dateCheckofSelect(th) == false)
							return false;
						else
							return true;
					}
			}

		if(ty == "Select"){
		
		
			//alert(th.length);
			if(th.options[th.selectedIndex].value=="")
				{
					alert(mesg);
					th.focus();
					return false;
				}
			return true;
		}	
		
		if(ty == "EMAIL")
		{

			if (th.value.length == "")
				{
					alert(mesg);
					th.focus();
					return false;
				}
			else
				{	
				  var at="@"
				  var dot="."
				  var lat=th.value.indexOf(at)
				  var lth=th.value.length
				  var ldot=th.value.indexOf(dot)
				  if (th.value.indexOf(at)==-1)
				  {
					alert(mesg);
				     return false;
				  }
				
				  if (th.value.indexOf(at)==-1 || th.value.indexOf(at)==0 ||
					th.value.indexOf(at)==lth){
					alert(mesg);
				     return false;
					  }
				
				  if (th.value.indexOf(dot)==-1 || th.value.indexOf(dot)==0 ||
				th.value.indexOf(dot)==lth){
					alert(mesg);
				      return false;
				  }
				
				   if (th.value.indexOf(at,(lat+1))!=-1){
					alert(mesg);
				      return false;
				   }
				
				   if (th.value.substring(lat-1,lat)==dot ||
					th.value.substring(lat+1,lat+2)==dot){
					alert(mesg);
				      return false;
				   }
				
				   if (th.value.indexOf(dot,(lat+2))==-1){
					alert(mesg);
				      return false;
				   }
				
				   if (th.value.indexOf(" ")!=-1){
					alert(mesg);
				      return false;
				   }
			}
		    return true;		
	}
	
			if(ty =="ALPHANUM")
			{
			
				if (!(isNaN(th.value)))
				{
								alert(mesg);
								th.select();
								th.focus();
								return false;
							}

				
				return true;
			}

}			

	
	
	
	function _dateCheck(dat){
	
		//alert(dat);
		//date format should be mm/dd/yyyy
		//extract the month value
		var mon,day,year;
		year = "";
		
		if(dat.value.length == 0)
			return true;
				
		arr = dat.value.split("/");
		//cannot have more than 2 separators
		if(arr.length > 3 || arr.length < 2 )
			{
				alert("Invalid Date !!!\n Date should be in MM/DD/YY \n OR MM/DD/YYYY format only");
				//dat.value="";
				//dat.select();
				dat.focus();
				return false;
			}
		else
			{
				if (arr.length > 1)//if length =2 then user has specified the month the day
				{
					if(arr[0].length == 0){
						alert("Invalid Month");
						dat.select();
						dat.focus();
						return false;	
					}
					else 
						 mon = arr[0];
																//If Day is less then  equal to  9  then concatinate 0  This code Addes by vikas Kumawat
				
						
					if(arr[1].length == 0){
						alert("Invalid Day");
						dat.select();
						dat.focus();
						return false;
					}
					else
						day = arr[1];
				}	
				if(arr.length > 2)//if length=3 then user has specified month,date & year.
					year = arr[2];
				
				//set the year if the user has not entered a year value
				if (year != "")
					{
						if (year.length == 2)
								year = "20" +year;		
						else
						{
							if (year.length == 3 || year.length == 1)
								{
									alert("Invalid Year Value");
									dat.select();
									dat.focus();
									return false;
								}
						}
					}
				else
					{
						var D = new Date();
						var  Y = D.getYear();
						//alert(navigator.appName);
						if( navigator.appName=="Netscape" && Y >= 100 )
							{
								Y = new String(Y);
								Y = Y.substring(1,Y.length);
								Y = "20" + Y;
								year = Y;
							}
							
						if( navigator.appName=="Microsoft Internet Explorer" && Y >= 100 )
							{
								Y = new String(Y);
								Y = Y.substring(2,Y.length);
								Y = "20" + Y;
								year = Y;
							}
					}
					//alert("mon="+mon+"Day="+day)
				if(mon.length > 2){
					alert("Invalid Month Value");
						//dat.select();
					dat.focus();
					return false;
				}
				if(mon.length < 2){
					mon=0+mon;
				}

				if(day.length > 2){
					alert("Invalid Day Value");
						//dat.select();
					dat.focus();
					return false;
				}
				if(day.length < 2){
					day=0+day;
				}

				
										
				if( _ValidMonth(dat,mon,day,year) == false)
					return false;
				else
						//alert(mon.length);
						/*if(mon.length < 2)
							{mon="0"+mon;}*/
						
						
					dat.value = mon + "/" + day + "/" + year ;
			}	  
				
		return true;
	}
	
		function _dateCheckofSelect(dat){
	
		//alert(dat);
		//date format should be mm/dd/yyyy
		//extract the month value
		var mon,day,year;
		year = "";
		
		if(dat.options[dat.selectedIndex].value.length == 0)
			return true;
				
		arr = dat.options[dat.selectedIndex].value.split("/");
		//cannot have more than 2 separators
		if(arr.length > 3 || arr.length < 2 )
			{
				alert("Invalid Date !!!\n Date should be in MM/DD/YY \n OR MM/DD/YYYY format only");
				//dat.value="";
				//alert(dat);
				//dat.select();
				dat.focus();
				return false;
			}
		else
			{
				if (arr.length > 1)//if length =2 then user has specified the month the day
				{
					if(arr[0].length == 0){
						alert("Invalid Month");
						//dat.select();
						dat.focus();
						return false;	
					}
					else 
						 mon = arr[0];
					
					if(arr[1].length == 0){
						alert("Invalid Day");
						//dat.select();
						dat.focus();
						return false;
					}
					else
						day = arr[1];
				}	
				if(arr.length > 2)//if length=3 then user has specified month,date & year.
					year = arr[2];
				
				//set the year if the user has not entered a year value
				if (year != "")
					{
						if (year.length == 2)
								year = "20" +year;		
						else
						{
							if (year.length == 3 || year.length == 1)
								{
									alert("Invalid Year Value");
									//dat.select();
									dat.focus();
									return false;
								}
						}
					}
				else
					{
						var D = new Date();
						var  Y = D.getYear();
						//alert(navigator.appName);
						if( navigator.appName=="Netscape" && Y >= 100 )
							{
								Y = new String(Y);
								Y = Y.substring(1,Y.length);
								Y = "20" + Y;
								year = Y;
							}
							
						if( navigator.appName=="Microsoft Internet Explorer" && Y >= 100 )
							{
								Y = new String(Y);
								Y = Y.substring(2,Y.length);
								Y = "20" + Y;
								year = Y;
							}
					}
				
										
				if( _ValidMonth(dat,mon,day,year) == false)
					return false;
				else
					dat.options[dat.selectedIndex].value = mon + "/" + day + "/" + year ;
			}	  
				
		return true;
	}
	//check for month validity
	function _ValidMonth(dt,checkMonth,checkDay,checkYear){
	
		var curdate = new Date();
		var curday = curdate.getDate();
		var curmonth = curdate.getMonth();
		var curyear = curdate.getYear();
		var maxdays = 0;
		
		//convert the string values to decimal values.
		checkMonth = parseInt(checkMonth,10);
		checkDay = parseInt(checkDay,10);
		checkYear = parseInt(checkYear,10);

		//check whether the month value is less than or equal to 12.
		
		if ( checkMonth > 0 && checkMonth <= 12 ) //if the month value is valid then 
			{					//set the number of days for the entered month value.
				//if( m==4 || m == 6 || m == 9 || m == 11)
					//var maxdays = 30;
					//alert(m);
				switch (checkMonth){
					case 4:
					case 6:
					case 9:
					case 11:
						maxdays = 30;
						//alert(maxdays);
						break;
					case 1:
					case 3:
					case 5:
					case 7:
					case 8:
					case 10:
					case 12:
					 	maxdays = 31;
						//alert(maxdays);
						break;
					case 2:
						if (checkYear == "")
							checkYear = curyear;
							
							if( checkYear % 4 > 0)
								maxdays = 28;
							else
								if( (checkYear % 100 == 0) && (checkYear % 400 > 0) )
									maxdays = 28;
								else 
									maxdays = 29;
						
						//alert(maxdays);
						break;
					default:
						break;
					}	
			}
		
		else
			{
				alert("Invalid Month");
				//dt.select();
				dt.focus();
				return false;
			}
		
		//alert(maxdays +"," + checkDay);
		
		if ( _checkDay(dt,maxdays,checkDay)== false )
				return false;
		
	return true;	
	}
	
	
	function _checkDay(Obj,Max_Days,Days){
		
		//alert(Max_Days + "," + Days);
		if( isNaN(parseInt(Days))== true)
			{
				
				alert("Invalid Day");
				//Obj.select();
				Obj.focus();
				return false;
			
			}
		
		if( parseInt(Days) > parseInt(Max_Days) || parseInt(Days) <= 0 )
			{
				
				alert("Invalid Day");
				//Obj.select();
				Obj.focus();
				return false;
			
			}
						
		return true;
		}
	///////////////////////////////////////////////////////////////////////////
	//	Function Name	:	_checkINT()
	//	Input			:	form.field.value
	//	Output			:	validated field value(returns true or false)
	///////////////////////////////////////////////////////////////////////////	
	function _checkINT(th,mesg){
	
		if (isNaN(th.value))
				{
					alert(mesg);
					th.select();
					th.focus();
					return false;
				}
		}
		
	//////////////////////////////////////////////////////////////////////////////////////////
	//	Function Name	:	_PassParameters(formObject)
	//	Input			:	form Object,
	//						No.Of form objects to skip on the form to be exlcuded.
	//						Hidden Variable Name
	//	Output			:	Concatenates all the form objects values in an single
	//						string and passes it to the next form defined in
	//						action attribute of the form.
	//					NOTE : form objects to be skipped should be at the
	//							end of the form.
	///////////////////////////////////////////////////////////////////////////////////////////
	function _PassParameters(formObj,n,HidVar){
		
		HidVar.value = "";	
			
		for(i=0;i<formObj.length-n;i++){

			if( formObj[i].value == "")	formObj[i].value = " ";

			if( formObj[i].type == "select-multiple" ) 
			{
				var tempStr;
				tempStr = concateSelectedOptions(formObj[i]);
				HidVar.value = HidVar.value+tempStr+"|";
			}
			else if( formObj[i].type == "select-one" ) 
			{
				temp = formObj[i].options[formObj[i].options.selectedIndex].value;
				if (temp == "") temp = " ";
				HidVar.value = HidVar.value+temp+"|";
			}
			else if( formObj[i].type == "checkbox" )
			{
				if(formObj[i].checked)
					HidVar.value = HidVar.value+"1|";
				else
					HidVar.value = HidVar.value+"0|";
			}
			else if( formObj[i].type == "Radio" )
			{
				if(formObj[i].checked)
					HidVar.value = HidVar.value+"1|";
				else
					HidVar.value = HidVar.value+"2|";
			}
			else
			{
				HidVar.value = HidVar.value+formObj[i].value+"|";
			}
		
		}
		alert(HidVar.value);
	}
	
	function concateSelectedOptions(th)
	{
				var temp = "";
				for (var i=0; i<th.options.length; i++)
				{
					if(th.options[i].selected)
					{
						if (temp != "") temp += ',';
						temp += th.options[i].value;
					}
				}
				if (temp == "") temp = " ";				
				return temp;
	}
	
	dayArray = new Array("Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday");
	monthArray = new Array("January","February","March","April","May","June","July","August","September","October","November","December");


function _DecimalCheck(th,TotSize,Decimal)
	{	  

		if(th.value=="")
			{return true;}
		else
			{	
				if(isNaN(th.value))
				{
					alert("Value should be numeric.");
					th.value="";
					th.focus();
					return false;
				}	
				
				else
				{
					dot="."
					var ValBeforeDot=0
					  if (th.value.indexOf(dot)==-1)
						 {
						 	ValBeforeDot=TotSize-Decimal
							if(th.value.length >ValBeforeDot )
								{	
									alert("Invalid Value. Please enter the value according the example  ");
									th.value="";
									th.focus();
									return false;
								}	
						 }
					else
						{
														
							ValBeforeDot=TotSize-Decimal
							if(th.value.indexOf(dot) > ValBeforeDot)
							{	
								alert("Invalid Value. Please enter the value according the example  ");
								th.value="";
								th.focus();
								return false;
							}

							if(th.value.substr(th.value.indexOf(dot)+1).length > Decimal)
							{
								alert("Invalid Value. Please enter the value according the example  ");
								th.value="";
								th.focus();
								return false;							
							}
							
														
						}	 
				
				}
			}
	}


function _DecimalCheckNotNull(th,TotSize,Decimal)
	{	  

		if(th.value=="")
			{
				alert("Field Can't be blank");
				return false;
			}
		else
			{	
				if(isNaN(th.value))
				{
					alert("Field should be numeric");
					th.value="";
					th.focus();
					return false;
				}	
				
				else
				{
					dot="."
					var ValBeforeDot=0
					  if (th.value.indexOf(dot)==-1)
						 {
						 	ValBeforeDot=TotSize-Decimal
							if(th.value.length >ValBeforeDot )
								{	
									alert("Invalid Value. Please enter the value according the example  ");
									th.focus();
									return false;
								}	
						 }
					else
						{
														
							ValBeforeDot=TotSize-Decimal
							if(th.value.indexOf(dot) > ValBeforeDot)
							{	
								alert("Invalid Value. Please enter the value according the example  ");
								th.focus();
								return false;
							}

							if(th.value.substr(th.value.indexOf(dot)+1).length > Decimal)
							{
								alert("Invalid Value. Please enter the value according the example  ");
								th.focus();
								return false;							
							}
							
														
						}	 
				
				}
			}
	}


	
//-->