jQuery.fn.pause = function(duration) {
    jQuery(this).animate({
        dummy: 1
    }, duration);
    return this;
};

// Function to show on focus effect on search field
jQuery(document).ready ( function () {
    var elements = jQuery("input#s");
    elements.focus(function() {
        jQuery(".thesis_widget_search p").addClass("focus");
        jQuery("#searchsubmit").addClass("btn-focus");
    });
    elements.blur(function() {
        jQuery(".thesis_widget_search p").removeClass("focus");
        jQuery("#searchsubmit").removeClass("btn-focus");
    });

     //preload images
    (function(jQuery) {
        var cache = [];
        // Arguments are image paths relative to the current page.
        jQuery.preLoadImages = function() {
            var args_len = arguments.length;
            for (var i = args_len; i--;) {
                var cacheImage = document.createElement('img');
                cacheImage.src = arguments[i];
                cache.push(cacheImage);
            }
        }
    })(jQuery);
var URL = "";
    var PATH = "http://" + window.location.hostname;
	
    jQuery.preLoadImages(PATH +"/wp-content/themes/thesis/custom/images/newsletter-input-bg.gif",
        PATH +"/wp-content/themes/thesis/custom/images/newsletter-submit-btn-bg.gif",
        PATH +"/wp-content/themes/thesis/custom/images/sub-bottom.gif",
        PATH +"/wp-content/themes/thesis/custom/images/sub-repeat-bg.gif",
        PATH +"/wp-content/themes/thesis/custom/images/sub-top.gif" );


    // ADDING THE HEADER INFO UNDER H1
    //jQuery('#tagline').html(jQuery('#header #logo').hide().html());

    // Subscribe by e-mail show function
    var collapse = true, collapseFocus = true;
    jQuery("#subscribe-email").hover( function () {
        collapse = false;
        jQuery(".newsletterOuterContainer").stop(true, true).slideDown("fast");
    },function () {
        collapse = true;
        setTimeout(function() {
            if(collapse && collapseFocus) {
                jQuery(".newsletterOuterContainer").slideUp("fast");
            }
        }, 800);
    });

    jQuery(".newsletterOuterContainer").hover(function () {
        collapse = false;
    }, function () {
        collapse = true;
        setTimeout(function() {
            if(collapse && collapseFocus) {
                jQuery(".newsletterOuterContainer").slideUp("fast");
            }
        }, 800);
    });

    jQuery("#newsletterForm .newsletterTextInput").focus( function () {
        collapseFocus = false;
    }).focusout (function () {
        collapseFocus = true;
        setTimeout(function() {
            if(collapse && collapseFocus) {
                jQuery(".newsletterOuterContainer").slideUp("fast");
            }
        }, 800);
    });

    jQuery("#newsletterFormDiv .submit").click(function () {
        collapseFocus = false;
    });

    jQuery('.newsletterTextInput').focus(function () {
        jQuery(this).css('background-position', '0 -28px');
    }).blur(function () {
        jQuery(this).css('background-position', '0 0');
    });

    jQuery("body").click ( function () {
        setTimeout(function() {
            jQuery(".newsletterOuterContainer").slideUp("fast");
        }, 800);
    });

    $('#newsletterFormDiv').click(function(event){
        event.stopPropagation();
    });

    //End Subscribe by e-mail script


    // hide the background image from the last category of categories widget
    jQuery('.widget_categories ul li:last').css({
        //"background": "none"
		"border-bottom": "0"
    });



    // hide separator line from the last header nav links
    jQuery('#header_area ul.menu li:last').addClass("last-header-link");

    // add class to the subscribe reloaded p
    jQuery('#commentform #subscribe-reloaded').parent().addClass("subcribe-comment");

    // added new class to last comment
    jQuery('dl#comment_list').each(function () {
        jQuery(this).find("dd.depth-1:last").addClass("last-comment");
    })


    // added new class to footer li
    jQuery("#footer ul:first").children("li").each(function (i) {
        i += 1;
        jQuery(this).addClass("footer-block" + i);
    });

    // Add new class on hover to li in tab area
    jQuery(".custom .slider li ul li a").hover(function () {
        $(this).parent('li').toggleClass("highlight");
    });




    // Add div for holding the sociable and tagging
    jQuery('#content .post_tags').insertBefore($('#content  #related'));
    var bgShadow = document.createElement('div');
    bgShadow.setAttribute('id', 'rest-info-separator')
    jQuery(bgShadow).insertBefore($('#content  .sociable'));


    //Add anchor in contact page
    var addanchor=document.createElement('a');
    addanchor.setAttribute('id', 'contactanchor')
    addanchor.setAttribute('name', 'contactanchor')
    jQuery(addanchor).insertBefore($('#wpcf7-f1-p2-o1'));




    /**
		 * Script to show sociable bookmark slide
		 **/
    jQuery('.sociable').hover(function() {
        jQuery('.sociable ul').stop(true).animate({
            width: 402
        }, 300);
    },function() {
        jQuery('.sociable ul').delay(300).animate({
            width: 105
        }, 200);
    });




    




    jQuery('#content').children('div.prev_next').addClass('prev-next-nav');

    jQuery('#content').children('.prev_next.post_nav').children('p').each(function () {
        var $a, $p, aHTML, aLink, aRel, pHTML;
        $a = jQuery(this).children('a');
        $p = jQuery(this);
        $p.css('visibility', 'visible');
        aHTML = $a.html();
        aLink = $a.attr('href');
        aRel = $a.attr('rel');
        $a.remove('a');
        pHTML = $p.html();
        $a = document.createElement('a');
        $a.setAttribute('href', aLink);
        $a.setAttribute('title', aHTML);
        $a.innerHTML = pHTML;
        $p.html('').attr('class', aRel);
        $p.append($a);

    });
	
	
	jQuery('#nav-menu > li').hover(
        function()
        {
            jQuery(this).addClass('mega-hover');
            jQuery(this).children('div').children('.sub').stop(true, true).fadeIn(1);

        },function()
        {
            jQuery(this).removeClass('mega-hover');
            jQuery(this).children('div').children('.sub').stop(true, true).slideUp(1);
        }
    );
	
	
	//jQuery('#logo a').attr("href", "http://www.fusioncharts.com");



});

