$(document).ready(function() {
    //linkfx
 $("#links a, a.url").hoverAttribute({tweenInFrom:"left",removeProtocol:true,removeWWW:true,highlightURLPart:"LastURIPart"});
 $("#links a, a.url").attr({target:"_blank"});
      //Text effect   
      $("#form-allowed-tags").unscramble();
      //LIGHTfx
      $("#light").click(function(){
     window.location=$(this).find("a").attr("href");
     return false;
});
      //img fx
$('img').addClass('myclass');
     //set opacity
     $('#sea').css ("opacity",0.1);
     $('#flash-background').css ("opacity",0);
      $('#flash-background').animate({opacity:'0.4' }, 18000);
      
      //DIV SEARCH
/*
       $('#sea').hover(function() {
        $(this).animate({opacity:'1' }, 400);
        }, function() {
          $(this).animate({ opacity:'0.1' }, 1000);        
        });
*/
          
        //  list animation  
        var fadeDuration = 150; //time in milliseconds
        
        $('.sf-menu ul a').hover(function() {
$(this).animate({ paddingLeft: '20px',paddingRight: '13px', opacity:'0.8'}, {duration: 'slow',easing: 'easeOutElastic'});
        }, function() {
          $(this).animate({ paddingLeft: '13px',paddingRight: '13px', opacity:'1' }, {duration: 'slow',easing: 'easeOutBounce'});        
        });
        
        
        
//HIGHLIGHT THE SEARCH
// Highlight sidebar when hovered (and fade down the content)
var	$content = jQuery("#content"),
		$sidebar = jQuery("#sea");
		
	var lowOpacity = 0.2;
	$sidebar
		.fadeTo(1000, lowOpacity)
		.hover(
			function(){
				$.fn.toggleSidebar("in");
			}, 
			function(){ 
				$.fn.toggleSidebar("out");
			});
	
	$.fn.toggleSidebar = function(inOut){
		if (inOut == "in") {
			if (!$sidebar.hasClass("sidebar-shown"))
				$sidebar.stop().fadeTo(300, 1).addClass("sidebar-shown"); 
			$content.stop().fadeTo(300, lowOpacity);
		}
		else {
			if (!$sidebar.hasClass("sidebar-focus"))
				$sidebar.stop().fadeTo(300, lowOpacity).removeClass("sidebar-shown"); 
			$content.stop().fadeTo(300, 1);
		}
	};
	
	$("input", $sidebar).bind('focus', function(){
		$sidebar.addClass("sidebar-focus");
	});
	$("input", $sidebar).bind('blur', function(){
		$sidebar.removeClass("sidebar-focus");
	});
	        
        
      });
      

    


//MESS WITH THE TEXT...
(function($) {
    
    function shuffle(a) {
        var i = a.length, j;
        while (i) {
            var j = Math.floor((i--) * Math.random());
            var t = a[i];
            a[i] = a[j];
            a[j] = t;
        }
    }
    
    function randomAlphaNum() {
        var rnd = Math.floor(Math.random() * 62);
        if (rnd >= 52) return String.fromCharCode(rnd - 4);
        else if (rnd >= 26) return String.fromCharCode(rnd + 71);
        else return String.fromCharCode(rnd + 65);
    }
    
    $.fn.rot13 = function() {
        this.each(function() {
            $(this).text($(this).text().replace(/[a-z0-9]/ig, function(chr) {
                var cc = chr.charCodeAt(0);
                if (cc >= 65 && cc <= 90) cc = 65 + ((cc - 52) % 26);
                else if (cc >= 97 && cc <= 122) cc = 97 + ((cc - 84) % 26);
                else if (cc >= 48 && cc <= 57) cc = 48 + ((cc - 43) % 10);
                return String.fromCharCode(cc);
            }));
        });
        return this;
    };
    
    $.fn.scrambledWriter = function() {
        this.each(function() {
            var $ele = $(this), str = $ele.text(), progress = 0, replace = /[^\s]/g,
                random = randomAlphaNum, inc = 3;
            $ele.text('');
            var timer = setInterval(function() {
                $ele.text(str.substring(0, progress) + str.substring(progress, str.length - 1).replace(replace, random));
                progress += inc
                if (progress >= str.length + inc) clearInterval(timer);
            }, 500);
        });
        return this;
    };
    
    $.fn.typewriter = function() {
        this.each(function() {
            var $ele = $(this), str = $ele.text(), progress = 0;
            $ele.text('');
            var timer = setInterval(function() {
                $ele.text(str.substring(0, progress++) + (progress & 1 ? '_' : ''));
                if (progress >= str.length) clearInterval(timer);
            }, 100);
        });
        return this;
    };
    
    $.fn.unscramble = function() {
        this.each(function() {
            var $ele = $(this), str = $ele.text(), replace = /[^\s]/,
                state = [], choose = [], reveal = 25, random = randomAlphaNum;
            
            for (var i = 0; i < str.length; i++) {
                if (str[i].match(replace)) {
                    state.push(random());
                    choose.push(i);
                } else {
                    state.push(str[i]);
                }
            }
            
            shuffle(choose);
            $ele.text(state.join(''));
            
            var timer = setInterval(function() {
                var i, r = reveal;
                while (r-- && choose.length) {
                    i = choose.pop();
                    state[i] = str[i];
                }
                for (i = 0; i < choose.length; i++) state[choose[i]] = random();
                $ele.text(state.join(''));
                if (choose.length == 0) clearInterval(timer);
            }, 400);
        });
        return this;
    };
    
})(jQuery);








