/**
 * swissbib Javascript Stuff.
 * @author project swissbib, G�nter Hipler
 * @version 0.1 first prototype
 * */
var swissbibgh = {

    initOnReady: function () {

       swissbibgh.initSelectSortShortList();
        swissbibgh.initLoginForm();


    },

    initSelectSortShortList: function () {
        jQuery("[name=selectedSorting]").bind('change',function (event)
        {

            //it's not possible to call submit on form because TP is missing the name for the forward action??
            //TP needs the following parameter provided by a submit button.
            //<html:submit styleClass="hidden" styleId="changeSortingbutton" property="change_sorting_${currentResultSet.dbIdentifier}">
            //    <jsp:attribute name="value">${igf:getLabel(pageContext, '', 'result.singlehitlistaction.sorting.button')}</jsp:attribute>
            //</html:submit>
            //e.g. change_sorting_4 (4-> databaseID)
            //Therefor the acton has to be triggered by this button using the click event
            //$(".RefineHitListForm").submit();
            $("#changeSortingbutton").click();
        });

        jQuery("[name=selectedHitlistSize]").bind('change',function (event)
        {

            //explanation for this see above
            //$(".RefineHitListForm").submit();
            $("#changeHitListSizebutton").click();
        });

        jQuery("[name=selectedListType]").bind('change',function (event)
        {

            //explanation for this see above
            //$(".RefineHitListForm").submit();
            $("#changeHitListSizebutton").click();
        });



        //change should only be possible because of event bubbling
        //event might be better bind on the select element itself 
        jQuery("#form_notepad_dummy").bind('change',function(event){

             //alert("value hidden: " + $("#hiddenMemorizeSelection")[0].value);
             $("#hiddenMemorizeSelection")[0].value = event.target.value;
             //$("#hiddensaveToListbutton").click();
            //alert("value notepad: " + event.target.value);
            //alert("value hidden: " + $("#hiddenMemorizeSelection")[0].value);
             $("#hiddensaveToListbutton").click();

        });

        jQuery("[name^=dummylistToDelete]").bind('click',function(event){

            

            $("#dummyHiddenMemorizeList")[0].value = this.attributes["listnumber"].nodeValue;
            $("#dummyHiddenDeleteListSubmit").click();

        });

        /*
        currently not used -> Problem with MemorizeBean
        jQuery("#callCurrentMemorizeListFromHitlist").bind('click',function(event){

            var tempselect =  $("[id^=form_notepad_dummy-selectedMemorizeList]")[0].value;
            var tempHref  =  this.attributes["href"].nodeValue;
            var selectedList = tempselect.split("_");
            selectedList = selectedList[1];
            tempHref = tempHref + "&selectedMemorizeList=" + selectedList;

            window.location.href = tempHref;

            //$("#form_notepad_dummy")[0].submit();
            return false;

        });
        */

    },
    initLoginForm: function() {

    }

	
};

jQuery(document).ready(function(){

    swissbibgh.initOnReady();

});
