(function($){		
    
    clickLogo = 
    function() {
        $('.logo').mousedown(function() {
            $(this).addClass('focus');
        });
        $('.logo').focusout(function() {
            $(this).removeClass('focus');
        });
        $('.logo').hover(
            function() {
                
            },
            function() {
            $(this).removeClass('focus');
            $(this).blur();
            });
         $('.logo').click(function(){
             $(this).removeClass('focus');
         });
    };
    
    loadCards =	
    function() { 
        if ($.cookie('images_loaded')!=1) {
            $('.background a').each(function(i) {
			
                if (i<12) {
                    $(this).fadeIn(400 * (i+1));
                }
            });
			
            $('.background a').each(function(i) {
                if (i>=12) {
                    $(this).fadeIn(400 * (i-11));
                }
            });
        } else {
            $('.background a').each(function(i) {
                $(this).show();
            });
        }
        $.cookie('images_loaded', '1');
    };

    addAlign= 
    function() {
        $('img.alignright').parent().addClass('alignright');
        $('img.alignleft').parent().addClass('alignleft');
        $('img.alignnone').parent().addClass('alignnone');
        $('img.aligncenter').parent().addClass('aligncenter');
    };
			
    animateTools =	
    function() {
        $('a.tool').hover(
            function() {
                $(this).stop().animate({
                    backgroundColor:'#dff759'
                },100, 'easeInSine');  
            },
            function() {
                $(this).stop().animate({
                    backgroundColor:'#e3f485'
                },300, 'easeOutBounce',function() {
                    $(this).animate({
                        backgroundColor:'#fafafa'
                    },200, 'linear');
                })
            });
	        $('a.tool_left').hover(
            function() {
                $(this).stop().animate({
                    backgroundColor:'#dff759'
                },100, 'easeInSine');  
            },
            function() {
                $(this).stop().animate({
                    backgroundColor:'#e3f485'
                },300, 'easeOutBounce',function() {
                    $(this).animate({
                        backgroundColor:'#fafafa'
                    },200, 'linear');
                })
            });		
				        $('a.tool_right').hover(
            function() {
                $(this).stop().animate({
                    backgroundColor:'#dff759'
                },100, 'easeInSine');  
            },
            function() {
                $(this).stop().animate({
                    backgroundColor:'#e3f485'
                },300, 'easeOutBounce',function() {
                    $(this).animate({
                        backgroundColor:'#fafafa'
                    },200, 'linear');
                })
            });	
			
			
    };

		
    bigActive =	
    function() {
        $('.content a.big').click(function() {
            $(this).siblings().removeClass('active');
            $(this).toggleClass('active','fast');
        });
        $('.content a.big').click(function() {
            $(this).siblings().removeClass('active');
            $(this).addClass('active');
        });
    };	
    
    
	
    cycleMain =
    function() { 
        $('.rotator').cycle({
            fx: 'scrollHorz',
            speed: 1500,
            timeout:0,
            sync: 1,
            reverse:1,
            easeIn: 'easeOutExpo',
            easeOut: 'easeOutExpo',
            delay: -100
        });
        $('.content a.one').click(function() {
            $('.rotator').cycle(0);
        });
        $('.content a.two').click(function() {
            $('.rotator').cycle(1);
        });
        $('.content a.three').click(function() {
            $('.rotator').cycle(2);
        });
    }
	
	    cycleTools =
     function() { 
        $('.toolslider').cycle({
            fx: 'scrollHorz',
            speed: 1000, 
            timeout:0,
            sync: 1,
            reverse:1,
            easeIn: 'easeOutExpo',
            easeOut: 'easeOutExpo',
            next: '.tool_right',
            prev: '.tool_left'
        });
    } 
	
    clearSearchBox = 
    function () {
        if ($('.header .search .searchinput').val()=='') {
            $('.header .search .searchinput').val('szukaj...');
        }
        $('.header .search .searchinput').focus(function() {
            if ($(this).val()=='szukaj...') {
                $(this).val('');
            }
        });
        $('.header .search .searchinput').focusout(function() {
            ;
            if ($(this).val()=='') {
                $(this).val('szukaj...');
            }
        });
    }

    filterTools =
    function () {
        var states = new Array();
        states['primary'] = new Array();
        states['secondary'] = new Array();
        var tool_states = new Array();
        var tool_states_complex = new Array();
        var tool_state= new Array();
        tool_state['primary']=new Array();
        tool_state['secondary']=new Array();
			
        items = $.each($('.level1 a[rel]'), function (index,value) {
            states['primary'][$(this).attr("rel")]="1";
        });
        subitems = $.each($('.level2 a[rel]'), function (index,value) {
            states['secondary'][$(this).attr("rel")]="1";
        });

        $.each($('.tool_filter a[rel]'), function (index,value) {
            $(this).click(function() {
                $(this).toggleClass('on');	
                var idx = $(this).attr("rel");
                if ($(this).parent().parent().hasClass('level1')) {
                    if ($(this).hasClass('on')) {
                        states['primary'][idx]="1";
                    } else {
                        states['primary'][idx]="0";
                    }
                } else if ($(this).parent().parent().hasClass('level2')){
                    if ($(this).hasClass('on')) {
                        states['secondary'][idx]="1";
                    } else {
                        states['secondary'][idx]="0";
                    }					
                }
                for(var state_key in states['primary'])
                {

                    $.each($('.alltools a.'+state_key), function (tool_index,tool_value) {
                        if (tool_states_complex[$(this).attr("id")]==undefined) {
                            tool_states_complex[$(this).attr("id")]= new Array();
                        }
                        if (tool_states_complex[$(this).attr("id")]['primary']==undefined) {
                            tool_states_complex[$(this).attr("id")]['primary']= new Array();
                        }
                        tool_states_complex[$(this).attr("id")]['primary'][state_key]=states['primary'][state_key];
                    })
                }
                for(var state_key in states['secondary'])
                {

                    $.each($('.alltools a.'+state_key), function (tool_index,tool_value) {
                        if (tool_states_complex[$(this).attr("id")]==undefined) {
                            tool_states_complex[$(this).attr("id")]= new Array();
                        }
                        if (tool_states_complex[$(this).attr("id")]['secondary']==undefined) {
                            tool_states_complex[$(this).attr("id")]['secondary']= new Array();
                        }
                        tool_states_complex[$(this).attr("id")]['secondary'][state_key]=states['secondary'][state_key];
                    })
                }
                for(var tool_key in tool_states_complex) {
						
                    tool_state['primary'][tool_key]=0;
                    for(var i in tool_states_complex[tool_key]['primary']) {
                        if (tool_states_complex[tool_key]['primary'][i]==1) {
                            tool_state['primary'][tool_key]++;
                        }
                    }
						
                }
                for(var tool_key in tool_states_complex) {
                    tool_state['secondary'][tool_key]=0;

                    for(var i in tool_states_complex[tool_key]['secondary']) {
                        if (tool_states_complex[tool_key]['secondary'][i]==1) {
                            tool_state['secondary'][tool_key]++;
                        }
                    }
						
                }

                for (var tool_key in tool_state['secondary']) {
                    //					if (tool_state['primary'][tool_key]==0 && tool_state['secondary'][tool_key]==0) {
                    //						$('.alltools a#'+tool_key).fadeTo('fast',0.2);
                    //					} else if (tool_state['primary'][tool_key]>0 && tool_state['secondary'][tool_key]>0) {
                    //						$('.alltools a#'+tool_key).fadeTo('fast',1);
                    //					} else if (tool_state['primary'][tool_key]>0 && tool_state['secondary'][tool_key]==0) {
                    //						$('.alltools a#'+tool_key).fadeTo('fast',0.2);
                    /*	} else i*/ if (tool_state['primary'][tool_key]==0) {
                        $('.alltools a#'+tool_key).parent().fadeOut('slow');
                    } else {
                        $('.alltools a#'+tool_key).parent().fadeIn('slow');
                    }
                }
            });
        });
		
    }			

    commentForm = 
    function() {
    //           $('.commentform').hide();
    //           $('.add_comment_title').click(function() {
    //               $('.commentform').toggle();
    //         });
    };

    officeMap =
    function() {
        //rezyserka start
        $('a.rezyserka').hover(
            function() {
                if ($('a.rezyserka').attr("class").indexOf('on')<0) {
                    $('a.recording_big').addClass('hover');
                    $('a.rezyserka').addClass('hover');
                }
                
            },
            function() {
                if ($('a.rezyserka').attr("class").indexOf('on')<0) {
                    $('a.recording_big').removeClass('hover');
                    $('a.rezyserka').removeClass('hover');
                }
            });     
        $('a.recording_big').hover(
            function() {
                if ($('a.rezyserka').attr("class").indexOf('on')<0) {
                    $('a.recording_big').addClass('hover');
                    $('a.rezyserka').addClass('hover');
                }
                
            },
            function() {
                if ($('a.rezyserka').attr("class").indexOf('on')<0) {
                    $('a.recording_big').removeClass('hover');
                    $('a.rezyserka').removeClass('hover');
                }
            });  
        /*   $('a.recording_big').click(function() {
            $('.zaplecze_buttons a').not('.rezyserka').removeClass('on');
            $('.zaplecze a').removeClass('active');
            $('.zaplecze a').removeClass('hover');
        //    $('.zaplecze_buttons p').hide('on');
            $('a.rezyserka').toggleClass('on');
            if ($('a.rezyserka').attr("class").indexOf('on')>0) {
                $('a.recording_big').addClass('active');
                
            } else {
                $('a.recording_big').removeClass('active');
            }
      //      $('p.rezyserka_info').toggle();
        });
            */
        /*   $('a.rezyserka').click(function() {
            $('.zaplecze_buttons a').not('.rezyserka').removeClass('on');
            $('.zaplecze a').removeClass('active');
            $('.zaplecze a').removeClass('hover');
            $('.zaplecze_buttons a').removeClass('hover');
      //      $('.zaplecze_buttons p').hide('on');
            $('a.rezyserka').toggleClass('on');
            if ($('a.rezyserka').attr("class").indexOf('on')>0) {
                $('a.recording_big').addClass('active');
                
            } else {
                $('a.recording_big').removeClass('active');
            }
     //       $('p.rezyserka_info').toggle();
        });
        */
        // rezyserka_end
        // focus start
        $('a.focusownia').hover(
            function() {
                if ($('a.focusownia').attr("class").indexOf('on')<0) {
                    $('a.focus').addClass('hover');
                    $('a.focusownia').addClass('hover');
                }
                
            },
            function() {
                if ($('a.focusownia').attr("class").indexOf('on')<0) {
                    $('a.focus').removeClass('hover');
                    $('a.focusownia').removeClass('hover');
                }
            });   
    
        $('a.focus').hover(
            function() {
                if ($('a.focusownia').attr("class").indexOf('on')<0) {
                    $('a.focus').addClass('hover');
                    $('a.focusownia').addClass('hover');
                }
                
            },
            function() {
                if ($('a.focusownia').attr("class").indexOf('on')<0) {
                    $('a.focus').removeClass('hover');
                    $('a.focusownia').removeClass('hover');
                }
            });  
    
    
        /*    $('a.focusownia').click(function() {
            $('.zaplecze_buttons a').not('.focusownia').removeClass('on');
            $('.zaplecze a').removeClass('active');
            $('.zaplecze a').removeClass('hover');
            $('.zaplecze_buttons a').removeClass('hover');
     //       $('.zaplecze_buttons p').hide('on');    
            $('a.focusownia').toggleClass('on');
            if ($('a.focusownia').attr("class").indexOf('on')>0) {
                $('a.focus').addClass('active');
                
            } else {
                $('a.focus').removeClass('active');
            }
     //       $('p.focusownia_info').toggle();
        });
            */
        /*   $('a.focus').click(function() {
            $('.zaplecze_buttons a').not('.focusownia').removeClass('on');
            $('.zaplecze a').removeClass('active');
            $('.zaplecze a').removeClass('hover');
            $('.zaplecze_buttons a').removeClass('hover');
      //      $('.zaplecze_buttons p').hide('on');    
            $('a.focusownia').toggleClass('on');
            if ($('a.focusownia').attr("class").indexOf('on')>0) {
                $('a.focus').addClass('active');
                
            } else {
                $('a.focus').removeClass('active');
            }
     //       $('p.focusownia_info').toggle();
        });    
            */
        // focus end
        // conference start
        $('a.cnference').hover(
            function() {
                if ($('a.cnference').attr("class").indexOf('on')<0) {
                    $('a.conference_big').addClass('hover');
                    $('a.cnference').addClass('hover');
                }
                
            },
            function() {
                if ($('a.cnference').attr("class").indexOf('on')<0) {
                    $('a.conference_big').removeClass('hover');
                    $('a.cnference').removeClass('hover');
                }
            });    
        $('a.conference_big').hover(
            function() {
                if ($('a.cnference').attr("class").indexOf('on')<0) {
                    $('a.conference_big').addClass('hover');
                    $('a.cnference').addClass('hover');
                }
                
            },
            function() {
                if ($('a.cnference').attr("class").indexOf('on')<0) {
                    $('a.conference_big').removeClass('hover');
                    $('a.cnference').removeClass('hover');
                }
            });      
        /*   $('a.cnference').click(function() {
            $('.zaplecze_buttons a').not('.cnference').removeClass('on');
            $('.zaplecze a').removeClass('active');
            $('.zaplecze a').removeClass('hover');
            $('.zaplecze_buttons a').removeClass('hover');
      //      $('.zaplecze_buttons p').hide('on');
            $('a.cnference').toggleClass('on');
            if ($('a.cnference').attr("class").indexOf('on')>0) {
                $('a.conference_big').addClass('active');     
            } else {
                $('a.conference_big').removeClass('active');
            }
     //       $('p.conference_info').toggle();
        });
           */ 
        /*
        $('a.conference_big').click(function() {
            $('.zaplecze_buttons a').not('.cnference').removeClass('on');
            $('.zaplecze a').removeClass('active');
            $('.zaplecze a').removeClass('hover');
            $('.zaplecze_buttons a').removeClass('hover');
       //     $('.zaplecze_buttons p').hide('on');
            $('a.cnference').toggleClass('on');
            if ($('a.cnference').attr("class").indexOf('on')>0) {
                $('a.conference_big').addClass('active');     
            } else {
                $('a.conference_big').removeClass('active');
            }
    //        $('p.conference_info').toggle();
        });    
        // conference end    
        // waiting start    
        */
        $('a.utc').hover(
            function() {
                if ($('a.utc').attr("class").indexOf('on')<0) {
                    $('a.waiting').addClass('hover');
                    $('a.utc').addClass('hover');
                }
                
            },
            function() {
                if ($('a.utc').attr("class").indexOf('on')<0) {
                    $('a.waiting').removeClass('hover');
                     $('a.utc').removeClass('hover');
                }
            });     
    
        $('a.waiting').hover(
            function() {
                if ($('a.utc').attr("class").indexOf('on')<0) {
                    $('a.waiting').addClass('hover');
                    $('a.utc').addClass('hover');
                }
                
            },
            function() {
                if ($('a.utc').attr("class").indexOf('on')<0) {
                    $('a.waiting').removeClass('hover');
                    $('a.utc').removeClass('hover');
                }
            });  
    
    /*      $('a.utc').click(function() {
            $('.zaplecze_buttons a').not('.utc').removeClass('on');
            $('.zaplecze a').removeClass('active');
            $('.zaplecze a').removeClass('hover');
            $('.zaplecze_buttons a').removeClass('hover');
     //       $('.zaplecze_buttons p').hide('on');
            $('a.utc').toggleClass('on');
            if ($('a.utc').attr("class").indexOf('on')>0) {
                $('a.waiting').addClass('active');     
            } else {
                $('a.waiting').removeClass('active');
            }
      //      $('p.utc_info').toggle();
        });    */
    /*
        $('a.waiting').click(function() {
            $('.zaplecze_buttons a').not('.utc').removeClass('on');
            $('.zaplecze a').removeClass('active');
            $('.zaplecze a').removeClass('hover');
            $('.zaplecze_buttons a').removeClass('hover');
      //      $('.zaplecze_buttons p').hide('on');
            $('a.utc').toggleClass('on');
            if ($('a.utc').attr("class").indexOf('on')>0) {
                $('a.waiting').addClass('active');     
            } else {
                $('a.waiting').removeClass('active');
            }
    //        $('p.utc_info').toggle();
        });   
        */
    //waiting end     
    };

    //debugging

    gridSwitcher =	
    function() {
        $('.switcher').click(function() {
            if ($('.over').hasClass('on')) {
                $('.over').css('background',"#fff").removeClass('on');
            } else {
                $('.over').css('background',"url('/wp-content/themes/cogision/grid.png') repeat-y #fff").addClass('on');
            }
        });
    };		
			
})(jQuery);	

