(function($){
	$.easing.elasout = function(x, t, b, c, d) {
		var s=1.70158;var p=0;var a=c;
		if (t==0) return b;  if ((t/=d)==1) return b+c;  if (!p) p=d*.3;
		if (a < Math.abs(c)) { a=c; var s=p/4; }
		else var s = p/(2*Math.PI) * Math.asin (c/a);
		return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b;
	};

	$.sw = function(){ initialize(); };
    $.sw.version = "1.0";
    
    var initialize = function(){

    	$(".home").click(function(){
    		$.scrollTo($("body"), {
    			duration: 500,
    			easing: "swing"
    		});
    		$.modal.close();
    	});
    	  	
    	$(".about").click(function(){
    		$.scrollTo($("#about"), {
    			duration: 1000,
    			easing: "elasout",
    			offset: {top: -30}
    		});

    	});
    	
    	$(".socialize").click(function(){
    		$.scrollTo($("#socialize"), {
    			duration: 500,
    			easing: "elasout",
    			offset: {top: -30}
    		});

    	});
    	    	
    	$(".disclaimer").each(function(){
    		$(this).click(function(){
    			var args = {
	    			minWidth: 520,
	    			overlay: true,
	    			id: "disclaimer"
	    		};
    			getModal(args);
    		});
    	});
    	
    	$(".download").each(function(){
    		$(this).click(download);
    	});
        	
    	setAudioPlayer();
    };
    
    var setAudioPlayer = function(){
    	//$("audio").mediaelementplayer();
    };
    
    var download = function(e){
    	e.preventDefault();  //stop the browser from following
    	window.location.href = 'lib/media/Shutterwax_-_Yellow_Magazine.zip';
    	var args = {
			minWidth: 520,
			overlay: true,
			id: "download"
		};
		getModal(args);
    };
    
    var getModal = function(args){
    	$("#" + args.id).modal({
			minWidth: args.minWidth,
			overlayClose: args.overlay,
			close: true,
			autoResize: true
		});
    };


})(jQuery);
