// JavaScript Document


function home_slideshow() {
		$('#slideshow').crossSlide({
		  sleep: 2,
		  fade: 1
		}, [
		  {
		  	src: '/themes/theme_001/images/home/plumbing.jpg'
		  }, {
		  	src: '/themes/theme_001/images/home/kitchen.jpg'
		  }, {
		  	src: '/themes/theme_001/images/home/bathroom.jpg'
		  }, {
		  	src: '/themes/theme_001/images/home/tiling.jpg'
		  }, {
		  	src: '/themes/theme_001/images/home/painting.jpg'
		  }, {
		  	src: '/themes/theme_001/images/home/handyman.jpg'
		  }, {
		  	src: '/themes/theme_001/images/home/garden.jpg'
		  }, {
		  	src: '/themes/theme_001/images/home/carpentry.jpg'
		  }
		]);
}


$(function() {
		   
	$("#page_new").hide();
	
	$(document).ready(function() {
    	$("#page_new").validate();
  	});

	
	$("a").click(function () {
    	$("#page_new").slideDown();
      	return true;
    });

}
);



// Initially set opacity on thumbs and add
// additional styling for hover effect on thumbs
var onMouseOutOpacity = 0.67;
$('#thumbs-adv ul.thumbs li').css('opacity', onMouseOutOpacity)
	.hover(
		function () {
			$(this).not('.selected').fadeTo('fast', 1.0);
		}, 
		function () {
			$(this).not('.selected').fadeTo('fast', onMouseOutOpacity);
		}
	);

$(document).ready(function() {
	// Initialize Advanced Galleriffic Gallery
	var galleryAdv = $('#gallery-adv').galleriffic('#thumbs-adv', {
		delay:                  2000,
		numThumbs:              12,
		preloadAhead:           10,
		enableTopPager:         true,
		enableBottomPager:      false,
		imageContainerSel:      '#slideshow-adv',
		controlsContainerSel:   '#controls-adv',
		captionContainerSel:    '#caption-adv',
		loadingContainerSel:    '#loading-adv',
		renderSSControls:       true,
		renderNavControls:      true,
		playLinkText:           'Play Slideshow',
		pauseLinkText:          'Pause Slideshow',
		prevLinkText:           '&lsaquo;&lsaquo; Previous Photo',
		nextLinkText:           'Next Photo &rsaquo;&rsaquo;',
		nextPageLinkText:       'Next &rsaquo;&rsaquo;',
		prevPageLinkText:       '&lsaquo;&lsaquo; Prev',
		enableHistory:          true,
		autoStart:              false,
		onChange:               function(prevIndex, nextIndex) {
			$('#thumbs-adv ul.thumbs').children()
				.eq(prevIndex).fadeTo('fast', onMouseOutOpacity).end()
				.eq(nextIndex).fadeTo('fast', 1.0);
		},
		onTransitionOut:        function(callback) {
			$('#slideshow-adv, #caption-adv').fadeOut('fast', callback);
		},
		onTransitionIn:         function() {
			$('#slideshow-adv, #caption-adv').fadeIn('fast');
		},
		onPageTransitionOut:    function(callback) {
			$('#thumbs-adv ul.thumbs').fadeOut('fast', callback);
		},
		onPageTransitionIn:     function() {
			$('#thumbs-adv ul.thumbs').fadeIn('fast');
		}
	});
	
	if ($('#slideshow').length) {
	

		home_slideshow();
		

		$('.services-thumbs img').hover(function() {
			$('#slideshow').unbind('crossSlide');
			var src = '/themes/theme_001/images/home/' + $(this).attr('class') + '.jpg';
			$('#slideshow img').attr('src', src);
		}, function() {
			//setTimeout("home_slideshow", 2000);
		});
		
		$('.services-thumbs dd').hover(function() {
			$('#slideshow').unbind('crossSlide');
			var src = '/themes/theme_001/images/home/' + $(this).prev().children('a').children('img').attr('class') + '.jpg';
			$('#slideshow img').attr('src', src);
		}, function() {
			//setTimeout("home_slideshow", 2000);
		});

		
	}
	
	
	if ($('#facebook_embed').length) {
		var fb_src = 'http://www.facebook.com/plugins/likebox.php?href=http%3A%2F%2Fwww.facebook.com%2Fpages%2FBath-United-Kingdom%2FJacks-Garden-Store%2F236426334026%23%21%2Fpages%2FChobham-United-Kingdom%2FAwesome-Africa-Handyman%2F84689663055&amp;width=500&amp;colorscheme=light&amp;connections=16&amp;stream=true&amp;header=true&amp;height=587';
		var fb_html = '<iframe src="' + fb_src + '" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:500px; height:587px;" allowTransparency="true"></iframe>';
		$('#facebook_embed').html(fb_html);
		//$('#facebook_embed iframe').attr("src",fb_src);
	}		

});



var timeout         = 500;
var closetimer		= 0;
var ddmenuitem      = 0;

function jsddm_open()
{	jsddm_canceltimer();
	jsddm_close();
	ddmenuitem = $(this).find('ul').eq(0).css('visibility', 'visible');}

function jsddm_close()
{	if(ddmenuitem) ddmenuitem.css('visibility', 'hidden');}

function jsddm_timer()
{	closetimer = window.setTimeout(jsddm_close, timeout);}

function jsddm_canceltimer()
{	if(closetimer)
	{	window.clearTimeout(closetimer);
		closetimer = null;}}

$(document).ready(function()
{	$('#primary_navigation > li').bind('mouseover', jsddm_open);
	$('#primary_navigation > li').bind('mouseout',  jsddm_timer);});

document.onclick = jsddm_close;

