function checkRadio (frmName, rbGroupName) {
 var radios = document[frmName].elements[rbGroupName];
 for (var i=0; i <radios.length; i++) {
  if (radios[i].checked) {
   return true;
  }
 }
 return false;
}


function IsEmpty(aTextField) {
   if ((document.getElementById(aTextField).value.length==0) ||
   (document.getElementById(aTextField).value==null)) {
      return true;
   }
   else { return false; }
}
function checkAgeCheckBox(f){

var dob=new Date();
var date=dob.getDate();
var month=dob.getMonth() + 1;
var year=dob.getFullYear();
var min_age = 18;

var avmonth=parseInt(document.getElementById("avmonth").options[document.getElementById("avmonth").selectedIndex].value);
var avday=parseInt(document.getElementById("avday").options[document.getElementById("avday").selectedIndex].value);
var avyear=parseInt(document.getElementById("avyear").options[document.getElementById("avyear").selectedIndex].value);

var theirDate = new Date((avyear + min_age), avmonth-1, avday);
var today = new Date;

age=year-avyear;

if(avmonth>month){age--;}
else{if(avday>=date){age--;}}

if(avmonth==0){alert("Please select a month.");return false;}
else if(avday==0){alert("Please select a day.");return false;}
else if(avyear==9999){alert("Please select a year.");return false;}
else if( (today.getTime() - theirDate.getTime()) < 0){alert("You must be over 18 to view this website.");return false;}
else{return true;}

}  
function betaSignUp(f){

var dob=new Date();
var date=dob.getDate();
var month=dob.getMonth() + 1;
var year=dob.getFullYear();

var fields_birthmonth=parseInt(document.getElementById("fields_birthmonth").options[document.getElementById("fields_birthmonth").selectedIndex].value);
var fields_birthday=parseInt(document.getElementById("fields_birthday").options[document.getElementById("fields_birthday").selectedIndex].value);
var fields_birthyear=parseInt(document.getElementById("fields_birthyear").options[document.getElementById("fields_birthyear").selectedIndex].value);
var fields_iam=parseInt(document.getElementById("fields_iam").options[document.getElementById("fields_iam").selectedIndex].value);

age=year-fields_birthyear;

if(fields_birthmonth>month){age--;}
else{if(fields_birthday>=date){age--;}}

if(IsEmpty("fields_fname")){alert("Please insert your first name.");return false;}
if(IsEmpty("fields_lname")){alert("Please insert your last name.");return false;}
if(fields_birthmonth==0){alert("Please select a month.");return false;}
if(fields_birthday==0){alert("Please select a day.");return false;}
if(fields_birthyear==9999){alert("Please select a year.");return false;}
if(age<18){alert("You must be over 18 to view this website.");return false;}
if(IsEmpty("fields_email")){alert("Please insert your E-mail Address.");return false;}
if (!/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.getElementById("fields_email").value)){alert("Please insert a valid E-mail Address.");return false;}
if(fields_iam==0){alert("Please select an option for 'I Am'.");return false;}
if (!checkRadio("contactUsForm","os")) {alert("Please select an operating system.");return false; }

}
function mediaCenterSignup(f){

if(IsEmpty("FirstName")){alert("Please insert your first name.");return false;}
if(IsEmpty("LastName")){alert("Please insert your last name.");return false;}
if(IsEmpty("Title")){alert("Please insert your company title.");return false;}
if(IsEmpty("Company")){alert("Please insert your company name.");return false;}
if(IsEmpty("CompanyUrl")){alert("Please insert your company URL.");return false;}
if(IsEmpty("Phone")){alert("Please insert your phone number.");return false;}
if(IsEmpty("Email")){alert("Please insert your E-mail Address.");return false;}
if (!/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.getElementById("Email").value)){alert("Please insert a valid E-mail Address.");return false;}
if (document.getElementById("Email").value != document.getElementById("Email2").value){alert("E-mail Addresses do not match.");return false;}
}

function contactValidation(f){
if(IsEmpty("FirstName")){alert("Please insert your first name.");return false;}
if(IsEmpty("LastName")){alert("Please insert your last name.");return false;}
if(IsEmpty("Email")){alert("Please insert your E-mail Address.");return false;}
if (!/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.getElementById("Email").value)){alert("Please insert a valid E-mail Address.");return false;}
if(IsEmpty("Comments")){alert("Please insert a comment.");return false;}
}

function newsletterValidation(f){
if(IsEmpty("fields_email")){alert("Please insert your E-mail Address.");return false;}
if (!/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.getElementById("fields_email").value)){alert("Please insert a valid E-mail Address.");return false;}
}

// var NSignUp = document.getElementById('emailSignupForm');
// 
// if (document.location.protocol === "https:")
// 
// 	NSignUp.action = "https://app.icontact.com/icp/signup.php";
// function nRequired() {
//   if (NSignUp["fields_email"].value == "") {
//     NSignUp["fields_email"].focus();
//     alert("The Email field is required.");
//     return false;
//   }
// 
// return true;


// var icpForm3162 = document.getElementById('icpsignup3162');
// 
// if (document.location.protocol === "https:")
// 
// 	icpForm3162.action = "https://app.icontact.com/icp/signup.php";
// function verifyRequired3162() {
//   if (icpForm3162["fields_email"].value == "") {
//     icpForm3162["fields_email"].focus();
//     alert("The Email field is required.");
//     return false;
//   }
// 
// 
// return true;
// }
//  