
// validate.js 
// a generic form validator 
// Phoenix IT Solutions

function formFocus()
{ // convenient way to start the form onLoad
  if(!document.forms.length) return;
  var els= document.forms[0].elements;
  for(var i= 0; i < els.length; i++)
    if(els[i].type != 'hidden') { els[i].focus(); return; }
}

function requireValue(fld)
{
  if(!fld.value.length)
  {
    status= 'The ' + fld.name + ' field cannot be left blank.';
    return false;
  }
  return true;
}

function fixInt(fld)
{ // integer check/complainer 
  if(!fld.value) return true; // blank fields are the domain of requireValue 

  val= parseInt(fld.value);

  if(((fld.value - val) != 0) || isNaN(val) || val <= 0)
  { // parse error 
    status= 'The ' + fld.name + ' field must contain a non zero positive number.';
    return false;
  }
  fld.value= val;
  return true;
}

function fixFloat(fld)
{ // decimal number check/complainer 
  if(!fld.value) return true; // blank fields are the domain of requireValue 
  var val= parseFloat(fld.value);
  if(((fld.value - val) != 0) || isNaN(val))
  { // parse error 
    status= 'The ' + fld.name + ' field must contain a number.';
    return false;
  }
  fld.value= val;
  return true;
}

function fixMoney(fld)
{ // monetary field check
  if(!fld.value) return true; // blank fields are the domain of requireValue 
  var val= fld.value;
  if(val.indexOf('$') == 0)
    val= parseFloat(fld.value.substring(1,40));
  else
    val= parseFloat(fld.value);
  if(isNaN(val))
  { // parse error 
    status= 'The ' + fld.name + ' field must contain a dollar amount.';
    return false;
  }
  val= Number(Math.round(val*100)).toString();
  var len= val.length;
  val= val.substring(0,len-2) + '.' + val.substring(len-2,len+1);
  fld.value= val;
  return true;
}

function fixFixed(fld,dec)
{ // fixed decimal fields 
  if(!fld.value) return true; // blank fields are the domain of requireValue 
  var val= parseFloat(fld.value);
  if(isNaN(val))
  { // parse error 
    status= 'The ' + fld.name + ' field must contain a number.';
    return false;
  }
  val= Number(Math.round(val*Math.pow(10,dec))).toString();
  var len= val.length;
  val= val.substring(0,len-dec) + '.' + val.substring(len-dec,len+1);
  fld.value= val;
  return true;
}

function fixDate(fld)
{ // tenacious date correction 
  if(!fld.value) return true; // blank fields are the domain of requireValue 
  var val= fld.value;
  var dt= new Date(val.replace(/\D/g,'/'));
  if(!dt.valueOf())
  { // the date was unparseable 
    status= 'The ' + fld.name + ' field has the wrong date.';
    return false;
  }
  fld.value= (dt.getMonth()+1)+'/'+dt.getDate()+'/'+dt.getFullYear();
  return true;
}

function fixRecentDate(fld,minyear)
{ // tenacious date correction 
  if(!fld.value) return true; // blank fields are the domain of requireValue 
  var val= fld.value;
  var dt= new Date(val.replace(/\D/g,'/'));
  if(!dt.valueOf())
  { // the date was unparseable 
    status= 'The ' + fld.name + ' field has the wrong date.';
    return false;
  }
  while(dt.getFullYear() < minyear) { dt.setFullYear(dt.getFullYear()+100); }
  fld.value= (dt.getMonth()+1)+'/'+dt.getDate()+'/'+dt.getFullYear();
  return true;
}

