(function($) {
    $.fn.customFadeIn = function(speed, callback) {
        $(this).fadeIn(speed, function() {
                if(jQuery.browser.msie)
                        $(this).get(0).style.removeAttribute('filter');
                if(callback != undefined)
                        callback();
        });
    };
    $.fn.customFadeOut = function(speed, callback) {
        $(this).fadeOut(speed, function() {
                if(jQuery.browser.msie)
                        $(this).get(0).style.removeAttribute('filter');
                if(callback != undefined)
                        callback();
        });
    };
})(jQuery);



$(function() {

	// inital fade in on document load

	//$('body').customFadeIn(1000);
	
	
	
	// 'tool tip' function for portfolio images 
	
	var offsetX = 20;
	var offsetY = 10;
	
	$('#portfolio a').hover(function(e) {
		
		// mouse over
		
		var href = $(this).attr('class');
		var alt = $(this).attr('alt');
		var caption = $(this).attr('id');
		
		$('#largeImage').remove();
		$('<div id="largeImage"><img src="' + href + '" alt="' + alt + '" /><p>' + caption + '</p></div>')
			.css('top', e.pageY + offsetY)
			.css('left', e.pageX + offsetX)
			.appendTo('body');
			
	}, function() {
		
		// mouse off
		
		$('#largeImage').remove();
		
	});
	
	$('a').mousemove(function(e) {
		$('#largeImage')
			.css('top', e.pageY + offsetY)
			.css('left', e.pageX + offsetX);
	});
	
	$('#largeImage').click(function() {
	
		$(this).fadeOut(700);
	
	});
	
	
	
	// function for smooth transition of Service elements

	$('#services a').click(function() {
	
		var anchor = $(this).attr('title');
	
		$('#popUpDiv').customFadeIn(700);
		$('.popUpContainer').css({'display' : 'none'});		
		$('.popUpContainer[title=' + anchor + ']').css({'display' : 'block', 'filter' : 'none'});
		
	});
	
	$('#popUpDiv').click(function() {
	
		$(this).fadeOut(700);
	
	});

});
