emailRegExp = new RegExp(/^([a-zA-Z0-9_\.\-+])+@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,6})+$/);

function getRandom()
{
    return Math.floor(Math.random()*100000);
}

function changeClass(elementId, className)
{
    document.getElementById(elementId).className = className;
}

/**
 * Toggle Blind makes your box blind up or down and applies a correct symbol to
 * the toggler.
 */
function toggleBlind(box, toggler)
{
    if (document.getElementById(box).style.display == 'none') {
        if (document.getElementById(toggler)) document.getElementById(toggler).innerHTML = '&#9660;'; 
        document.getElementById(box).style.display = 'block';
    }
    else {
        if (document.getElementById(toggler)) document.getElementById(toggler).innerHTML = '&#9658;';
        document.getElementById(box).style.display = 'none';
	}
}

function toggleOpen(box, toggler)
{
        if (document.getElementById(toggler)) document.getElementById(toggler).innerHTML = '&#9660;'; 
        document.getElementById(box).style.display = 'block';
}

function toggleClose(box, toggler)
{
        if (document.getElementById(toggler)) document.getElementById(toggler).innerHTML = '&#9658;';
        document.getElementById(box).style.display = 'none';
}

function setAllCheckboxes(form, pattern, checked)
{
    var re = new RegExp(pattern);
    for (var i=0; i < form.elements.length; i++) {
        checkbox = form.elements[i];
        if (typeof(checkbox.name) != 'string') {
            continue;
        }
        if (checkbox.name.match(re)) {
            checkbox.checked = checked;
        }
    }
}

function toggleAllCheckboxes(form, pattern)
{
    var re = new RegExp(pattern);
    var middleValue = (form.elements.length/2);
    var x = 0;
    var y = 0;
    var checked = false;

    for (var i=0; i < form.elements.length; i++) {
        checkbox = form.elements[i];
        if (checkbox.type == 'checkbox') {
            if (checkbox.name.match(re)) {
                if (checkbox.checked) {
                    x++;
                }
                y++;
            }
        }
    }
    if (x == 0) {
    //    alert('if ' + x + ' == 0 then checked');
        checked = true;
    } else if (x == y) {
  //      alert('if ' + x + ' == ' + y + ' then unchecked');
        checked = false;
    } else if (x > middleValue) {
  //      alert('if ' + x + ' > ' + middleValue + ' then checked');
        checked = true;
    } else if (x < middleValue) {
  //      alert('if ' + x + ' < ' + middleValue + ' then unchecked');
        checked = false;
    }

    for (var i=0; i < form.elements.length; i++) {
        checkbox = form.elements[i];
        if (checkbox.type == 'checkbox') {
            if (checkbox.name.match(re)) {
                checkbox.checked = checked
            }
        }
    }
}

function invertAllCheckboxes(form, pattern)
{
    var re = new RegExp(pattern);

    for (var i=0; i < form.elements.length; i++) {
        checkbox = form.elements[i];
        if (typeof(checkbox.name) != 'string') {
            continue;
        }
        if (checkbox.name.match(re)) {
            if (checkbox.checked) {
                checkbox.checked = false;
            } else {
                checkbox.checked = true;
            }
        }
    }
}

function toggleCheckbox(form, pattern, value)
{
    var re = new RegExp(pattern);

    for (var i=0; i < form.elements.length; i++) {
        checkbox = form.elements[i];
        if (typeof(checkbox.name) != 'string') {
            continue;
        }
        if (checkbox.name.match(re)) {
            if (value == 'false') {
                checkbox.checked = false;
            } else {
                checkbox.checked = true;
            }
        }
    }
}

function toggleAllCheckboxesById(form, pattern)
{
	var re = new RegExp(pattern);
    for (var i=0; i < form.elements.length; i++) {
        checkbox = form.elements[i];
        if (typeof(checkbox.id) != 'string') {
            continue;
        }
        if (checkbox.id.match(re)) {
            if (checkbox.checked) {
                checkbox.checked = false;
            } else {
                checkbox.checked = true;
            }
        }
    }
}

/**
 * Works like toggleAllCheckboxesById but also changes the values of the checkboxes
 **/