function fixTime(fld,starthour) 
{ // tenacious time correction 
  if(!fld.value) return true; // blank fields are the domain of requireValue 
  var hour= 0; 
  var mins= 0;
  var ampm= 'am';
  val= fld.value;
  var dt= new Date('1/1/2000 ' + val);
  if(('9'+val) == parseInt('9'+val))
  { hour= val; }
  else if(dt.valueOf())
  { hour= dt.getHours(); mins= dt.getMinutes(); }
  else
  {
    val= val.replace(/\D/g,':');
    hour= parseInt(val);
    mins= parseInt(val.substring(val.indexOf(':')+1,20));
    if(val.indexOf('pm') > -1) ampm= 'pm';
    if(isNaN(hour)) hour= 0;
    if(isNaN(mins)) mins= 0;
  }
  if(hour < starthour) { ampm= 'pm'; }
  while(hour > 12) { hour-= 12; ampm= 'pm'; }
  while(mins > 60) { mins-= 60; hour++; }
  if(mins < 10) mins= '0' + mins;
  if(!hour)
  { // the date was unparseable 
    status= 'The ' + fld.name + ' field has the wrong time.';
    return false;
  }
  fld.value= hour + ':' + mins + ampm;
  return true;
}

function fixPhone(fld,defaultAreaCode)
{ // tenacious phone # correction 
  if(!fld.value) return true; // blank fields are the domain of requireValue 
  var val= fld.value.replace(/\D/g,'');
  if(val.length == 7)
  {
    fld.value= ( defaultAreaCode ? '(' + defaultAreaCode + ')' : '' ) +
      val.substring(0,3) + '-' + val.substring(3,20);
    return true;
  }
  if(val.length == 10)
  {
    fld.value= '(' + val.substring(0,3) + ')' + val.substring(3,6) + '-' + val.substring(6,20);
    return true;
  }
  if(val.length < 7)
  {
    status= 'The phone number you supplied for the ' + fld.name + ' field was too short.';
    return false;
  }
  if(val.length > 10)
  {
    status= 'The phone number you supplied for the ' + fld.name + ' field was too long.';
    return false;
  }
  status= 'The phone number you supplied for the ' + fld.name + ' field was wrong.';
  return false;
}

function fixSSN(fld)
{ // tenacious SSN correction; fieldname isn't a big consideration, probably only one SSN per form 
  if(!fld.value) return true; // blank fields are the domain of requireValue 
  var val= fld.value;
  if(val.length = 0)
  { status= 'No Social Security Number was entered.'; return false; }
  val= val.replace(/\D/g,'');
  if( val.length < 9 )
  {
    status= 'The Social Security Number you provided is not long enough.';
    return false;
  }
  if( val.length > 9 )
  {
    status= 'The Social Security Number you provided is too long.';
    return false;
  }
  fld.value= val.substring(0,3) + '-' + val.substring(3,5) + '-' + val.substring(5,12);
  return true;
}

function nameContains(name,str)
{ // Check for nontrivial inclusion 
  // OK, *some* trivial cases must be handled...
  if(name == str || name.toLowerCase() == str.toLowerCase()) return true;
  var nlen= name.length;
  var slen= str.length;
  var endat= nlen - slen;
  // too small to fit?
  if(nlen > str) return false;
  if(name.toLowerCase() == name || name.toUpperCase() == name)
  { // all lower/upper case name? underscores separate
    if(name.indexOf('_') == -1) return false;
    str= str.toLowerCase();
    if( name.indexOf(str + '_') == 0 ||
      name.indexOf('_' + str + '_') > -1 ||
      name.substring(endat-1,nlen+1) == ('_' + str) )
      return true;
  }
  else
  { // proper case name? uppercase starts new words 
    var sep= name.substring(slen,slen+1);
    if( name.indexOf(str) == 0 && sep == sep.toUpperCase() ) return true;
    if( name.indexOf(str.toLowerCase()) == 0 && sep == sep.toUpperCase() ) return true;
    var sep= name.substring(endat-1,endat);
    if( name.substring(endat,nlen+1) == str ) return true;
    for(var index= name.indexOf(str); index > -1; index= name.indexOf(str,index+1))
    { // for each occurence of the word, is it followed by a non-lowercase char? 
      endat= index+slen;
      sep= name.substring(endat,endat+1);
      if(sep == sep.toUpperCase()) return true;
    }
  }
  return false;
}


