function byId(id) {
  return document.getElementById(id);
}

function init() {
  byId('about').onmouseover = function() {
    submenu('a');
  }
  byId('packages').onmouseover = function() {
    submenu('p');
  }
  byId('your_industry').onmouseover = function() {
    submenu('yi');
  }
  byId('guide').onmouseover = function() {
    submenu('g');
  }
  byId('contact').onmouseover = function() {
    submenu('c');
  }
  byId('usr').onclick = function() {
    plchldr(byId('usr'), 'username');
  }
  byId('pwd').onclick = function() {
    plchldr(byId('pwd'), 'password');
  }
  byId('usr').onblur = function() {
    plchldr(byId('usr'), 'username');
  }
  byId('pwd').onblur = function() {
    plchldr(byId('pwd'), 'password');
  }
}

function submenu(cat) {
  byId('about_submenu').style.display = 'none';
  byId('packages_submenu').style.display = 'none';
  byId('your_industry_submenu').style.display = 'none';

  switch(cat) {
    case 'a':
      byId('about_submenu').style.display = 'block';
      break;
    case 'p':
      byId('packages_submenu').style.display = 'block';
      byId('packages_submenu').style.margin = '0 0 0 250px';
      break;
    case 'yi':
      byId('your_industry_submenu').style.display = 'block';
      byId('your_industry_submenu').style.margin = '0 0 0 165px';
      break;
  }
}

function showGuide(l, id) {
  arr = l.split(',');
  for(i = 0; i < arr.length; i++) {
    byId(arr[i] + 'a').style.display = 'none';
  }
  byId(id + 'a').style.display = 'block';
}

function guideInit() {
  this.guide = ['Folder', 'CreateFolder', 'ResponseMessage', 'ChangeAutoReplyMessage', 'ChangeAutoReplyMessageViaMobile', 'AddContact', 'AddContactViaExcel', 'CreateGroup', 'MessageContacts', 'MessageGroup', 'MessageOrganization', 'ChangeProfile'];
  list = this.guide.join(',');

  this.gInit = function() {
    for(i = 0; i < this.guide.length; i++) {
      this.setAction(this.guide[i]);
    }
  };

  this.setAction = function(id) {
    byId(id).onclick = function() {
      showGuide(list, id);
    }
  }
    
}

function plchldr(obj, def_val) {
  if(obj.value == def_val) {
    obj.value = '';
    return;
  }
  if(obj.value == '') {
    obj.value = def_val;
    return;
  }
}
