// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults




function showtip(text)
{
    Tip(text, WIDTH, 150, BALLOON, true, ABOVE, true)
}



function popup(url, window_width, window_height)
{
    popup(url, window_width, window_height, 'no')
}

function popup(url, window_width, window_height, scrollbars)
{
    var window_top = (screen.height - window_height) / 2;
    var window_left = (screen.width - window_width) / 2;

    result = window.open(url, '', 
        'width=' + window_width + ',height=' + window_height + 
        ',top=' + window_top + ',left=' + window_left + 
        ',menubar=no,scrollbars=' + scrollbars + ',location=no,status=no,resizable=no');
    result.focus();
}

function go(url)
{
    window.location = url;
    return false;
}


function passwordChanged(pwd) 
{
  var strength = document.getElementById('strength');
  var strongRegex = new RegExp("^(?=.{8,})(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9])(?=.*\\W).*$", "g");
  var mediumRegex = new RegExp("^(?=.{7,})(((?=.*[A-Z])(?=.*[a-z]))|((?=.*[A-Z])(?=.*[0-9]))|((?=.*[a-z])(?=.*[0-9]))).*$", "g");
  var enoughRegex = new RegExp("(?=.{6,}).*", "g");

  if (pwd.value.length==0) {
    strength.innerHTML = '';
  } 
  else if (false == enoughRegex.test(pwd.value)) {
    strength.innerHTML = 'Short';
  } 
  else if (strongRegex.test(pwd.value)) {
    strength.innerHTML = '<span style="color:green">Strong!</span>';
  } 
  else if (mediumRegex.test(pwd.value)) {
    strength.innerHTML = '<span style="color:orange">Medium!</span>';
  } 
  else { 
    strength.innerHTML = '<span style="color:red">Weak!</span>';
  }
}



function disableEnterKey(e)
{
    var key;

    if(window.event) {
      key = window.event.keyCode;     //IE
    }
    else {
      key = e.which;     //firefox
    }

    if(key == 13) {
      return false;
    }
    else {
      return true;
    }
}

function submitenter(form, e)
{
  var keycode;
  if (window.event) keycode = window.event.keyCode;
  else if (e) keycode = e.which;
  else return true;

  if (keycode == 13) {
    form.submit();
    return false;
  }
  else {
     return true;
  }
}

function emailChange()
{
  if (document.f1.email.value.length > 0 && document.f1.email_mobiquus.value.length == 0) {
    document.f1.email_mobiquus.value = document.f1.email.value.replace(/@/, ".")
  }
}