function isMemberOf(elem,classname)
{ // checks to see if elem is a member of the (style) class 
  // trivial cases first: no membership or simple equality
  if(!elem.className)
    return false
  else if(elem.className == classname)
    return true;
  else if(elem.className.indexOf(' ') > -1)
  { // multiple class names; use split, if avail 
    if(parseInt(navigator.appVersion) >= 4)
    {
      var names= elem.className.split(' ');
      for(var index= 0; index < names.length; index++)
        if(names[index] == classname)
          return true;
    }
    // older browsers can fake it 
    // WARNING: "fine" can be found in "oldRefined"
    else if(elem.className.indexOf(classname) > -1)
      return true;
  }
  return false;
}

function checkClass(el)
{
  if(el.type == 'text')
  { // text fields 
    if(isMemberOf(el,'required') && !requireValue(el)) return false;
    if(isMemberOf(el,'date') && !fixDate(el)) return false;
    if(isMemberOf(el,'time') && !fixTime(el)) return false;
    if(isMemberOf(el,'ssn') && !fixSSN(el)) return false;
    if(isMemberOf(el,'phone') && !fixPhone(el)) return false;
    if(isMemberOf(el,'money') && !fixMoney(el)) return false;
    if(isMemberOf(el,'int') && !fixInt(el)) return false;
    if(isMemberOf(el,'float') && !fixFloat(el)) return false;
  } // handle required select and select-multiple 
  else if(el.type.substring(0,3) == 'sel' && 
    isMemberOf(el,'required') && el.selectedIndex == -1) return false;
  return true;
}

function autocheckByClass(frm) 
{ // uses the CSS class of form elements to determine type 
  for(var index= 0; index < frm.elements.length; index++)
    if(!checkClass(frm.elements[index])) 
    { alert(status); frm.elements[index].focus(); return false; }
  for(var index= 0; index < frm.elements.length; index++)
    if(frm.elements[index].type == 'submit') frm.elements[index].disabled= true;
  return true;
}

function autocheckByBlur(frm)
{ // uses the onBlur handler of form elements to check value 
  status= '';
  for(var index= 0; index < frm.elements.length; index++)
  {
    var el= frm.elements[index];
    if(el.type != 'hidden' && el.name && el.onblur)
    {
      el.onblur();
      if(status) 
      {
        alert(status);
        el.focus(); 
        return false;
      }
    }
  }
  for(var index= 0; index < frm.elements.length; index++)
    if(frm.elements[index].type == 'submit') frm.elements[index].disabled= true;
  return true;
}