function toggleAllCheckboxesByIdSetValue(form, pattern, checkedValue, uncheckedValue)
{
	var re = new RegExp(pattern);
    for (var i=0; i < form.elements.length; i++) {
        checkbox = form.elements[i];
        if (typeof(checkbox.id) != 'string') {
            continue;
        }
        if (checkbox.id.match(re)) {
            if (checkbox.checked) {
                checkbox.checked = false;
                checkbox.value = uncheckedValue;
            } else {
                checkbox.checked = true;
                checkbox.value = checkedValue;
                
            }
        }
    }
}

/**
 * switchVisible div hides all DOM nodes in an array except for one
 */
function switchVisibleDiv(visible, collection)
{
    for (var i=0;i<collection.length;i++) {
        if (document.getElementById(collection[i]) != null && typeof(document.getElementById(collection[i])) == 'object' && document.getElementById(collection[i]).style.display != 'none') {
                document.getElementById(collection[i]).style.display = 'none';
        }
    }
    
    if (typeof(visible) == 'object') {
        visible.each(function(div) {
            if (typeof(document.getElementById(div)) == 'object' && document.getElementById(div).style.display == 'none') {
                document.getElementById(div).style.display = 'block';
            }
        });
    }
    if (typeof(visible) == 'string' && document.getElementById(visible) &&  document.getElementById(visible).style.display == 'none') {
        document.getElementById(visible).style.display = 'block';
    }
}

/**
 * Function used to display error messages
 */
function displayError(title, content)
{
    window.scrollTo(0,0);
    var errorDiv = Builder.node('div'); errorDiv.style.display = 'block'
    var errorTitle = Builder.node('h5');
    var errorParagraph = Builder.node('p');
    errorTitle.innerHTML = title;

    errorParagraph.innerHTML = content;
    
    errorDiv.appendChild(errorTitle);
    errorDiv.appendChild(errorParagraph);
    document.getElementById('globalErrorContainerBox').style.display = 'block';
    document.getElementById('globalErrorBox').appendChild(errorDiv);
    if (document.getElementById('globalErrorBox').style.display == 'none') {
        toggleBlind('globalErrorBox', 'toggleGlobalErrorBox');
    }
	//new Effect.BlindDown(errorDiv, {duration: 0.5, queue: 'end'});
    new Effect.Highlight('globalErrorBox', {duration: 0.5, queue: 'end'});
}

function flushErrors()
{
    var container = document.getElementById('globalErrorBox')
    //container.hide(); 
    for (var i = container.childNodes.length - 1; i >= 0; i--) {
        container.removeChild(container.childNodes[i]);
    }
}

/**
 * Convert JSON to string, display 'Ajax error'
 */
function displayAjaxError(t)
{
    try {
        var serverData = eval('(' + t.responseText + ')');
        content = serverData.errorMessage;
        title = '';
        displayError(title, content);
    } catch(e) {
        errorParagraph.innerHTML = t.status + ' -- ' + t.statusText;
    }
}

function moveFile(fileId, folderId)
{
    new Ajax.Request('/file/move/' + fileId, {
        method: 'post',
        postBody: 'folderId=' + folderId,
        onFailure: displayAjaxError,
        on403: displayAjaxError
    });
}

function popupWindow(url, width, height)
{
    window.open(url, '_blank', 'location=no,menubar=no,toolbar=no,status=no,copyhistory=no,width=' + width + ',height=' + height + ',scrollbars=yes');
}

// Given a 9 digit string it will return the 10:th digit of a Swedish personal number
function getPersonalNumberCheckDigit(digits)
{
    var t = 0;
    for (var i = 0; i < digits.length; i++) {
        var n = parseInt(digits.charAt(i)) * ((i % 2 == 0) ? 2 : 1);
        if (n > 9) {
            n = String(n);
            t = t + parseInt(n.charAt(0)) + parseInt(n.charAt(1));
        } else {
            t = t + n;
        }
    }

    t = String(t);

    var retVal = 10 - parseInt(t.charAt(t.length - 1));
    if (retVal >= 10) retVal = 0;
    return retVal;
}

function cloneAndAppend(origObj, containerObj)
{
    var cloneObj = origObj.cloneNode(true);
    cloneObj.style.display = 'block';
    cloneObj.id = null;
    cloneObj.value = '';
    containerObj.appendChild(cloneObj);
}

