//*********************************** Check Null ******************************
function chknull(txtbox, txtname)
{
if (txtbox.value == '')
{
alert(txtname);
txtbox.focus();
return false;	
}
return true;
}

//********************* Check for Max length reached **************************

function chkmax(txtbox, txtlen, txtname)
{
if (txtbox.value.length > txtlen)
{
alert('Please limit ' + txtname + ' to only ' + txtlen + ' characters.')
txtbox.focus();
return false;
}
return true;
}

//********************* Authenticate Combo Selection ******************************

function chkcombo(cmbbox,cmbname)
{

cmbValue = cmbbox.options[cmbbox.selectedIndex].value;	
if (cmbValue == "-1")
{
alert(cmbname);
cmbbox.focus();
return false;	
}
return true; 
}
function chkemailsimple(txtbox, txtname)	{

if (!chknull(txtbox, txtname)) return false;
if(txtbox.value.indexOf('@') == -1 || txtbox.value.indexOf('.') == -1)	{
alert("Please enter valid email address.");
txtbox.focus();
return false;	
}
return true;
}


//*******************Set Deadline Date**********************************************
function chkValidDate(mm,dd,yy){
//mm	= parseInt(document.form1.month.options[document.form1.month.selectedIndex].value);
//dd	= parseInt(document.form1.day.options[document.form1.day.selectedIndex].value);
//yy	= parseInt(document.form1.year.options[document.form1.year.selectedIndex].value);

if(mm == 4 || mm == 6 || mm == 9 || mm == 11)
{
max_days = 30;
}
else if(mm == 2)
{		// February			
if(yy % 4 == 0)
{	// Leap Year
max_days = 29;
}
else
{				// Not a Leap Year
max_days = 28;	
}			
}
else
{
max_days = 31;	
}
if (dd >max_days )
return false;
else
return true;	
}	

//--------------------------------------------- Friend Form Validation ...
function Validate(thisForm) {

	if(!chknull(thisForm.yname,"Please enter your Name.")){
		return(false);
	} 
	else if(!chkemailsimple(thisForm.yemail,"Please enter your E-mail.")){
		return(false);
	}
	else {
		var iFriendCnt = 0;
		iFriendCnt = thisForm.iFriendCnt.value;

		for(i=0;i<iFriendCnt;i++){
			if(i==0){
				if(!chknull(thisForm.Fname[i],"Please enter your Friend's Name.")){
					return(false);
				}
				else if(!chkemailsimple(thisForm.Femail[i],"Please enter your Friend's E-mail Address.")){
					return(false);
				}
			}
			else {
					if(thisForm.Fname[i].value.length>0){
						if(!chkemailsimple(thisForm.Femail[i],"Please enter your Friend's E-mail Address.")){
							return(false);
						}
					} 
					else if(thisForm.Femail[i].value.length>0){
						if(!chknull(thisForm.Fname[i],"Please enter your Friend's Name.")){
							return(false);
						}
						if(!chkemailsimple(thisForm.Femail[i],"Please enter your Friend's E-mail Address.")){
							return(false);
						}
					}
			}
		}
	}
	return(true);
}

/* Contact US */
function DNV()
{

if (document.form1.name.value=="")
{
alert("Please provide Name!")
document.form1.name.focus()
return false
}

if (document.form1.gender.value=="")
{
alert("Please provide your gender")
document.form1.gender.focus()
return false
}
if (document.form1.age.value=="")
{
alert("Please provide your age")
document.form1.age.focus()
return false
}
if (document.form1.grade.value=="")
{
alert("Please provide your grade!")
document.form1.grade.focus()
return false
}	
if (document.form1.email.value=="")
{
alert("Please provide your email!")
document.form1.email.focus()
return false
}	
if (document.form1.thought.value=="")
{
alert("Please provide your thought!")
document.form1.thought.focus()
return false
}
}
/* Help */
function DNVHelp()
{

if (document.form1.uname.value=="")
{
alert("Please provide your name")
document.form1.uname.focus()
return false
}
if (document.form1.email.value=="")
{
alert("Please provide your email")
document.form1.email.focus()
return false
}
if (document.form1.query.value=="")
{
alert("Please provide your query!")
document.form1.query.focus()
return false
}	
if (document.form1.age.value=="")
{
alert("Please provide your age!")
document.form1.age.focus()
return false
}
}
/* Send An Article */
function DNVArticle()
{

if (document.form1.fmail.value=="")
{
alert("Please provide here a valid email address!")
document.form1.fmail.focus()
return false
}

if (document.form1.uname.value=="")
{
alert("Please provide your full name!")
document.form1.uname.focus()
return false
}

if (document.form1.uemail.value=="")
{
alert("Please provide here a valid email address!")
document.form1.uemail.focus()
return false
}
}