$(document).ready(function() {
    var currentUrl = $.url.attr("source");
    var selectedUrl = $.url.setUrl(currentUrl).segment(0);
    $("div.global-top-menu a").removeClass('selected');
    $("div.global-top-menu a[href*='" + selectedUrl + "']").addClass('selected');
    $("div.global-top-menu a[href*='" + selectedUrl + "']").attr('href', '#DomainServices');

    $("table.data").tablesorter({ widthFixed: false, widgets: ['zebra'], headers: { 0: { sorter: false }, 1: { sorter: false }, 2: { sorter: false }, 3: { sorter: false }, 4: { sorter: false }, 5: { sorter: false }, 6: { sorter: false }, 7: { sorter: false }, 8: { sorter: false }, 9: { sorter: false }, 10: { sorter: false}} });
    $("a.modalbox").fancybox({
        'type': 'ajax'
    });
    $("a.modalbox-swf").fancybox({
        'type': 'swf'
    });
    if ($('span.image').html() != null) {
        $('span.image').each(function(i) {
            this.id = 'ImagePreview' + i;
            var ImgHeight = ($('#' + this.id + '.image img').height()) + 10;
            var ImgWidth = $('#' + this.id + '.image img').width();
            $('#' + this.id + '.image').append('<span>' + $('#' + this.id + ' img').attr("alt") + '</span>');
            $('#' + this.id + '.image span').attr('style', 'margin-top:' + ImgHeight + 'px; width: ' + ImgWidth + 'px;');
        });
    }

    $('ul#faqList').simpleFAQ({
        data: faqs,
        allowSearch: true,
        searchNode: '#faqSearch',
        minSearchScore: 0.5
    })
    $('#simpleFAQSearch').keyup(function(jQEvent, results) {
        // If the user has no search query, show all results
        if (this.value.length < 1) {
            $('.simpleFAQ').show();
        }
    });
    $('.simpleFAQ').show();


    $("span.image[rel=preview] img").click(function() {
        ImageSrc = this.src.replace(new RegExp("-small", "i"), '-larg');
        ImageTitle = this.alt;
        $.fancybox({
            'padding': 0,
            'autoScale': true,
            'transitionIn': 'elastic',
            'transitionOut': 'fade',
            'overlayColor': '#000',
            'overlayOpacity': 0.7,
            'title': ImageTitle,
            'href': ImageSrc,
            'type': 'image',
            'titlePosition': 'inside'
        });
        return false;
    });



    //=============================================================================/
    //==================[VPS]============================================/
    //=============================================================================/

    var clientsalespagelinkVPS = '/VPS/VPS';
    // array : CPU Core , CPU Speed , RAM , HDD , BW , OS-1 , OS-2 , OS-3 , Price , Order id , Desc  /
    var VPS_plane = [16];
    VPS_plane[0] = [1, 2.66, 256, 10, 100, 'CentOS Linux 5.4', '', '', 19000, 1, '* Microsoft Windows 32-bit / 64-bit R2 edition'];
    VPS_plane[1] = [1, 2.66, 512, 20, 200, 'Windows Server 2003<span class="sup">*</span>', 'CentOS Linux 5.4', '', 29000, 2, '* Microsoft Windows 32-bit / 64-bit R2 edition'];
    VPS_plane[2] = [1, 2.66, 768, 30, 300, 'Windows Server 2003<span class="sup">*</span>', 'CentOS Linux 5.4', '', 39000, 3, '* Microsoft Windows 32-bit / 64-bit R2 edition'];
    VPS_plane[3] = [1, 2.66, 1024, 40, 400, 'Windows Server 2003<span class="sup">*</span>', 'CentOS Linux 5.4', '', 49000, 4, '* Microsoft Windows 32-bit / 64-bit R2 edition'];
    VPS_plane[4] = [2, 5.32, 1280, 50, 500, 'Windows Server 2008<span class="sup">*</span>', 'Windows Server 2003<span class="sup">*</span>', 'CentOS Linux 5.4', 59000, 5, '* Microsoft Windows 32-bit / 64-bit R2 edition'];
    VPS_plane[5] = [2, 5.32, 1536, 60, 600, 'Windows Server 2008<span class="sup">*</span>', 'Windows Server 2003<span class="sup">*</span>', 'CentOS Linux 5.4', 69000, 6, '* Microsoft Windows 32-bit / 64-bit R2 edition'];
    VPS_plane[6] = [2, 5.32, 1792, 70, 700, 'Windows Server 2008<span class="sup">*</span>', 'Windows Server 2003<span class="sup">*</span>', 'CentOS Linux 5.4', 79000, 7, '* Microsoft Windows 32-bit / 64-bit R2 edition'];
    VPS_plane[7] = [2, 5.32, 2048, 80, 800, 'Windows Server 2008<span class="sup">*</span>', 'Windows Server 2003<span class="sup">*</span>', 'CentOS Linux 5.4', 89000, 8, '* Microsoft Windows 32-bit / 64-bit R2 edition'];
    VPS_plane[8] = [3, 7.99, 2304, 90, 900, 'Windows Server 2008<span class="sup">*</span>', 'Windows Server 2003<span class="sup">*</span>', 'CentOS Linux 5.4', 99000, 9, '* Microsoft Windows 32-bit / 64-bit R2 edition'];
    VPS_plane[9] = [3, 7.99, 2560, 100, 1000, 'Windows Server 2008<span class="sup">*</span>', 'Windows Server 2003<span class="sup">*</span>', 'CentOS Linux 5.4', 109000, 10, '* Microsoft Windows 32-bit / 64-bit R2 edition'];
    VPS_plane[10] = [3, 7.99, 2816, 110, 1100, 'Windows Server 2008<span class="sup">*</span>', 'Windows Server 2003<span class="sup">*</span>', 'CentOS Linux 5.4', 119000, 11, '* Microsoft Windows 32-bit / 64-bit R2 edition'];
    VPS_plane[11] = [3, 7.99, 3072, 120, 1200, 'Windows Server 2008<span class="sup">*</span>', 'Windows Server 2003<span class="sup">*</span>', 'CentOS Linux 5.4', 129000, 12, '* Microsoft Windows 32-bit / 64-bit R2 edition'];
    VPS_plane[12] = [4, 10.65, 3328, 130, 1300, 'Windows Server 2008<span class="sup">*</span>', 'Windows Server 2003<span class="sup">*</span>', 'CentOS Linux 5.4', 139000, 13, '* Microsoft Windows 32-bit / 64-bit R2 edition'];
    VPS_plane[13] = [4, 10.65, 3584, 140, 1400, 'Windows Server 2008<span class="sup">*</span>', 'Windows Server 2003<span class="sup">*</span>', 'CentOS Linux 5.4', 149000, 14, '* Microsoft Windows 32-bit / 64-bit R2 edition'];
    VPS_plane[14] = [4, 10.65, 3840, 150, 1500, 'Windows Server 2008<span class="sup">*</span>', 'Windows Server 2003<span class="sup">*</span>', 'CentOS Linux 5.4', 159000, 15, '* Microsoft Windows 32-bit / 64-bit R2 edition'];
    VPS_plane[15] = [4, 10.65, 4098, 160, 1600, 'Windows Server 2008<span class="sup">*</span>', 'Windows Server 2003<span class="sup">*</span>', 'CentOS Linux 5.4', 169000, 16, '* Microsoft Windows 32-bit / 64-bit R2 edition'];


    $.ajaxSetup({
        cache: true
    });


    $("#slider").slider({
        animate: 'true',
        min: 0,
        max: 15,
        step: 1,
        value: 0,
        range: 'min',

        stop: function(event, ui) {
            //            $("#result")
            //            $('#CPUCore').text(VPS_plane[ui.value][0]);
            //            $('#CPUSPEED').text(VPS_plane[ui.value][1]);
            //            $('#RAM').text(VPS_plane[ui.value][2]);
            //            $('#Storage').text(VPS_plane[ui.value][3]);
            //            $('#Bandwidth').text(VPS_plane[ui.value][4]);
            //            $('#OS1').html(VPS_plane[ui.value][5]);
            //            $('#OS2').html(VPS_plane[ui.value][6]);
            //            $('#OS3').html(VPS_plane[ui.value][7]);
            //            $('#PRICE').text(VPS_plane[ui.value][8]);
            //            $('#ORDERLINK').attr('href', clientsalespagelink + VPS_plane[ui.value][9]);
            //            $('#DESC').text(VPS_plane[ui.value][10]);
        },

        slide: function(event, ui) {

            $("#result")
            $('#CPUCore').text(VPS_plane[ui.value][0]);
            $('#CPUSPEED').text(VPS_plane[ui.value][1]);
            $('#RAM').text(VPS_plane[ui.value][2]);
            $('#Storage').text(VPS_plane[ui.value][3]);
            $('#Bandwidth').text(VPS_plane[ui.value][4]);
            $('#OS1').html(VPS_plane[ui.value][5]);
            $('#OS2').html(VPS_plane[ui.value][6]);
            $('#OS3').html(VPS_plane[ui.value][7]);
            $('#PRICE').text(VPS_plane[ui.value][8]);
            $('#ORDERLINK').attr('href', clientsalespagelinkVPS + VPS_plane[ui.value][9] + '.html');
            $('#DESC').text(VPS_plane[ui.value][10]);


            for (var y = 0; y <= ui.value; y++) {
                if (y >= 12) {
                    $("li.node-" + (y + 1)).addClass("power");
                    $(".curent-title").text("Enterprise");
                }
                else if (y >= 4 && y <= 7) {
                    $("li.node-" + (y + 1)).addClass("normal");
                    $(".curent-title").text("Developer");
                }
                else if (y >= 0 && y <= 3) {
                    $("li.node-" + (y + 1)).addClass("active");
                    $(".curent-title").text("Starter");
                }
                else if (y >= 8 && y <= 11) {
                    $("li.node-" + (y + 1)).addClass("high");
                    $(".curent-title").text("Business");
                }
            }
            for (var y = ui.value + 1; y <= 16; y++) {
                $("li.node-" + (y + 1)).removeClass("active");
                $("li.node-" + (y + 1)).removeClass("normal");
                $("li.node-" + (y + 1)).removeClass("high");
                $("li.node-" + (y + 1)).removeClass("power");
            }
        }
    });




    //=============================================================================/
    // Reseller
    //=============================================================================/
    var ajax_load_default = "<div class='loader'></div>";
    var clientsalespagelink = '/ResellerPanel/pricelist-';
    var loadUrlResellerPlatformfeature = "/ResellerPanel/ResellerPlatformfeature-"
    var windows_reseller_plane = [11];
    // array : HDD , Domain , Database , IP Address , Banwidth , Nameserver Price , Price , WHMCS id //
    windows_reseller_plane[0] = [2, 20, 10, 1, 20, 20000, 25000, 11, ''];
    windows_reseller_plane[1] = [4, 40, 20, 1, 40, 20000, 30000, 12, ''];
    windows_reseller_plane[2] = [6, 60, 30, 2, 60, 15000, 35000, 13, ''];
    windows_reseller_plane[3] = [8, 80, 40, 2, 80, 15000, 40000, 14, ''];
    windows_reseller_plane[4] = [10, 100, 50, 3, 100, 0, 45000, 15, ''];
    windows_reseller_plane[5] = [12, 120, 60, 3, 120, 0, 50000, 16, ''];
    windows_reseller_plane[6] = [14, 140, 70, 4, 140, 0, 55000, 17, ''];
    windows_reseller_plane[7] = [16, 160, 80, 4, 160, 0, 60000, 18, ''];
    windows_reseller_plane[8] = [18, 180, 90, 5, 180, 0, 65000, 19, ''];
    windows_reseller_plane[9] = [20, 200, 100, 5, 200, 0, 70000, 20, ''];
    windows_reseller_plane[10] = [30, 'UNLIMITED', 200, 6, 300, 0, 100000, 21, ''];

    var linux_reseller_plane = [11];
    linux_reseller_plane[0] = [2, 20, 10, 1, 20, 20000, 20000, 31, ''];
    linux_reseller_plane[1] = [4, 40, 20, 1, 40, 20000, 25000, 32, ''];
    linux_reseller_plane[2] = [6, 60, 30, 2, 60, 15000, 30000, 33, ''];
    linux_reseller_plane[3] = [8, 80, 40, 2, 80, 15000, 35000, 34, ''];
    linux_reseller_plane[4] = [10, 100, 50, 3, 100, 0, 40000, 35, ''];
    linux_reseller_plane[5] = [12, 120, 60, 3, 120, 0, 45000, 36, ''];
    linux_reseller_plane[6] = [14, 140, 70, 4, 140, 0, 50000, 37, ''];
    linux_reseller_plane[7] = [16, 160, 80, 4, 160, 0, 55000, 38, ''];
    linux_reseller_plane[8] = [18, 180, 90, 5, 180, 0, 60000, 39, ''];
    linux_reseller_plane[9] = [20, 200, 100, 5, 200, 0, 65000, 40, ''];
    linux_reseller_plane[10] = [30, 'UNLIMITED', 200, 6, 300, 0, 90000, 41, ''];


    $('a.switch-os').click(function() {
        $('#ResellerType').val($(this).text());

        $('a.switch-os').removeClass("selected-windows");
        $('a.switch-os').removeClass("selected-linux");
        $(this).addClass("selected-" + $('#ResellerType').val());
        $('#reseller-feature-slider').attr('class', 'reseller-' + $('#ResellerType').val());

        if ($('#ResellerType').val() == 'windows') {
            $('#PRICE').text(windows_reseller_plane[$('#CurrentStep').val() - 1][6] + ' T');
            $('#ORDERLINK').attr('href', clientsalespagelink + windows_reseller_plane[$('#CurrentStep').val() - 1][7] + '.html');
        } else {
            $('#PRICE').text(linux_reseller_plane[$('#CurrentStep').val() - 1][6] + ' T');
            $('#ORDERLINK').attr('href', clientsalespagelink + linux_reseller_plane[$('#CurrentStep').val() - 1][7] + '.html');
        };
        $('#reseller-feature-tabs')
            .html(ajax_load_default)
            .load(loadUrlResellerPlatformfeature + $('#ResellerType').val() + ".html");
    });

    $('#reseller-feature-tabs')
                .html(ajax_load_default)
                .load(loadUrlResellerPlatformfeature + $('#ResellerType').val() + ".html", function() {
					$("#tabs").tabs().addClass('ui-tabs-vertical ui-helper-clearfix');
					$("#tabs li").removeClass('ui-corner-top').addClass('ui-corner-left');
					$(".modalbox-body").attr('style', 'margin: 0px !important;');
				});
    $("#reseller-slider").slider({
        animate: 'true',
        min: 0,
        max: 10,
        step: 1,
        value: 0,
        range: 'min',

        stop: function(event, ui) {
            $("#reseller-result")

            if ($('#ResellerType').val() == 'windows') {
                $('#HDD').text(windows_reseller_plane[ui.value][0]);
                $('#DOMAIN').text(windows_reseller_plane[ui.value][1]);
                if ($('#DOMAIN').text() == 'UNLIMITED') {
                    $('#DOMAIN').css('font-size', '15px');
                } else {
                    $('#DOMAIN').css('font-size', '19px');
                };
                $('#DB').text(windows_reseller_plane[ui.value][2]);
                $('#IP').text(windows_reseller_plane[ui.value][3]);
                $('#BW').text(windows_reseller_plane[ui.value][4]);
                if (windows_reseller_plane[ui.value][5] != 0) {
                    $('#PNS').text('Optional');
                    $('#PNSprice').text(windows_reseller_plane[ui.value][5] + 'T one time');
                } else {
                    $('#PNS').text('Free');
                    $('#PNSprice').text('');
                };
                $('#PRICE').text(windows_reseller_plane[ui.value][6] + ' T');
                $('#ORDERLINK').attr('href', clientsalespagelink + windows_reseller_plane[ui.value][7] + '.html');
                $('#DESC').text(windows_reseller_plane[ui.value][8]);
            } else {
                $('#HDD').text(linux_reseller_plane[ui.value][0]);
                $('#DOMAIN').text(linux_reseller_plane[ui.value][1]);

                if ($('#DOMAIN').text() == 'UNLIMITED') {
                    $('#DOMAIN').css('font-size', '15px');
                } else {
                    $('#DOMAIN').css('font-size', '19px');
                };

                $('#DB').text(linux_reseller_plane[ui.value][2]);
                $('#IP').text(linux_reseller_plane[ui.value][3]);
                $('#BW').text(linux_reseller_plane[ui.value][4]);
                if (linux_reseller_plane[ui.value][5] != 0) {
                    $('#PNS').text('Optional');
                    $('#PNSprice').text(linux_reseller_plane[ui.value][5] + 'T one time');
                } else {
                    $('#PNS').text('Free');
                    $('#PNSprice').text('');
                };
                $('#PRICE').text(linux_reseller_plane[ui.value][6] + ' T');
                $('#ORDERLINK').attr('href', clientsalespagelink + linux_reseller_plane[ui.value][7] + '.html');
                $('#DESC').text(linux_reseller_plane[ui.value][8]);
            };
        },

        slide: function(event, ui) {
            $("#CurrentStep").val(ui.value + 1);
            for (var y = 0; y <= ui.value; y++) {
                if (y >= 0 && y <= 3) {
                    $("li.node-" + (y + 1)).addClass("active");
                    $(".curent-title").text("Starter Reseller");
                }
                else if (y >= 4 && y <= 7) {
                    $("li.node-" + (y + 1)).addClass("normal");
                    $(".curent-title").text("Budget Reseller");
                }
                else if (y >= 8 && y <= 10) {
                    $("li.node-" + (y + 1)).addClass("high");
                    $(".curent-title").text("Premium Reseller");
                }
            }
            for (var y = ui.value + 1; y <= 11; y++) {
                $("li.node-" + (y + 1)).removeClass("active");
                $("li.node-" + (y + 1)).removeClass("normal");
                $("li.node-" + (y + 1)).removeClass("high");
                $("li.node-" + (y + 1)).removeClass("power");
            }
        }
    });




    // Top Menu Navigation Fix
    //=================================================
    $('.radmenu').mouseout(function() {
        $('li.item').attr('style', 'z-index: 10');
    });


    // Dedicated Server tabs Configuration
    //==============================================
    if ($('div.dedicated-server-tab-btn').text() != "") {
        $('div.dedicated-server-tab-btn').tabs({
            fx: { opacity: 'toggle' },
            idPrefix: 'dedicated-server-tab-btn',
            spinner: 'Retrieving data...',
            collapsible: false,
            event: 'click'
        });
    };


    // Equal Heights Plugin
    // Equalize the heights of elements. Great for columns or any elements
    // that need to be the same size (floats, etc).
    // Version 1.0
    // Updated 12/10/2008
    // Copyright (c) 2008 Rob Glazebrook (cssnewbie.com) 
    //================================================================
    $.fn.equalHeights = function(minHeight, maxHeight) {
        tallest = (minHeight) ? minHeight : 0;
        this.each(function() {
            if ($(this).height() > tallest) {
                tallest = $(this).height();
            }
        });
        if ((maxHeight) && tallest > maxHeight) tallest = maxHeight;
        return this.each(function() {
            $(this).height(tallest).css("overflow", "auto");
        });
    };



    // Home Page menu
    //===========================================================
    $('ul.home-header-menu > li').hover(
        function() {
            var $this = $(this);
            $('div.menu-body', $this).stop(true, true).animate({
                'bottom': '0px'
            }, 100);
            $('i', $this).stop(true, true).animate({
                'top': '-35px'
            }, 200);
        },
        function() {
            var $this = $(this);
            $('div.menu-body', $this).stop(true, true).animate({
                'bottom': '-123px'
            }, 300);
            $('i', $this).stop(true, true).animate({
                'top': '0px'
            }, 400);
        }
    );

    // Domain Price Box Tabs
    //===========================================================

    $('table.price-list-table tbody tr:odd').addClass('odd-tr');

    //When page loads...
    $(".tab_content").hide(); //Hide all content
    $("ul.tabs li:first").addClass("active").show(); //Activate first tab
    $(".tab_content:first").show(); //Show first tab content

    //On Click Event
    $("ul.tabs li").click(function() {

        $("ul.tabs li").removeClass("active"); //Remove any "active" class
        $(this).addClass("active"); //Add "active" class to selected tab
        $(".tab_content").hide(); //Hide all tab content

        var activeTab = $(this).find("a").attr("href"); //Find the href attribute value to identify the active tab + content
        $(activeTab).fadeIn(); //Fade in the active ID content
        return false;
    });


    //currency formater
    //====================================================
    $('.price').currency({ s: ",", d: ".", c: 0 });

    //===[Corner Rounder]==========================


    // Site Map Corner
    //===========================================
    $('.site-map').corner("round 8px").parent().css('padding', '10px').corner("round 10px")



    // Graphical Ordered List
    //==========================================================
    $("#SimpleNumbering>li").each(function(i) {
        i = i + 1;
        $(this).addClass("item" + i);
    });

    // Live support Popup window
    //=======================================================================
    $('.livePopup').popupWindow({
        windowURL: 'http://support.mizban.net/visitor/index.php?_m=livesupport&_a=startclientchat&sessionid=5903da704975ff0a734bcde5c9ed31a9&proactive=0&departmentid=0&randno=29&fullname=&email=',
        windowName: 'LiveSupport'
    });

});

 function prepareSeal() {
     window.open('', 'srsSeal', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=630,height=350');
 };
 