function ajaxSubmit(form, onSuccessMethod)
{
    var serializedData = Form.serialize(form);
    if (form.method == 'get') {
        new Ajax.Request(form.action + '?' + serializedData, {
            method: 'get',
            onFailure: 'displayAjaxError',
            onSuccess: onSuccessMethod
        });
    } else if (form.method == 'post') {
        new Ajax.Request(form.action, {
            method: 'post',
            postBody: serializedData,
            onFailure: 'displayAjaxError',
            onSuccess: onSuccessMethod
        });
    }
}

function randomPassword(length)
{
    chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
    pass = "";
    for(x=0;x<length;x++)
    {
        i = Math.floor(Math.random() * chars.length);
        pass += chars.charAt(i);
    }
    return pass;
}


function locationChange(element, locationId)
{
    var parentLocationId;
    var parentLocationElement;

    // Remove all location selectors subordinate to the current
    if (element.nextSibling != undefined) {
        element.parentNode.removeChild(element.nextSibling);
    }
    if (element.selectedIndex == 0) { return; }

    parentLocationId = locationId;
    parentLocationElement = element.parentNode;
    new Ajax.Request('/ajax/location/' + locationId, {
        method: 'get',
        onFailure: displayAjaxError,
        onSuccess: function(t) {
            var serverData = eval('(' + t.responseText + ')');
            // Build a new selector
            if (serverData.length > 1) {
                locationSubContainer = Builder.node('div');
                locationList = Builder.node('select', {
                    name: 'location',
                    id: 'location' + parentLocationId,
                    className: 'textarea',
                    onchange: 'locationChange(this, this.value);'
                });
                serverData.each(function(location) {
                    option = Builder.node('option', {value: location.id}, location.name);
                    locationList.appendChild(option);
                });
               locationList.selectedIndex = 0;
               locationSubContainer.appendChild(locationList);
               parentLocationElement.appendChild(locationSubContainer);
               locationList.focus();
            }
        }
    });
}

function checkFreeAlias(textbox, errorTitle, errorText)
{
    var alias = textbox.value;
    new Ajax.Request('/system/checkFreeAlias?alias=' + encodeURIComponent(alias), {
        method: 'get',
        onFailure: displayAjaxError,
        onSuccess: function(t) {
            var serverData = eval('(' + t.responseText + ')');
            if (serverData) {
                textbox.className = 'textarea';
            } else {
                textbox.className = 'required';
                displayError(errorTitle, errorText);
            }
        }
    }); 
}

/*function goodCampaignCode(code)
{
    new Ajax.Request('/system/checkCampaignCode?code=' + encodeURIComponent(code), {
        method: 'get',
        onFailure: displayAjaxError,
        onSuccess: function(t) {
            var serverData = eval('(' + t.responseText + ')');
            if (serverData) {
                textbox.className = 'textarea';
            } else {
                textbox.className = 'required';
                displayError(errorTitle, errorText);
            }
        }
    }); 
}*/

mceCountInstance = false;
function countMceEditorChars(inst) {
    mceCountInstance = inst;
    var textBody = inst.getBody()
    if (textBody.textContent) var text = textBody.textContent;
    if (textBody.innerText) var text = textBody.innerText;
   
    var resultField = document.getElementById('mceCharCounter');
    var length;
    if (text) {
        length = text.length;
    } else {
        length = 0;
    }
    if (document.getElementById('messageSubject')) {
        length += document.getElementById('messageSubject').value.length;
    }
    if (resultField) {
        if (resultField.textContent) resultField.textContent = length;
        if (resultField.innerText) resultField.innerText = length;
    }
    t=setTimeout("countMceEditorChars(mceCountInstance)", 1000);
}

/**
 * Functio to hide a popup element
 * @param {String} el
 */
function hideElement(el){
    document.getElementById(el).style.display='none';
}

/**
 * Function to display a popup element
 * @param {String} id
 * @param {Integer} id
 * @param {DOMObject} el
 */
function displayElement(type, id, el){
    var l = Ext.get(type + '_' + id);
    l.setStyle("display","block");
    if(Ext.isIE){
        l.setStyle("white-space","nowrap");
    }
    l.alignTo(el, "br", [2, -1]);
}

/**
 * Change the display state of a popup element between 'none' and 'block'
 * @param {String} type
 * @param {Integer} id
 * @param {DOMObject} el
 */
