﻿
        var prevTabId = 1;
        function changeTab(id) {
            $("#tab" + prevTabId).hide();
            $(".tab" + prevTabId).css({ 'background': 'url(/images/HomeNew/inactive_tab.jpg) no-repeat', 'color': '#328cc4' });
            $(".tab" + id).css({ 'background': 'url(/images/HomeNew/active_tab.jpg) no-repeat', 'color': '#999999' });
            $("#tab" + id).show();
            prevTabId = id;
        }
        var prevPanel = 'EmailedRecipes';
        function ChangePanel(value) {
            var id = $(value).val();
            $("#" + prevPanel).hide();
            $("#" + id).show();
            prevPanel = id;
        }

        $(document).ready(function() {
            var id = $("#cmdmostPopular").val();
            $("#" + prevPanel).hide();
            $("#" + id).show();
        });

        //    if ((jQuery.browser.msie) & (jQuery.browser.version == 6.0)) {
        //       }
        //        else {
        //             $("#" + prevPanel).slideUp("slow", function() {
        //                $("#" + id).slideDown("slow");
        //             });
        //        }


        var tab_count;
        var tab_interval;
        var tab_timeout;
        var old_tab = 1;
        var imageOldTab = 1;
        var current_tab = 0;
        var paused;
        var userClick;
        $(document).ready(function() {
            ChangeImageSrc(1);
            tab_interval = setInterval(tab_rotate, 7000);


            if (changeStyle == 'true') {
                $(".RightTabWidthHeight").css({ 'float': 'nodne', 'height': 'auto' });
                $(".LeftTabWidthHeight").css({ 'height': 'auto', 'width': 'auto' });
                $(".SidesBorder").css({ 'height': 'auto' });
                $("#BottomSection").css({ 'height': 'auto' });
                $(".AuthorEditor").css({ 'width': 'auto' });
                $("#promotiom1").css({ 'float': 'left' });
                $(".tab1").css({ 'height': '40px' });
                $("#Row3").css({ 'position': 'inherit' });

                NoOfTabs = 7;
                clearInterval(tab_interval);
            }
            tab_count = NoOfTabs;
            for (i = parseInt(tab_count) + 1; i <= 7; i++) {
                //      $("#tabLeftBody" + i).remove();
                //       $("#tabRightBody" + i).remove();
                //     $("#tabMessage" + i).remove();
                //   $("#btn" + i).remove();
            }
            var width
            if ((jQuery.browser.msie) & (jQuery.browser.version == 7.0)) {
                width = (7 - parseInt(tab_count)) * 29 + $("#messages").width();
            }
            else {
                width = (7 - parseInt(tab_count)) * 30 + $("#messages").width();
            }
            $("#messages").css({ 'width': width });


            $("#previous").click(function() {
                clearInterval(tab_interval);
                paused = true;
                if (current_tab == 1)
                    current_tab = parseInt(NoOfTabs) + 1;
                current_tab = current_tab - 1;
                ChangeImageSrc(current_tab);
                $("#btnPause").attr("src", "/images/HomeNew/btnNext.jpg");
                //      tab_timeout = setTimeout(tab_Start, 5000);
            });

            $("#next").click(function() {
                clearInterval(tab_interval);
                paused = true;
                if (current_tab == NoOfTabs)
                    current_tab = 0;
                current_tab = current_tab + 1;
                ChangeImageSrc(current_tab);
                $("#btnPause").attr("src", "/images/HomeNew/btnNext.jpg");
                //       tab_timeout = setTimeout(tab_Start, 5000);
            });

            $("#pause").click(function() {
                if (paused == true) {
                    tab_interval = setInterval(tab_rotate, 7000);
                    paused = false;
                    $("#btnPause").attr("src", "/images/HomeNew/btnPause.jpg");
                }
                else {
                    clearInterval(tab_interval);
                    paused = true;
                    $("#btnPause").attr("src", "/images/HomeNew/btnNext.jpg");
                }
            });

            $(".NumericButtons").click(function() {
                paused = true;
                $("#btnPause").attr("src", "/images/HomeNew/btnNext.jpg");
                userClick = true;
                var tabNumber = parseInt(this.id.substring(3, this.id.length));
                current_tab = tabNumber;
                ChangeImageSrc(tabNumber);
                clearInterval(tab_interval);
            });

        });

        function tab_Start() {
            tab_interval = setInterval(tab_rotate, 7000);
        }

        function tab_rotate() {

            clearInterval(tab_interval);
            if (current_tab > NoOfTabs - 1) {
                current_tab = 0;
            }
            current_tab = current_tab + 1;
            ChangeImageSrc(current_tab);
            tab_interval = setInterval(tab_rotate, 7000);
        }

        function ChangeImageSrc(currentTab) {
            var imageNo;
            var showTabNo;
            var nextTab;

            $("#tabLeftBody" + old_tab).css({ 'display': 'none' }); //.hide();
            $("#tabRightBody" + old_tab).css({ 'display': 'none' }); //.hide();
            $("#tabMessage" + old_tab).css({ 'display': 'none' }); //.hide();

            switch (currentTab) {
                case 1:
                    showTabNo = subimage1Path;
                    if (tab_count >= 2) {
                        nextTab = subimage2Path;
                        $("#tabRightImage" + nextTab).attr("src", image2Path);
                    }
                    $("#lnktabRightImage" + showTabNo).attr("href", Image1URL);
                    if (userClick == true) {
                        $("#tabRightImage" + showTabNo).attr("src", image1Path);
                    }
                    break;
                case 2:
                    showTabNo = subimage2Path;
                    if (tab_count >= 3) {
                        nextTab = subimage3Path;
                        $("#tabRightImage" + nextTab).attr("src", image3Path);
                    }
                    if (userClick == true) {
                        $("#tabRightImage" + showTabNo).attr("src", image2Path);
                    }
                    $("#lnktabRightImage" + showTabNo).attr("href", Image2URL);
                    break;
                case 3:
                    showTabNo = subimage3Path;
                    if (tab_count >= 4) {
                        nextTab = subimage4Path;
                        $("#tabRightImage" + nextTab).attr("src", image4Path);
                    }
                    if (userClick == true) {
                        $("#tabRightImage" + showTabNo).attr("src", image3Path);
                    }
                    $("#lnktabRightImage" + showTabNo).attr("href", Image3URL);
                    break;
                case 4:
                    showTabNo = subimage4Path;
                    if (tab_count >= 5) {
                        nextTab = subimage5Path;
                        $("#tabRightImage" + nextTab).attr("src", image5Path);
                    }
                    if (userClick == true) {
                        $("#tabRightImage" + showTabNo).attr("src", image4Path);
                    }
                    $("#lnktabRightImage" + showTabNo).attr("href", Image4URL);
                    break;
                case 5:
                    showTabNo = subimage5Path;
                    if (tab_count >= 6) {
                        nextTab = subimage6Path;
                        $("#tabRightImage" + nextTab).attr("src", image6Path);
                    }
                    if (userClick == true) {
                        $("#tabRightImage" + showTabNo).attr("src", image5Path);
                    }
                    $("#lnktabRightImage" + showTabNo).attr("href", Image5URL);
                    break;
                case 6:
                    showTabNo = subimage6Path;
                    if (tab_count >= 7) {
                        nextTab = subimage7Path;
                        $("#tabRightImage" + nextTab).attr("src", image7Path);
                    }
                    if (userClick == true) {
                        $("#tabRightImage" + showTabNo).attr("src", image6Path);
                    }
                    $("#lnktabRightImage" + showTabNo).attr("href", Image6URL);
                    break;
                case 7:
                    showTabNo = subimage7Path;
                    if (userClick == true) {
                        $("#tabRightImage" + showTabNo).attr("src", image7Path);
                    }
                    $("#lnktabRightImage" + showTabNo).attr("href", Image7URL);
                    break;
            }

            $("#tabLeftBody" + showTabNo).css({ 'display': 'block' }); //.show();
            $("#tabRightBody" + showTabNo).css({ 'display': 'block' }); //.show();
            $("#tabMessage" + showTabNo).css({ 'display': 'block' }); //.show();
            $("#imgBtn" + imageOldTab).attr("src", "/images/HomeNew/" + imageOldTab + "_inactive.jpg");
            $("#imgBtn" + currentTab).attr("src", "/images/HomeNew/" + currentTab + "_active.jpg");
            old_tab = showTabNo;
            imageOldTab = currentTab;

                 
        }
