function validate_submit_form() {
  var file_name = document.getElementById('upload_file').value;
  var question_desc = document.getElementById('userquestion').value;

  if(file_name == '' && question_desc == '') {
    alert('Either upload a file or Enter the question in text box');
    return false;
  }

  if(question_desc.length > 500) {
    alert('Question Description Can Not Be More Than 500 Characters');
    return false;
  }

  var uname = document.getElementById('username').value;

  if(uname.length == 0) {
    alert('Please Enter Your Name');
    return false;
  }

//   var phone = document.getElementById('phone').value;
// 
//   if(phone.length == 0) {
//     alert('Please Enter The Phone No.');
//     return false;
//   }
// 
//   if(!IsNumeric(phone)) {
//     alert('Please Enter Numeric only');
//     return false;
//   }
//     
//   if(phone.length > 15) {
//     alert('Please Enter Valid Phone Number');
//     return false;
//   }
// 
//   if(document.getElementById('education').value == "") {
//     alert('Please Enter Your Education');
//     return false;
//   }
// 
//   if(document.getElementById('address').value == "") {
//     alert('Please Enter Your Address');
//     return false;
//   }

  var email = document.getElementById('email').value;

  if(!isValidEmail(email)) {
    return false;
  }
  
//   var age = document.getElementById('age').value;
//   if(age.length == 0) {
//     alert('Please Enter Your Age');
//     return false;
//   }
// 
//   if(!IsNumeric(age)) {
//     alert('Please Enter Only Numerics for age');
//     return false;
//   }
// 
//   if(age.length > 3) {
//     alert('Age Can not greater than 3 digits');
//     return false;
//   }
// 
//   if(document.getElementById('country').value == "") {
//     alert('please Enter Your Country Name');
//     return false;
//   }

  if(!document.getElementById('agree_terms').checked) {
    alert('Accept the terms and condition before submitting comment');
    return false;
  }

  document.leadership_quest.submit();
  return true;
}

function isValidEmail(email) {
    if (! allValidChars(email)) {  // check to make sure all characters are valid
       alert('Invalid email address.');
       return false;
    }
    if (email.indexOf("@") < 1) { //  must contain @, and it must not be the first character
       alert('Invalid email address.');
       return false;
    } else if (email.lastIndexOf(".") <= email.indexOf("@")) {  // last dot must be after the @
        alert('Invalid email address.');
        return false;
    } else if (email.indexOf("@") == email.length) {  // @ must not be the last character
        alert('Invalid email address.');
        return false;
    } else if (email.indexOf("..") >=0) { // two periods in a row is not valid
        alert('Invalid email address.');
        return false;
    } else if (email.indexOf(".") == email.length) {  // . must not be the last character
        alert('Invalid email address.');
        return false;
    }
    return true;
}

function allValidChars(email) {
  var parsed = true;
  var validchars = "abcdefghijklmnopqrstuvwxyz0123456789@.-_";
  for (var i=0; i < email.length; i++) {
    var letter = email.charAt(i).toLowerCase();
    if (validchars.indexOf(letter) != -1)
      continue;
    parsed = false;
    break;
  }
  return parsed;
}


function IsValidName(sText) {
  var ValidChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
  var IsCharacter=true;
  var Char;

  for (i = 0; i < sText.length && IsCharacter == true; i++) {
    Char = sText.charAt(i); 
    if (ValidChars.indexOf(Char) == -1) {
      IsCharacter = false;
    }
  }
  return IsCharacter;
}

function IsNumeric(sText) {
  var ValidChars = "0123456789";
  var IsNumber=true;
  var Char;

  for (i = 0; i < sText.length && IsNumber == true; i++) {
    Char = sText.charAt(i); 
    if (ValidChars.indexOf(Char) == -1) {
      IsNumber = false;
    }
  }
  return IsNumber;
}

function close_alert() {
  document.getElementById('success_alert').style.display = 'none';
}

function verify_values() {
  if(document.getElementById('comment-author').value == "") {
    alert('Name can not be left blank');
    return false;
  }

  if(document.getElementById('comment-email').value == "") {
    alert('Email can not be left blank');
    return false;
  }
  email = document.getElementById('comment-email').value;

  if(!isValidEmail(email)) {
    return false;
  }

  if(document.getElementById('comment-text').value == "") {
    alert('Please enter text in comment box');
    return false;
  }

  if(!document.getElementById('agree_terms').checked) {
    alert('Accept the terms and condition before submitting comment');
    return false;
  }
  return true;
}

/* This function is used to display comment box */
function open_comment_box() {
  document.getElementById('comment_box').style.display = '';
}

/* This function is used to hide comment box */
function hide_commentbox() {
  document.getElementById('comment_box').style.display = 'none';
}

var menuwidth=525;
//configure scroll speed (1-10), where larger is faster
var scrollspeed=3;
//specify menu content
var loadedyes=0;

function moveleft() { 
  if (loadedyes) {
    if ( parseInt(cross_scroll.style.left)>(menuwidth-actualwidth) ) {
      cross_scroll.style.left=parseInt(cross_scroll.style.left)-scrollspeed+"px"
    }
  }
 
  lefttime = setTimeout(function(){ moveleft() },50);
}

function moveright() { 
  if (loadedyes) {
    if ( parseInt(cross_scroll.style.left)<0 )
      cross_scroll.style.left=parseInt(cross_scroll.style.left)+scrollspeed+"px"
  }
  righttime = setTimeout(function(){ moveright() },50);
}

var actualwidth1 = 0;
function fillup(actualwidth1) {
  cross_scroll = document.getElementById('featured');
  actualwidth = actualwidth1;
  loadedyes=1;
}

function popitup(url) {
  newwindow=window.open(url,'name','top=200,left=400,height=300,width=450');
  if (window.focus) {newwindow.focus()}
  return false;
}

function show_questionbox(id) {

  if(document.ask_question.speakers.selectedIndex == 0) {
    document.getElementById(id).style.display = 'none';
  } else {
    document.getElementById(id).style.display = 'block';
    var dd = document.ask_question.speakers.selectedIndex;
    var ss = document.ask_question.speakers[dd].text; 
    document.getElementById('speaker_name').value = ss;

  }
}

function verify_value() {

  if(document.ask_question.speakers.selectedIndex == 0) {
    alert('Please Select Speakers');
    return false;
  }
  if(document.getElementById('question_desc').value == '') {
    alert('Please enter question description');
    return false;
  }
  
  document.ask_question.submit();
  return true;
}