var timeout = '';

jQuery(document).ready(function() {
    // Click event on link to open tabs
    jQuery(".rzconfigurator_openlink").click(function(e) {
        e.preventDefault();
        openLightbox();
    });
      
    // Click event on mask
    jQuery(".rzconfigurator_tabs_mask").live("click", function() {
        closeLightbox();
    });  
    
    // Click event on close link
    jQuery(".rzconfigurator_close_link").live("click", function() {
        closeLightbox();
    }); 
    
    // Inactive link
    jQuery("a.inactive_link").live("click", function() {
        return false;
    });
    
    // Click event on overview link
    jQuery(".menue_link_left_1").click(function() {
        // Delete temp config
        jQuery(document.body).removeData("tempConfig");
        jQuery(document.body).removeData("tempProduct");
        
        jQuery(".rzconfigurator_tabs_menue_right a").addClass("inactive_link").removeClass("rzconfigurator_tabs_menue_link");
        
        jQuery(".rzconfigurator_tabs_menue_left").css("width", 138);
        
        jQuery(this).parent().fadeOut("slow", function() {
            jQuery(".rzconfigurator_close_link_wrap").animate({
                "margin-top": "20px"
            }, 500, function() {
                jQuery(".rzconfigurator_tabs_menue_right a").removeClass("inactive_link").addClass("rzconfigurator_tabs_menue_link");                
            });
        }); 
        
        //jQuery("a.option_single_link").removeData();
        //jQuery(".tx-rzconfigurator-pi3").expire();
    });     
    
    // Key event on ESC key
    jQuery(document).keyup(function(event) {
        if(event.keyCode == 27) {
            closeLightbox();
        }
    });       
    
    jQuery(".rzconfigurator_tabs_menue_link").live("click", function() {    
        setTimeout( function() { 
            jQuery(".rzconfigurator_close_link_wrap").stop(true, true);            
            jQuery(".rzconfigurator_close_link_wrap").animate({
                "margin-top": "0"
            }, 500);             
        },500);        
        
        // Remove previous active elements
        jQuery(".rzconfigurator_tabs_menue_right").children().removeClass("menue_active");
        
        // Remove class from container
        jQuery(".rzconfigurator_tabs_content_inner").removeClass("imt_configurator_inner");
        
        // Remove alternate menue and show normal menue again
        jQuery(".rzconfigurator_tabs_menue_right_new").remove();
        jQuery(".rzconfigurator_tabs_menue_right").show();
        
        // Active
        jQuery(this).parent().addClass("menue_active");
        
        var rel = jQuery(this).attr("rel");
        
        // Show overview link
        if(jQuery(this).parent().attr("rel") > 0) {
            jQuery(".rzconfigurator_close_link_wrap").animate({
                "margin-top": "0"
            }, 500, function() {         
                jQuery(".menue_single_left_1").fadeIn("slow"); 
            });
        }
        else {
            jQuery(".menue_single_left_1").fadeOut("slow"); 
        }        
        
        // Empty content
        jQuery(".rzconfigurator_tabs_content_inner_content").empty();
        
        // Add loading icon
        jQuery(".rzconfigurator_tabs_content_inner_content").addClass("loading");
        
        // Clear timeout
        clearTimeout(timeout);           
        
        timeout = setTimeout( function() {     
            jQuery.ajax({
                url: '?eID=tx_rzconfigurator_tabs',
                data: 'rel=' + rel + '&lang=' + lang,
                type: 'POST',        
                success: function(result) {                      
                    // Append result
                    jQuery(".rzconfigurator_tabs_content_inner_content").removeClass("loading").append().html(result).hide();
                    jQuery(".rzconfigurator_tabs_content_inner_content").fadeIn("slow");
                    
                    // CSS handling
                    jQuery(".rzconfigurator_tabs_content_inner_content").attr("class",'').addClass("rzconfigurator_tabs_content_inner_content");
                    jQuery(".rzconfigurator_tabs_content_inner_content").addClass("content_inner_" + rel);
                                        
                    setMaskHeight();
                }   
            });
        },500);
    });
    
    jQuery(".imt_rzconfigurator_information_link").live("click", function(event) {
        event.preventDefault();
                
        jQuery(".rzconfigurator_tabs_content").fadeOut("fast",function() {    
            jQuery(".rzconfigurator_tabs_menue_left").css("width", 146);
            
            // Add class to container
            jQuery(".rzconfigurator_tabs_content_inner").addClass("imt_configurator_inner");

            // Get rel
            var rel = jQuery(".imt_rzconfigurator_information_link").attr("rel");
            var rev = jQuery(".imt_rzconfigurator_information_link").attr("rev"); 

            // Save initial redirectID and product group ID
            jQuery.data(document.body, 'redirectID', rel);  
            jQuery.data(document.body, 'productGroup', rev); 

            // Hide menue
            jQuery(".rzconfigurator_tabs_menue_right").hide();
            jQuery(".rzconfigurator_tabs_menue_right").after('<div class="rzconfigurator_tabs_menue_right_new"></div>');

            // Append configurator
            showLoader();
            getNormalPages(rel, "0");
            userAuth();
            getFirstContent(false,'');
        
            jQuery(".rzconfigurator_tabs_menue_link_configurator").live("click", function(event) {
                event.stopImmediatePropagation();
                
                if(jQuery.data(document.body, "tempConfig")) {
                    var configConfirm = confirm(translator.translate('confirm_tempConfig'));
                }
                
                if(configConfirm || !jQuery.data(document.body, "tempConfig")) {
                    jQuery(document.body).removeData("tempConfig");
                    jQuery(document.body).removeData("tempProduct");
            
                    // Remove saved bookmark in DOM
                    jQuery.data(document.body, 'configID', ''); 

                    // Remove previous active elements
                    jQuery(".rzconfigurator_tabs_menue_right_new").children().removeClass("menue_active");

                    // Active
                    jQuery(this).parent().addClass("menue_active");    

                    // Get rel
                    var rel = jQuery(this).attr("rel");

                    // Empty content
                    jQuery(".rzconfigurator_tabs_content_inner_content").empty();            

                    // Add loading icon
                    jQuery(".rzconfigurator_tabs_content_inner_content").addClass("loading");            

                    // Clear timeout
                    clearTimeout(timeout);               

                    timeout = setTimeout( function() {
                        // Hardcoding of page where product configurator is placed
                        if(rel == 'configurator_page') {
                            getFirstContent(false,'');
                        }

                        else {                    
                            jQuery.ajax({
                                url: '?eID=tx_rzconfigurator_tabs',
                                data: 'getContent=1&page='+ rel,
                                type: 'POST',        
                                success: function(resultContent) {                      
                                    // Append result
                                    jQuery(".rzconfigurator_tabs_content_inner_content").hide().removeClass("loading").append().html(resultContent);   
                                    jQuery(".rzconfigurator_tabs_content_inner_content").fadeIn("slow");   

                                    jQuery.liveReady("#tx-srfeuserregister-pi1-fe_users_form fieldset", function () {
                                        // this is $(document), or the element(s) added
                                        jQuery(this).children("dl").children("dt").children("label").children("span").each(function() {
                                            jQuery(this).parent().parent().next().children().addClass("rzconfigurator-required-field");                  
                                        }); 
                                    });
                                }   
                            }); 
                        }                   
                    }, 500);   
                }
            });
        
            // Login button click event
            jQuery(".imt_rzconfigurator_login_button").live("click", function(event) {
                event.preventDefault();
                event.stopImmediatePropagation();
            
                // Get redirect page id
                var redirectID = jQuery('input[name="redirect_pid"]').val();
            
                var user = jQuery("input#user").val();
                var pass = jQuery("input#pass").val();
            
                loginUser(redirectID, user, pass);
            
                setMaskHeight(); 
            });
        
            // Logout button click event
            jQuery(".configurator_link_right_logout").live("click", function(event) {
                event.stopImmediatePropagation();
            
                jQuery(".rzconfigurator_tabs_content").fadeOut("fast", function() {
                    var redirectID = jQuery.data(document.body, "redirectID");

                    jQuery(".rzconfigurator_tabs_menue_right_new").empty();
                    showLoader();
                    getNormalPages(redirectID, "1");
                    getFirstContent(false,'');  
                });
            
                jQuery(".rzconfigurator_tabs_content").fadeIn("fast");
            });
            
            // User register
            jQuery("input.rzconfigurator-srfeuserregister-pi1-submit").live("click", function(event) {
                event.preventDefault();
                event.stopImmediatePropagation();
                
                // Get form values
                var formValues = jQuery("#tx-srfeuserregister-pi1-fe_users_form").serializeObject();
                
                // Get required form fields
                var requiredFields = jQuery(".rzconfigurator-required-field").serializeObject();
                
                jQuery.ajax({
                    url: '?eID=tx_rzconfigurator_register',
                    data: {
                        formValues: formValues,
                        requiredFields: requiredFields
                    },
                    type: 'POST',        
                    success: function(resultRegister) {                      
                        // Error or user already exists in DB      
                        if(resultRegister == "error" || resultRegister == "already" || resultRegister == "check") {
                            jQuery.ajax({
                                url: '?eID=tx_rzconfigurator_register',
                                data: resultRegister+"=1&lang="+lang,
                                type: 'POST',        
                                success: function(resultError) {      
                                    // Delete previous error message
                                    jQuery("#tx-srfeuserregister-pi1-fe_users_form fieldset").children("legend").children("span").remove();
                                    
                                    // Add error message
                                    jQuery("#tx-srfeuserregister-pi1-fe_users_form fieldset").children("legend").append("<span></span>");
                                    jQuery("#tx-srfeuserregister-pi1-fe_users_form fieldset").children("legend").children("span").css({
                                        "color": "#DF201C",
                                        "font-style": "italic",
                                        "font-weight": "normal",
                                        "margin-left": "5px"
                                    });
                                    jQuery("#tx-srfeuserregister-pi1-fe_users_form fieldset").children("legend").children("span").append(resultError).hide().fadeIn("slow");
                                }
                            });
                        }
                        
                        else {
                            var user = jQuery("input#tx-srfeuserregister-pi1-email").val();
                            var pass = jQuery("input#tx-srfeuserregister-pi1-password").val();
                            var redirectID = jQuery('input[name="redirect_pid"]').val(); 
                            
                            loginUser(redirectID, user, pass);
                        }
                    }   
                }); 
            });

        }); 

        jQuery(".rzconfigurator_tabs_content").fadeIn("fast");
    });
    
    jQuery(".rzconfigurator_tabs_content").fadeIn("fast");

    function loginUser(redirectID, user, pass) {        
        jQuery.ajax({
            url: '?eID=tx_rzconfigurator_login',
            data: 'user='+user+'&pass='+pass,
            type: 'POST',        
            success: function(resultLogin) {                                          
                // Login successfull
                if(resultLogin == 1) {                    
                    // Close lightbox
                    jQuery(".rzconfigurator_tabs_content").fadeOut("fast", function() { 
                        
                        // Remove login
                        jQuery(".rzconfigurator_login_wrapper").fadeOut("slow", function() {
                            jQuery(this).remove();
                        });   
                        
                        // Empty menue
                        jQuery(".rzconfigurator_tabs_menue_right_new").empty();       
                        
                        // Show loader
                        showLoader();
                        
                        // Get content
                        if(jQuery.data(document.body, "tempConfig")) {
                            var newConfig = jQuery.data(document.body, "tempConfig");
                            var tempProduct = jQuery.data(document.body, "tempProduct");
                            
                            jQuery.ajax({
                                url: '?eID=tx_rzconfigurator_tabs',
                                data: 'getContent=1&page=100',
                                type: 'POST',        
                                success: function(result) { 
                                    // Append result
                                    jQuery(".rzconfigurator_tabs_content_inner_content").removeClass("loading").append().html(result).hide(); 
                                    
                                    // Hide infobox
                                    jQuery(".tx-rzconfigurator-pi6").hide();
                                    jQuery(".tx-rzconfigurator-pi6").before('<div class="tx-rzconfigurator-pi6-loading"></div>');                                    
                                    
                                    // Create config
                                    jQuery.ajax({
                                        url: '?eID=tx_rzconfigurator_config',
                                        data: {
                                            config: newConfig,
                                            rev: tempProduct
                                        },
                                        type: 'POST',      
                                        success: function(resultUid) {  
                                            jQuery.ajax({
                                                url: '?eID=tx_rzconfigurator_email',
                                                data: {
                                                    lang: lang,
                                                    resultUid: resultUid                                 
                                                },
                                                type: 'POST',        
                                                success: function(resultMail) {                      
                                                    // Remove temp config
                                                    jQuery(document.body).removeData("tempConfig");
                                                    jQuery(document.body).removeData("tempProduct");
                                                    
                                                    // Get content
                                                    var result = jQuery(".rzconfigurator_tabs_content_inner_content").html();                                                    
                                                    
                                                    // Replace process_numer marker
                                                    var newResult = str_replace("###VORGANGSNUMMER###",resultMail,result);   
                                                    
                                                    // Ajax request infobox
                                                    var url = window.location.href;
                                                    var type = '?type=8002';

                                                    // If there is at least one GET parameter
                                                    url_with_params = url.match(/tx_rzconfigurator_pi1/); 
                                                    url_with_index = url.match(/index.php/); 
                                                    url_with_id = url.match(/id/); 
                                                    if(url_with_params || url_with_index || url_with_id) {
                                                        type = '&type=8002'; 
                                                    }    

                                                    // Make ajax request
                                                    jQuery.ajax({
                                                        url: url + type,
                                                        data: config,
                                                        type: 'POST',        
                                                        success: function(resultInfobox) {     
                                                            jQuery(".tx-rzconfigurator-pi6-loading").hide().remove();
                                                            jQuery(".tx-rzconfigurator-pi6").empty().append().html(resultInfobox).hide().fadeIn("slow");
                                                        }   
                                                    });                                                            
                                                    
                                                    // Empty container and append new content with process number and fade in
                                                    jQuery(".rzconfigurator_tabs_content_inner_content").empty().append().html(newResult).hide();    
                                                    jQuery(".rzconfigurator_tabs_content_inner_content").fadeIn("slow");                                                    
                                                }   
                                            });                                           
                                        }
                                    });

                                    // CSS handling
                                    jQuery(".rzconfigurator_tabs_content_inner_content").attr("class",'').addClass("rzconfigurator_tabs_content_inner_content");
                                    jQuery(".rzconfigurator_tabs_content_inner_content").addClass("content_inner_" + rel);

                                    setMaskHeight();
                                }   
                            });
                        }      
                        else {
                            getFirstContent(false,'');
                        }
                        
                        // Create new menue
                        jQuery.ajax({
                            url: '?eID=tx_rzconfigurator_tabs',
                            data: 'configurator=1&redirect=1&page='+ redirectID,
                            type: 'POST',        
                            success: function(resultPages) {                                         
                                // Save redirectID as data
                                jQuery(document.body).removeData("redirectID");
                                jQuery.data(document.body, 'redirectID', redirectID);

                                // Get json
                                var json = jQuery.parseJSON(resultPages);
   
                                // Count json object elements
                                var jsonCount = getPropertyCount(json);
                                
                                /* Mozilla displays the JSON object in right order, but other browsers don't, so create a reversed array for all browsers except Mozilla [BEGIN] */

                                if (!jQuery.browser.mozilla) {
                                    var arr = [];

                                    // Create array
                                    jQuery.each(json, function (k, v) {
                                        arr.push({
                                            "id": k,
                                            "title": v
                                        });
                                    });    

                                    // Reverse array
                                    json = arr.reverse();
                                }

                                /* Mozilla displays the JSON object in right order, but other browsers don't, so create a reversed array for all browsers except Mozilla [BEGIN] */                                
   
                                var counter = 1;
                                jQuery.each(json, function(k, v) {   
                                    if (!jQuery.browser.mozilla) {
                                        var k = v.id;
                                        var v = v.title;
                                    }                                    
                                    if(counter == 1) {
                                        jQuery(".rzconfigurator_tabs_menue_right_new").append('<div class="rzconfigurator_tabs_menue_single menue_active menue_single_'+ k +'"><a href="javascript:void(0);" class="rzconfigurator_tabs_menue_link_configurator menue_link_'+ k +'" rel="configurator_page">&nbsp;</a></div>');
                                    }
                                    else if(counter == jsonCount) {
                                        jQuery(".rzconfigurator_tabs_menue_right_new").append('<div class="rzconfigurator_tabs_menue_single menue_single_'+ k +' configurator_link_right_wrapper"><a href="javascript:void(0);" class="configurator_link_right_logout">'+ v +'</a></div>');
                                    }
                                    else if(counter == jsonCount-1) {
                                        var username = getUser();
                                        jQuery(".rzconfigurator_tabs_menue_right_new").append('<div class="imt_rzconfigurator_login_notice"><span>'+ v + ' <a href="javascript:void(0);" class="edit_profile" rel="101">' + username +'</a> |</span></div>');
                                        
                                        // Get width
                                        var loginNoticeWidth = jQuery(".imt_rzconfigurator_login_notice").children("span").width();

                                        // Process login notice
                                        jQuery(".imt_rzconfigurator_login_notice").hide().css("left",792-loginNoticeWidth).show();                                        
                                    }
                                    else {
                                        jQuery(".rzconfigurator_tabs_menue_right_new").append('<div class="rzconfigurator_tabs_menue_single menue_single_'+ k +'"><a href="javascript:void(0);" class="rzconfigurator_tabs_text rzconfigurator_tabs_menue_link_configurator menue_link_'+ k +'" rel="'+ k +'">'+ v +'</a></div>');
                                    }
                                                
                                    counter++;
                                });
                            }   
                        });  
                    });    
                        
                    jQuery(".rzconfigurator_tabs_content").fadeIn("fast");
                }
                else if(resultLogin == 0 || resultLogin == 2) {
                    // Get error text
                    var errorDiv = "rzconfigurator_login_status_error";
                    getErrorText(errorDiv);
                }
            }   
        });          
    }

    function userAuth() {
        setTimeout( function() { 
            jQuery.ajax({
                url: '?eID=tx_rzconfigurator_tabs',
                data: 'user_auth=1',
                type: 'POST',        
                success: function(result) {                      
                    // User is logged in
                    if(result == 1) {
                        jQuery(".configurator_link_right_login").removeAttr("class").addClass("configurator_link_right_logout");
                    }

                    // User is not logged in
                    else {
                // Do nothing
                }
                }   
            });   
        }, 500);
    }

});