function switchDisplayState(type, id, el){
    var l = Ext.get(type + '_' + id);
    if(l.getStyle('display') == 'block'){
        l.setStyle("display","none");
    }else{
        displayPopup(type, id, el);
    }
}

function clearForm(formId) 
{ 
    var form, elements, i, elm;

    form = document.getElementById ? document.getElementById(formId) : document.forms[formId]; 

    if (document.getElementsByTagName) {
        inputs = form.getElementsByTagName('input');
            
        for (i=0, elm;elm=inputs.item(i++);) {
            switch (elm.getAttribute('type')) {
                case 'text': 
                    elm.value = '';
                    break;
            }
        }

        selects = form.getElementsByTagName('select');

        for (i=0, elm;elm=selects.item(i++);) {
            elm.selectedIndex = 0;
        }

    } else {
        elements = form.elements;
        for (i=0, elm; elm=elements[i++]; ) { 
            switch (elm.type) {
                case 'text':
                    elm.value = '';
                    break;
            }
        }
    }
    return true;
}

function noButtonDoubleClick() 
{
    var buttons, inputs, i, elm;

    if (document.getElementsByTagName) {
        buttons = document.getElementsByTagName('button');

        for (i=0, elm; elm=buttons.item(i++);) {
            elm.onclick = "this.disable = true; this.innerHtml = 'Laddar...'";
        }

        inputs = document.getElementsByTagName('input');

        for (i=0, elm;elm=inputs.item(i++);) {
            switch (elm.getAttribute('type')) {
                case 'submit': 
                    elm.onclick = 'this.disable = true; this.value = "Laddar..."';
                    break;
            }
        }

    } 
}

function centerPopup(pageURL, title, width, height) 
{
    var leftPosition = (screen.width/2)-(width/2);
    var topPosition = (screen.height/2)-(height/2);
    var parameters = 'toolbar=no, location=no, directories=no, status=no, scrollbars=no, resizable=no, width=' + width + ', height=' + height + ', top=' + topPosition + ', left=' + leftPosition + ', menubar=no';

    if (navigator.appVersion.indexOf("MSIE")!=-1) {
        title = null;
    }

    window.open (pageURL, title, parameters);
}

/***
 * A JS class that creats a sticky banner, only works in IE7 and above, firefox.
 */
function stickyAdBanner() 
{
    this.layerPosition="fixed";
    this.layerZIndex="999999";
    this.layerX="0px";
    this.layerY="0px";
    this.marginLeftRight=0;
    this.marginTopBottom=0;
    this.ieVersion=0;
    
    this.layerVerticalPosition="BOTTOM";
    this.layerHorizontalPosition="LEFT";
    
    this.layerHeight="100px";
    this.layerWidth="100%";
    
    this.layerName='stickyAdBanner';
    this.className='stickyBottomAd';
    this.data=''

    this.testWindowSize = function() 
    {
        if (document.getElementById(this.fixLayerName) && document.getElementById(this.layerName)) {
            document.body.style.width = "100%";

            var documentHeight=document.documentElement.clientHeight;
            var bodyWidth = document.body.clientWidth;
            var placeAtPosition = documentHeight-(this.layerHeight.substr(0,this.layerHeight.length));

            document.getElementById(this.layerName).style.left = "0px";
            
            document.getElementById(this.layerName).style.top = placeAtPosition+"px";

            document.body.style.height = document.documentElement.clientHeight;
            
            document.getElementById(this.fixLayerName).style.height = placeAtPosition+"px";

            if (bodyWidth < 1000) {
                document.getElementById(this.fixLayerName).style.overflowX = "scroll";
            }
            if (bodyWidth > 1000) {
                document.getElementById(this.fixLayerName).style.overflowX = "hidden";
            
            }
        }                   
    }
    
    this.setData = function(data) 
    {
        this.data = data;
    }
    
    this.setClass = function(className) 
    {
        this.className = 'stickyAdBanner ' + className;
    }

    this.fixLayout = function() 
    {
        document.documentElement.style.overflowY = "hidden";
        if (this.layerVerticalPosition == "BOTTOM") {
            setInterval(this.testWindowSize, 200);
        }
    }

    this.render = function(layerHeight, layerVerticalPosition, layerHorizontalPosition) 
    {     
        this.layerHeight=layerHeight + "px";

        if (layerVerticalPosition) {
            this.layerVerticalPosition=layerVerticalPosition;
        }

        if (layerHorizontalPosition) {
            this.layerHorizontalPosition=layerHorizontalPosition;
        }

        this.layerName=this.layerName + '_' + this.layerVerticalPosition + '_' + this.layerHorizontalPosition;
        this.fixLayerName=this.layerName + '_fix';

        if (this.layerX == "50%") {
            this.marginLeftRight=this.layerWidth/2;
        }
        if (this.layerY == "50%") {
            this.marginTopBottom=this.layerHeight/2;
        }

        if (navigator.appVersion.indexOf("MSIE")!=-1) {
            var sttemp=navigator.appVersion.split("MSIE")
            this.ieVersion=parseFloat(sttemp[1])
        }

        if (this.ieVersion==6.0){
            this.layerPosition="absolute";
            this.fixLayout();
        }
        document.write('<div class="' + this.className + '" id="' + this.layerName + '" style="margin-' + this.layerHorizontalPosition + ':-' + this.marginLeftRight + 'px; margin-' + this.layerVerticalPosition + ':-' + this.marginTopBottom + 'px; overflow: visible; Z-INDEX: ' + this.layerZIndex + '; ' + this.layerHorizontalPosition + ': ' + this.layerX + '; VISIBILITY: visible; POSITION: ' + this.layerPosition + '; ' + this.layerVerticalPosition + ': ' + this.layerY + '; HEIGHT: ' + this.layerHeight + 'px; WIDTH: ' + this.layerWidth + '">');
        document.write(this.data);
        document.write('</div>');
        
        if (this.ieVersion==6.0) {
            document.write('<DIV id=' + this.fixLayerName + ' style="OVERFLOW-Y: scroll; LEFT: 0px; OVERFLOW: auto; WIDTH: 100%; POSITION: absolute; TOP: 0px; HEIGHT: 100%">');
        }    
    }
}

