﻿$(document).ready(function(){
					

	if ($('#front_display').length > 0) {			
	$('#front_display ul').cycle({
		speed: 2000,
		timeout: 4500,
		//sync: false,
		random: '1',
		containerheight: '400px'
		});
		
	$('#front_display').click(function(){
		window.location('/news');
	})
	
	}		
	
	
	if ($('#lisbon .holder').length > 0) {			
    $('#lisbon .holder').cycle({
        fx:     'fade',
        speed:  'slow',
        timeout: 0,
        pager:  '#lisbon .thumbnails',
        pagerAnchorBuilder: function(idx, slide) {
            return '#lisbon .thumbnails li:eq(' + (idx) + ') a';
        }
    });
	}    
    
    if ($('#london .holder').length > 0) {			
	$('#london .holder').cycle({
        fx:     'fade',
        speed:  'slow',
        timeout: 0,
        pager:  '#london .thumbnails',
        pagerAnchorBuilder: function(idx, slide) {
            return '#london .thumbnails li:eq(' + (idx) + ') a';
        }
    })
    }


    if ($('.inventory #holder').length > 0) {			
		$('.inventory #holder').cycle({
        fx:     'fade',
        speed:  'slow',
        timeout: 0,
        pager:  '#carousel',
        cleartype:     1,
        //click:' #holder',
        pagerAnchorBuilder: function(idx, slide) {
            return '#carousel li:eq(' + (idx) + ') a';
        }
    })
    }



	$("a[href^='http:']").not("[href*='jorgewelsh.com']").attr('target','_blank');

		
	var elements = $('.publication');
    $('.tabs a').click(function () {
		classtoFilter = "."+this.hash.substring(1,this.hash.length);	
        $('.books li').hide();
        $('.books li.'+classtoFilter).fadeIn();
        $('.tabs a').removeClass('current');
        $(this).addClass('current');
        return false;
   }).filter(':first').click();
   
   
   // detect #
   if (document.location.hash) {
	var classtoFilter = "."+document.location.hash.substring(1,document.location.hash.length);		
    elements.hide().filter(classtoFilter).fadeIn();
    $('.tabs a').removeClass('current');
    $(document.location.hash).addClass('current');
	}
	
	
	
	// Inventory chooser
	
    if ($('#screens').length > 0) {			
	$('#screens').cycle({
        fx:     'fade',
        speed:  600,
        timeout: 5000,
		pause:true,
		pagerEvent: 'mouseover',
		pager:  '#inventory_chooser',
    	pagerAnchorBuilder: function(idx, slide) { 
        // return selector string for existing anchor 
        	return '#inventory_chooser .selector:eq(' + idx + ') a'; 
    	}
    	//pauseOnPagerHover: true
    });
    }
   
    if ($('#freeform').length > 0) {			
	$("#freeform").validate();
	}


	$(".placeholder").inFieldLabels();

	$("a.zoom").fancybox({
		'padding': 0,
		'overlayOpacity': .7,
		'overlayColor': '#000',
		'transitionOut': null,
		'speedOut':0
		});
		
	if ($('#images').length >0) {
		$('#images').cycle({
			timeout: 0,
			next: '#nav .next',
			prev: '#nav .previous',
        	after: function(curr, next, opts) {
           		$('#page').html((opts.currSlide + 1)  + " of " + opts.slideCount + " images");
           		// if (opts.currSlide != 0) { $('.previous').show();} else { $('.previous').hide();}
            }
		});
	}
	
	if ($(".toggle_shipping").length > 0) {
		$("#shipping").hide();
		$(".toggle_shipping").click(function(e){
			e.preventDefault;
			$("#shipping").toggle()
			
		})
		
	}
})