function getErrorText(errorDiv) {
    var errorText = jQuery("."+errorDiv).text();

    // Change text
    jQuery(".rzconfigurator_login_status").children().fadeOut("slow", function() {                        
        // Add class (red)
        jQuery(".rzconfigurator_login_status").addClass("rzconfigurator_red");                            

        jQuery(this).empty().append(errorText).fadeIn("slow");
    });    
}

function getNormalPages(rel, logout) {
    // Get pages 
    jQuery.ajax({
        url: '?eID=tx_rzconfigurator_tabs',
        data: 'configurator=1&page='+ rel+'&logout='+logout,
        type: 'POST',        
        success: function(result) {                      
            // Get json
            var json = jQuery.parseJSON(result);        

            // Count json object elements
            var jsonCount = getPropertyCount(json);

            /* Mozilla displays the JSON object in right order, but other browsers don't, so create a reversed array for all browsers except Mozilla [BEGIN] */
            
            if (!jQuery.browser.mozilla) {
                var arr = [];

                // Create array
                jQuery.each(json, function (k, v) {
                    arr.push({
                        "id": k,
                        "title": v
                    });
                });    

                // Reverse array
                json = arr.reverse();
            }
            
            /* Mozilla displays the JSON object in right order, but other browsers don't, so create a reversed array for all browsers except Mozilla [BEGIN] */

            var counter = 1;
            jQuery.each(json, function(k, v) {  
                if (!jQuery.browser.mozilla) {
                    var k = v.id;
                    var v = v.title;
                }
                
                if(counter == 1) {
                    jQuery(".rzconfigurator_tabs_menue_right_new").append('<div class="rzconfigurator_tabs_menue_single menue_active menue_single_'+ k +'"><a href="javascript:void(0);" class="rzconfigurator_tabs_menue_link_configurator menue_link_'+ k +'" rel="configurator_page">&nbsp;</a></div>');
                }
                else if(counter == jsonCount) {
                    jQuery(".rzconfigurator_tabs_menue_right_new").append('<div class="rzconfigurator_tabs_menue_single menue_single_'+ k +' configurator_link_right_wrapper"><a href="javascript:void(0);" class="rzconfigurator_tabs_menue_link_configurator configurator_link_right_login menue_link_'+ k +'" rel="'+ k +'">'+ v +'</a></div>');
                }
                else if(counter == jsonCount-1) {
                    var username = getUser();
                    
                    if(username) {
                        jQuery(".rzconfigurator_tabs_menue_right_new").append('<div class="imt_rzconfigurator_login_notice"><span>'+ v + ' <a href="javascript:void(0);" class="edit_profile" rel="101">' + username +'</a> |</span></div>');
                    }
                    
                    else {
                        jQuery(".rzconfigurator_tabs_menue_right_new").append('<div class="rzconfigurator_tabs_menue_single menue_single_'+ k +'"><a href="javascript:void(0);" class="rzconfigurator_tabs_text rzconfigurator_tabs_menue_link_configurator menue_link_'+ k +'" rel="'+ k +'">'+ v +'</a></div>');
                    }
                        
                    // Get width
                    var loginNoticeWidth = jQuery(".imt_rzconfigurator_login_notice").children("span").width();
                        
                    // Process login notice
                    jQuery(".imt_rzconfigurator_login_notice").hide().css("left",791-loginNoticeWidth).show();
                }                    
                else {
                    jQuery(".rzconfigurator_tabs_menue_right_new").append('<div class="rzconfigurator_tabs_menue_single menue_single_'+ k +'"><a href="javascript:void(0);" class="rzconfigurator_tabs_text rzconfigurator_tabs_menue_link_configurator menue_link_'+ k +'" rel="'+ k +'">'+ v +'</a></div>');
                }

                counter++;
            });

            //setMaskHeight();                  
        }   
    });      
}

