		//---------------- Javascript Functions -----------------------//		
		// Project Name					: XPREZTO - EMS
		// Date of Creation				: 30-08-2006
		// Last Date of Modification	: 31-08-2006
		//------------------------------------------------------------//		
	
	/*var message="Function Disabled!";
		self.status='';		
		///////////////////////////////////
		function clickIE4()
		{
			if (event.button==2)
			{
				//alert(message);
				return false;
			}
		}

		function clickNS4(e)
		{
			if (document.layers||document.getElementById&&!document.all)
			{
				if (e.which==2||e.which==3)
				{
					//alert(message);
					return false;
				}
			}
		}

		if (document.layers)
		{
			document.captureEvents(Event.MOUSEDOWN);
			document.onmousedown=clickNS4;
		}
		else if (document.all&&!document.getElementById)
		{
			document.onmousedown=clickIE4;
		}
		document.oncontextmenu=new Function("return false")

		*/
			
		
		// ------ Accept Numeric from '0' to '9' Only ----------		
		
			function Right(str, n)
			{
					if (n == 0)
					return "";
					else if (n >String(str).length)
					return str;
					else {
					var iLen = String(str).length;
					return String(str).substring(0,n);
					}
			}
				
			function Left(str, n)
			{
					alert(n);
					if (n = 0)
					return "";
					else if (n > String(str).length)
					return str;
					else
					return String(str).substring(str.length,n+1);
			}



			function isNumeric(val)
			{
				var dig="";
				var strst="";var strend="";
				var strsub="";
				for( i1=0;i1<500;i1++)
				{
					strst="";
					strend="";
					strsub="";
					dig=document.getElementById(val).value;
					for( i=0;i<dig.length;i++)
					{
						strsub=dig.substring(i,i+1);
						if(parseFloat(strsub,10)==(strsub*1))
						{
							
						}
						else
						{
							strst=dig.substring(0,i);
							strend=dig.substring(i+1,dig.length)
							dig=dig.substring(0,dig.length) ; 
							document.getElementById(val).value=strst+strend;
						}
					}
				}
			}
			
			function isAlpha(val)
			{
				var dig="";
				var strst="";var strend="";
				var strsub="";
				for( i1=0;i1<500;i1++)
				{
					strst="";
					strend="";
					strsub="";
					dig="";
					dig=document.getElementById(val).value;
					for( i=0;i<dig.length+1;i++)
					{
						strsub=dig.substring(i,i+1);
						if(parseFloat(strsub,10)==(strsub*1))
						{
							strst=dig.substring(0,i);
							strend=dig.substring(i+1,dig.length)
							dig=dig.substring(0,dig.length) ; 
							document.getElementById(val).value=strst+strend;
							
						}
						else
						{
							
						}
					}
				}
			}
		
			function Numeric()
			{		
					
				if((keynum >= 48 && keynum <= 57))
				{
					keynum = keynum ;
					
				} 
				else
				{
					keynum = 0;
				}
				
				if((event.charCode >= 48 && event.charCode <= 57))
				{
					event.charCode = event.charCode ;
					
				} 
				else
				{
					event.charCode = 0;
				
			
				}
			}
			// ------ Accept Email  ----------		
			function Email()
			{				
				if(!(((event.keyCode>=65)&&(event.keyCode<=90))||((event.keyCode>=97)&&(event.keyCode<=122))||(event.keyCode==64)||((event.keyCode >= 48 && event.keyCode <= 57) || (event.keyCode == 46)||(event.keyCode == 95))))
				{					
					event.keyCode = 0;
				}
			}
				

			
			// ------ Accept Alphabets from 'A' to 'Z' & Numbers Only ----------		
			function AlphaUpperNumeric()
			{								
				if((event.keyCode >= 65 && event.keyCode <= 90) || (event.keyCode >=48 && event.keyCode <=57))
				{
					event.keyCode = event.keyCode ;
				} 
				else
				{
					event.keyCode = 0;
				}
			}
			
			//---Accept Numbers from '0' to '9' and '+' -----------
			function NumericPlus()
			{								
				if((event.keyCode >= 48 && event.keyCode <= 57) || (event.keyCode==43))
				{
					event.keyCode = event.keyCode ;
				} 
				else
				{
					event.keyCode = 0;
				}
			}
			
			// ------ Accept Decimal from '0' to '9' and '.' Only ----------
			function Decimal()
			{				
				if((event.keyCode >= 48 && event.keyCode <= 57) || (event.keyCode == 46))
				{
					event.keyCode = event.keyCode ;
				} 
				else
				{
					event.keyCode = 0;
				}
			}
			
			// ------ Accept Upper Case,lower Case and Space and numbers Only ----------
			function Alphanumeric()
			{	
				if((event.keyCode >= 48 && event.keyCode <= 57))
				{					
					event.keyCode = event.keyCode ;
				} 
				else
				{
					AlphaULS();					
				}

			}					
			
			// ------ Accept Numbers Only ----------
			function Numeric()
			{	
				if((event.keyCode >= 48 && event.keyCode <= 57))
				{					
					event.keyCode = event.keyCode ;
				} 
				else
				{
					event.keyCode= 0;
				}
			}					
			
			
			// ------ Accept Upper Case,lower Case and Space Only ----------
			function AlphaULS()
			{				
				if(!(((event.keyCode>=65)&&(event.keyCode<=90))||((event.keyCode>=97)&&(event.keyCode<=122))||(event.keyCode==32)))
				{					
					event.keyCode = 0;
				}						
			}					
				
			//-------------- Confirm function for Delete -------------//
			function confirm_delete()
			{
				if(confirm("Are you sure want to Delete?")==true)
				{
					return true;
				}
				else
				{
					return false;
				}
			}
			

	
					
			
			// ------ Phone Number Validation(0-9 , -  )----------		
			function PhoneValidation()
			{								
				if((event.keyCode >= 48 && event.keyCode <= 57)|| (event.keyCode==44)|| (event.keyCode==45) || (event.keyCode==32))
				{
					event.keyCode = event.keyCode ;
				} 
				else
				{
					event.keyCode = 0;
				}
			}
			// ------ Address Validation (0-9 , A - Z a - z , / - .- ,#,@ )----------		
			function Address()
			{	
				if(!(((event.keyCode>=65)&&(event.keyCode<=90))||((event.keyCode>=97)&&(event.keyCode<=122))||(event.keyCode==32)||(event.keyCode==35)||(event.keyCode==64)||((event.keyCode >= 44 && event.keyCode <= 57))))
				{					
					event.keyCode = 0;
				}

			}

				//--------------- To Check the Form Controls -----------		
			
			function formValidator(ID,strElements)
			{
				var stringArray = strElements.split(',');
				for (var iLoop=0; iLoop < stringArray.length ; iLoop++)
				{
					var strCurrElement = stringArray[iLoop];				
					var theForm = document.getElementById(ID);			
					var allvalid = true;
					var alertstr = "";
					var validstr = "All form data is correct.\n\n";
					var num_of_elements = theForm.length;
					var radio_selected = false;
					var checkbox_selected = false;			
					for (var i=0; i<num_of_elements; i++) 
					{
						var theElement = theForm.elements[i];
						var element_type = theElement.type;				
						var element_name = theElement.name;
						var element_value = theElement.value;
						
						if(strCurrElement == element_name)			
						{
							// Check Text Box ...
							if (element_type == "text") 				
							{											
								if (trim(element_value).length == 0) 
								{					
									alert("Empty field not allowed!");
									theElement.focus();
									theElement.style.backgroundColor = "#ffff99";
									return false;
								}
								else
								{
									theElement.style.backgroundColor = "#ffffff";
								}
							}
							// Check Drop-down lists ...
							if (element_type.indexOf("select") > -1) 
							{						
								var index = theElement.selectedIndex;					
								if (index == "0") 
								{
									alert("Select Value!");
									theElement.focus();
									theElement.style.backgroundColor = "#ffff99";
									return false;
								}
								else
								{
									theElement.style.backgroundColor = "#ffffff";
								}
							}
							// Check Textarea boxes ...
							if (element_type == "textarea") 
							{
								if (element_value.length == 0) 
								{					
									alert("Empty not allowed!");
									theElement.focus();
									theElement.style.backgroundColor = "#ffff99";
									return false;
								}
								else
								{
									theElement.style.backgroundColor = "#ffffff";
								}
							}
							
							// Check List Box...
							if (element_type.indexOf("multiple") > -1) 
							{										
								var index = theElement.selectedIndex;					
								if (index < 1) 
								{
									alert("Select Value!");
									theElement.focus();
									theElement.style.backgroundColor = "#ffff99";
									return false;
								}
								else
								{
									theElement.style.backgroundColor = "#ffffff";
								}
							}
							
							// Check File Browser...
							if (element_type.indexOf("file") > -1) 
							{										
								if (trim(element_value).length == 0) 
								{					
									alert("Empty field not allowed!");
									theElement.focus();
									theElement.style.backgroundColor = "#ffff99";
									return false;
								}
								else
								{
									theElement.style.backgroundColor = "#ffffff";
								}
							}
							
							// Check Radio buttons ...
							if (element_type == "radio" ) 
							{
								if (theElement.checked == true) 
								{
									radio_selected = true;
									validstr += "From form element '" + element_name + 
									"' you selected the \"" + element_value + "\" button.\n\n";
								}
							}
														
							// Check Checkboxes ...
							if (element_type == "checkbox") 
							{
								if (theElement.checked == true) 
								{
									checkbox_selected = true;
									validstr += "From form element '" + element_name + 
									"' you selected the \"" + element_value + "\" checkbox.\n\n";
								}
							}
						}
					}
				}
			}					
			
			
			// Removes leading whitespaces
			function LTrim( value ) 
			{
				var re = /\s*((\S+\s*)*)/;
				return value.replace(re, "$1");
			}

			// Removes ending whitespaces
			function RTrim( value ) 
			{
				var re = /((\s*\S+)*)\s*/;
				return value.replace(re, "$1");
			}

			// Removes leading and ending whitespaces
			function trim( value ) 
			{
				return LTrim(RTrim(value));	

			}
			
		function ChkPerTime(ID1,ID2,ID3,ID4)
		{
			alert('test');
			// --------From and To Time Validation ------------
			var fromTime	= document.getElementById(ID1).value + ':' + document.getElementById(ID2).value 
			var toTime 		= document.getElementById(ID3).value + ':' + document.getElementById(ID4).value 

			var Status1 = CheckValid(fromTime,toTime);
			
			if(Status1 == false)
			{
				alert("To Time Should be Greater than From Time");
				return false;
			}
			return true;
		}

		function CheckValid(stTime,edTime)
		{	
			var strArryFrom  = stTime.split(':');
			var iHrsFrom = strArryFrom[0];
			var iMinFrom = strArryFrom[1];	
			var strArryTo  = edTime.split(':');
			var iHrsTo = strArryTo[0];
			var iMinTo = strArryTo[1];
			var blnStatus = "0"  ;
			if((iHrsTo == iHrsFrom) && (iMinTo > iMinFrom))
			{
				blnStatus = "1";
			}
			else if(iHrsTo > iHrsFrom) 
			{
				blnStatus = "1";
			}
			
			if(blnStatus=="0")
			{
				return false;
			}
			else if(blnStatus=="1")
			{
				return true;
			} 
			return false;
		}


		function CheckTime(stTime,edTime)
		{	
			var strArryFrom  = stTime.split(':');
			var iHrsFrom = strArryFrom[0];
			var iMinFrom = strArryFrom[1];	
			var strArryTo  = edTime.split(':');
			var iHrsTo = strArryTo[0];
			var iMinTo = strArryTo[1];
			var blnStatus = "0"  ;
			if((iHrsTo == iHrsFrom) && (iMinTo > iMinFrom))
			{
				blnStatus = "1";
			}
			else if(iHrsTo > iHrsFrom) 
			{
				blnStatus = "1";
			}
			if(blnStatus=="0")
			{
				return false;
			}
			else if(blnStatus=="1")
			{
				return true;
			} 
			return false;
			
		}
		function CheckBetweenTime(ID1,ID2,ID3,ID4,ID5,ID6,ID7,ID8)
		{
			// --------From and To Time Validation 
			var fromTime	= document.getElementById(ID1).value + ':' + document.getElementById(ID2).value 
			var toTime 		= document.getElementById(ID3).value + ':' + document.getElementById(ID4).value 
			var lunFromTime = document.getElementById(ID5).value + ':' + document.getElementById(ID6).value 
			var lunToTime   = document.getElementById(ID7).value + ':' + document.getElementById(ID8).value 

			var Status1 = CheckTime(fromTime,toTime);
			if(Status1 == false)
			{
				alert("To Time Should be Greater than From Time");
				return false;
			}
			var Status2 = CheckTime(lunFromTime,lunToTime);	
			if(Status2 == false)
			{
				alert("Lunch To Time Should be Greater than Lunch From time");
				return false;
			}	
			var Status1 = CheckTime(fromTime,lunFromTime);
			var Status2 = CheckTime(lunToTime,toTime);	
			if((Status1 == false)||(Status2 == false))
			{
				alert("Lunch Time Should be Between Working Hours");
				return false;
			}
			return true;
		}




		function isEmail(ID)
		{			
			var EmailIdvalue = document.getElementById(ID).value;
			if(EmailIdvalue == "")
			{				
				return true;
			}
			if (EmailIdvalue.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1)
			{
				return true;
			}
			else
			{
				alert("Invalid E-mail Address!");
				document.getElementById(ID).select();
				document.getElementById(ID).focus();
				return false;
			}			
		}



			// ------ Accept Upper Case,lower Case and NoSpace  ----------
			function AlphaULNS()
			{				
				if(!(((event.keyCode>=65)&&(event.keyCode<=90))||((event.keyCode>=97)&&(event.keyCode<=122))))
				{					
					event.keyCode = 0;
				}						
			}	
			
			// ---------------Accept Lowercase uppercase Numbers and undersocre only----
			
			function UserNameValidation()
			{	
				if((event.keyCode >= 48 && event.keyCode <= 57) || (event.keyCode==95 ))
				{					
					event.keyCode = event.keyCode ;
				} 
				else
				{
					AlphaULNS();					
				}

			}	

