<!--
var valid_html_elements = "-strong/-b,br,-em/-i, -u,-blockquote,-ol,-ul,-li,span[align|class],font[size|color],p";

var confirm_timeout = null;
var error_big_timeout = null;
var error_timeout = null;

$(document).ready(function() {
    var elements = $('.relnofollow');
    for(i=0; i<elements.length; i++) {
        var newhtml = '<a rel="nofollow"';
        var spans = $(elements[i]).children().filter('span');
        for(j=0; j<spans.length; j++) {
            if($(spans[j]).html() != '') {
                newhtml = newhtml + ' ' + $(spans[j]).attr("class") + '="' + $(spans[j]).html() + '"';
            }
        }
        newhtml = newhtml + '>';
        $(elements[i]).children().filter('span').remove();
        newhtml = newhtml + $(elements[i]).html() + '</a>';
        $(elements[i]).before(newhtml);
        $(elements[i]).remove();
    }
});

function el(id)
{
  var o = document.getElementById(id);
  if(!o || o.id == id) return o;
  o = document.getElementsByName(id);
  for (var i=0; i < o.length; i++)
    if (o[i].id == id) return o[i];
  return null;
}

function showError(e, bAutohide)
{
  if(e == null) return;
  $(e).fadeIn("slow").addClass("error-item");
  if(typeof(bAutohide) != 'undefined' && bAutohide)
  {
    clearTimeout(error_timeout);
    error_timeout = setTimeout(function() { $(e).fadeOut("slow", function() { $(".error-item").removeClass("error-item").addClass("fm-error"); }); }, 10000);
  }
}

function showErrorBig(e, bAutohide)
{
  if(e == null) return;
  $(e).addClass("main-error").show();
  //$(e).fadeIn("slow").addClass("main-error");
  if(typeof(bAutohide) != 'undefined' && bAutohide)
  {
    clearTimeout(error_big_timeout);
    error_big_timeout = setTimeout(function() { $(e).fadeOut("slow", function() { $(".main-error").removeClass("error-item").addClass("fm-error"); }); }, 10000);
  }
}

function hideError(e)
{
  if(e == null) return;
  clearTimeout(error_big_timeout);
  clearTimeout(error_timeout);
  $(e).hide().removeClass("error-item").addClass("fm-error");
}

function showConfirmation(e, bAutohide)
{
  if(e == null) return;
  //$(e).addClass("confirm-error").removeClass("confirm").fadeIn("slow");
  $(e).addClass("confirm-error").removeClass("confirm").show();
  if(typeof(bAutohide) != 'undefined' && bAutohide)
  {
    clearTimeout(confirm_timeout);
    confirm_timeout = setTimeout(function() { $(".confirm-error").fadeOut("slow", function() { $(e).removeClass("confirm-error").addClass("confirm"); }); }, 10000);
  }
}

function showWarning(e)
{
  if(e == null) return;
  e.className = 'EmptyList-show';
}

function hideConfirmation(e)
{
  if(e == null) return;
  clearTimeout(confirm_timeout);
  $(e).hide().removeClass("confirm-show").addClass("confirm");
}

function isTextEmpty(t)
{
  if(t == null) return true;
  var x = trimString(t.value);
  return x == null || x == "" || x.length == 0;
}

function areTextsEmptyOrDifferent(t1, t2)
{
  if(t1 == null || t2 == null) return true;
  var x = trimString(t1.value);
  var y = trimString(t2.value);
  return x == null || y == null || x == "" || x != y;
}

function isSelectionInvalid(s)
{
  if(s == null) return true;
  return s.value == null || s.value == "";
}

function isSelectEmpty(s)
{
  if(s == null) return true;
  return s.options.length == 0;
}

