// begin main menu cufon config 
Cufon.replace('.overallmenu > ul > li.current_page_item > a, .overallmenu > ul > li.current_page_ancestor > a, .overallmenu > ul > li.current-menu-item > a, .overallmenu > ul > li.current-menu-ancestor > a');
Cufon.replace('.overallmenu > ul > li > a', {
    hover: true
});
Cufon.refresh('.overallmenu > ul > li.current_page_item > a, .overallmenu > ul > li.current_page_ancestor > a, .overallmenu > ul > li.current-menu-item > a, .overallmenu > ul > li.current-menu-ancestor > a');
// end main menu cufon config

/* begin cufon replacer */
Cufon.replace('h1, h2, h3, h4, h5, h6, .custom_title, .firstLetter span, .slider_text_more,h2 > a,',{
    hover: true
});
Cufon.replace('.intro_text, .intro_image', {
    textShadow: '1px 1px #fff'
});
Cufon.replace('.page_top_title, .page_top_desc, .page_top_desc > ul > li > a', {
    textShadow: '1px 1px #444',hover: true
});
/* end cufon replacer */


  
jQuery(document).ready(function() {

	
    $(".footer_social_networks ul li,.footer_widgetcenter a").fadeTo('normal', 0.4);
    $(".footer_social_networks ul li,.footer_widgetcenter a").hover(function(){
        $(this).fadeTo('normal', 1);
    }, function() {
        $(this).fadeTo('normal', 0.4);
    });   

    $(".small_text").focus(function () {
        $(this).css({
            "backgroundPosition":"0 -28px"
        });
    });
    $(".small_text").blur(function () {
        $(this).css({
            "backgroundPosition":"0 0"
        });
    });   
	
});

/* begin scrolltop control */
$(function(){
    sh = $(window).height() / 2;
    xh = $(document).height() /2 - sh;
});	

var scrolltotop={
	
    setting: {
        startline:200, 
        scrollto: 0, 
        scrollduration:1000, 
        fadeduration:[200, 50]
        },
    controlHTML: '<span class="scroll_up"></span>',
    controlattrs: {
        offsetx:5, 
        offsety:5
    }, 
    anchorkeyword: '#top',
    state: {
        isvisible:false, 
        shouldvisible:false
    },

    scrollup:function(){
        if (!this.cssfixedsupport) 
            this.$control.css({
                opacity:0
            }) 
        var dest=isNaN(this.setting.scrollto)? this.setting.scrollto : parseInt(this.setting.scrollto)
        if (typeof dest=="string" && jQuery('#'+dest).length==1) 
            dest=jQuery('#'+dest).offset().top
        else
            dest=0
        this.$body.animate({
            scrollTop: dest
        }, this.setting.scrollduration);
    },

    keepfixed:function(){
        var $window=jQuery(window)
        var controlx=$window.scrollLeft() + $window.width() - this.$control.width() - this.controlattrs.offsetx
        var controly=$window.scrollTop() + $window.height() - this.$control.height() - this.controlattrs.offsety
        this.$control.css({
            left:controlx+'px', 
            top:controly+'px'
            })
		
	
    },

    togglecontrol:function(){
        var scrolltop=jQuery(window).scrollTop()
        if (!this.cssfixedsupport)
            this.keepfixed()
        this.state.shouldvisible=(scrolltop>=xh)? true : false
        if (this.state.shouldvisible && !this.state.isvisible){
            this.$control.stop().animate({
                opacity:1
            }, this.setting.fadeduration[0])
            this.state.isvisible=true
        }
        else if (this.state.shouldvisible==false && this.state.isvisible){
            this.$control.stop().animate({
                opacity:0
            }, this.setting.fadeduration[1])
            this.state.isvisible=false
        }
    },
	
    init:function(){
        jQuery(document).ready(function($){
            var mainobj=scrolltotop
            var iebrws=document.all
            mainobj.cssfixedsupport=!iebrws || iebrws && document.compatMode=="CSS1Compat" && window.XMLHttpRequest //not IE or IE7+ browsers in standards mode
            mainobj.$body=(window.opera)? (document.compatMode=="CSS1Compat"? $('html') : $('body')) : $('html,body')
            mainobj.$control=$('<div id="topcontrol"><span class="scroll_up"></span></div>')
            .css({
                position:mainobj.cssfixedsupport? 'fixed' : 'absolute', 
                bottom:mainobj.controlattrs.offsety, 
                right:mainobj.controlattrs.offsetx, 
                opacity:0, 
                cursor:'pointer'
            })
            .attr({
                title:'Scroll Back to Top'
            })
            .click(function(){
                mainobj.scrollup();
                return false
                })
            .appendTo('body')
            if (document.all && !window.XMLHttpRequest && mainobj.$control.text()!='') //loose check for IE6 and below, plus whether control contains any text
                mainobj.$control.css({
                    width:mainobj.$control.width()
                    }) //IE6- seems to require an explicit width on a DIV containing text
            mainobj.togglecontrol()
            $('a[href="' + mainobj.anchorkeyword +'"]').click(function(){
                mainobj.scrollup()
                return false
            })
            $(window).bind('scroll resize', function(e){
                mainobj.togglecontrol()
            })
        })
    }
}

scrolltotop.init()
/* end scrolltop control */
