/*
Restoration & Beyond - Navigation aids

Copyright (c) 2009 Cool Blue Brand Communications, http://www.coolblue.co.uk

Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
*/

$(function() {

					
	// help boxes hide (will need to be supplimented by cookies)
	$(".helpbox a.hide").click(function() {
		$(this).closest(".helpbox").slideUp();
	});
	
	// featured credits
	$(".featuredcredit").hide();
	
	$(".featuredleft, .featuredright").hoverIntent(function() {
		$(".featuredcredit", this).fadeIn();
	}, function() {
		$(".featuredcredit", this).fadeOut();
	});
	
	// top icon help tips
	$(".icons a").hoverIntent(function() {
		$(".description span").text($(this).attr("title"));
		$("#undernav .description").slideDown(150);
	}, function() {
		$("#undernav .description").slideUp(150);
	});
	
	// sidebar slide images
	$(".bluebg .slideimg").css({"right": "-20px"});
	
	$(".bluebg").hover(function() {
		$(".slideimg", this).stop().animate({"right": "0"}, 300);
	}, function() {
		$(".slideimg", this).stop().animate({"right": "-20px"}, 300);
	});
	
	// fancy multi-image thumbnails
	$("ul.fancyimage").each(function(i,f) {
		$(f).hover(function() { // fade in and out on hover
			$(".fancynav", this).hide().fadeIn(200);
		},function() {
			$(".fancynav", this).show().fadeOut(200);
		});
		var nav = $('<li class="fancynav"></li>'); // create new list item to hold navigation tabs
		$("li:first", $(f)).show();
		if ($("li", $(f)).size() > 1) { // should be more than one list item, otherwise don't bother
			$("li", $(f)).each(function(j, g) {
				var navEl = $('<a href="big/' + $("img",$(g)).attr("src") + '">' + (j+1) + '</a>'); // create a link using the image's src attribute as the basis for its link
				if (j == 0) { navEl.addClass("fancynavactive"); } // make the first item active
				navEl.mouseenter(function() { // add functionality to the link
					if (!navEl.hasClass("fancynavactive")) { // make sure this isn't already the active item
						$("li:not(.fancynav)", $(f)).hide(); // hide all images
						$("li.fancynav a", $(f)).removeClass("fancynavactive"); // get rid of the active class on all items...
						navEl.addClass("fancynavactive"); // ... and put it back on the current item
						$(g).show(); // show the current image
					}
				});
				navEl.appendTo(nav); // add the link to the nav list
			});
			nav.appendTo($(f)); // add the nav list to the fancyimage list
		}
	});
	
	// contact form handler
	
	$(".contactform").hide();
	
	

	$(".contact").click(function() {
		$(".contactform").slideDown();
	});
	
	$(".contact").click(function() {
		$(".contactform2").slideDown();
	});
	
	$(".close").click(function() {
		$(".contactform").slideUp();
	});
	
	$(".close").click(function() {
		$(".contactform2").slideUp();
	});
	
	$('a[@rel*=lightbox]').lightBox(); 
	
	
	
	// password strength tester
	$('#password').pstrength({'minChar': 6, 'minCharText': 'Minimum of %d characters'});
	
	

});