/*
 * 	Easy Slider - jQuery plugin
 *	written by Alen Grakalic	
 *	http://cssglobe.com/post/3783/jquery-plugin-easy-image-or-content-slider
 *
 *	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
 *
 */
 
/*
 *	markup example for $("#images").easySlider();
 *	
 * 	<div id="images">
 *		<ul>
 *			<li><img src="images/01.jpg" alt="" /></li>
 *			<li><img src="images/02.jpg" alt="" /></li>
 *			<li><img src="images/03.jpg" alt="" /></li>
 *			<li><img src="images/04.jpg" alt="" /></li>
 *			<li><img src="images/05.jpg" alt="" /></li>
 *		</ul>
 *	</div>
 *
 */

(function($) {

	$.fn.easySlider = function(options){
	  
		// default configuration properties
		var defaults = {
			prevId: 		'prevBtn',
			prevText: 		'Prev',
			nextId: 		'nextBtn',	
			nextText: 		'Nxt',
			orientation:	'', //  'vertical' is optional;
			speed: 			800			
		}; 
		
		var options = $.extend(defaults, options);  
		
		return this.each(function() {  
			obj = $(this); 				
			var s = $("li", obj).length;
			var w = obj.width(); 
			var h = obj.height(); 
			var ts = s-4;
			var t = 0;
			var vertical = (options.orientation == 'vertical');
			$("ul", obj).css('width',s*w);			
			if(!vertical) $("li", obj).css('float','left');
			$(obj).after('<div id="'+ options.prevId +'"><a href=\"javascript:void(0);\"><img src=\"images/2010/prev-arrow.png\" title=\"Previous Services\" border=\"0\"></a></div> <div id="'+ options.nextId +'"><a href=\"javascript:void(0);\"><img src=\"images/2010/next-arrow.png\" title=\"Next Services\" border=\"0\"></a></div>');		
			$("a","#"+options.prevId).hide();
			$("a","#"+options.nextId).hide();
			$("a","#"+options.nextId).click(function(){		
				animate("next");
				if (t>=ts) $(this).fadeOut();
				$("a","#"+options.prevId).fadeIn();
			});
			$("a","#"+options.prevId).click(function(){		
				animate("prev");
				if (t<=0) $(this).fadeOut();
				$("a","#"+options.nextId).fadeIn();
			});	
			function animate(dir){
				if(dir == "next"){
					t = (t>=ts) ? ts : t+1;	
				} else {
					t = (t<=0) ? 0 : t-1;
				};								
				if(!vertical) {
					p = (t*w*-1);
					$("ul",obj).animate(
						{ marginLeft: p }, 
						options.speed
					);				
				} else {
					p = (t*h*-1);
					$("ul",obj).animate(
						{ marginTop: p }, 
						options.speed
					);					
				}
			};
			if(s>1) $("a","#"+options.nextId).fadeIn();	
		});
	  
	};

})(jQuery);

/*	ChillTip Version 1.0
	by Christopher Hill - http://www.chillwebdesigns.co.uk/
	Last Modification: 01/05/10
	
	For more information, visit:
	http://www.chillwebdesigns.co.uk/chilltip.html
	
	Licensed under the Creative Commons Attribution 2.5 License - http://creativecommons.org/licenses/by/2.5/
	- Free for use in both personal and commercial projects
	- Attribution requires leaving author name, author link, and the license info intact
*/

$(document).ready(function(){
						   
// ChillTip Version 1.0 - add class="chillTip" and title="This is a Chilltip" tag to img,a,span attributes. 
						   
$('.chillTip').mouseover(function(){								  
	$('body').append('<div class="title"></div>');
	var title = $(this).attr("title");
	$('.title').append('<p>' + title + '</p>');
	// Change the value below to change opacity of the ChillTip from 0-100 or 0.0-1.0
	$('.title').css("filter:","alpha(opacity=85)").css("-moz-opacity","0.85").css("-khtml-opacity", "0.85").css("opacity", "0.85");  
	$('.title').fadeIn(500);  //ChillTip fade in time (recommended 500ms)
	this.tip = this.title;
	this.title = "";
	});

$('.chillTip').mousemove(function(e){
	var border_top = $(window).scrollTop(),border_right = $(window).width(),offset = 5,left_pos,top_pos;
    if(	border_right - (offset *2) >= $('.title').width() + e.pageX){left_pos = e.pageX + offset;}
	else{left_pos = border_right - $('.title').width() - offset;}
	if(border_top + (offset *2 ) >= e.pageY - $('.title').height()){top_pos = border_top + offset;}
	else{top_pos = e.pageY-$('.title').height( )- offset;}	
	$('.title').css({left:left_pos, top:top_pos});
	});

$('.chillTip').mouseout(function(){
	$('.title').remove();
	this.title = this.tip;
	});

});