function getFirstContent(callback,config) {
    // Ajax request
    var url = window.location.href;
    var type = '?type=8000';

    // If there is at least one GET parameter
    url_with_params = url.match(/tx_rzconfigurator_pi1/); 
    url_with_index = url.match(/index.php/); 
    url_with_id = url.match(/id/); 
    if(url_with_params || url_with_index || url_with_id) {
        type = '&type=8000'; 
    }                        

    jQuery.ajax({
        url: url + type,
        data: 'productGroup='+ jQuery.data(document.body, "productGroup"),
        type: 'POST',        
        success: function(resultContent) {                              
            if(callback === true) {
                // Append result
                jQuery(".rzconfigurator_tabs_content_inner_content").append().html(resultContent).hide();                   
                
                bookmarkEdit(config);
            }
            
            else {
                // Append result
                jQuery(".rzconfigurator_tabs_content_inner_content").removeClass("loading").append().html(resultContent).hide();   
                
                // This is the same ajax request as above, to clear the cache. ToDO: Clear cache properly?
                jQuery.ajax({
                    url: url + type,
                    data: 'productGroup='+ jQuery.data(document.body, "productGroup"),
                    type: 'POST',        
                    success: function(resultContent2) {                              
                            // Append result
                            jQuery(".rzconfigurator_tabs_content_inner_content").empty().append().html(resultContent2).hide();  
                            jQuery(".rzconfigurator_tabs_content_inner_content").fadeIn("slow"); 
                        } 
                });                                   
            }
        }   
    });     
}

