﻿var radioListID;
var textBoxID;



function searchTabSwitch ( tabname )
{
}

function convertResourceLinks()
{
    for( var i=1; i<=2; i++ )
    {
        var shortcutsList = document.getElementById('shortcutsList'+i).getElementsByTagName("a");
        for( var j=0; j<shortcutsList.length; j++ )
        {
            if( shortcutsList[j].attributes.getNamedItem("ext").value == "True" )
                shortcutsList[j].setAttribute("href","http://biblextern.sh.se/login?url=" +shortcutsList[j].href);
        }
    }
}



function formOnSend()
{
    var form = document.getElementById('aspnetForm');
    var radioItemsIDStart = radioListID.substring(0,radioListID.length-1);

    var item0 = document.getElementById( radioItemsIDStart + "0");
    var item1 = document.getElementById( radioItemsIDStart + "1" );
    var item2 = document.getElementById( radioItemsIDStart + "2" );
    if( form != null && item0 != null && item1 != null && item2 != null )
    {
        if( item2.checked )
        {
            try
            {
                document.getElementById('__VIEWSTATE').parentNode.removeChild(document.getElementById('__VIEWSTATE'));
                document.getElementById('__EVENTVALIDATION').parentNode.removeChild(document.getElementById('__EVENTVALIDATION'));
                form.action = "http://www.lb.stockholm.se/cgi-bin/absok.cgi";
                form.acceptCharset = "iso-8859-1";
                var textBox = document.getElementById( textBoxID );
                textBox.name = "text";
            }
            catch( e ) {}
        }
    }	        
}

(function($) {
    
    $.fn.extend({
        moreErrands: function(config) {
            var defaults = {
                fxspeed: 'fast', // speed (String|Number): "slow", "normal", or "fast") or the number of milliseconds to run the animation
                moreLinksText: 'Fler ärenden...',
                title: 'Klicka för att visa fler ärenden'
            };
            var options = $.extend(defaults, config);
            
            $(this).find('li.hide').each(function(i){
                $(this).hide();
            });
            //$(this).after('<h2><a id="moreErrLink">' + options.moreLinksText +'</a></h2>');
            $(this).append('<li id="moreErr" title="' +options.title +'"><a id="moreErrLink">' + options.moreLinksText +'</a></li>');
            $('#moreErrLink').click(function(event){
                $('#errands').find('li.hide').each(function(i){
                    $(this).show(options.fxspeed);
                });
                $('li.hide:first').find('a').focus();
                $('li#moreErr').hide();
                //$(this).hide();
            });
        }
    });
})(jQuery);