function bottomAdTestWindowSize(layerHeight) {
    if (document.getElementById('adtomasticky') && document.getElementById('stickyBottomAd')) {
        document.body.style.width = "100%";

        var documentWidth=document.documentElement.clientHeight;
        var bodyWidth = document.body.clientWidth;
        var placeBottom = documentWidth-layerHeight;

        document.getElementById("stickyBottomAd").style.left = "0px";
        document.getElementById("stickyBottomAd").style.top = placeBottom+"px";
        document.body.style.height = document.documentElement.clientHeight;
        document.getElementById("adtomasticky").style.height = placeBottom+"px";

        if (bodyWidth < 1000) {
            document.getElementById("adtomasticky").style.overflowX = "scroll";
        }
        if (bodyWidth > 1000) {
            document.getElementById("adtomasticky").style.overflowX = "hidden";
        }
    }
}

function adtFixLayout(layerHeight) {
    document.documentElement.style.overflow = "hidden";
    setInterval('bottomAdTestWindowSize(' + layerHeight + ')', 200);
}

function bottomAdBanner(layerHeight, layerVerticalPosition, layerHorizontalPosition, output, cssClass) {
    var layerPosition="fixed";
    var layerZIndex="999999";
    var layerX="0px";
    var layerY="0px";
    var layerHeight=layerHeight + "px";
    var layerWidth="100%";
    var marginLeftRight=0;
    var marginTopBottom=0;
    var ieVersion=0;

    if (layerX == "50%") {
    var marginLeftRight=layerWidth/2;
    }
    if (layerY == "50%") {
    var marginTopBottom=layerHeight/2;
    }

    if (navigator.appVersion.indexOf("MSIE")!=-1) {
        sttemp=navigator.appVersion.split("MSIE")
            ieVersion=parseFloat(sttemp[1])
    }

    if (ieVersion==6.0){
        var layerPosition="absolute";
        adtFixLayout(layerHeight.substr(0,(layerHeight.length-2)));
    }

    if (output == '') {
        output = "Det finns inget innehåll i bannern";
    }

    document.write('<div class="stickyAdBanner ' + cssClass + '" id="stickyBottomAd" style="margin-' + layerHorizontalPosition + ':-' + marginLeftRight + 'px; margin-' + layerVerticalPosition + ':-' + marginTopBottom + 'px; overflow: visible; Z-INDEX: ' + layerZIndex + '; ' + layerHorizontalPosition + ': ' + layerX + '; VISIBILITY: visible; POSITION: ' + layerPosition + '; ' + layerVerticalPosition + ': ' + layerY + '; HEIGHT: ' + layerHeight + 'px; WIDTH: ' + layerWidth + 'px">');
    document.write(output);
    document.write('</div>');

    if (ieVersion==6.0) {
        document.write('<DIV id=adtomasticky style="OVERFLOW-Y: scroll; LEFT: 0px; OVERFLOW: auto; WIDTH: 100%; POSITION: absolute; TOP: 0px; HEIGHT: 100%">');
    }
}


