//function restricts  the no of character  more than from the define length. e.g.  in text field , you can give a maximum limit for the character When you will use onKeyup event. 
/***************************************************
 *The information contained here in is confidential and 
 * proprietary to MIND and forms the part of the MIND 
 *Author				:
 *Date of Creation 		:
 *Copyright Notice 		:Copyright(C)2000 MIND.All rights reserved
 *Project	  			:STARS
 *Operating environment :Tomcat, sql server 2000 
 *Description 			:This is a Java Script Validation file.
 *Modification 			:1.Restricting the entry of quotes(', ", \) in the fields 
 *Reason of Modification:1.Generating error on retrieving from database
 *Date of Modification  :1.16-Apr-2007  
 *Modification By		:Samir
 *Revision History		:
 *Editor				:Editplus
 *******************************************************/
 //*************added by Manoj Kumar Gupta on 03/July/08************************************************* 
//****************************Number Validation upto three decimal************************
//function for restrict value after three decimal
function upToThreeDecimal(val)
{
   var m = val.value;
   var strLength = m.length;
   var loc = m.indexOf(".");
   if(loc == '-1')
   {
   }
   else
   {
  	  var a = m.substring(0,loc+1);
	  if((loc+1) < strLength)
	  {
	    var b = m.substring(loc+1,strLength);
		if(b.length > 3)
		{
		  b = b.substring(0,3);
		  val.value = a+b;
		}
	  }  
   }
   
   // restrict more than one dot(.)
    var intFlag = 0;
    for(var i=0; i<strLength; i++)
	{	  
		var lchar = val.value.charAt(i); 
		
        //alert(val.value);
		   
		  if(lchar == '.')
		   {
		      intFlag++;
		   }
			
		   if(intFlag > 1)
		   {
		      var tst = val.value.substring(0, i);
			  //var last = val.value.substring(i+1,strLength);
			 // alert("i=="+i);
			  //val.value = tst+last;
			  val.value = tst;
			  break;
			  //i--;
		   }

		   if(lchar == '\\')
		   {
		      var tst = val.value.substring(0, i);
			  val.value = tst;
			  break;
		   }
	   }
}

//*************Number Validation before decimal************************
//function to restrict three numbers before decimal
function maxThreeNum(val)
{
	var m = val.value;
	var len = m.length;
	var str_Rec = m.indexOf(".");
	if(str_Rec == "-1")
	{
		var a = m.substring(0,len);
		var b = a.length;
		if(b > 3)
		{	
			//alert("1");
			var c = a.substring(0,3);
			val.value = c;
		}
	}
	
}
//*************End of JS methods by Manoj Kumar Gupta*************************************************	
 
function test()
{
	alert("test successfull");
}
function limitlength(obj, length)
{
	//alert("123");
    var maxlength=length;
    if (obj.value.length>maxlength)
        obj.value=obj.value.substring(0, maxlength);
}

