
/*  */

                /**/
            


jQuery(document).ready(function() {
    jQuery.noConflict();




        jQuery(".OpenDialog").each(function () {   
            jQuery(this).bind("click", function () {
                jQuery(this).next().modal({
                    'onClose': function (dialog) {
                        dialog.data.fadeOut('slow', function () {
                            dialog.container.hide('slow', function () {
                                dialog.overlay.slideUp('slow', function () {
                                    jQuery.modal.close();
                                });
                            });
                        });
                    } 
                });
                return false;
            });    
        });

        jQuery("input[rel='acceptlink']").click(function(){
            id = jQuery(this).attr("id");
            href = jQuery(this).attr("data-link");
            if (jQuery(this).is(':checked')){
                jQuery("a[id='"+id+"']").attr("href",href);
            } else {
                jQuery("a[id='"+id+"']").removeAttr("href");
            }
        });


        




        jQuery(".nobasic").each(function () {     
            jQuery(this).bind("click", function () {
                var tableGrid = jQuery(this).next(".tableGrid").clone();
                jQuery(this).next().next(".modalWindowContainer").html(tableGrid);
                //jQuery(".modalWindowContainer table").tablesorter({
                //    widgets: ['zebra']
                //});
                jQuery(this).next().next(".modalWindowContainer").modal({
                    overlayId: 'TableModalOverlay',
                    containerId: 'TableModalContainer',
                    onShow: function (d) {
                       var sm = this;
                       d.container.css({height:0, width:0}); // reset dimensions
                       sm.setContainerDimensions();
                       jQuery('.simplemodal-wrap').css("overflow","auto");
                       if (parseInt(jQuery('#TableModalContainer').css("height"))<760) {
                           //jQuery('.simplemodal-wrap').css("cssText", "max-height: "+(parseInt(jQuery('#TableModalContainer').css("height"))-40)+"px !important;"+jQuery('.simplemodal-wrap').css("cssText"));
                            jQuery('.simplemodal-wrap').css("cssText", "max-height: "+(parseInt(jQuery('#simplemodal-data').css("height")))+"px !important;"+jQuery('.simplemodal-wrap').css("cssText"));
                            sm.setContainerDimensions();
                       }
                    },
                    'onClose': function (dialog) {
                        dialog.data.fadeOut('slow', function () {
                            dialog.container.hide('slow', function () {
                                dialog.overlay.slideUp('slow', function () {
                                    jQuery.modal.close();
                                    jQuery(".modalWindowContainer").css("display", "none");
                                });
                            });
                        });
                    }
                });
            });        
        });


        jQuery(".nomyTable").tablesorter({
            widgets: ['zebra']
        });

        jQuery('.modalWindowContainer table, .myTable').each(function(){
            jQuery(this).find('tr:even').addClass('even');
            jQuery(this).find('tr:odd').addClass('odd');
        });



                /*
                * if in https mode, change all internal links to http, because only the loginform should use https
                */
                jQuery(document).ready(function(){
                    if (document.location.protocol == "https:") {
                        jQuery('a').each(function(){
                            if(jQuery(this).attr("href")){
                                if (jQuery(this).attr("href").indexOf("/") == 0) {
                                    jQuery(this).attr("href","http://"+document.location.hostname+jQuery(this).attr("href"));
                                }
                            }
                        });
                    }
                });
            


                jQuery(function(){
                    
                });
                jQuery(function(){
                    
                });
            

       
               jQuery("#register").hide();
               jQuery("#login").show();
               jQuery("#showLogin").click(function () {
                   jQuery("#register").hide();
                   jQuery("#login").show();
               });
               jQuery("#vertical_slide").click(function () {
                   jQuery("#login").hide();
                   jQuery("#register").show();
               });       


                var arrowUp;
                var arrowDown;
                var aktuellerArrow;
                
                var toggleStatus = false;
                var arrowUpAll;
                var arrowDownAll;
                var aktuellerArrowAll;

                // Function for Master Toggle

                jQuery('.toggleButtonAll').each(function(){
                    if(jQuery(this).css('display')=='inline'){
                        jQuery('.hideSection').hide();
                    };
                    jQuery(this).bind("click", function () {
                        arrowUpAll = '/files/toggle_hide.png';
                        arrowDownAll = '/files/toggle_show.png';
                        aktuellerArrowAll = jQuery(this).find(".arrow").attr('src');
                        
                        if(toggleStatus == false){
                            jQuery('.hideSection').show();
                            if (aktuellerArrowAll == arrowDownAll){
                                jQuery(this).find(".arrow").attr('src', '/files/toggle_hide.png'); 
                                aktuellerArrowAll = arrowUpAll;
                                jQuery('.toggleButton').find(".arrow").attr('src', '/files/toggle_minus.png');
                                aktuellerArrow = arrowUp;

                            } else{
                                jQuery(this).find(".arrow").attr('src', '/files/toggle_show.png'); 
                                aktuellerArrowAll = arrowDownAll;
                                jQuery('.toggleButton').find(".arrow").attr('src', '/files/toggle_plus.png');
                                aktuellerArrow = arrowDown;
                            };
                            toggleStatus = true;
                        }else{
                            jQuery('.hideSection').hide();
                            if (aktuellerArrowAll == arrowDownAll){
                                jQuery(this).find(".arrow").attr('src', '/files/toggle_hide.png'); 
                                aktuellerArrowAll = arrowUpAll;
                                jQuery('.toggleButton').find(".arrow").attr('src', '/files/toggle_minus.png');
                                aktuellerArrow = arrowUp;
                            } else{
                                jQuery(this).find(".arrow").attr('src', '/files/toggle_show.png'); 
                                aktuellerArrowAll = arrowDownAll;
                                jQuery('.toggleButton').find(".arrow").attr('src', '/files/toggle_plus.png');
                                aktuellerArrow = arrowDown;
                            };
                            toggleStatus = false;
                        }
                    });
                });
                // Function for the Multi-Toggle 
                jQuery(".notoggleButton").each(function () {   
                    if(jQuery(this).css('display')=='inline'){
                        jQuery(this).parent().next().hide();
                    };
                    arrowUp = '/files/toggle_plus.png';
                    arrowDown = '/files/toggle_minus.png';
                    jQuery(this).bind("click", function () {
                        aktuellerArrow = jQuery(this).find(".arrow").attr('src');
                        if (aktuellerArrow == arrowDown){
                            jQuery(this).find(".arrow").attr('src', '/files/toggle_plus.png'); 
                        } else{
                            jQuery(this).find(".arrow").attr('src', '/files/toggle_minus.png'); 
                        };
                        jQuery(this).parent().next().toggle();
                    });
                });


            


        

    jQuery("#registerform input").each(function(){
        if(jQuery(this).attr("required") == "required"){
            jQuery(this).siblings("span").append('<span>*</span>');
        }
    });

    jQuery("#registerform select").each(function(){
        if(jQuery(this).attr("required") == "required"){
            jQuery(this).siblings("span").append('<span>*</span>');
        }
    });

    jQuery("#contact_form input").each(function(){
        if(jQuery(this).attr("required") == "required"){
            jQuery(this).siblings("span").append('<span>*</span>');
        }
    });

});

