function validate()
{	
	if (document.online.chkBhopal.checked==false && document.online.chkAhmedabad.checked==false && document.online.chkChandigarh.checked==false && document.online.chkLudhiana.checked==false && document.online.chkJaipur.checked==false && document.online.chkMumbai.checked==false && document.online.chkAhemedabad2.checked==false && document.online.chkAllCity.checked==false)
	{
		alert ("Select at least one city");
		document.online.chkBhopal.focus();
		return(false);
	}
	else if (isdate(document.online.txtBookingDate.value)==false)
	{
		document.online.txtBookingDate.focus();
		return(false);
	
	}
	else if (isnum(document.online.txtTotalStall.value)==false)
	{
		alert ("Enter valid numeric No of Total Stall(s)");
		document.online.txtTotalStall.focus();
		return(false);
	}
	else if(isnum(document.online.txtTotalValue.value)==false)
	{
		alert ("Enter valid numeric Total Value of Stall(s)");
		document.online.txtTotalValue.focus();
		return(false);
	}
	else if(document.online.txtDraftNo.value=="")
	{
		alert ("Enter Draft No");
		document.online.txtDraftNo.focus();
		return(false);
	}
	else if(isdate(document.online.txtDraftDate.value)==false)
	{
		document.online.txtDraftDate.focus();
		return(false);
		
	}
	else if(document.online.txtDrawnOn.value=="")
	{
		alert ("Enter Drawn on");
		document.online.txtDrawnOn.focus();
		return(false);
	}
	else if(isnum(document.online.txtDraftValue.value)==false)
	{
		alert ("Enter valid numeric Draft for Ruppees");
		document.online.txtDraftValue.focus();
		return(false);
	}
	else if(document.online.txtFasciaBoard.value=="")
	{
		alert ("Enter Fascia Board");
		document.online.txtFasciaBoard.focus();
		return(false);
	}
	else if(document.online.txtName.value=="")
	{
		alert ("Enter Name");
		document.online.txtName.focus();
		return(false);
	}
	else if(document.online.txtDesignation.value=="")
	{
		alert ("Enter Designation");
		document.online.txtDesignation.focus();
		return(false);
	}
	else if(document.online.txtOrganization.value=="")
	{
		alert ("Enter Organization");
		document.online.txtOrganization.focus();
		return(false);
	}
	else if(document.online.txtAddress1.value=="")
	{
		alert ("Enter Address");
		document.online.txtAddress1.focus();
		return(false);
	}
	else if(isemail(document.online.txtEmail1.value)==false)
	{
		document.online.txtEmail1.focus();
		return(false);
	}
	else if(isemail2(document.online.txtEmail2.value)==false && document.online.txtEmail2.value!="")
	{
		alert("Enter valid email id in correct format (contact@sysport.net)");
		document.online.txtEmail2.focus();
		return(false);
	}
	else
	{
		document.online.txtITMFor.value=""
		if(document.online.chkBhopal.checked==true)
		{
			document.online.txtITMFor.value="Bhopal"
		}
		if(document.online.chkAhmedabad.checked==true)
		{
			document.online.txtITMFor.value=document.online.txtITMFor.value + ",Ahmedabad"
		}
		if(document.online.chkChandigarh.checked==true)
		{
			document.online.txtITMFor.value=document.online.txtITMFor.value + ",Chandigarh"
		}
		if(document.online.chkLudhiana.checked==true)
		{
			document.online.txtITMFor.value=document.online.txtITMFor.value + ",Ludhiana"
		}
		if(document.online.chkMumbai.checked==true)
		{
			document.online.txtITMFor.value=document.online.txtITMFor.value + ",Mumbai"
		}
		if(document.online.chkJaipur.checked==true)
		
		{
			document.online.txtITMFor.value=document.online.txtITMFor.value + ",Jaipur"
		}
		if(document.online.chkAhmedabad2.checked==true)
		{
			document.online.txtITMFor.value=document.online.txtITMFor.value + ",Ahmedabad"
		}
		
		if(document.online.chkAllCity.checked==true)
		{
			document.online.txtITMFor.value=""
			document.online.txtITMFor.value="AllCities"
		}
		return(true);
	}
}

function isdate(strDate)
{
	var ss,leapyear;
	ss = strDate.split("/");
	var today = new Date();
	today = today.getYear();
	today = '20'+today;

	if ((strDate.substr(1,1) != "/" && strDate.substr(2,1) != "/") || (strDate.substr(3,1) != "/" && strDate.substr(4,1) != "/" && strDate.substr(5,1) != "/"))
	{
	
		alert("Enter date in correct form (dd/mm/yyyy)");
		return false;
	}
  
	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 (dd/mm/yyyy)");
		return false;
	 }
	else if (ss[2] < 1900 || ss[2] > today)
	 {
		alert("Enter Valid Year [Between 1900-To current Year]");
		return false;
	 }
	
	else if(ss[1] < 1 || ss[1] > 12)
	{
		alert("Enter Valid Month [Between 1-12]");
		return false;
	}
	
	else if(ss[0] < 1 || ss[0] > 31)
	{
		alert("Enter Valid day [Between 1-31]");
		return false;
	}
	
	else if(ss[1]==4 || ss[1] == 6 || ss[1] == 9 || ss[1] == 11)
	{
		if(ss[0] > 30)
		{
			alert("For this month day should be less than 30");
		return false;
		 }
	}
	
	else if(ss[1] == 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[0] > 29))
		 {
			alert("This is leap year so date can't greater than 29");
			return false;
		 }
		 else if(!(leapyear) && ss[0] > 28)
		 {
			alert("This is not leap year so date can't greater than 28");
			return false;
		 }
		 
	}
	else 
	return true;
}

function isemail(strEmail) //functions for dividing a sting
{
	if (instr(1,strEmail,'@')==-1)
	{
		alert("Enter valid email id in correct format (contact@sysport.net)");
		return false;
	}
	else if(instr(instr(1,strEmail,'@')+1,strEmail,'@')!=-1)
	{
		alert("Enter valid email id in correct format (contact@sysport.net)");
		return false;
	}
	else if(instr(instr(1,strEmail,'@')+2,strEmail,'.')==-1)
	{
		alert("Enter valid email id in correct format (contact@sysport.net)");
		return false;
	}
	return true;
}
function isemail2(strEmail) //functions for dividing a sting
{
	if (instr(1,strEmail,'@')==-1)
	{
		return false;
	}
	else if(instr(instr(1,strEmail,'@')+1,strEmail,'@')!=-1)
	{
		return false;
	}
	else if(instr(instr(1,strEmail,'@')+2,strEmail,'.')==-1)
	{
		return false;
	}
	return true;
}
function instr(Start,targetstr,character) //functions for dividing a sting
{
	var i;
	var ch;
	for(i=Start;i <= targetstr.length;++i)
	{
		ch =targetstr.charAt(i);
		if(ch==character) 
		{
			return i;
			break;
		}
	}
	return -1;
}

function isnum(argvalue)
{
	argvalue = argvalue.toString();
	for (var n = 0; n < argvalue.length; n++)
		if ((argvalue.substring(n, n+1) < "0" || argvalue.substring(n, n+1) > "9") && (argvalue.substring(n, n+1) != " "))  
			return false;
	return true;
}


