/*
 * 	Easy Slider 1.5 - jQuery plugin
 *	written by Alen Grakalic	
 *	http://cssglobe.com/post/4004/easy-slider-15-the-easiest-jquery-plugin-for-sliding
 *
 *	Copyright (c) 2009 Alen Grakalic (http://cssglobe.com)
 *	Dual licensed under the MIT (MIT-LICENSE.txt)
 *	and GPL (GPL-LICENSE.txt) licenses.
 *
 *	Built for jQuery library
 *	http://jquery.com
 *
 */
$(document).ready(function(){
	$("a.website-design-menu-10").click(function(){		
		$("#slider").html('<div class=\"website-design-inner-top\">Demand our best.</div><div class=\"website-design-inner\">No matter the task, we work until you are excited. Including: <br /><div class=\"leftarr\"><!-- --></div>Site Design<br /><div class=\"leftarr\"><!-- --></div>Web Application Development<br /><div class=\"leftarr\"><!-- --></div>Brand Development<br /><div class=\"leftarr\"><!-- --></div>Online Marketing<br /><div class=\"leftarr\"><!-- --></div>Site Monetization<br />Anything that can be done with silly putty and maple syrup</div><div class=\"website-design-inner-top\">MidWhere?</div><div class=\"website-design-inner\">Working with a design company in the Midwest is a lot like working with a neighbor (the one that actually returns your power tools). Our team is dedicated to making you comfortable during the entire design and development process. We will walk you through every step of the way by producing tangible milestones and waiting for your  feedback instead of racing to the finish. <br /><br />We take the time to understand your business and your customers, because a well-planned consumer experience will help win repeat business and separate your company from the pack.<br /></div>');
		$("a.website-design-menu-21").removeClass().addClass("website-design-menu-20");
		$("a.website-design-menu-31").removeClass().addClass("website-design-menu-30");
		$("a.website-design-menu-10").removeClass().addClass("website-design-menu-11");
		$("#prevBtn").hide();
		$("#nextBtn").hide();
		$("#website-design-content-1").removeClass().addClass("website-design-content-2");

	});
	$("a.website-design-menu-21").click(function(){		
		$("#slider").html('<ul><li><a href=\"portfolio.htm#1\"><img src=\"images/p-puzzlefactory.jpg\" alt=\"Puzzle Factory\" border=\"0\"/></a></li><li><a href=\"portfolio.htm#2\"><img src=\"images/p-wiredhub.gif\" alt=\"WiredHub\" border=\"0\" /></a></li><li><a href=\"portfolio.htm#3\"><img src=\"images/p-touchsupport.gif\" alt=\"Touch Support\" border=\"0\" /></a></li></ul>');
		$("a.website-design-menu-11").removeClass().addClass("website-design-menu-10");
		$("a.website-design-menu-31").removeClass().addClass("website-design-menu-30");
		$("a.website-design-menu-20").removeClass().addClass("website-design-menu-21");
		$("#prevBtn").show();
		$("#nextBtn").show();
		$("#website-design-content-1").removeClass().addClass("website-design-content-1");
	});
	$("a.website-design-menu-30").click(function(){		
		$("#slider").html('<div class=\"website-design-inner-top\">Lead Developer - David Lindahl</div><div class=\"website-design-inner\">Having founded nearly a dozen companies, Mr. Lindahl understands the needs of our clients. Over the past 10 years, Dave created and developed over 100 sites and brand identities.<br /><br /><div class=\"leftarr\"><!-- --></div>Email: dave@lnmedia.com<br /><div class=\"leftarr\"><!-- --></div>Phone: 765 404 1763</div>');
		$("a.website-design-menu-21").removeClass().addClass("website-design-menu-20");
		$("a.website-design-menu-11").removeClass().addClass("website-design-menu-10");
		$("a.website-design-menu-30").removeClass().addClass("website-design-menu-31");
		$("#prevBtn").hide();
		$("#nextBtn").hide();
		$("#website-design-content-1").removeClass().addClass("website-design-content-2");
	});
});

(function($) {

  $.fn.easySlider = function(options){
    // default configuration properties
    var defaults = {			
	prevId: 		'prevBtn',
	prevText: 		'Previous',
	nextId: 		'nextBtn',	
	nextText: 		'Next',
	controlsShow:	true,
	controlsBefore:	'',
	controlsAfter:	'',	
	controlsFade:	true,		
	vertical:		false,
	speed: 			500,
	auto:			false,
	pause:			14000,
	continuous:		false
    }; 
		
    var options = $.extend(defaults, options);  
				
    this.each(function() {  
	var obj = $(this); 				
	var s = $("li", obj).length;
	var w = $("li", obj).width(); 
	var h = $("li", obj).height(); 
	obj.width(w); 
	obj.height(h); 
	obj.css("overflow","hidden");
	var ts = s-1;
	var t = 0;
	$("ul", obj).css('width',s*w);			
	if(!options.vertical) $("li", obj).css('float','left');
			
	if(options.controlsShow){
	  var html = options.controlsBefore;	  
	  html += options.controlsAfter;						
	  $(obj).after(html);										
	};
	
			$("a","#"+options.nextId).click(function(){		
				animate("next",true);
			});
			$("a","#"+options.prevId).click(function(){		
				animate("prev",true);				
			});	
	
			
			function animate(dir,clicked){
				var ot = t;				
				switch(dir){
					case "next":
						t = (ot>=ts) ? (options.continuous ? 0 : ts) : t+1;						
						break; 
					case "prev":
						t = (t<=0) ? (options.continuous ? ts : 0) : t-1;
						break; 
					default:
						break; 
				};	
				
				var diff = Math.abs(ot-t);
				var speed = diff*options.speed;						
				if(!options.vertical) {
					p = (t*w*-1);
					$("ul",obj).animate(
						{ marginLeft: p }, 
						speed
					);				
				} else {
					p = (t*h*-1);
					$("ul",obj).animate(
						{ marginTop: p }, 
						speed
					);					
				};
				
				if(!options.continuous && options.controlsFade){					
					if(t==ts){
						$("a","#"+options.nextId).hide();
					} else {
						$("a","#"+options.nextId).show();					
					};
					if(t==0){
						$("a","#"+options.prevId).hide();
					} else {
						$("a","#"+options.prevId).show();
					};					
				};				
				
				if(clicked) clearTimeout(timeout);
				if(options.auto && dir=="next" && !clicked){;
					timeout = setTimeout(function(){
						animate("next",false);
					},diff*options.speed+options.pause);
				};
				
			};
			// init
			var timeout;
			if(options.auto){;
				timeout = setTimeout(function(){
					animate("next",false);
				},options.pause);
			};		
		
			if(!options.continuous && options.controlsFade){					
				$("a","#"+options.prevId).hide();
				
			};				
			
		});
	  
	};

})(jQuery);



