function del()
{
	var aa;
	aa = confirm("Are you sure you want to delete this record");
	if(aa)
	{
		return true;
	}
	else
	{
		return false;
	}
}
function checkemail(textfldobj)
{
  if (textfldobj.value.indexOf('@') == -1 || textfldobj.value.indexOf('.')== -1)
  {
  //alert("Please enter a Valid Email Id.");
  textfldobj.focus();
  return false;
  }
  return true
}
function charlen(txtobj,minlen)
{
	
	var totchars = txtobj.value.length;
	if(totchars < minlen)
	{
		txtobj.focus();
		return false;
	}
	
	return true;
}

function copyHours (formobj)
	{
				formobj.open_tue.checked = formobj.open_mon.checked;
				formobj.hours_tue.value = formobj.hours_mon.value;
				formobj.open_wed.checked = formobj.open_mon.checked;
				formobj.hours_wed.value = formobj.hours_mon.value;
			    formobj.open_thu.checked = formobj.open_mon.checked;
		        formobj.hours_thu.value = formobj.hours_mon.value;
	            formobj.open_fri.checked = formobj.open_mon.checked;
				formobj.hours_fri.value = formobj.hours_mon.value;
				formobj.open_sat.checked = formobj.open_mon.checked;
				formobj.hours_sat.value = formobj.hours_mon.value;
				formobj.open_sun.checked = formobj.open_mon.checked;
				formobj.hours_sun.value = formobj.hours_mon.value;
	}
			function clearHours (formobj) 
	{
				formobj.open_mon.checked = false;
				formobj.hours_mon.value = '';
				formobj.open_tue.checked = false;
				formobj.hours_tue.value = '';
				formobj.open_wed.checked = false;
				formobj.hours_wed.value = '';
				formobj.open_thu.checked = false;
				formobj.hours_thu.value = '';
				formobj.open_fri.checked = false;
				formobj.hours_fri.value = '';
			    formobj.open_sat.checked = false;
				formobj.hours_sat.value = '';
				formobj.open_sun.checked = false;
				formobj.hours_sun.value = '';
	}
			function setOpen (tbox,cbox) 
		   {
				var currentObj = document.getElementById(tbox);
				var changeObj = document.getElementById(cbox);
			if (currentObj.value==null || currentObj.value.length==0) 
			   {
					changeObj.checked = false;
				} else 
				{
					changeObj.checked = true;
				 }
			}

function chkExtension(txtfield)
{


	var filename,filenamelen
	var fileext,fileextlen
	var allowedtypes = [".jpg",".JPG",".jpeg",".JPEG",".gif",".GIF"]
	var dotpos
	filename = txtfield.value
	filenamelen = filename.length
	dotpos = filename.lastIndexOf(".")
	fileextlen = (filenamelen - dotpos - 1)
	
	if (fileextlen >= 3 && fileextlen <= 4) //this allows files with a min of 3 and max of 4 chars in their extension
	{
	fileext = filename.substring(dotpos,filenamelen)
	//alert (fileext)
		for(var ctr=0;ctr<allowedtypes.length;ctr++)
		{
			
			if(allowedtypes[ctr] == fileext)
			{
				return true
			}		
		}
		alert("Only JPG/JPEG/GIF type picture files are allowed.\n Please select a valid file type.")	

	}
	else
	alert("The file you have selected is not a valid picture file.\nPlease select a different file.")
	
	return false


}

function emptyField(formobj)
{
	if(formobj.value.length==0)
	{
		 formobj.focus();
		 return true;
	}
	for(var i=0;i < formobj.value.length;++i)
	{
		var ch =formobj.value.charAt(i);
	if(ch!=' '&&ch!= '\t') 
		return false;
	}
	formobj.focus();
	return true;
}

function empty(textobj)
{
	if(textobj.value.length==0)
	{
		// textobj.focus();
		 return true;
	}
	for(var i=0;i < textobj.value.length;++i)
	{
		var ch =textobj.value.charAt(i);
	if(ch!=' '&&ch!= '\t') 
		return false;
	}
	//textobj.focus();
	return true;
}


function isblank(blafield)
{
if(blafield.indexOf(' ') ==1)
{
return false;

}
else
{
return true;
}
}




function isNum(argvalue) 
{
argvalue = argvalue.toString();

if (argvalue.length == 0)
{
return true;
}

for (var n = 0; n < argvalue.length; n++)
{
if(argvalue.substring(n, n+1) == "0")
continue;
else if(argvalue.substring(n, n+1) == "1")
continue;
else if(argvalue.substring(n, n+1) == "2")
continue;
else if(argvalue.substring(n, n+1) == "3")
continue;
else if(argvalue.substring(n, n+1) == "4")
continue;
else if(argvalue.substring(n, n+1) == "5")
continue;
else if(argvalue.substring(n, n+1) == "6")
continue;
else if(argvalue.substring(n, n+1) == "7")
continue;
else if(argvalue.substring(n, n+1) == "8")
continue;
else if(argvalue.substring(n, n+1) == "9")
continue;
else if(argvalue.substring(n, n+1) == ".")
continue;

else if(argvalue.substring(n, n+1) == " ")
continue;

else

return false;
}
return true;
}


function isdate(sdate)
{


var s,ss,leapyear;
s = sdate.value;
if (s=="")
{
return false;
}
ss = s.split("/");
var today = new Date();
today = today.getYear();
today = '20'+today;

if ((s.substr(1,1) != "/" && s.substr(2,1) != "/") || (s.substr(3,1) != "/" && s.substr(4,1) != "/" && s.substr(5,1) != "/"))
	{
	
		alert("Enter date in correct form (mm/dd/yyyy)");
		return val_focus(sdate);
		
	}
  
	else if ((ss[0].length > 2) || (ss[0].length < 1) || (ss[1].length > 2) || ss[1].length < 1 || (ss[2].length != 4) || (!isNum(ss[0])) || (!isNum(ss[1])) || (!isNum(ss[2])))
	 {
		alert("Enter date in Correct format (mm/dd/yyyy)");
		return val_focus(sdate);
	 }
	else if (ss[2] < 1900 || ss[2] > today)
	 {
		alert("Enter Valid Year [Between 1900-To current Year]");
		return val_focus(sdate);
	 }
	
	else if(ss[0] < 1 || ss[0] > 12)
	{
		alert("Enter Valid Month [Between 1-12]");
		return val_focus(sdate);
	}
	
	else if(ss[1] < 1 || ss[1] > 31)
	{
		alert("Enter Valid day [Between 1-31]");
		return val_focus(sdate);
	}
	
	else if(ss[0]==4 || ss[0] == 6 || ss[0] == 9 || ss[0] == 11)
	{
		if(ss[1] > 30)
		{
			alert("For this month day should be less than 30");
			return val_focus(sdate);
		 }
	}
	
	else if(ss[0] == 2)
	{
		if((ss[2]%4)==0) 
		{	
			if((ss[2]%100)==0)
			{	
				if((ss[2]%400) ==0)
				leapyear = true;
				else
				leapyear = false;
			}
			else
			leapyear = true;	
		}		
	    else 
		    leapyear = false;
		 
		if((leapyear) && (ss[1] > 29))
		 {
			alert("This is leap year so date can't greater than 29");
			return val_focus(sdate);
		 }
		 else if(!(leapyear) && ss[1] > 28)
		 {
			alert("This is not leap year so date can't greater than 28");
			return val_focus(sdate);
		 }
		 
	}
	else 
	return false;
 }


 function val_focus(formobj)
{
 formobj.select();
 formobj.focus();
 return true;

}
 
