$(document).ready(function() {
    $('#navigation ul').superfish({ 
		hoverClass:    'hover',
		pathLevels:    1,
		delay:         800,
		animation:     {opacity:'show'},
		speed:         'normal',
		autoArrows:    false,
		dropShadows:   true,
		disableHI:     false
    });

});
function buildImages(int_width, int_height, str_cropratio, str_image, str_image_title, bool_transition) {	
	var width = 100;
	var height = 100;
	var cropratio = "1:1";
	var imageSrc = "/images/uploads/";
	var imageTitle = "";
	if ((int_width != '') && (int_width != width)) {
		width = (int_width);
	}
	if ((int_height != '') && (int_height != height)) {
		height = (int_height);
	}
	if ((str_cropratio != '') && (str_cropratio != cropratio)) {
		cropratio = str_cropratio;
	}
	if ((str_image_title != '') && (str_image_title != imageTitle)) {
		imageTitle = str_image_title;
	}
	imageSrc = imageSrc + str_image;
	var colorImage = '';
	var greyscaleImage = '';
	var spacer = '';
	var images = '';
	if (bool_transition) {
		/* two image fade */
		greyscaleImage = '<img src="/assets/functions/image.php/' + str_image + '?greyscale=true&amp;width=' + (width) + '&amp;height=' + (height) + '&amp;cropratio=' + cropratio + '&amp;image=' + imageSrc + '" alt="' + imageTitle + '" class="greyscale" width="' + (width) + '" height="' + (height) + '" />';
		colorImage = '<img src="/assets/functions/image.php/' + str_image + '?width=' + (width) + '&amp;height=' + (height) + '&amp;quality=100&amp;cropratio=' + cropratio + '&amp;image=' + imageSrc + '" alt="' + imageTitle + '"  width="' + (width) + '" height="' + (height) + '" />';
		images = '<span class="image"><span class="overlay greyscale" style="width:' + (width + 2) + 'px; height:' + (height + 2) + 'px; ">' + greyscaleImage + '</span><span class="overlay color" style="width:' + (width + 2) + 'px; height:' + (height + 2) + 'px;">' + colorImage + '</span></span>';	
	} else {
		/* one image, fade the border */
		colorImage = '<img src="/assets/functions/image.php/' + str_image + '?width=' + (width) + '&amp;height=' + (height) + '&amp;quality=100&amp;cropratio=' + cropratio + '&amp;image=' + imageSrc + '" alt="' + imageTitle + '"  width="' + (width) + '" height="' + (height) + '"  />';
		spacer = '<img src="/assets/images/spacer.png" width="' + (width) + '" height="' + (height) + '" />';
		images = '<span class="image"><span class="overlay greyscale" style="width:' + (width) + 'px; height:' + (height) + 'px;">' + colorImage + '</span><span class="overlay color" style="width:' + (width) + 'px; height:' + (height) + 'px; ">' + spacer + '</span></span>';
	}
	$(".overlay.color").livequery(function() {
		$(this).hide();
	});
	return images;
};
function imageTransition(el) {
	$(el).hover(
		function() {
			$(this).find('.overlay.color').fadeIn(400).click(function(e) {
				
				var link = $(this).parent().parent().attr('href');
				document.location.href = link;
				
			});
		},
		function() {
			$(this).find('.overlay.color').fadeOut(400);
		}
	);
};	
function buildSlideShow(el) {
	$(el).before('<div id="slideshowNav"></div>').cycle({
		fx:'fade',
		timeout:4500,
		speed:1000,
		prev: '#slideshowPrev',
		next: '#slideshowNext',
		after:onAfter,
		pager: '#slideshowNav',
		pause:1,
		cleartype: 1,
		delay:2000
	});
	$("#slideshowPrev").hover(
		function() {
			$(this).css("color", "#ffffff");
		},
		function() {
			$(this).css("color", "#979797");
		}
	);
	$("#slideshowNext").hover(
		function() {
			$(this).css("color", "#ffffff");
		},
		function() {
			$(this).css("color", "#979797");
		}
	);
	function onAfter(curr, next, opts) {
		var index = $(this).parent().children().index(this);
	}
	var ct= $("#slideshowNav a").length;
	if (ct > 0) {	
		$("#slideshowNav").livequery(function() {
			$(this).append(' &#124; ');
		});
		$("#slideshowNav a").livequery(function() {
			$(this).before(' &#124; ');
		});
	}
	$("#slideshow .imageWrapper a").each(function(i) {
		$(this).prepend('<span class="tooltip" id="tooltip-lightbox-'+i+'"><span>+</span></span>');
		var imgClass = $(this).find('.tooltip').next().attr('class');
		$(this).find('.tooltip').addClass(imgClass);
		$(this).hover(
			function() {
				$(this).find('.tooltip').fadeTo(250,0.8);
			},
			function() {
				$(this).find('.tooltip').fadeTo(250, 0);
			}
		);

	});
};
function hideEl(el) {
	$(el).hide();
};


