var whitespace = " \t\n\r";

function isEmpty(s)
{
   return ((s == null) || (s.length == 0))
}
function isWhitespace (s)
{  

	var i;
	// Is s empty?
	if (isEmpty(s)) return true;

	 // Search through string's characters one by one
	 // until we find a non-whitespace character.
	 // When we do, return false; if we don't, return true.
	 for (i = 0; i < s.length; i++)
	 {   
		 // Check that current character isn't whitespace.
		 var c = s.charAt(i);
 
		 if (whitespace.indexOf(c) == -1) return false;
	 }
 
	 // All characters are whitespace.
	 return true;
}
function BuildStr(s, s1)
{
	  if (s.length> 0) s = s + "\n";
	  s = s + s1;
	  return s;
}

function isCharsInBag (s, bag)
{  
  var i;
  // Search through string's characters one by one.
  // If character is 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) return false;
  }
  return true;
}

function echeck(str) 
	{
		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   return true;
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
			return true;
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    return true;
   		}

		 if (str.indexOf(at,(lat+1))!=-1){
			return true;
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
			return true;
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
			return true;
		 }
		
		 if (str.indexOf(" ")!=-1){
			return true;
		 }

 		 return false;					
	}

function monthno(mnth)
{
	getmonthno=13
	mnth=mnth.toLowerCase();
	switch(mnth)
	{
		case "jan": getmonthno = 1; break;
		case "feb": getmonthno = 2; break;
		case "mar": getmonthno = 3; break;
		case "apr": getmonthno = 4; break;
		case "may": getmonthno = 5; break;
		case "jun": getmonthno = 6; break;
		case "jul": getmonthno = 7; break;
		case "aug": getmonthno = 8; break;
		case "sep": getmonthno = 9; break;
		case "oct": getmonthno = 10; break;
		case "nov": getmonthno = 11; break;
		case "dec": getmonthno = 12; break;       
	}
	return getmonthno;				
}

function monthname(mnth)
{
	getmonthname=13
	mnth=mnth;
	switch(mnth)
	{
		case "01": getmonthname= "jan"; break;
		case "02": getmonthname= "feb"; break;
		case "03": getmonthname= "mar"; break;
		case "04": getmonthname= "apr"; break;
		case "05": getmonthname= "may"; break;
		case "06": getmonthname= "jun"; break;
		case "07": getmonthname= "jul"; break;
		case "08": getmonthname= "aug"; break;
		case "09": getmonthname= "sep"; break;
		case "10": getmonthname= "oct"; break;
		case "11": getmonthname= "nov"; break;
		case "12": getmonthname= "dec"; break;       
	}
	return getmonthname;				
}
function checkDates(paramStartDate, paramEndDate)
{
	
	dtfrom=paramStartDate;

	if(dtfrom!="")
	{
		dt1_s=dtfrom.split("-");
		dt1_d=dt1_s[0]	
		dt1_m=dt1_s[1]
		dt1_y=dt1_s[2]		
	}
	
	dtto=paramEndDate;

	if(dtto!="")
	{
		dt2_s=dtto.split("-");
		dt2_d=dt2_s[0]	
		dt2_m=dt2_s[1]
		dt2_y=dt2_s[2]		
	}
		
	
	var dteStart = new Date(dt1_y, dt1_m, dt1_d,0,0,0);
	var dteEnd = new Date(dt2_y, dt2_m, dt2_d,0,0,0);

	var dteCurrent = new Date();	

	if(dteStart.valueOf() - dteEnd.valueOf() > 0)
	{
	   getvalno=0
	}
	else
	{
		getvalno=1;
	}
	return getvalno;				
}


function checknumeric(thefval,thestr)
{
	if(!isCharsInBag(thefval, thestr) || isNaN(thefval))
		{
			alert("Please enter numeric value");
			return false;
		}
}