function autocheck(frm)
{ // uses the best available method to check form values 
  var bchar= navigator.appName.substring(0,1);
  if(isMemberOf(frm,'autocheck'))
  { return autocheckByClass(frm); }
  else if(parseInt(navigator.appVersion) >= 4 && 
    ( navigator.userAgent.indexOf('MSIE') > -1 || 
      navigator.userAgent.indexOf('Gecko') > -1 || 
      navigator.userAgent.indexOf('(compat') == -1 ))
  { return autocheckByBlur(frm); }
  else
  { return autocheckByName(frm); }
}
function check_Junk(txtName,junkType)
	{

		l_value=txtName.value;

		if (junkType=='Name')
				{						
					var junkchar = new Array(100);
					    junkchar[0]="~";   junkchar[1]="`";  junkchar[2]="!";  junkchar[3]="@";  junkchar[4]="#";
						junkchar[5]="$";   junkchar[6]="%";  junkchar[7]="^";  junkchar[8]="*";  junkchar[9]="_";
						junkchar[10]="+";  junkchar[11]="|"; junkchar[12]="="; junkchar[13]="\\"; junkchar[14]=":";
						junkchar[15]="\"";  junkchar[16]=";"; junkchar[17]="'"; junkchar[18]="<"; junkchar[19]=">";
						junkchar[20]="?";	junkchar[21]="1"; junkchar[22]="2"; junkchar[23]="3"; junkchar[24]="4";
						junkchar[25]="5";  junkchar[26]="6"; junkchar[27]="7"; junkchar[28]="8"; junkchar[29]="9";
						junkchar[30]="0";	
					
				}
			
		if (junkType=='NameSearch')
				{					
					var junkchar = new Array(100);
					    junkchar[0]="~";   junkchar[1]="`";  junkchar[2]="!";  junkchar[3]="@";  junkchar[4]="#";
						junkchar[5]="$";   junkchar[6]="%";  junkchar[7]="^";  junkchar[8]="";  junkchar[9]="_";
						junkchar[10]="+";  junkchar[11]="|"; junkchar[12]="="; junkchar[13]="\\"; junkchar[14]=":";
						junkchar[15]="\"";  junkchar[16]=";"; junkchar[17]="'"; junkchar[18]="<"; junkchar[19]=">";
						junkchar[20]="?";
					
				}
							
		if (junkType=='Code')
				{						
					var junkchar = new Array(100);
					    junkchar[0]="~";   junkchar[1]="`";  junkchar[2]="!";  junkchar[3]="@";  junkchar[4]="#";
						junkchar[5]="$";   junkchar[6]="%";  junkchar[7]="^";  junkchar[8]="*";  junkchar[9]="_";
						junkchar[10]="+";  junkchar[11]="|"; junkchar[12]="="; junkchar[13]="\\"; junkchar[14]=":";
						junkchar[15]="\"";  junkchar[16]=";"; junkchar[17]="'"; junkchar[18]="<"; junkchar[19]=">";
						junkchar[20]="(";  junkchar[21]=")"; junkchar[22]="-"; junkchar[23]="{"; junkchar[24]="}";
						junkchar[25]="[";  junkchar[26]="]"; junkchar[27]=","; junkchar[28]="/";
						junkchar[29]="&";junkchar[30]="?";
				}
			
		if (junkType=='CodeSearch')
				{						
					var junkchar = new Array(100);
					    junkchar[0]="~";   junkchar[1]="`";  junkchar[2]="!";  junkchar[3]="@";  junkchar[4]="#";
						junkchar[5]="$";   junkchar[6]="%";  junkchar[7]="^";  junkchar[8]="_";
						junkchar[9]="+";  junkchar[10]="|"; junkchar[11]="="; junkchar[12]="\\"; junkchar[13]=":";
						junkchar[14]="\"";  junkchar[15]=";"; junkchar[16]="'"; junkchar[17]="<"; junkchar[18]=">";
						junkchar[19]="(";  junkchar[20]=")"; junkchar[21]="-"; junkchar[22]="{"; junkchar[23]="}";
						junkchar[24]="[";  junkchar[25]="]"; junkchar[26]=","; junkchar[27]="/";
						junkchar[28]="&";junkchar[29]="?";
				}
			
		if (junkType=='Email')
				{					alert("emal"+txtName);
					var junkchar = new Array(100);
					    junkchar[0]="~";   junkchar[1]="`";  junkchar[2]="!";  junkchar[3]="";  junkchar[4]="#";
						junkchar[5]="$";   junkchar[6]="%";  junkchar[7]="^";  junkchar[8]="*";  junkchar[9]="?";
						junkchar[10]="+";  junkchar[11]="|"; junkchar[12]="="; junkchar[13]="\\"; junkchar[14]=":";
						junkchar[15]="\"";  junkchar[16]=";"; junkchar[17]="'"; junkchar[18]="<"; junkchar[19]=">";
						junkchar[20]="(";  junkchar[21]=")"; junkchar[22]="-"; junkchar[23]="{"; junkchar[24]="}";
						junkchar[25]="[";  junkchar[26]="]"; junkchar[27]=""; junkchar[28]="/";junkchar[29]=" ";
						junkchar[30]="&";				
				}
										
		if (junkType=='Other')
				{						
					var junkchar = new Array(100);
					    junkchar[0]="~";   junkchar[1]="`";  junkchar[2]="#";  junkchar[3]="^";  junkchar[4]="|"; 
					    junkchar[5]="\"";					
				}			
		
		strtext= l_value;
		var sJunkList = "";
			
		for(i=0 ; i<junkchar.length; i++)
			{
				if(strtext.indexOf(junkchar[i])>-1)
					{
						
						if (sJunkList.length == "0")
							{
								sJunkList = junkchar[i];
							}
						else
							{
								sJunkList = sJunkList + ", "  + junkchar[i];
							}						
					}
			}  
			
			if (sJunkList != "")
				{
					//alert("Do not enter Special Character(s) like  "+sJunkList+".");
					status= 'Do not enter Special Character(s) like '+sJunkList+' in ' + txtName.name + ' field.';
					return false;
				}			
	}		