function getUser() {
    var output;
    jQuery.ajax({
        url: '?eID=tx_rzconfigurator_login',
        data: 'getUser=1',
        type: 'POST',     
        async: false,
        success: function(result) {                      
            // Return result
            output = result;  
        }   
    }); 
    
    return output;
}

function showLoader() {
    // Empty content
    jQuery(".rzconfigurator_tabs_content_inner_content").empty();

    // Add loading icon
    jQuery(".rzconfigurator_tabs_content_inner_content").addClass("loading");    
}

function openLightbox() {        
    // Check if overview link is visible
    if(jQuery(".menue_single_left_1").is(":visible")) {
        jQuery(".rzconfigurator_close_link_wrap").css("margin-top", 0);
    }
    
    // Get document height
    documentHeight = jQuery(document).height();    
    
    var mask = '<div class="rzconfigurator_tabs_mask" style="display:none;height:'+documentHeight+'px;">&nbsp;</div>';
    
    // Add mask
    jQuery('#imt_page').append(mask);
        
    // Fade in mask
    jQuery('.rzconfigurator_tabs_mask').fadeIn('slow');

    // Show content
    jQuery('.rzconfigurator_tabs_content').fadeIn('slow');     
}

function closeLightbox() {
    // Remove mask
    jQuery('.rzconfigurator_tabs_mask').fadeOut('slow', function() {
        jQuery('.rzconfigurator_tabs_mask').remove();
    });

    // Hide content
    jQuery('.rzconfigurator_tabs_content').fadeOut('slow');     
}

function setMaskHeight() {
    jQuery(".rzconfigurator_tabs_mask").css({
        height: 0
    });      
    
    // Get document height
    var documentHeight = jQuery(document).height();   

    // Change mask height
    jQuery(".rzconfigurator_tabs_mask").css({
        height: documentHeight
    });      
}

/* Helper functions BEGIN */

function getPropertyCount(obj) {
    var count = 0,
    key;

    for (key in obj) {
        if (obj.hasOwnProperty(key)) {
            count++;
        }
    }

    return count;
}

// sr_feuser_register function which is not loaded in the lightbox --> error, so therefore an empty function here
function updateForm() {
// Does nothing
}

/* Helper functions END */
