$(function() {
    $('body').addClass('Ready');
    Cufon.refresh();
								
		
    function ChangeHeightShadow(x){
        height = $('div.Bt').eq(x).outerHeight(true);
        $('.Menu span.Shadow.Vertical').height(height);
        height = $('.SubMenu').eq(x).outerHeight(true);
        $('.Menu .SubMenu div.Shadow.Vertical').height(height);
        width = $('.SubMenu').eq(x).outerWidth(true)-3;
        $('.Menu .SubMenu div.Shadow.Horizontal').width(width);
    }
    ChangeHeightShadow(0);
																
    $('div.Select .Select').change(function() {
        $val = $(this).val();
        $('.Select .Change').html($val);
    });
																
																															
    $('.page-template-_ObszaryDzialania-php .Cl.Cl296 .Desc').each(function() {			
        $h = $(this).height();
        $(this).css('height',$h);
    });												
																
   
                
    $(".Customer .Slider").scrollable({
        circular: false
    });
    $('.Customer .Slider .Slide .IconOffer').each(function() {
        $w = 0;
        $w += $(this).width();
    });
    $(".Customer .IconOffer[title]").tooltip({
        effect: 'fade',
        predelay: 100,
        fadeOutSpeed: 100,
        position: "top right",
        offset: [6, -10]
    });
                
                 
                  
    $('.Team').click(function() {
        $(this).find('.More').toggleClass('Show');
        $(this).find('.Nav').toggleClass("Open");
    });
                
                                    
                
    $(".Gallery").scrollable({
        circular: false,
        prev: '.Gallerys .Nav .Prev',
        next: '.Gallerys .Nav .Next'
    });
                
                
    $(".home .Slider").scrollable({ 
        vertical: false,
        circular: true, 
        mousewheel: false
    }).navigator({
        navi: ".SliderTab",
        naviItem: 'a',
        activeClass: 'current' 
    }).autoscroll(4000);
		
    $('.SliderTab').css('left',(400-$('.SliderTab').width())/2);
			
           
    // Kreski
    $('body h1.Change').each(function() {
        $ww = $(this).parent().width();
        $w = $(this).parent().width() - $(this).width();
        $h = $(this).height();
        $(this).html('<span class="Text">'+$(this).html()+'</span><span class="Line" style="width: '+$w+'px; height: '+$h+'px;">&nbsp;</span><span class="Clear"></span>');
        $(this).css('width',$ww);
    });
    $('body.page-template-_ObszaryDzialania-php h3').each(function() {
        $ww = $(this).parent().width();
        $w = $(this).parent().width() - $(this).width()-12;
        $h = $(this).height();
        $(this).html('<span class="Text">'+$(this).html()+'</span><span class="Line" style="width: '+$w+'px">&nbsp;</span><span class="Clear"></span>');
        $(this).css('width',$ww);
    });
    $('body.page-template-_CaseStudies-php h3').each(function() {
        $ww = $(this).parent().width();
        $w = $(this).parent().width() - $(this).width()-12;
        $h = $(this).height();
        $(this).html('<span class="Text">'+$(this).html()+'</span><span class="Line" style="width: '+$w+'px">&nbsp;</span><span class="Clear"></span>');
        $(this).css('width',$ww);
    });
																	
																
																
    $BiuroPrasoweH = $('.BiuroPrasowe').height();
    $TitterLiHSum = 0;
    $n = 0;
    $start = 0;
    $Play = true;
    $('ul.twitter li').each(function() {	
        $d1 = $BiuroPrasoweH - $TitterLiHSum;
        $TitterLiH = $(this).height();
        $TitterLiHSum += $TitterLiH;	
        $d2 = $BiuroPrasoweH - $TitterLiHSum;
											
        if($TitterLiHSum > $BiuroPrasoweH && $Play == true){
            if(Math.abs($d1) < Math.abs($d2)){
                $Play = false;
                $start = $n-1;
            }else{
                $Play = false;
                $start = $n;
            }
        }

        $n++;
    });
    $('ul.twitter li').eq($start).addClass('End');
    for($x = ($start+1); $x < $n; $x++){
        $('ul.twitter li').eq($x).css('display','none');
    }
																
																
																
    Cufon.CSS.ready(function() {
        $('body').addClass('Ready');
        Cufon.refresh();
    });  

         
    $('body.home .Article .Click').hover(function(){
        $(this).parents('.Article').eq(0).addClass('hover');
        $x = 	$(this).parents('.Article');
        Cufon.refresh();
    },function(){
        $(this).parents('.Article').eq(0).removeClass('hover');
        Cufon.refresh();
    });  
																												
    $('.Articles .Article .Click').hover(function(){
        $(this).parents('.Article').eq(0).addClass('hover');
        $x = 	$(this).parents('.Article');
        Cufon.refresh();
    },function(){
        $(this).parents('.Article').eq(0).removeClass('hover');
        Cufon.refresh();
    });
			
                        
                        
                    
                    
                    
    // Overlay                
                    
    $('.Rss a').click(function() {
        $("#Rss").data('overlay').load();
                     
    });  
    $('a.InformacjePrawne').click(function() {
        $("#InformacjePrawne").data('overlay').load();
                     
    });  
    $('a.SieciOrganizacyjne').click(function() {
        $("#SieciOrganizacyjne").data('overlay').load();
                     
    });  
    
    
    $(".Overlay").overlay({
        top: 160,
        mask: {
            color: '#000000',
            loadSpeed: 200,
            opacity: 0.8
        },
        closeOnClick: true,
    });
           
           
           
           
           


    $.tools.validator.localize("pl", {
        ':Kod'    : 'Podaj kod',
        ':email'  : 'Podaj email',
        '[required]'  : 'Wymagane'
    });
    $.tools.validator.fn("input[rel]", function(input, value) {
        var rel = input.attr("rel");
					
        return value != rel ? true : {     
            pl: "Wymagane"
        };
    });
    $.tools.validator.fn("textarea[rel]", function(input, value) {
        var rel = input.html();
					
        return value != rel ? true : {     
            pl: "Wymagane"
        };
    });
    $('#Kontakt').validator({
        lang: 'pl',
        offset: [18, 0],
        position: 'top right'
    }).submit(function(e){
        if (!e.isDefaultPrevented()) {
        //$('.Information.Success').addClass('Show');
        //$('.Information.Error').removeClass('Show');
        //e.preventDefault();
        }else{
            $('.Information.Error').addClass('Show');
        }
    });


	
		
		
});



$(document).ready(function($) {
    $('body').addClass('Ready');
    $('body').css('visibility','visible');
    Cufon.refresh();
});