function isValidDate(txtName) 
	{
			mdateVal=txtName.value;
			if(mdateVal!="")
				{
					var datePattern = /^(\d{1,2})(\/|-)(\d{1,2})\2(\d{4})$/;
					var matches = mdateVal.match(datePattern);
        	        if (matches == null)
						{
						// for 2 digit years
						datePattern = /^(\d{1,2})(\/|-)(\d{1,2})\2(\d{4})$/;
						matches = mdateVal.match(datePattern);
		        
						if (matches == null)
							{
								alert("Date is not in a valid format.Year should have four digits.")
								return false;
							}
						}
					day = matches[1];
					month = matches[3];
					year = matches[4];
					if (year ==0 )
						{	
							alert("Year must not be Zero.");
            				return false;
            			}
            		if (year <=1899)
						{
							alert("Date must be Greater than or Equal to 01/01/1900.");
            				return false;
						}	
//					if(month.length != 2)
//						{
//							alert("Month must be of two digits.")
//							return false;
//						}
					if (month < 1 || month > 12)
						{
							alert("Month must be between 1 and 12.");
            				return false;
						}
 					if (day < 1 )
						{
							alert("Day can not have value less than 1");
            				return false;
						}
					if (month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12)
						{
							if (( day > 31) || ( day < 1))
								{
									alert("Day must be between 1 and 31");
									return false;
								}  
						}
					if ( month == 4 || month == 6 || month == 9 || month == 11)
						{
							if (( day > 30)|| ( day < 1))
								{
									alert("Day must be between 1 and 30");
									return false;
								}  
						}
					if (month==2)
						{
							if (((year%400)==0)||(((year%4)==0)&&((year%100)!=0)))
								{
									if((day > 29)|| ( day < 1))
										{
											alert("Day must be between 1 and 29");
								            return false;
             
										}
								}
							else
								{
									if((day > 28) || ( day < 1))
										{
											alert("Day must be between 1 and 28");
											return false;
										}
          
								}	
						}
				} 
		return true;
	}

function checkEmail(txtName)
	{

		l_value=txtName.value;
        newstr= new String(l_value);
        if (newstr!="")
			{
			if((newstr.indexOf("@")<1)||(newstr.indexOf(".")<3)||(newstr.length<7)) //||(newstr.indexOf(".")<newstr.indexOf("@"))
				{
					status= 'Please enter correct email in ' + txtName.name + ' field.';
					return false;
				}
			return true
			}		
	}

/** start isEmpty  function**/
function isEmpty(str)
	{
	var trimmed = trim(str);
	return((trimmed==null) || (trimmed.length==0))
	}

