var container = null;
var ul = null;
var p = 0, mltp = 0, k = 0, itemsWidth = 0;
jQuery(window).load(function () {
    container = jQuery('div#slideBlock');
    ul = jQuery('ul', container);
	var li_width = 0;
	ul.children('li').each(function(){
		li_width = li_width + jQuery(this).outerWidth(true);
	});
	if(li_width>0) ul.css("width", (li_width+125)+"px");
    if (ul.innerWidth() > container.outerWidth()) {
        jQuery("#SliderSingle").slider({
            from: 0,
            to: 100,
            step: 10,
            round: 0,
            smooth: true,
            skin: "round",
            limits: false,
            onstatechange: function(value){
                refreshSwatch();
                return false;
            }
        });
    }
    else {
        jQuery("#sliderWrapper").css("display", "none");
    }
});
function refreshSwatch(){
    itemsWidth = ul.innerWidth() - container.outerWidth();
    p = jQuery(".jslider-pointer").position();
    mltp = (itemsWidth / jQuery("#slideBlock").width()).toFixed(4);
    k = (p.left * mltp) * -1; 
    jQuery("#slideBlock").css('left', k + "px");
};
jQuery(document).ready(function(){
	if (jQuery('#tabs-stat').size() > 0) jQuery("#tabs-stat").tabs();
	if (jQuery('#tabs-stat-1').size() > 0) jQuery("#tabs-stat-1").tabs();
	if (jQuery('#tabs-stat-2').size() > 0) jQuery("#tabs-stat-2").tabs();
	if (jQuery('#tabs-stat-3').size() > 0) jQuery("#tabs-stat-3").tabs();
	jQuery("#button_1").click(function(){
		jQuery("#popupContact_1").fadeIn();
	});
	jQuery("#button_2").click(function(){
		jQuery("#popupContact_2").fadeIn();
	});
	jQuery("#button_3").click(function(){
		jQuery("#popupContact_3").fadeIn();
	});
});