function isEmailInvalid(t)
{
  var r = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+(lan|ac|ad|ae|aero|af|ag|ai|al|am|an|ao|aq|ar|arpa|as|asia|at|au|aw|ax|az|ba|bb|bd|be|bf|bg|bh|bi|biz|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cat|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|com|coop|cr|cu|cv|cx|cy|cz|de|dj|dk|dm|do|dz|ec|edu|ee|eg|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gg|gh|gi|gl|gm|gn|gov|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|im|in|info|int|io|iq|ir|is|it|je|jm|jo|jobs|jp|ke|kg|kh|ki|km|kn|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|mg|mh|mil|mk|ml|mm|mn|mo|mobi|mp|mq|mr|ms|mt|mu|museum|mv|mw|mx|my|mz|na|name|me|nc|ne|net|nf|ng|ni|nl|no|np|nr|nu|nz|om|org|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|pro|ps|pt|pw|py|qa|re|ro|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|so|sr|st|su|sv|sy|sz|tc|td|tel|tf|tg|th|tj|tk|tl|tm|tn|to|tp|tr|travel|tt|tv|tw|tz|ua|ug|uk|um|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yu|za|zm|zw)$/i;
  return !r.test(t.value);
}

function manageIdentifier(element)
{
        if (!element){
                var element = el('Identifier');
        }
}


function tidyEmail(email)
{
        email = trimString(email);
        var parts = email.split("@");
        parts[parts.length-1] = parts[parts.length-1].toLowerCase();
        return parts.join("@");
}