/** start trim function**/
function trim(Str)
	{
	if((Str != "") && (Str.indexOf(" ",0)!=-1))
		{
		var iMax = Str.length;
		var end = Str.length;
		var c;
		for(i=0;1<iMax;i++)
			{
			c = Str.substring(0,1);
			if (c == " ")
				{
				Str=Str.substring(1,end);
				end = Str.length;
				}
			else
				break;
			}
		iMax = Str.length;
		end = Str.length;
		for(i=iMax;i>0;i--)
			{
			c = Str.substring(end-1,end)
			if (c == " ")
				{				
				Str=Str.substring(0,end-1);
				end = Str.length;
				}
			else
				break;
			}
		}
	return Str;
	}


function autocheckByName(frm) 
{ // uses names of form elements to determine type 
 
  for(var index= 0; index < frm.elements.length; index++)
  {
    var el= frm.elements[index];
    if((el.type == 'text' || el.type == 'password')&&!(el.disabled))
    { // text fields 
//	  alert("id[0]"+el.id.charAt(0));
		if ((el.id.charAt(0)=="M") && isEmpty(el.value))
	      { alert('The ' + el.name + ' field cannot be left blank.'); el.focus(); return false; }
		if ((el.id.charAt(1)=="D") && isValidDate(el)==false)
	      { el.focus(); return false; }
		else if ((el.id.charAt(1)=="N") && check_Junk(el,'Name')==false)
	      { alert(status); el.focus(); return false; }
		else if ((el.id.charAt(1)=="C") && check_Junk(el,'Code')==false)
	      { alert(status); el.focus(); return false; }
		else if ((el.id.charAt(1)=="E") && checkEmail(el) == false)
	      { alert(status); el.focus(); return false; }
		if ((el.id.charAt(2)=="N") && !fixInt(el))
		  { alert(status); el.focus(); return false; }
		if ((el.id.charAt(2)=="R") && !fixFloat(el))
		  { alert(status); el.focus(); return false; }
			
//      if(nameContains(el.name,'number') 
//      { alert(status); el.focus(); return false; }
//      if(nameContains(el.name,'SSN') && !fixSSN(el))
//      { alert(status); el.focus(); return false; }
//      if( ( nameContains(el.name,'Phone') ||
//        nameContains(el.name,'Fax') || 
//        nameContains(el.name,'Pager') ) &&
//        !fixPhone(el))
//      { alert(status); el.focus(); return false; }

    }
   //  handle required select and select-multiple 
     else if(el.type.substring(0,3) == 'sel'&& el.selectedIndex ==-1 && el.id.charAt(0)=="M")
    { alert(el.name+" Field Cannot be Empty");el.focus(); return false; }
    
    else if(el.type.substring(0,3) == 'sel'&& el.id.charAt(1)=="S"&& isEmpty(el.options[el.selectedIndex].text))
    { alert(el.name+" Field Cannot be Empty");el.focus(); return false; }
   
  }
  //for(var index= 0; index < frm.elements.length; index++)
   // if(frm.elements[index].type == 'submit') frm.elements[index].disabled= true;
  return true;
}


function goalert(frm,name){
	
alert("Enter Date using Date Picker !!");
for(var index= 0; index < frm.elements.length; index++)
  {
    var el= frm.elements[index];
  
 if(el.name==name){

  el.value=""
  var MonthName = new Array('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec')
var d = new Date();
var t_date = d.getDate();       // Returns the day of the month
var t_mon = d.getMonth();       // Returns the month as a digit
var t_year = d.getFullYear();   // Returns 4 digit year

el.value=t_date+'-'+MonthName[t_mon]+'-'+t_year

}
}

}



function Check_Date(frm,name){
var flag=false;
var dpic_date = eval("document."+frm+"."+name+".value");

var MonthName = new Array('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec')
var d = new Date();
var t_date = d.getDate();       // Returns the day of the month
var t_mon = d.getMonth()+1;       // Returns the month as a digit
var t_year = d.getYear();   // Returns 4 digit year
var hrs = d.getHours();   // hrs
var mins = d.getMinutes();   // mins
var secs = d.getSeconds();   // secs
var SysDate=new Date(t_mon+'/'+t_date+'/'+t_year+" "+hrs+":/"+mins+":"+secs);
var arrays = dpic_date.split("-");
var st=getMonthValue(arrays[1])+'/'+arrays[0]+'/'+arrays[2];
var datePickerDate=new Date(st);

	 if(datePickerDate > SysDate){
		alert( name +" Can't Be Greater Than Current Date")	
		}else {
			flag=true;
		}
	return flag;
}

