
var htmlText = new Array();

htmlText[0] = '<div id="pic-block1"> \
    <div class="iePNG pic-block-txt"> \
        <div class="pic-block-h2">Where the sites live</div> \
        <p>You think that a housekeeper can never become a hosting guru? Nah... We do not think so and we will prove you that.</p> \
    </div> \
</div>';
htmlText[1] = '<div id="pic-block2"> \
    <div class="iePNG pic-block-txt"> \
        <div class="pic-block-h2">Where the sites live</div> \
        <p>You think that creating a good site requires a fortune? Let us show you how you can do it having $5 in your pocket.</p> \
    </div> \
</div>';
htmlText[2] = '<div id="pic-block3"> \
    <div class="iePNG pic-block-txt"> \
        <div class="pic-block-h2">Where the sites live</div> \
        <p>You think that your business is too big for Virtual hosting, but you are not yet ready for a dedicated solution? Have a look at our VPS plans, that is the right decision for you.</p> \
    </div> \
</div>';
htmlText[3] = '<div id="pic-block4"> \
    <div class="iePNG pic-block-txt"> \
        <div class="pic-block-h2">Where the sites live</div> \
        <p>You think that company who sells virtual hosting can not provide reliable dedicated servers of a high quality? Just try and you will see that we can.</p> \
    </div> \
</div>';




$(function() {
    var fish = $('#js-block');
    var index = 0;
    $('div#plans-block>div').each(function() {
        var item = $(this).attr('class').match(/plan(\d+)/);
        if (item != null) {
            $(this).bind('mouseover', function() {
                // change 2-nd row with pre-filled HTML content
                fish.html(htmlText[item[1] - 1]);
            });

            index++;
        }
    });
});



// tabs go
$(document).ready(function(){
	$("#menu > ul").tabs({
		fxFade: true,
		fxSpeed: 'slow'
	});
});
// end tabs go

// png fix
$(document).ready(function(){ 
	$(document).pngFix(); 
}); 
// end png fix

// sitevalley server slider and server mode radio links
$(document).ready(function(){
    if($('div.slider-box').length > 0) {
        //alert($(document));
        $(document).bind('dragstart', function(){ return false });
        var server_price = function(engine, vps) {
            var prices = [9, 14, 29, 59];
            var price_index = (engine == 'openvz' ? 0 : 1) + vps;
            return prices[price_index] + '';
        }
        var order_link = function(engine, vps) {
            var links = {
                'openvz': ['39', '40', '41'],
                'xen': ['9', '10', '11']
            }
            //if(typeof(engine)=='undefined') engine = 'openvz';
            return '/clients/cart.php?a=add&pid=' + links[engine][vps];
        }
        var server_params = {
            'memory': ['256 MB', '512 MB', '1024 MB'],
            'space': ['20 GB', '30 GB', '80 GB'],
            'bandwidth': ['100 GB', '200 GB', '500 GB'],
            'ips': ['1', '1', '1']
        }
        
        $('a.check').click(function(){
            if(!$(this).hasClass('check-act')) {
                $('a.check').toggleClass('check-act').next().toggleClass('check-txt-act');
                $('td.prict2').html(server_price($(this).attr('engine'), $sv_slider.slider.tick_index));
                $('a.vps1-order').attr('href', order_link($(this).attr('engine'), $sv_slider.slider.tick_index));
            }
            $(this).blur();
            return false;
        }).next().css('cursor', 'pointer').click(function(){
            $(this).prev().click();
        });
        
        var tick_handler = function(e, t){
            $('td.prict2').html(server_price($('a.check.check-act').attr('engine'), t));
            $('div.slider-name').removeClass('slider-name-act').filter('[level='+t+']').addClass('slider-name-act');
            $('span.scale').each(function(i){
                var m = $(this).attr('class').match(/scale\-bg(\d)(\d)/);
                $(this).removeClass(m[0]).addClass('scale-bg' + m[1] + (t+1));
            });
            $('a.vps1-order').attr('href', order_link($('a.check.check-act').attr('engine'), t));
            $('td[server_param]').each(function(){
                $(this).html(server_params[$(this).attr('server_param')][t])
            });
        }
        
        $('div.slider-name').css('cursor', 'pointer').click(function(){
            var tick = parseInt($(this).attr('level'));
            tick_handler(null, tick);
            $sv_slider.slider.tick_index = tick;
            $sv_slider.slider.getBack();
        });
        
        $sv_slider = $('div.slider-box').sitevalleySlider({
            slider: $('div.slider-box div.slider'),
            tickranges: [0, 82, 247],
            ticks: [0, 165, 330]
        }, tick_handler);
    }
});