//function for restirct the special character or numeric value or character value(Only character and spaces are allowed)
function charactercheck(val, type) 
{
	
   if(type=='c')                                    //c for charcter only
   {
	   mikExp = /[$\\@\\\#%\^\&\*\>\<\(\)\[\]\+\_\{\}\`\~\=\.\|\,\'\"\?\/\>\<\!\-\:\;\\0\\1\\2\\3\\4\\5\\6\\7\\8\\9]/;
	   //alert(mikExp);
   }
   else if(type=='n')                                // n for number only
   {
	   mikExp =	/[$\\@\\\#%\^\&\\*\(\)\[\]\+\_\{\}\`\~\=\.\|\,\'\"\?\/\>\<\!\-\:\;\\a\\b\\c\\d\\e\\f\\g\\h\\i\\j\\k\\l\\m\\n\\o\\p\\q\\r\\s\\t\\u\\v\\w\\x\\y\\z\\A\\B\\C\\D\\E\\F\\G\\H\\I\\J\\K\\L\\M\\N\\O\\P\\Q\\R\\S\\T\\U\\V\\W\\X\\Y\\Z]/;
	   //alert(mikExp);
   }
   else if(type=='n.')                                // n for number only
   {
	   mikExp =	/[$\\@\\\#%\^\&\ \*\(\)\[\]\+\_\{\}\`\~\=\|\,\'\"\?\/\>\<\!\-\:\;\\a\\b\\c\\d\\e\\f\\g\\h\\i\\j\\k\\l\\m\\n\\o\\p\\q\\r\\s\\t\\u\\v\\w\\x\\y\\z\\A\\B\\C\\D\\E\\F\\G\\H\\I\\J\\K\\L\\M\\N\\O\\P\\Q\\R\\S\\T\\U\\V\\W\\X\\Y\\Z]/;
   }
   else if(type=='cn')                              // cn for character and no only
   {
	   mikExp = /[$\\@\\\#%\^\&\*\(\)\[\]\+\_\{\}\`\~\=\.\|\,\'\"\?\/\>\<\!\-\:\;]/;
	    //alert(mikExp);
   }
   else if(type=='un')                              // cn for character and no only
   {
	   mikExp = /[$\\@\\\#%\^\&\*\(\)\[\]\+\{\}\`\~\=\|\,\'\"\?\/\>\<\!\-\:\;]/;
	    //alert(mikExp);
   }
   else if(type=='cn,')                              // cn for character and no only
   {
	   mikExp = /[$\\@\\\#%\^\&\*\(\)\[\]\+\_\{\}\`\~\=\.\|\'\"\?\/\>\<\!\-\:\;]/;
	    //alert(mikExp);
   }
   else if(type=='cn:')                              // cn for character and no only
   {
	   mikExp = /[$\\@\\\#%\^\&\*\(\)\[\]\+\_\{\}\`\~\=\.\|\,\'\"\?\/\>\<\!\-\;]/;
	    //alert(mikExp);
   }
   else if(type=='phone')
   {
        mikExp =	/[$\\@\\\#%\^\&\*\[\]\+\_\{\}\`\~\=\.\|\,\'\"\?\/\>\<\!\:\;\\a\\b\\c\\d\\e\\f\\g\\h\\i\\j\\k\\l\\m\\n\\o\\p\\q\\r\\s\\t\\u\\v\\w\\x\\y\\z\\A\\B\\C\\D\\E\\F\\G\\H\\I\\J\\K\\L\\M\\N\\O\\P\\Q\\R\\S\\T\\U\\V\\W\\X\\Y\\Z]/;
		//alert("in phone");
   }
   else if(type=='allSpecialChar')                                    //except these special characters
   {
	   mikExp = /[$\\@\\\#%\^\&\*\(\)\[\]\+\_\{\}\`\~\=\.\|\,\'\"\?\/\>\<\!\-\:\;\\]/;
	   //alert(mikExp);
   }
   else if(type=='allSpecialCharCus')                                    //except these special characters
   {
	   mikExp = /[$\\@\\\#%\^\&\*\(\)\[\]\+\{\}\`\~\=\|\,\'\"\?\/\>\<\!\:\;\\]/;
	   //alert(mikExp);
   }
   else if(type=='specialChar')                                    //except these special characters
   {
	   mikExp = /[%\&\*\`\'\>\<\"\?]/;
	   //alert(mikExp);
	   
	   
   }
   
   else if(type=='num')                                // n for number and - only  added by balvinder on 08 feb 2010
   {
	   mikExp =	/[$\\@\\\#%\^\&\\*\(\)\[\]\+\_\{\}\`\~\=\.\|\,\'\"\?\/\>\<\!\\:\;\\a\\b\\c\\d\\e\\f\\g\\h\\i\\j\\k\\l\\m\\n\\o\\p\\q\\r\\s\\t\\u\\v\\w\\x\\y\\z\\A\\B\\C\\D\\E\\F\\G\\H\\I\\J\\K\\L\\M\\N\\O\\P\\Q\\R\\S\\T\\U\\V\\W\\X\\Y\\Z]/;
	   //alert(mikExp);
   }
   else if(type=='pwd')
   {
        mikExp = /[=\&\*\%\?\>\<\'\"\-\\]/;						// change by samir Ranjan Padhi on 7/oct/2007
  
		//alert("in pwd");
   }
   else if(type=='ad')
   {
        mikExp = /[=\'\>\<\"\\]/;						// change by samir Ranjan Padhi on 6/25/2007
		//alert("in pwd");
   }
   else if(type=='an')
   {												// an for alphanumeric only // change by samir on 4/16/2007
        
		mikExp = /[\'\"\>\<\;\\]/;
		//alert("in an");
   }
   else if(type=='specialCharComma')                                  
   {											 
	   mikExp = /[%\&\*\`\'\"\?\,]/;				 //except these special characters add ,(comma) also by samir on 6/oct/2007
	   //alert(mikExp);
   }
   else if(type=='specialChar_And')                                    //except these special characters
   {
	   mikExp = /[%\*\`\'\>\<\"\?]/;
	   //alert(mikExp);
   } else if(type=='specialChar1')                                    //except these special characters  added by sachin sachdeva
   {
	   mikExp = /[$\\@\\\#%\^\&\*\(\)\+\_\{\}\`\~\=\'\"\?\>\<\!\:\;\\]/; 
	   //alert(mikExp);
   }
   else if(type=='c.')                                //  added by sachin sachdeva
   {
	   mikExp = /[$\\@\\\#%\^\&\*\(\)\[\]\+\_\{\}\`\~\=\|\,\'\"\?\/\>\<\!\-\:\;\\0\\1\\2\\3\\4\\5\\6\\7\\8\\9]/;
	   //alert(mikExp);
   } 
   else if(type=='cn-')                                  // added by sachin sachdeva
   {
	   mikExp = /[$\@\#%\^\&\*\(\)\+\_\{\}\`\~\=\.\,\'\"\?\>\<\!\:\;\\]/; 
	   //alert(mikExp);
   }else if(type=='nc')                                               // number and colon allowed By jyoti
   {
      mikExp =    /[$\\@\\\#%\^\&\ \*\(\)\[\]\+\_\{\}\`\~\=\.\|\,\'\"\?\/\>\<\!\-\;\\a\\b\\c\\d\\e\\f\\g\\h\\i\\j\\k\\l\\m\\n\\o\\p\\q\\r\\s\\t\\u\\v\\w\\x\\y\\z\\A\\B\\C\\D\\E\\F\\G\\H\\I\\J\\K\\L\\M\\N\\O\\P\\Q\\R\\S\\T\\U\\V\\W\\X\\Y\\Z]/;
   }
   else
   {
	   mikExp = /[\`]/;
	  // alert("nothing");
   }
	   

 
  
   /*
	var dataMikExp="";


	alert(mikExp)
	
	alert(mikExp.charAt(0))
	
	alert(mikExp.length)
	//alert(mikExp.length)
	
	//dataMikExp= mikExp.replace(/\&lt;/g,'<');
	
	//alert(dataMikExp)

	
	for(i=0;i<mikExp.length;i++)
	{
	
		alert(mikExp.charAt(i))
		dataMikExp=mikExp+mikExp.charAt(i)+",";
	
	}

 	alert(dataMikExp);*/
 
  
   var strPass = val.value;
   var strLength = strPass.length; 
  
   //var lchar = val.value.charAt((strLength) - 1);
   //alert("length is=="+strLength); 
  	
  	var charData="";
  	
  	
   if(strLength > 0)
   {
   		var flg=false;
	   for(var i=0; i<strLength; i++)
	   {
		   //alert("inside for ");
		   var lchar = val.value.charAt(i); 
		   if(lchar.search(mikExp) != -1) 
           {
           	charData=lchar;
           		flg=true;
           		break;
              //var tst = val.value.substring(0, i);
			  //var last = val.value.substring(i+1,strLength);
              //val.value = tst+last;
			  //i--;
			
		   }
		  
	   }
	   
	   if(flg)
	   {
	   /*
	   		var dataMik="";
	   		
	   		for(i=0;i<mikExp.length;i++)
	   		{
	   			dataMik=dataMik+mikExp[i]+","
	   		
	   		}
	   */
	   
//	   	var mikExp1=mikExp.replace('[\]','\\');
	  // var mikExp1= mikExp.replace(/\[\]/g,'\\');
	  
	 // alert(val);
	 // alert(val.name);
	  
	  //  var targetdiv = document.getElementById(val.name);
	    
	   // alert(targetdiv);
	    
	   //	var leftPosition=leftPosition(targetdiv);
	   // var topPosition=topPosition(targetdiv);
	    
	    
	   // alert(leftPosition);
	   
	   /*
	   var target=val;
	   
		var left = 0;
	  if(target.offsetParent) {
	    while(1) {
	      left += target.offsetLeft;
	      if(!target.offsetParent) {
	        break;
	      }
	      target = target.offsetParent;
	    }
	  } 
  
     
     var target1=val;
     var top = 0;
  if(target1.offsetParent) {
    while(1) {
      top += target1.offsetTop;
      if(!target1.offsetParent) {
        break;
      }
      target1 = target1.offsetParent;
    }
    }
    
  	top=top+20;
     */
     
     var left = 30;
      var top = 30;
     
     // var top = val.offsetParent;
	   
	   //	alert(top);
	   
	   	  creatediv('CommonValidaDyna',""+charData+" is not allowed ",flg+'',val,'200','20',left,top);	
	   
	   	
	   }
	  /* else
	   {
	   		if(document.getElementById("CommonValidaDyna") != null)
	   		{
	   		 	var obj=document.getElementById("CommonValidaDyna");
				document.body.removeChild(obj);
	   		}
	   }*/
	   
   }
   /*if(lchar.search(mikExp) != -1) 
   {
      var tst = val.value.substring(0, (strLength) - 1);
      val.value = tst;
   }*/
}

function creatediv(id, string,flggg,val, width, height, left, top) { 
	var newdiv="";
	
	var flag=flggg;
	
	
		if(document.getElementById("CommonValidaDyna") != null)
		{
		
			var obj=document.getElementById("CommonValidaDyna");
			document.body.removeChild(obj);
		}
	
	
	if(document.getElementById("CommonValidaDyna") == null)
	{
   		var newdiv = document.createElement('div');
   	}
  
   
   newdiv.id="CommonValidaDyna";
   
 
   
   if (width) {
       newdiv.style.width = 300;
   }
   
   if (height) {
       newdiv.style.height = 100;
   }
   
   if ((left || top) || (left && top)) {
       newdiv.style.position = "absolute";
       
       if (left) {
           newdiv.style.left = left;
       }
       
       if (top) {
           newdiv.style.top = top;
       }
   }
   
   newdiv.style.background = "#fffe98";
   
   newdiv.style.border = "4px solid #000";
      
   var html = "";
   html +="<table onmouseover='closefun()'>";
   html +="<tr>";
   html +="<td class='Tabdata'>";
   html +="<strong><font color='#046ea4'>"+string+"</font><strong>";
   html +="</td>";
   html +="</tr>";
   html +="</table>";
   
   //alert(flag)
    
   if (flag == 'true') 
   {
   		//newdiv.style.display="";
   		
   		   		
      				 newdiv.innerHTML = html;
       				 document.body.appendChild(newdiv);
        
        	 		var strPass = val.value;
  			 		var strLength = strPass.length; 
        
		           
				 	   for(var i=0; i<strLength; i++)
					   {
						   //alert("inside for ");
						   var lchar = val.value.charAt(i); 
						   if(lchar.search(mikExp) != -1) 
				           {
				         			           	
				              var tst = val.value.substring(0, i);
							  var last = val.value.substring(i+1,strLength);
				              val.value = tst+last;
							  i--;
							
						   }
						  
					   }
					
        	setTimeout('callRemoveCharData();',1000*1); 
        //newdiv.style.display="inline";
   }
    else {
    
    	
    	setTimeout('callRemoveCharData();',1000*1); 
    	
   }
  
  
} 

	
 
function callRemoveCharData()
{
		//alert(newdiv)
		//newdiv.innerHTML = "";
       // var obj=document.getElementById("CommonValidaDyna");
     
       if(document.getElementById("CommonValidaDyna") != null)
       {
       	var obj=document.getElementById("CommonValidaDyna");
			document.body.removeChild(obj);
		}	

}

function closefun()
{
	//alert(strid);
	
	var st=document.getElementById("CommonValidaDyna");
	st.style.display="inline";
		
	st.style.visibility="hidden";
	st.style.display="none";
	
	
}


//function for checking the starting zero, spaces and tab character (all leading zero will be remove)
function zeroChecking(val)
{
   var strPass = val.value;
   var strLength = strPass.length; 
   var flag = "y";
   var count = 0;
   if(strLength > 0)
   {
	   for(var i=0; i<strLength; i++)
	   {
		   var lchar = strPass.charAt(i); 
		   if((lchar == "0" || lchar==" " || lchar=="\t") && flag=="y")
		   {
			  count++;
		   }
		   if(lchar!="0" || lchar!=" ")
			   flag="n";
	   }
	   if(count > 0)
	   {
		  //var tst = val.value.substring(0, i);
		  var last = val.value.substring(count,strLength);
          val.value = last;
	   }
	   
   } 
}
//function for checking the starting spaces (all leading spaces will be remove)
function spaceChecking(val)
{
   var strPass = val.value;
   var strLength = strPass.length; 
   var flag = "y";
   var count = 0;
   if(strLength > 0)
   {
	   for(var i=0; i<strLength; i++)
	   {
		   var lchar = strPass.charAt(i); 
		   if(lchar==" " && flag=="y")
		   {
			  count++;
		   }
		   if(lchar!=" ")
			   flag="n";
	   }
	   if(count > 0)
	   {
		  //var tst = val.value.substring(0, i);
		  var last = val.value.substring(count,strLength);
          val.value = last;
	   }
	   
   } 
}



function check_alph_only(obj)
{
  var  str = obj.value;
  var     s_regexp	=	new RegExp("[*,&,%,$,#,@,!,~,?,<,>,>,:,;,=,',-,1,2,3,4,5,6,7,8,9,0]");
  var     desc		=	s_regexp.test(str);
  if(desc==true)	
  {
     alert(" valid");       
	 return true;
  }
  else
  {
	  alert("not valid");
	  obj.value="";
	  obj.focus();
	  return false;
  }
}

//****************************Number Validation upto two decimal************************
//function for restrict value after two decimal
function upToTwoDecimal(val)
{
   var m = val.value;
   var strLength = m.length;
   var loc = m.indexOf(".");
   if(loc == '-1')
   {
   }
   else
   {
  	  var a = m.substring(0,loc+1);
	  if((loc+1) < strLength)
	  {
	    var b = m.substring(loc+1,strLength);
		if(b.length > 2)
		{
		  b = b.substring(0,2);
		  val.value = a+b;
		}
	  }  
   }
   
   // restrict more than one dot(.)
    var intFlag = 0;
    for(var i=0; i<strLength; i++)
	{	  
		var lchar = val.value.charAt(i); 
		
        //alert(val.value);
		   
		  if(lchar == '.')
		   {
		      intFlag++;
		   }
			
		   if(intFlag > 1)
		   {
		      var tst = val.value.substring(0, i);
			  //var last = val.value.substring(i+1,strLength);
			 // alert("i=="+i);
			  //val.value = tst+last;
			  val.value = tst;
			  break;
			  //i--;
		   }

		   if(lchar == '\\')
		   {
		      var tst = val.value.substring(0, i);
			  val.value = tst;
			  break;
		   }
	   }
}


//*************Email Validation*********************
function echeck(str)                             // note here str is the value of email text field
{
		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
		 }

 		 return true					
	}




//***************Phone Validation********************

// Declaring required variables
var digits = "0123456789";
// non-digit characters which are allowed in phone numbers
var phoneNumberDelimiters = "()- ";
// characters which are allowed in international phone numbers
// (a leading + is OK)
var validWorldPhoneChars = phoneNumberDelimiters + "+";
// Minimum no of digits in an international phone no.
var minDigitsInIPhoneNumber = 10;

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;
}

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++)
    {   
        // Check that current character isn't whitespace.
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function checkInternationalPhone(strPhone){
s=stripCharsInBag(strPhone,validWorldPhoneChars);
return (isInteger(s) && s.length >= minDigitsInIPhoneNumber);
}

function ValidatePhoneNo(obj){
	var Phone=obj;
	
	if ((Phone.value==null)||(Phone.value=="")){
		alert("Please Enter your Phone Number")
		Phone.focus()
		return false
	}
	if (checkInternationalPhone(Phone.value)==false){
		alert("Please Enter a Valid Phone Number")
		Phone.value=""
		Phone.focus()
		return false
	}
	return true
 }

//************************Money Validation**********************************

function moneyFormat(textObj) {
   var newValue = textObj.value;
   var decAmount = "";
   var dolAmount = "";
   var decFlag = false;
   var aChar = "";
   // ignore all but digits and decimal points.
   for(i=0; i < newValue.length; i++) {
      aChar = newValue.substring(i,i+1);
      if(aChar >= "0" && aChar <= "9") {
         if(decFlag) {
            decAmount = "" + decAmount + aChar;
         }
         else {
            dolAmount = "" + dolAmount + aChar;
         }
      }
      if(aChar == ".") {
         if(decFlag) {
            dolAmount = "";
            break;
         }
         decFlag=true;
      }
   }
   // Ensure that at least a zero appears for the dollar amount.

   if(dolAmount == "") {
      dolAmount = "0";
   }
   // Strip leading zeros.
   if(dolAmount.length > 1) {
      while(dolAmount.length > 1 && dolAmount.substring(0,1) == "0") {
         dolAmount = dolAmount.substring(1,dolAmount.length);
      }
   }
   // Round the decimal amount.
   if(decAmount.length > 2) {
      if(decAmount.substring(2,3) > "4") {
         decAmount = parseInt(decAmount.substring(0,2)) + 1;
         if(decAmount < 10) {
            decAmount = "0" + decAmount;
         }
         else {
            decAmount = "" + decAmount;
         }
      }
      else {
         decAmount = decAmount.substring(0,2);
      }
      if (decAmount == 100) {
         decAmount = "00";
         dolAmount = parseInt(dolAmount) + 1;
      }
   }
   // Pad right side of decAmount
   if(decAmount.length == 1) {
      decAmount = decAmount + "0";
   }
   if(decAmount.length == 0) {
      decAmount = decAmount + "00";
   }
   // Check for negative values and reset textObj
   if(newValue.substring(0,1) != '-' ||
         (dolAmount == "0" && decAmount == "00")) {
      textObj.value = dolAmount + "." + decAmount;

   }
   else{
      textObj.value = '-' + dolAmount + "." + decAmount;
   }
}

// Function for check the date codition is second date should be grater or equal to the first date
function checkDate(form1,firstDate,secondDate,firstDateObject,secondDateObject,message1,message2)
{
	//Second date should be equal or greater from the first date
	//get today date info
	var todayDate=firstDate;                //today date
	//alert("firstDate is=="+todayDate);
	var dDate=secondDate;
	//alert("dob is"+DOB);

	var d=todayDate.substr(6,4);
	var year=parseInt(d,10);

	var a =todayDate.substr(3,2);
	var month=parseInt(a,10);

	var c =todayDate.substr(0,2);
	var day=parseInt(c,10);

    //get departure date information
	var f=dDate.substr(6,4);
	var year1=parseInt(f,10);

	var b=dDate.substr(3,2);
	var month1=parseInt(b,10);

	var h=dDate.substr(0,2);
	var day1=parseInt(h,10);
	
	if(year>year1)
	{
		 alert(message1);
		 secondDateObject.value="";
		 secondDateObject.focus();
		 return false;
	}//end of if
	
	if((year==year1)&&(month>month1))
	{
		 alert(message1);
		 secondDateObject.value="";
		 secondDateObject.focus();
		 return false;
	}//end of elseif
	
	if((year==year1)&&(month==month1)&&(day>day1))
	{		
		 alert(message1);
		 secondDateObject.value="";
		 secondDateObject.focus();
		 return false;
	}//end of elseif
}
//**** diabled right click button to be safe from popup untill press button	by SANJEET KUMAR
function rightClick()
{
			var oLastBtn=0;
			bIsMenu = false;
			//No RIGHT CLICK************************
			// ****************************
			if (window.Event) 
			document.captureEvents(Event.MOUSEUP); 
			function nocontextmenu()
			{ 
			event.cancelBubble = true 
			event.returnValue = false; 
			return false; 
			} 
			function norightclick(e) 
			{ 
			if (window.Event) 
			{ 
			if (e.which !=1) 
			return false; 
			} 
			else 
			if (event.button !=1) 
			{ 
			event.cancelBubble = true 
			event.returnValue = false; 
			return false; 
			} 
			} 
			document.oncontextmenu = nocontextmenu; 
			document.onmousedown = norightclick; 
			//**************************************
			// ****************************
			// Block backspace onKeyDown************
			// ***************************
		
		
		    	 function onKeyDown() {
		    	 	if ( (event.altKey) || ((event.keyCode == 8) && 
		    	 			(event.srcElement.type != "text" &&
		    	 			event.srcElement.type != "textarea" &&
		    	 			event.srcElement.type != "password")) || 
		    	 			((event.ctrlKey) && ((event.keyCode == 78) || (event.keyCode == 82)) ) ||
		    	
		    	
		
		
		        	 			(event.keyCode == 116) ) {
		        	 		event.keyCode = 0;
		        	 		event.returnValue = false;
		        	 	}
		        	 }
}


// Function for check the date codition is second date should be grater than the first date
function checkDateGrater(form1,firstDate,secondDate,firstDateObject,secondDateObject,message1,message2)
{
	//Second date should be equal or greater from the first date
	//get today date info
	var todayDate=firstDate;                //today date
	//alert("firstDate is=="+todayDate);
	var dDate=secondDate;
	//alert("dob is"+DOB);

	var d=todayDate.substr(6,4);
	var year=parseInt(d,10);

	var a =todayDate.substr(3,2);
	var month=parseInt(a,10);

	var c =todayDate.substr(0,2);
	var day=parseInt(c,10);

    //get departure date information
	var f=dDate.substr(6,4);
	var year1=parseInt(f,10);

	var b=dDate.substr(3,2);
	var month1=parseInt(b,10);

	var h=dDate.substr(0,2);
	var day1=parseInt(h,10);
	
	if(year>year1)
	{
		 alert(message1);
		 secondDateObject.value="";
		 secondDateObject.focus();
		 return false;
	}//end of if
	
	if((year==year1)&&(month>month1))
	{
		 alert(message1);
		 secondDateObject.value="";
		 secondDateObject.focus();
		 return false;
	}//end of elseif
	
	if((year==year1)&&(month==month1)&&(day>=day1))
	{		
		 alert(message1);
		 secondDateObject.value="";
		 secondDateObject.focus();
		 return false;
	}//end of elseif
}
function isWhitespace(charToCheck) {
	var whitespaceChars = " \t\n\r\f";
	return (whitespaceChars.indexOf(charToCheck) != -1);
}
function ltrim(str) { 
	for(var k = 0; k < str.length && isWhitespace(str.charAt(k)); k++);
	return str.substring(k, str.length);
}
function rtrim(str) {
	for(var j=str.length-1; j>=0 && isWhitespace(str.charAt(j)) ; j--) ;
	return str.substring(0,j+1);
}
function trim(str) {
	return ltrim(rtrim(str));
}

/*
function trim(str)
{
    if (str != null) 
    {
       var i;
       for (i=0; i<str.length; i++) 
       {            
	       if (str.charAt(i)!=" ") 
	       {                
	       	str=str.substring(i,str.length);                 
	      	break;           
	       }         
       }             
       for (i=str.length-1; i>=0; i--) 
       {            
       if (str.charAt(i)!=" ") 
       {                
       str=str.substring(0,i+1);                 
       break;            
       }         
       }                 
       if (str.charAt(0)==" ") 
       {            
       return "";         
       }
       else
       {           
         return str;        
       }   
   }
}*/
// function added by ankoor on 07-11-2008 for alpha numeric character in password 
//**************Validation for upper case character************************
	  function checkUchar(sText)
	  {
	  	 var strValidUchar	="ABCDEFGHIJKLMNOPQRSTUVWXYZ";		 
		 var strFlag		=true;
		 var strChar ;
		 for(i=0;i<sText.length && strFlag == true;i++)
		 {
		 	strChar = sText.charAt(i);
		 	if(strValidUchar.indexOf(strChar) != -1)
		 	{
		 		strFlag = false;
		 	}
		 }
		 return strFlag;		 
	  }
//**************Validation for lower case character************************
	  function checkLchar(sText)
	  {
	  	 var strValidLchar	="abcdefghijklmnopqrstuvwxyz";
		 var strFlag		=true;
		 var strChar ;
		 
		 for(i=0;i<sText.length && strFlag == true;i++)
		 {
		 	strChar = sText.charAt(i);
		 	if(strValidLchar.indexOf(strChar) != -1)
		 	{
		 		strFlag = false;
		 	}
		 }
		 return strFlag;		 
	  }
//**************Validation for number************************
	  function checkNum(sText)
	  {
	  	 var strValidNum	="0123456789";
		 var strFlag		=true;
		 var strChar ;
		 
		 for(i=0;i<sText.length && strFlag == true;i++)
		 {
		 	strChar = sText.charAt(i);
		 	if(strValidNum.indexOf(strChar) != -1)
		 	{
		 		strFlag = false;
		 	}
		 }
		 return strFlag;		 
	  }
////**************Validation for special character************************
	 function checkSpec(sText)
	  {
	  	 var strValidSpec	="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789~!@#$^()_[]{}\|;:/<>.+=,%`";
		 var strFlag		=true;
		 var strChar ;
		 
		 for(i=0;i<sText.length ;i++)
		 {
		 	strChar = sText.charAt(i);		 	
		 	if(strValidSpec.indexOf(strChar) != -1)
		 	{
		 		strFlag = false;
		 	}
		 	else
		 	{
		 		strFlag = true;
		 		break;
		 	}		 	
		 }
		 return strFlag;		 
	  }	  
	  function checkSpec1(sText)
	  {
	  	 var strValidSpec	="~!@#$^()_[]{}\|;:/<>.+=,%`";
		 var strFlag		=true;
		 var strChar ;
		 
		 for(i=0;i<sText.length && strFlag == true;i++)
		 {
		 	strChar = sText.charAt(i);
		 	if(strValidSpec.indexOf(strChar) != -1)
		 	{
		 		strFlag = false;
		 	}
		 }
		 return strFlag;		 
	  }
// end ankoor 07-11-2008

//code for disable the backspace button(but allow text correction) and F11 Key
if (typeof window.event != 'undefined')
     document.onkeydown = function()
                          {
							 /*if(event.keyCode == 122)
							 {
								event.cancelBubble = true;
								event.keyCode = 0;
								return false;
							 }*/
							 if(event.srcElement.tagName != null){							 
	                             if (event.srcElement.tagName.toUpperCase() != 'INPUT' && event.srcElement.tagName.toUpperCase() !='TEXTAREA')
	                                return (event.keyCode != 8);
	                         }   
                           }
   else
     document.onkeypress = function(e)
                           {
                             if (e.target.nodeName.toUpperCase() != 'INPUT' && e.target.nodeName.toUpperCase() != 'TEXTAREA')
                               return (e.keyCode != 8);
                           }


// Time Validation By Jyoti Bikash Panda

function checkTime(varTime1,varTime2,varMerid1,varMerid2,varflag)
{



var HH1 = "";
var MM1 = "";
var Merid1 = "";
var HH2 = "";
var MM2 = "";
var Merid2 = "";



var resultflag= new Boolean(true);

if(varTime1 != "")
{

HH1 = varTime1.substring(0,varTime1.indexOf(":"));

MM1 = varTime1.substring(varTime1.indexOf(":")+1,varTime1.length);
Merid1=varMerid1;


}
if(varTime2 != "")
{
HH2 = varTime2.substring(0,varTime2.indexOf(":"));
MM2 = varTime2.substring(varTime2.indexOf(":")+1,varTime2.length);
Merid2=varMerid2;
}

// On Same Day Event(12:00 AM to 11:59 AM)
if(varflag == "single")
{
	if(HH1 == 12 && HH2 == 12) // 12,12
	{
			
			if(Merid1 == "PM" && Merid2 == "AM")
			{
				resultflag = false;
			}
			if(Merid1 == Merid2)
			{
				if(MM1 > MM2)
				{
					resultflag = false;
				}
				
			}
					
	}
	else if(HH1 == 12 && HH2 != 12) //12 , 11
	{
		if(HH1 > HH2) // 12,10
		{
			
			if(Merid1 == "PM" && Merid2 == "AM")
			{
				
				resultflag = false;
			}
			
		}
		
		
		
	}
	else if(HH1 != 12 && HH2 != 12) //11,10 2:59,2:30
	{
		
		if(HH1 == HH2) // 11, 11
		{
			if(MM1 > MM2)
			{
			
				if(Merid1 == "PM" && Merid2 == "PM")
				{
					resultflag = false;	
					
				}
				else if(Merid1 == "AM" && Merid2 == "AM")
				{
					
					resultflag = false;	 
					
				}
				
			}
			else
			{
				if(Merid1 == "PM" && Merid2 == "AM")
				{
					resultflag = false;	
				}
			}	
		}	
		else if(HH1 > HH2) //11,10
		{
			if(Merid1 == "PM" && Merid2 == "AM")
			{
				resultflag = false;	
			}
			else if(Merid1 == "AM" && Merid2 == "AM")
			{
				resultflag = false;	
			}
			else if(Merid1 == "PM" && Merid2 == "PM")
			{
				resultflag = false;	
			}
		}
		else if(HH1 < HH2) // 10,11
		{
			if(Merid1 == "PM" && Merid2 == "AM")
			{
				resultflag = false;	
			}
			
			
		}
	}
	else if(HH1 != 12 && HH2 == 12) //11,12
	{
			
		
		if(HH1 < HH2) // 10,12
		{
			if(Merid1 == "PM" && Merid2 == "AM")
			{
				resultflag = false;	
			}
			else if(Merid1 == "AM" && Merid2 == "AM")
			{
				resultflag = false;	
			}
			else if(Merid1 == "PM" && Merid2 == "PM")
			{
				resultflag = false;	
			}
			
		}
	}
}
else if(varflag == "multi")
{
	if(HH1 == 12 && HH2 == 12) // 12,12
	{
			
			if(Merid1 == "PM" && Merid2 == "AM")
			{
				resultflag = false;
			}
			if(Merid1 == Merid2)
			{
				if(MM1 > MM2)
				{
					resultflag = false;
				}
				
			}
					
	}
	else if(HH1 == 12 && HH2 != 12) //12 , 11
	{
		if(HH1 > HH2) // 12,10
		{
			
			if(Merid1 == "PM" && Merid2 == "AM")
			{
				
				resultflag = false;
			}
			
		}
		
		
		
	}
	else if(HH1 != 12 && HH2 != 12) //11,10 2:59,2:30
	{
		
		if(HH1 == HH2) // 11, 11
		{
			if(MM1 > MM2)
			{
				if(Merid1 == "PM" && Merid2 == "PM")
				{
					resultflag = false;	
					
				}
				else if(Merid1 == "AM" && Merid2 == "AM")
				{
					
					resultflag = false;	 
					
				}
				
			}
			else
			{
				if(Merid1 == "PM" && Merid2 == "AM")
				{
					resultflag = false;	
				}
			}	
		}	
		else if(HH1 > HH2) //11,10
		{
			if(Merid1 == "PM" && Merid2 == "AM")
			{
				resultflag = false;	
			}
			else if(Merid1 == "AM" && Merid2 == "AM")
			{
				resultflag = false;	
			}
			else if(Merid1 == "PM" && Merid2 == "PM")
			{
				resultflag = false;	
			}
		}
		else if(HH1 < HH2) // 10,11
		{
			if(Merid1 == "PM" && Merid2 == "AM")
			{
				resultflag = false;	
			}
			
			
		}
	}
	else if(HH1 != 12 && HH2 == 12) //11,12
	{
			
		
		if(HH1 < HH2) // 10,12
		{
			if(Merid1 == "PM" && Merid2 == "AM")
			{
				resultflag = false;	
			}
			else if(Merid1 == "AM" && Merid2 == "AM")
			{
				resultflag = false;	
			}
			else if(Merid1 == "PM" && Merid2 == "PM")
			{
				resultflag = false;	
			}
			
		}
	}
	
}

return resultflag;
}

//End
function test1(obj1,length,str)
{				
	charactercheck(obj1,str);
}
		