function getMonthValue(month)
{
	var month_value;
	month_Array =new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");

for(var i=0;i<month_Array.length;i++){
	if(month==month_Array[i]){
		month_value=i;

		}
	}
	return month_value+1;
}



function textCounter( field, name, maxlimit ) {
	
	var len = eval("document."+field+"."+name+".value");
	var path=eval("document."+field+"."+name);
       
  if ( len.length > maxlimit )
  {
 // maxlimit=+maxlimit;
   alert( "Textarea value can only be " +maxlimit+"characters in length." );
   path.value = path.value.substring( 0, maxlimit );
  // "document."+field+"."+name+".value"=len.substring(0,maxlimit);
    return false;
  }
  
}

function Date_TimeDiff(firstDte,secondDte,Ope){
		var bolflg = false;
		firstDte = firstDte.split('-');
		secondDte = secondDte.split('-');
		var firstDteN = new Date(firstDte[0],getMonthValue(firstDte[1]),firstDte[2],firstDte[3],firstDte[4],firstDte[5])
		var secondDteN = new Date(secondDte[0],getMonthValue(secondDte[1]),secondDte[2],secondDte[3],secondDte[4],secondDte[5])
		if(Ope =='<' && firstDteN < secondDteN ){
			bolflg= true;
		}
		if(Ope =='<=' && firstDteN <= secondDteN ){
			bolflg= true;
		}
		if(Ope =='>' && firstDteN > secondDteN ){
			bolflg= true;
		}
		if(Ope =='>=' && firstDteN >= secondDteN ){
			bolflg= true;
		}
		return bolflg;
	}

	function DateDiff(firstDte,secondDte,Ope){
		var bolflg = false;
		firstDte = firstDte.split('-');
		secondDte = secondDte.split('-');
		var firstDteN = new Date(firstDte[0],firstDte[1],firstDte[2])
		var secondDteN = new Date(secondDte[0],secondDte[1],secondDte[2])
		if(Ope =='<' && firstDteN < secondDteN ){
			bolflg= true;
		}
		if(Ope =='<=' && firstDteN <= secondDteN ){
			bolflg= true;
		}
		if(Ope =='>' && firstDteN > secondDteN ){
			bolflg= true;
		}
		if(Ope =='>=' && firstDteN >= secondDteN ){
			bolflg= true;
		}
		return bolflg
	}

///IN USE
	function Date_TimeDiff_AmPm(firstDte,secondDte,Ope){
		var bolflg = false;
		firstDte = firstDte.split('-');
		secondDte = secondDte.split('-');
		if(firstDte[5] =='1' ){ // here 1 means PM
			firstDte[3] = parseInt(firstDte[3]) + 12;
		}
		if(secondDte[5] =='1' ){
			secondDte[3] = parseInt(secondDte[3]) + 12;
		}
		var firstDteN = new Date(firstDte[0],getMonthValue(firstDte[1]),firstDte[2],firstDte[3],firstDte[4],0)
		var secondDteN = new Date(secondDte[0],getMonthValue(secondDte[1]),secondDte[2],secondDte[3],secondDte[4],0)
		if(Ope =='<' && firstDteN < secondDteN ){
			bolflg= true;
		}
		if(Ope =='<=' && firstDteN <= secondDteN ){
			bolflg= true;
		}
		if(Ope =='>' && firstDteN > secondDteN ){
			bolflg= true;
		}
		if(Ope =='>=' && firstDteN >= secondDteN ){
			bolflg= true;
		}
		return bolflg;
	}