function doesContainEmail(t)
{
  var r = /([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+(lan|ac|ad|ae|aero|af|ag|ai|al|am|an|ao|aq|ar|arpa|as|asia|at|au|aw|ax|az|ba|bb|bd|be|bf|bg|bh|bi|biz|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cat|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|com|coop|cr|cu|cv|cx|cy|cz|de|dj|dk|dm|do|dz|ec|edu|ee|eg|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gg|gh|gi|gl|gm|gn|gov|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|im|in|info|int|io|iq|ir|is|it|je|jm|jo|jobs|jp|ke|kg|kh|ki|km|kn|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|mg|mh|mil|mk|ml|mm|mn|mo|mobi|mp|mq|mr|ms|mt|mu|museum|mv|mw|mx|my|mz|na|name|me|nc|ne|net|nf|ng|ni|nl|no|np|nr|nu|nz|om|org|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|pro|ps|pt|pw|py|qa|re|ro|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|so|sr|st|su|sv|sy|sz|tc|td|tel|tf|tg|th|tj|tk|tl|tm|tn|to|tp|tr|travel|tt|tv|tw|tz|ua|ug|uk|um|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yu|za|zm|zw)/;
  return r.test(t.value);
}

function doesContainURL(t)
{
  var r = /(ftp:\/\/|http:\/\/|https:\/\/)?([\w]+)(\.[\w]+)*(\.ac|\.ad|\.ae|\.aero|\.af|\.ag|\.ai|\.al|\.am|\.an|\.ao|\.aq|\.ar|\.arpa|\.as|\.asia|\.at|\.au|\.aw|\.ax|\.az|\.ba|\.bb|\.bd|\.be|\.bf|\.bg|\.bh|\.bi|\.biz|\.bj|\.bm|\.bn|\.bo|\.br|\.bs|\.bt|\.bv|\.bw|\.by|\.bz|\.ca|\.cat|\.cc|\.cd|\.cf|\.cg|\.ch|\.ci|\.ck|\.cl|\.cm|\.cn|\.co|\.com|\.coop|\.cr|\.cu|\.cv|\.cx|\.cy|\.cz|\.de|\.dj|\.dk|\.dm|\.do|\.dz|\.ec|\.edu|\.ee|\.eg|\.er|\.es|\.et|\.eu|\.fi|\.fj|\.fk|\.fm|\.fo|\.fr|\.ga|\.gb|\.gd|\.ge|\.gf|\.gg|\.gh|\.gi|\.gl|\.gm|\.gn|\.gov|\.gp|\.gq|\.gr|\.gs|\.gt|\.gu|\.gw|\.gy|\.hk|\.hm|\.hn|\.hr|\.ht|\.hu|\.id|\.ie|\.il|\.im|\.in|\.info|\.int|\.io|\.iq|\.ir|\.is|\.it|\.je|\.jm|\.jo|\.jobs|\.jp|\.ke|\.kg|\.kh|\.ki|\.km|\.kn|\.kr|\.kw|\.ky|\.kz|\.la|\.lb|\.lc|\.li|\.lk|\.lr|\.ls|\.lt|\.lu|\.lv|\.ly|\.ma|\.mc|\.md|\.mg|\.mh|\.mil|\.mk|\.ml|\.mm|\.mn|\.mo|\.mobi|\.mp|\.mq|\.mr|\.ms|\.mt|\.mu|\.museum|\.mv|\.mw|\.mx|\.my|\.mz|\.na|\.name|\.me|\.nc|\.ne|\.net|\.nf|\.ng|\.ni|\.nl|\.no|\.np|\.nr|\.nu|\.nz|\.om|\.org|\.pa|\.pe|\.pf|\.pg|\.ph|\.pk|\.pl|\.pm|\.pn|\.pr|\.pro|\.ps|\.pt|\.pw|\.py|\.qa|\.re|\.ro|\.ru|\.rw|\.sa|\.sb|\.sc|\.sd|\.se|\.sg|\.sh|\.si|\.sj|\.sk|\.sl|\.sm|\.sn|\.so|\.sr|\.st|\.su|\.sv|\.sy|\.sz|\.tc|\.td|\.tel|\.tf|\.tg|\.th|\.tj|\.tk|\.tl|\.tm|\.tn|\.to|\.tp|\.tr|\.travel|\.tt|\.tv|\.tw|\.tz|\.ua|\.ug|\.uk|\.um|\.us|\.uy|\.uz|\.va|\.vc|\.ve|\.vg|\.vi|\.vn|\.vu|\.wf|\.ws|\.ye|\.yt|\.yu|\.za|\.zm|\.zw)/;
  return r.test(t.value);
}

function isUrlInvalid(t)
{
  r = /^(https?:\/\/)?[\w-]+([.][\w-]+)+(:[0-9]+)?(\/.*)?$/;
  return !r.test(t.value);
}

function isDateValid(d, m, y)
{
        isIntDateValid(d.value, m.value, y.value);
}

function isIntDateValid(d, m, y)
{
        d = parseInt(d, 10);
        m = parseInt(m, 10);
        y = parseInt(y, 10);
        return d > 0 && (d <= [, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][m] || d == 29 && m == 2 && y % 4 == 0 && (y % 100 > 0 || y % 400 == 0));
}

function doesContainPhoneNumber(t)
{
  r = /\+43|0043|0664|0676|0699|01\/|^0\/|0-|^0[0-8]+/;
  return r.test(t.value);
}

function isRadioGroupChecked(r)
{
  if(r == null) return false;
  if(typeof(r.length) == 'undefined') return r.checked; //only 1 radio in group
  for(i = 0 ; i < r.length ; i++)
    if(r[i].checked) return true;
  return false;
}

function getRadioCheckedValue(r)
{
  if(r == null) return false;
  if(typeof(r.length) == 'undefined') return r.value; //only 1 radio in group
  for(i = 0 ; i < r.length ; i++)
    if(r[i].checked) return r[i].value;
  return false;
}

function isInteger(t)
{
  r = /^[\+\-]?\d+$/;
  return r.test(t.value);
}

function isNonNegativeInteger(t)
{
  if(t == null) return false;
  r = /^\+?\d+$/;
  return r.test(t.value);
}

function isIntegerInvalid(s, min, max)
{
  return !isInteger(s) || s.value < min || s.value > max;
}

function isFloat(t)
{
  if(t == null) return false;
  r = /^[\+\-]?\d*\.*\d*[eE]?[\+\-]?\d*$/;
  return r.test(t.value);
}

function isNonNegativeFloat(t)
{
  if(t == null) return false;
  r = /^\+?\d*\.*\d*[eE]?[\+\-]?\d*$/;
  return r.test(t.value);
}

function isFloatInvalid(s, min, max)
{
  return !isInteger(s) || s.value < min || s.value > max;
}

function isNumber (t)
{
  if(t == null) return false;
  var num = parseFloat(t.value) + '';
  if (t.value != '' + num && t.value != '' + num + '0') return false;
  return true;
}
function hasHTMLTags(t)
{
  if(t == null) return false;
  r = /<[^>]*>/;
  return r.test(t.value);
}

function roundFloat(s, dec)
{
  f = Math.pow(10, dec);
  s.value = Math.round(s.value * f) / f;
}

function trimString(s)
{
  return s.replace(/^\s+/g, '').replace(/\s+$/g, '');
}

function addSelectedToMultiSelect(s, ms, max)
{
  if(s == null || ms == null) return false;
  for(si = 0 ; si < s.length ; si++)
  {
    if(ms.length >= max) return false;
    if(!s.options[si] || !s.options[si].selected) continue;
    for(msi = 0 ; msi < ms.length ; msi++)
      if(ms.options[msi] && s.options[si].text == ms.options[msi].text) return false;
    ms.options[ms.length] = new Option(s.options[si].text, s.options[si].value);
    s.options[si].disabled = true;
    s.options[si].selected = false;
    return true;
  }
  return false;
}

function addValueInMultiSelectToMultiSelect(v, mss, msd, max)
{
  if(mss == null || msd == null) return false;
  for(i = 0 ; i < mss.length ; i++)
          if(mss.options[i].value == v)
              mss.options[i].selected = true;
  addSelectedToMultiSelect(mss, msd, max);
  for(i = 0 ; i < mss.length ; i++)
          if(mss.options[i].value == v)
              mss.options[i].selected = false;
}

function deleteSelectedFromMultiSelect(ms, s)
{
  if(ms == null) return false;
  var bDeleted = false;
  for(i = ms.length - 1 ; i >= 0 ; i--)
    if(ms.options[i] && ms.options[i].selected)
    {
        for(si = 0 ; si < s.length ; si++)
                if(s.options[si].value == ms.options[i].value) s.options[si].disabled = false;
        ms.options[i] = null;
        bDeleted = true;
    }
    return bDeleted;
}

function selectValueInSelect(v, s)
{
  if(s == null) return;
  for(i = 0 ; i < s.length ; i++)
  {
    v1 = "$" + s.options[i].value + "$"
    v2 = "$" + v + "$"
    if(v1 == v2)
    {
      s.options[i].selected = true;
      return;
    }
  }
}

function selectAllInMultiSelect(ms)
{
  if(ms == null) return;
  for(i = 0 ; i < ms.length ; i++)
    ms.options[i].selected = true;
}

function emptySelect(s)
{
  if(s == null) return;
  while(s.length > 0) s.remove(0);
}

function appendToSelect(s, v, t)
{
  if(s == null) return;
  s.options[s.length] = new Option(t, v);
}

function selectValueInRadio(v, r)
{
    if(r == null) return;
        for(i = 0; i < r.length ; i++)
          if(r[i].value == v)
    {
      r[i].checked = true;
      return;
    }
}
function isDateRangeInvalid(startD, startM, startY, endD, endM, endY)
{
  var start = new Date();
  var end = new Date();

  if(startD.value) start.setDate(eval(startD.value));
  if(startM.value) start.setMonth(eval(startM.value) -1);
  if(startY.value) start.setYear(eval(startY.value));

  if(endD.value) end.setDate(eval(endD.value));
  if(endM.value) end.setMonth(eval(endM.value) -1);
  if(endY.value) end.setYear(eval(endY.value));

  return start > end;
}
function isWithinLength(t, l)
{
  if(t == null) return false;
  return (trimString(t.value).length) >= l;
}
function limitLength(field, maxlen)
{
  if(field == null) return;
  if (field.value.length > maxlen)
    field.value = field.value.substring(0, maxlen);
}
function fixFloat(f)
{
  if(/,/.test(f.value)) f.value = f.value.replace(',', '.');
}
function IsMultiSelectValid(CONTROL, iMin, iMax)
{
  if(CONTROL == null) return;
  var iSelected = 0;
  for(var i = 0 ; i < CONTROL.length ; i++)
    if(CONTROL.options[i].selected == true) iSelected++;
  return (iMin == -1 || iSelected >= iMin) && (iMax == -1 || iSelected <= iMax);
}

function isFuture(m, y)
{
  var d = new Date();
  var now = new Date();
  d.setMonth(eval(m.value) -1);
  d.setYear(eval(y.value));
  return d > now;
}

function clean(f)
{
  if(f == null) return;
  f.value = '';
}

function setFocus(e)
{
  if(e == null
  || e.style.display == "none"
  || e.style.visibility == "hidden"
  || e.disabled == true) return;
  e.focus();
}

function setDisplayNone(e)
{
  if(e == null) return;
  e.style.display = "none";
}

function setDisplayBlock(e)
{
  if(e == null) return;
  e.style.display = "block";
}

function popItUp(url, title, height, width) //DO NOT use titles with more than 1 word because ie does not like it for some reason.
{
  var config='height='+height+',width='+width+',toolbar=no,menubar=no,scrollbars=yes,resizable=no,location=no,directories=no,status=no,top=100,left=200';
  var newwindow = window.open(url, title, config);
  if (window.focus) { newwindow.focus() }
    return false;
}

function unescapeHTML(str) //From prototype.js
{
  var div = document.createElement('div');
  div.innerHTML = stripTags(str);
  return div.childNodes[0] ? (div.childNodes.length > 1 ?
  $A(div.childNodes).inject('',function(memo,node){ return memo+node.nodeValue }) :
  div.childNodes[0].nodeValue) : '';
}

function stripTags(str)  //From prototype.js
{
  return str.replace(/<\/?[^>]+>/gi, '');
}

$(document).ready(function() {  //Adds bg-color to active fieldset
    $("input, select, textarea").focus(function() {
        $(this).parents().filter("fieldset:first").addClass("hover-fieldset");
    }).blur(function() {
        $(this).parents().filter("fieldset:first").removeClass("hover-fieldset");
    });
    
    $("form").submit(function() {
        if($(".error:visible, .fm-error:visible, .description-error, .main-error").size() == 0) {
            $("input[type=submit]:not(.nodisable), input[type=image]:not(.nodisable), input[type=button]:not(.nodisable)").attr("disabled", "true");
        }
    });
});

/*
 * Code below is functionality added to jQuery 1.2.2
 */
jQuery.fn.stripTags = function() {
  if (this.length) {
          var text = stripTags($(this).val()).replace(/&nbsp;/gi, ' ');
          $(this).val(text);
        }

        return this;
};

jQuery.validator.addMethod("multiselect", function(value, element) {
    var selected = countMultiSelectedValues(element.id)
    //Element can be a select or a hidden input if there is only one value available.
    //Do not validate value when element is a hidden input.
    return (element.type == 'hidden') || (selected > 0);
});

jQuery.validator.addMethod("greaterThan", function(value, element, param) {
  return value.length==0 || parseInt(value, 10) >= parseInt($(param).val(), 10);
});

function normalizeSearch(t){
  var str = t.Keywords.value;
  t.Keywords.value=str.replace(/^\.+/, "");
  return true;
}

function cleanInvalidChars(input, regex) {
        var newval = $(input).val().replace(regex, '');
        $(input).val(newval.toUpperCase());
}

function highlightOnHover(elements, hoverClass) {
    elements.mouseover(function(event){$(this).addClass(hoverClass);});
    elements.mouseout(function(event){$(this).removeClass(hoverClass);});
}

function addToggleView(list, expandedViewLink, listViewLink, changeFunction) {
    expandedViewLink.parent().show();
    expandedViewLink.click(function(){
        list.removeClass('list-view');
        list.addClass('expanded-view');
        $(this).addClass("active");
        listViewLink.removeClass("active");
        if(changeFunction) {
            changeFunction('expanded-view');
        }
    });
    listViewLink.click(function(){
        list.removeClass('expanded-view');
        list.addClass('list-view');
        $(this).addClass("active");
        expandedViewLink.removeClass("active");
        if(changeFunction) {
            changeFunction('list-view');
        }
    });
}

function setPreferencesCookie(value)
{
    var cookieName = 'user-preferences';
    
    document.cookie = cookieName + "=" + escape(value) + ";path=/";
}

function getPreferencesCookie()
{
    var cookieName = 'user-preferences';

    if (document.cookie.length > 0) {
        c_start=document.cookie.indexOf(cookieName + "=");
        if (c_start != -1) {
            c_start = c_start + cookieName.length + 1;
            c_end = document.cookie.indexOf(";", c_start);
            if (c_end == -1) {
                c_end = document.cookie.length;
            }
            return unescape(document.cookie.substring(c_start, c_end));
        }
    }
    return "";
}

function addUserPreference(name, value) {
    var cookieContent = getPreferencesCookie();
    var userPreferences = cookieContent.split("|");
    var userPreference;
    var updated = false;

    for(i=0; i<userPreferences.length; i++) {
        userPreference = userPreferences[i].split("=");
        if(name == userPreference[0]) {
            userPreferences[i] = name + "=" + value;
            updated = true;
        }
    }
    if(!updated) {
        userPreferences[userPreferences.length] = name + "=" + value;
    }

    cookieContent = userPreferences.join("|");
    setPreferencesCookie(cookieContent);
}

function getUserPreference(name) {
    var cookieContent = getPreferencesCookie();
    var userPreferences = cookieContent.split("|");

    for(i=0; i<userPreferences.length; i++) {
        userPreference = userPreferences[i].split("=");
        if(name == userPreference[0]) {
            return userPreference[1];
        }
    }
    return false;
}

function postToUrl(path, params, method) {
    method = method || "post"; // Set method to post by default, if not specified.

    // The rest of this code assumes you are not using a library.
    // It can be made less wordy if you use one.
    var form = document.createElement("form");
    form.setAttribute("method", method);
    form.setAttribute("action", path);

    for(var key in params) {
        var hiddenField = document.createElement("input");
        hiddenField.setAttribute("type", "hidden");
        hiddenField.setAttribute("name", key);
        hiddenField.setAttribute("value", params[key]);

        form.appendChild(hiddenField);
    }

    document.body.appendChild(form); // Not entirely sure if this is necessary
    form.submit();
}

function postToUrlFromSerializeArray(path, fields, method) {
    method = method || "post"; // Set method to post by default, if not specified.

    // The rest of this code assumes you are not using a library.
    // It can be made less wordy if you use one.
    var form = document.createElement("form");
    form.setAttribute("method", method);
    form.setAttribute("action", path);

    $.each(fields, function(i, field){
        var hiddenField = document.createElement("input");
        hiddenField.setAttribute("type", "hidden");
        hiddenField.setAttribute("name", field.name);
        hiddenField.setAttribute("value", field.value);

        form.appendChild(hiddenField);
    });

    document.body.appendChild(form); // Not entirely sure if this is necessary
    form.submit();
}

function showInputToolTip() {
    tooltip = $(this).siblings('label').children('.tooltip');
    intleftpos = parseInt($(this).outerWidth() + $(this).siblings().outerWidth());
    intleftpad = parseInt($(this).parent().css('padding-left'));
    leftpos = intleftpos + intleftpad + 20 + "px";
    $(tooltip).css("left", leftpos);
    $('.tooltip').hide();
    $(tooltip).show();
}

function hideInputToolTip() {
    $(this).siblings('label').children('.tooltip').hide();
}

function setDescendantZIndex(elements) {
    // Thickbox has z-index >= 100
    init = 99;
    step = 1;
    var zIndexNumber = init;
    elements.each(function() {
        $(this).css('zIndex', zIndexNumber);
        zIndexNumber -= step;
    });
}

function loadInDialog(link, width, height) {
    var dialog = $('<div class="dialog"></div>');
    var width = (!width)?465:width;
    var height = (!height)?270:height;
    dialog.dialog({
		autoOpen: false,
	    closeOnEscape: true,
		title: link.attr('title'),
		modal: true,
		width: width,
		height: height,
        open: function () {
            $(this).load(link.attr('href'));
        }
    });  
    
    
    link.click(function(e) {
        e.preventDefault();
	dialog.dialog('open');
    });
}

function showSalaryMandatory() {
    form = $(this).parents('form');
    visiblePaymentElements = $(form).find("input.salary, select.salary").filter(":visible");
    if(visiblePaymentElements.length > 1 && visiblePaymentElements.filter(':filled').length > 0) {
        $(form).find(".salary-mandatory").show();
    } else {
        $(form).find(".salary-mandatory").hide();
    }
}


