// JavaScript Document
function echeck(str) {
if (str.length > 0 )
{
var at="@"
var dot="."
var lat=str.indexOf(at)
var lstr=str.length
var ldot=str.indexOf(dot)
if (str.indexOf(at)==-1){

return false
}

else if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){

return false
}

else if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){

return false
}

else if (str.indexOf(at,(lat+1))!=-1){

return false
}

else if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){

return false
}

else if (str.indexOf(dot,(lat+2))==-1){

return false
}

else if (str.indexOf(" ")!=-1){

return false
}
else if (str.lastIndexOf(".")>lstr-3)
{

return false
}
else
{
return true					
}
}
else
{
return true
}
}
function trimString (str)
{
while (str.charAt(0) == ' ')
str = str.substring(1);
while (str.charAt(str.length - 1) == ' ')
str = str.substring(0, str.length - 1);
return str;
}
function numcheck(str)
{
var tr=true;
var s=str.length;
if(s==0)
{
return true;
}
else
{
for(i=0;i<s;i++)
{
if(str.charCodeAt(i)<48||str.charCodeAt(i)>57)
{
tr=false;
break;
}
}
if(tr==false)
{
return false;
}
else
{
return true;
}
}
}
function phonecheck(st1,st2,st3)
{
	if(st1 == "" || st2 == "" || st3 == "")
	{
		return false;
		
	}
	else if(st1.length != 3 || st2.length != 3 || st3.length != 4)
	{
		return false;
	}
	else if(isNaN(st1) || isNaN(st2) || isNaN(st3))
	{
		return false;

	}
	else
	{
	
		return true;
	}

}
function phonecheck1(st1,st2,st3)
{
	if(st1 == "" && st2 == "" && st3 == "")
	{
		return true;
	}
	else
	{
		if(st1 == "" || st2 == "" || st3 == "")
		{
			return false;
			
		}
		else if(st1.length != 3 || st2.length != 3 || st3.length != 4)
		{
			return false;
		}
		else if(isNaN(st1) || isNaN(st2) || isNaN(st3))
		{
			return false;
	
		}
		else
		{
		
			return true;
		}
	}
}
function bdatecheck(st1,st2,st3)
{
	if(st1 == "" || st2 == "" || st3 == "")
	{
		return false;
		
	}
	else
	{
	
		return true;
	}

}

function valid_date(d,b,f)
{
 		var err=0
 		var psj=0;
  				
		
		if (b<1 || b>12 || isNaN(b)==true) 
		{
			
			return false;
			err = 1
		}
		if (isNaN(d)==true) 
		{
			
			return false;
			err = 1
		}
		if (isNaN(f)==true) 
		{
			
			return false;
			err = 1
		}
		
		if (d<1 || d>31) err = 1
		if (f<1900 || f>9999) err = 1
		if (b==2 || b==4 || b==6 || b==9 || b==11)
		{
   			if (d==31) 
   			{
	   			err=1
	   					
	   			return false;
   			}
		}

		if (b==2)
		{
	 // feb
	 var g=parseInt(f/4)
	 if (isNaN(g))
	  {
		  err=1
	  }
	  if (d>29) 	  
	  {
	  	err=1
		
	    return false; 
	  }
	  if (d==29 && ((f/4)!=parseInt(f/4))) 
	  {
		  err=1
		  
	      return false; 
	  }
	  
 } 
 
 if (err==1)
  {
	  
	  return false;
	  
  }
  else
  {
  	return true;
  }	
}  
function valid_date1(p)
{
 		var qw=p.split("/");
		b=eval(qw[0]);
		d=eval(qw[1]);
		f=eval(qw[2]);
		
		var err=0
 		var psj=0;
  				
		if (b=="" && d=="" && f=="")
		{
		
			return true;
		
		
		}
		
		if (b<1 || b>12 || isNaN(b)==true) 
		{
			
			return false;
			err = 1
		}
		if (isNaN(d)==true) 
		{
			
			return false;
			err = 1
		}
		if (isNaN(f)==true) 
		{
			
			return false;
			err = 1
		}
		
		if (d<1 || d>31) err = 1
		if (f<1900 || f>9999) err = 1
		if (b==2 || b==4 || b==6 || b==9 || b==11)
		{
   			if (d==31) 
   			{
	   			err=1
	   					
	   			return false;
   			}
		}

		if (b==2)
		{
	 // feb
	 var g=parseInt(f/4)
	 if (isNaN(g))
	  {
		  err=1
	  }
	  if (d>29) 	  
	  {
	  	err=1
		
	    return false; 
	  }
	  if (d==29 && ((f/4)!=parseInt(f/4))) 
	  {
		  err=1
		  
	      return false; 
	  }
	  
 } 
 
 if (err==1)
  {
	  
	  return false;
	  
  }
  else
  {
  	return true;
  }	
}  

function futuredate(sday,smonth,syear)
{
	
	
	b12=eval(b12);
	if(b12.length==1)
	{
		b12="0"+b12;
	}
	
	b13=eval(b13);
	if(b13.length==1)
	{
		b13="0"+b13;
	}
	
	b14=eval(b14);
	
	
	if (smonth >=b13 && sday > b12 && syear == b14)
	{
		return true;

	}
	else if(smonth >b13 && syear==b14)
	{
		return true;
	}
	else if(syear > b14)
	{
		return true;
	}
	else 
	{
		return false;
	}
}
function checkcontactinfo(str)
{
	var mycheck=true;
	//var reUsername =new Array('/[a-zA-Z0-9]*@[a-zA-Z0-9_]*\.[a-zA-Z]*/','/[0-9]*\-[0-9]*\-[0-9]*/');
	
	var reUsername =new Array('/[0-9]*\-[0-9]*\-[0-9]*/');
	for(j=0;j<reUsername.length;j++)
	{
		var matchArray = str.match(reUsername[j]); 
		if (matchArray == null)
		{ 
		
		}
		else
		{
			mycheck=false;
			break;
		}
	}
	return mycheck;
}

function closeMessage(id){
	var messageBox = document.getElementById(id);
	if(messageBox != null)
		messageBox.style.display = "none";
}
