jQuery(document).ready(function(){

    // Menu

    jQuery("ul.menu").superfish();


    //Hovers for big buttons

    $(".border-header-text a").mouseover(function(){
      $(".border-header-text").attr('style','background-position:bottom;');
    }).mouseout(function(){
      $(".border-header-text").attr('style','background-position:top;');
    });

    $(".red-tape a").mouseover(function(){
      $(".red-tape").attr('style','background-position:bottom;');
    }).mouseout(function(){
      $(".red-tape").attr('style','background-position:top;');
    });

    $(".gray-tape a").mouseover(function(){
      $(".gray-tape").attr('style','background-position:bottom;');
    }).mouseout(function(){
      $(".gray-tape").attr('style','background-position:top;');
    });

    $(".footer-red-tape a").mouseover(function(){
      $(".footer-red-tape").attr('style','background-position:bottom center;');
    }).mouseout(function(){
      $(".footer-red-tape").attr('style','background-position:top center;');
    });

    jQuery('.nav-center .sub-menu').attr('style', 'display:block!important;visibility:visible!important');

    $('.nivo-directionNav a').html('');

    $().piroBox({
        my_speed: 300, //animation speed
        bg_alpha: 0.5, //background opacity
        slideShow : 'true', // true == slideshow on, false == slideshow off
        slideSpeed : 3, //slideshow
        close_all : '.piro_close' // add class .piro_overlay(with comma)if you want overlay click close piroBox
    });

    // Clear Widget Titles

    jQuery('.footer_widgettitle').each(function(){
        jQuery(this).remove();
    });


    //HORIZONTAL SLIDER
    function mycarousel_initCallback(carousel)
    {
        // Disable autoscrolling if the user clicks the prev or next button.
        carousel.buttonNext.bind('click', function() {
            carousel.startAuto(0);
        });

        carousel.buttonPrev.bind('click', function() {
            carousel.startAuto(0);
        });

        // Pause autoscrolling if the user moves with the cursor over the clip.
        carousel.clip.hover(function() {
            carousel.stopAuto();
        }, function() {
            carousel.startAuto();
        });
    }

    jQuery('#mycarousel').jcarousel({
        auto: 3,
        wrap: 'circular',
        scroll: 1,
        animation:  1200,
        easing: 'easeInOutBack',
        initCallback: mycarousel_initCallback
    });

    jQuery('.jcarousel-item').each(function(){
        jQuery('img',this).stop().animate({
            opacity:1
        },0);
    });
    
    jQuery('a','#mycarousel').hover(function(){
        jQuery('img',this).stop().animate({
            opacity:0.4
        },500);
    },function(){
        jQuery('img',this).stop().animate({
            opacity:1
        },300);
    });

    //Arrow fix

    var prev = $('.jcarousel-prev');
    var next = $('.jcarousel-next');

    $('#wraper-slider').append(prev);
    $('#wraper-slider').append(next);

    $('.jcarousel-skin-tango .jcarousel-prev').remove();
    $('.jcarousel-skin-tango .jcarousel-next').remove();

    // Sidebar fix

    jQuery('.sidebar_widget_holder').each(function(){

        var checker = jQuery('.sidebar_widgettitle', this).html();
        if (checker !== null){}else{

            var menjac = jQuery(this).html();
            jQuery(this).empty().append('<div class="widget-top"></div>' + menjac);
        }
    });

    




    //WP Recent fix

    $('div[class*="recent-posts"] a').attr('style', 'line-height:20px!important;padding: 7px 20px;');

    $('.footer_box-down .app_recent_post:last').attr('style','padding:0px!important');

    $('.footer_box-down .app_recent_comm:last').attr('style','padding:0px!important');

    $('.sidebar_widget_holder .app_recent_post:last').attr('style','padding:0px!important');
    
    $('.sidebar_widget_holder .app_recent_comm:last').attr('style','padding:0px!important');
    
    $('div[class*="recent-posts"] li').attr('style', 'margin:0px;');

    $('.recentcomments a').attr('style', 'line-height:20px!important;width:231px;');

    jQuery('#menu-left').addClass("sf-menu");
    jQuery('#menu-right').addClass("sf-menu");

    jQuery(".menu ul li:first-child").before('<li class="sub-menu-top"></li>');
    jQuery(".menu ul li:last-child").after('<li class="sub-menu-bottom"></li>');
    
    //Pirobox
        
    jQuery('.pirobox').each(function(){
        jQuery('img',this).animate({
            opacity:1
        },0);
    });
	
    jQuery('img','.pirobox').hover(function(){
        jQuery(this).stop().animate({
            opacity:0.4
        },500);
    },function(){
        jQuery(this).stop().animate({
            opacity:1
        },300);
    });
	
    //Tag Cloud
    jQuery('.tagcloud a').each(function(){
        var acont = jQuery(this).html();
        jQuery(this).html('<div class="sidebar-tags-button"><div class="button-left-tag"></div><div class="button-center-tag">'+acont+'</div><div class="button-right-tag"></div></div>');
    });
	
		
    //Search style


    jQuery(".top-content-title #searchsubmit").remove();
    jQuery(".top-content-title .screen-reader-text").remove();

    jQuery(".top-search div .screen-reader-text").remove();

    var searchfix2 = $('.sidebar_widget_holder #searchform').html();
    $('.sidebar_widget_holder #searchform').html('').append('<div class="search-left"></div><div class="search-center">'+searchfix2+'</div>');
    jQuery(".search-center div .screen-reader-text").remove();

    var searchfix3 = $('.footer-search_box #searchform').html();
    $('.footer-search_box #searchform').html('').append('<div class="search-left"></div>'+searchfix3);
    jQuery(".footer-search_box div .screen-reader-text").remove();
    jQuery(".footer-search_box div #searchsubmit").val('');

    var searchfix4 = $('.footer_box-down #searchform').html();
    $('.footer_box-down #searchform').html('').append('<div class="search-left"></div><div class="search-center">'+searchfix4+'</div>');
    jQuery(".search-center div .screen-reader-text").remove();


        
    //Prevent empty search form submit
    jQuery('#searchsubmit').click(function(e){
        e.preventDefault();
        var value = jQuery('#s').val();
        if(value !== ""){
            jQuery('#searchform').submit();
        }
    });


    jQuery('.images img').hover(function(){
        jQuery('img',this).stop().animate({
            opacity:0.4
        },500);
    },function(){
        jQuery('img',this).stop().animate({
            opacity:1
        },300);
    });


});

