function validate_email(field,alerttxt)
{
with (field)
{
apos=value.indexOf("@");
dotpos=value.lastIndexOf(".");
if (apos<1||dotpos-apos<2) 
  {alert(alerttxt);return false;}
else {return true;}
}
}

function validate_required(field,alerttxt)
{
with (field)
{
if (value==null||value=="")
  {alert(alerttxt);return false;}
else {return true}
}
}


function validate_form(thisform)
{
with (thisform)
{
if (validate_required(name,"Please, write your first name.")==false)
  {name.focus();return false;}
}
with (thisform)
{
if (validate_required(name2,"Please, write your last name.")==false)
  {name2.focus();return false;}
}
with (thisform)
{
if (validate_email(email,"Not a valid e-mail address!")==false)
  {email.focus();return false;}
}
with (thisform)
{
if (validate_required(country,"Please, select a country")==false)
  {country.focus();return false;}
}

with (thisform)
{
var found_it
for (var i=0; i<gender.length; i++)  {

    if (gender[i].checked)  {

    found_it = gender[i].value //set found_it equal to checked button's value

    } 

}
if(!found_it){ //if found_it is equal to false or null, a button has NOT been checked

alert("Please select a gender");
country.focus();return false;
}
}



with (thisform)
{
var found_it1
for (var i=0; i<accom.length; i++)  {

    if (accom[i].checked)  {

    found_it1 = accom[i].value //set found_it equal to checked button's value

    } 

}
if(!found_it1){ //if found_it is equal to false or null, a button has NOT been checked

alert("Please select accommodation type");
year_e.focus();return false;
}
}


/*


with (thisform)
{
var found_it2
for (var i=0; i<detoxprogram.length; i++)  {

    if (detoxprogram[i].checked)  {

    found_it2 = detoxprogram[i].value //set found_it equal to checked button's value

    } 

}
var found_it3
for (var i=0; i<wellnessprogram.length; i++)  {

    if (wellnessprogram[i].checked)  {

    found_it3 = wellnessprogram[i].value //set found_it equal to checked button's value

    } 

}
if(!found_it2 & !found_it3){ //if found_it is equal to false or null, a button has NOT been checked

alert("Please select a program");
year_e.focus();return false;
}
}


*/


/*
with (thisform)
{
if (validate_required(program1,"Please, select a country")==false)
  {country.focus();return false;}
}
*/

with (thisform)
{
var found_it4
for (var i=0; i<program.length; i++)  {

    if (program[i].checked)  {

    found_it4 = program[i].value //set found_it equal to checked button's value

    } 

}

var found_it6

if(oto.checked) {found_it6 = oto.value}




if((program_drop.value==null||program_drop.value=="")&!found_it4&!found_it6){ //if found_it is equal to false or null, a button has NOT been checked
alert("Please select a program");
year_e.focus();return false;
}
}










}