function openMenuElement(id, alignTo)
{
    element.style.display = 'block';
    element.style.top = (alignTo.offsetTop + alignTo.offsetHeight) + 'px';
    element.style.left = (alignTo.offsetLeft) + 'px';
    Effect.SlideDown(id, {duration: 1.0});
}
function closeMenuElement(id)
{
    Effect.SlideUp(id, {duration: 1.0});
}

function openMenuElementItem(item, alignTo)
{
    element.style.display = 'block';
    element.style.top = (alignTo.offsetTop) + 'px';
    element.style.left = (alignTo.offsetLeft + alignTo.offsetWidth) + 'px';
    Effect.SlideDown(item, {duration: 1.0, scaleX: true, scaleY: true});
}
function closeMenuElementItem(item)
{
    Effect.SlideUp(item, {duration: 1.0, scaleX: true, scaleY: true});
}
// Check if summoned inputs are disabled
function toggleDisabledByName(form, pattern) {
    var re = new RegExp(pattern);
    for (var i=0; i < form.elements.length; i++) {
        person = form.elements[i];
        if (typeof(person.name) != 'string') {
            continue;
        }
        if (person.name.match(re) && !person.name.match(new RegExp('^summon'))) {
            if (!person.disabled) {
                person.disabled = true;
            } else {
                person.disabled = false;
            }
        }
    }
}

function toggleDisabledById(form, pattern) {
    var re = new RegExp(pattern);
    for (var i=0; i < form.elements.length; i++) {
        person = form.elements[i];
        if (typeof(person.id) != 'string') {
            continue;
        }
        if (person.id.match(re) && !person.id.match(new RegExp('sSPersonId'))) {
            if (!person.disabled) {
                person.disabled = true;
            } else {
                person.disabled = false;
            }
        }
    }
}

// Toggle radioboxes
function toggleAllRadioboxes(form, pattern)
{
    var re = new RegExp(pattern);
    for (var i=0; i < form.elements.length; i++) {
        radio = form.elements[i];
        if (typeof(radio.name) != 'string') {
            continue;
        }
        if (radio.id.match(re)) {
            if (!radio.checked) {
                radio.checked = true;
            }
        }
    }
}


function checkIfChecked(form, pattern)
{
    var re = new RegExp(pattern);
    var checked = false;

    for (var i=0; i < form.elements.length; i++) {
        checkbox = form.elements[i];
        if (checkbox.type == 'checkbox') {
            if (checkbox.name.match(re)) {
                if (checkbox.checked) {
                    return true;
                }
            }
        }
    }
    return false;
}

function checkDubbleIfChecked(form, pattern, pattern2)
{
    var re = new RegExp(pattern);
    var re2 = new RegExp(pattern2);
    var checked = false;

    for (var i=0; i < form.elements.length; i++) {
        checkbox = form.elements[i];
        if (checkbox.type == 'checkbox') {
            if (checkbox.name.match(re)) {
                if (checkbox.checked) {
                    matchThis = checkbox.name.replace(/[^0-9]/g, '');
                    for (var x=0; x < form.elements.length; x++) {
                        checkbox2 = form.elements[x];
                        if (checkbox2.type == 'checkbox') {
                            if (checkbox2.name.match(re2)) {
                                if (checkbox2.checked) {
                                    if (checkbox2.name.replace(/[^0-9]/g, '') == matchThis) {
                                        return true;
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    return false;
}

function lokActivityHasLeader(form)
{
    if (document.getElementById("lok_activity").checked) {
        if (checkIfChecked(form, '^participated')) {
            if (checkDubbleIfChecked(form, '^participated', '^leader')) {
                return true
            } else {
                alert("Du måste markera minst en Ledare för att registrera en LOK-händelse.");
                return false;
            }
        }
    }
    // No summons
    return true;
}
