dedicatedFadeIn = 0;
dedicatedFadeOut = 0;
sharedFadeIn = 0;
sharedFadeOut = 0;

function servicesShared(e) {
  if (e.type == "click") {
    vfhSolution.value = "shared";
    document.getElementById("domains-form").submit()
  } else {
   if (e.type == "mouseover") {
     if (!sharedFadeIn) opacityFadeIn("hosting-shared-image-over", 0);
       sharedFadeIn = 1;
       sharedFadeOut = 0;
     } else {
       setTimeout("if (sharedFadeOut == 1) opacityFadeOut('hosting-shared-image-over', 100); sharedFadeIn = 0;", 1);
       sharedFadeOut = 1;
     }
  }
}

function servicesDedicated(e) {
  if (e.type == "click") {
    vfhSolution.value = "dedicated";
    document.getElementById("domains-form").submit()
  } else {
   if (e.type == "mouseover") {
     if (!dedicatedFadeIn) opacityFadeIn("hosting-dedicated-image-over", 0);
       dedicatedFadeIn = 1;
       dedicatedFadeOut = 0;
     } else {
       setTimeout("if (dedicatedFadeOut == 1) opacityFadeOut('hosting-dedicated-image-over', 100); dedicatedFadeIn = 0;", 1);
       dedicatedFadeOut = 1;
     }
  }
}

function domain () {
  vDomain.value = vDomain.value.replace(/[^a-z0-9.-]+/ig, '')
}

function domainSubmit() {
  document.getElementById("domains-form").submit()
}

function loadEventsHome() {
  loadEvents();

  vShared = document.getElementById("servicesSharedImage");
  vDedicated = document.getElementById("servicesDedicatedImage");
  vDomain = document.getElementById("domain");
  vfhSolution = document.getElementById("domains-form-hosting");
  vfhSubmit = document.getElementById("domains-form-submit");

  AttachEventHandler("hosting-shared-overlay", "click", servicesShared);
  AttachEventHandler("hosting-shared-overlay", "mouseout", servicesShared);
  AttachEventHandler("hosting-shared-overlay", "mouseover", servicesShared);
  AttachEventHandler("hosting-dedicated-overlay", "click", servicesDedicated);
  AttachEventHandler("hosting-dedicated-overlay", "mouseout", servicesDedicated);
  AttachEventHandler("hosting-dedicated-overlay", "mouseover", servicesDedicated);
  AttachEventHandler("domains-form-input", "keychange", domain);
  AttachEventHandler("domains-form-input", "keydown", domain);
  AttachEventHandler("domains-form-input", "keypress", domain);
  AttachEventHandler("domains-form-input", "keyup", domain);
  AttachEventHandler("domains-form-input", "change", domain);
  AttachEventHandler("domains-form-submit", "click", domainSubmit)
}

AttachEventHandler(window, "load", loadEventsHome)
