$(document).ready(function () {

//cufon effect
    Cufon.replace('.cufon', {
        hover: true,
        fontFamily: 'knockout'
    });
       
    Cufon.replace('#access a', {
        hover: true,
        fontFamily: 'knockout'
    });
    
    Cufon.replace('.expandable', {
        hover: true,
        //textShadow: '1px 1px 1px #95857d',
        fontFamily: 'knockout'
    });

    Cufon.replace('.modern .entry-meta', {
        hover: true,
        fontFamily: 'knockout'
    });

    Cufon.replace('.post-content h2', {
        hover: true,
        fontFamily: 'knockout'
    });
    
    Cufon.replace('.post-content h3', {
        hover: true,
        fontFamily: 'knockout'
    });
    
    Cufon.replace('.form-title', {
        hover: true,
        fontFamily: 'marketingscript'
    });     
    
    Cufon.replace('.menus.item .post-content h2', {
        hover: true,
        fontFamily: 'marketingscript'
    });
    
    Cufon.replace('.about .post-431 h2', {
        hover: true,
        fontFamily: 'marketingscript'
    });
    
   
//add element to each navigation item, ready for the the hover state in future   
    $('#menu-top-nav li.menu-item a').before('<span class="color-bar" style="display:none"></span>');
    
	$('#menu-top-nav li.menu-item').append('<span class="arrow-up" style="display:none"></span>');

//top nav hover effect	
    $("#access a").hover(function () {
    	$(this).prev().stop().fadeTo(300, 1);
        $(this).next().slideDown('fast');
    }, function () {
    	$(this).prev().stop().fadeTo(300, 0);
        $(this).next().slideUp('fast');
    });

//image hover effect
    $("a.image-link").hover(function () {
        $(this).children("img").stop().fadeTo(300, 0.5);
    }, function () {
        $(this).children("img").stop().fadeTo(300, 1);
    });


//expandable button 
    $("a.brown").hover(function () {
        $(this).animate({
        	backgroundColor: "#252525",
            paddingLeft: "+=18",
            paddingRight: "+=18"
        }, 200);
    }, function () {
        $(this).animate({
        	backgroundColor: "#d7b06e",
            paddingLeft: "-=18",
            paddingRight: "-=18"
        }, 200);
    });
    
    $("a.dark").hover(function () {
        $(this).animate({
        	backgroundColor: "#a09c9c",
            paddingLeft: "+=18",
            paddingRight: "+=18"
        }, 200);
    }, function () {
        $(this).animate({
        	backgroundColor: "#2b2b2b",
            paddingLeft: "-=18",
            paddingRight: "-=18"
        }, 200);
    });
    
    $("a.blue").hover(function () {
        $(this).animate({
        	backgroundColor: "#2b2b2b",
            paddingLeft: "+=18",
            paddingRight: "+=18"
        }, 200);
    }, function () {
        $(this).animate({
        	backgroundColor: "#1da5e3",
            paddingLeft: "-=18",
            paddingRight: "-=18"
        }, 200);
    });
    
    $("a.orange").hover(function () {
        $(this).animate({
        	backgroundColor: "#2b2b2b",
            paddingLeft: "+=18",
            paddingRight: "+=18"
        }, 200);
    }, function () {
        $(this).animate({
        	backgroundColor: "#fc8f2f",
            paddingLeft: "-=18",
            paddingRight: "-=18"
        }, 200);
    });
    
    $("a.pink").hover(function () {
        $(this).animate({
        	backgroundColor: "#2b2b2b",
            paddingLeft: "+=18",
            paddingRight: "+=18"
        }, 200);
    }, function () {
        $(this).animate({
        	backgroundColor: "#d644d6",
            paddingLeft: "-=18",
            paddingRight: "-=18"
        }, 200);
    });
    
    $("a.green").hover(function () {
        $(this).animate({
        	backgroundColor: "#2b2b2b",
            paddingLeft: "+=18",
            paddingRight: "+=18"
        }, 200);
    }, function () {
        $(this).animate({
        	backgroundColor: "#3ca94b",
            paddingLeft: "-=18",
            paddingRight: "-=18"
        }, 200);
    }); 
    
    $("a.red").hover(function () {
        $(this).animate({
        	backgroundColor: "#2b2b2b",
            paddingLeft: "+=18",
            paddingRight: "+=18"
        }, 200);
    }, function () {
        $(this).animate({
        	backgroundColor: "#d83740",
            paddingLeft: "-=18",
            paddingRight: "-=18"
        }, 200);
    });  
    
    $("a.venue-bottom").hover(function () {
        $(this).stop().animate({
        	backgroundColor: "#d644d6"
        }, 200);
    }, function () {
        $(this).stop().animate({
        	backgroundColor: "#2b2b2b"
        }, 200);
    });
    

	$("a.lime").live({
	  mouseenter: function() {
	    $(this).animate({
	        	backgroundColor: "#2b2b2b",
	            paddingLeft: "+=18",
	            paddingRight: "+=18"
	        }, 200);
	  },
	  mouseleave: function() {
	    $(this).animate({
	        	backgroundColor: "#74bc07",
	            paddingLeft: "-=18",
	            paddingRight: "-=18"
	        }, 200);
	  }
	});
	
//hide "required fields" message when form submitted.

	$(".gform_wrapper").append('<span class="form-desc">* Required Fields</span>');
 
 //twitter widget scroll  
	$('.twitter-widget ul').serialScroll({
		items:'li',
		prev:'.twitter-widget span.prev',
		next:'.twitter-widget span.next',
		duration:500,
		force:true,
		axis:'y',
		easing:'linear',
		lazy:true,// NOTE: it's set to true, meaning you can add/remove/reorder items and the changes are taken into account.
		//interval:1, // yeah! I now added auto-scrolling
		step:1 // scroll 2 news each time
	});
	
//load more content	
	var count = 0;
    $(".load-more a").live({
	     click: function () {
	    	count++;
	    	$(".unload-"+count).slideDown(1000);
	    }
    });
  
//replace select form element to list so they are stylable  
	function createDropDown(selectID){
		var source = $("#"+selectID);
		//var selectParent = $("#"+selectID+"select");
		var selectParent = $("#"+selectID).parent();
		var selected = source.find("option[selected]");
		var options = $("option", source);
		var target = selectID+"-target";
		$(selectParent).append('<dl id="'+target+'" class="dropdown"></dl>');
		$("#"+target).append('<dt><a mySelect="'+selectID+'" href="javascript:;">' + selected.text() +
		'<span class="value">' + selected.val() +
		'</span></a></dt>')
		$("#"+target).append('<dd><ul></ul></dd>');
		options.each(function(){
		$("#"+target+" dd ul").append('<li><a mySelect="'+selectID+'" href="javascript:;">' +
		$(this).text() + '<span class="value">' +
		$(this).val() + '</span></a></li>');
		});
	} 
	createDropDown('filter-day');
	createDropDown('filter-events');
	createDropDown('filter-type');
	createDropDown('filter-location');
	
	$(".dropdown dt a").click(function() {
		$(".dropdown dd ul").fadeOut('fast');
		var mySelect = $(this).attr('mySelect');
		var myTarget = "#"+mySelect+"-target";
		$(myTarget+".dropdown dd ul").fadeIn('fast');
	});
	
	$(document).bind('click', function(e) {
		var $clicked = $(e.target);
		if (! $clicked.parents().hasClass("dropdown"))
			$(".dropdown dd ul").fadeOut('fast');
	});
	
	$(".dropdown dd ul li a").click(function() {
		var text = $(this).html();
		var mySelect = $(this).attr('mySelect');
		var myTarget = "#"+mySelect+"-target";
		$(myTarget+".dropdown dt a").html(text);
		$(".dropdown dd ul").hide();
		var source = $("#"+mySelect);
		source.val($(this).find("span.value").html());
		source.trigger('change');

	});
	
// Lightboxes

    $("a.book-table").fancybox({
        'transitionIn': 'fade',
        'transitionOut': 'fade',
        'speedIn': 500,
        'speedOut': 500,
        'padding': 0,
        'margin': 0,
        'autoDimensions': false,
        'width': 610,
        'height': 620,
        'overlayColor': '#000',
        'overlayOpacity': 0.7,
        'scrolling': 'no',
        'onComplete': function () {
            $("#fancybox-content").css('height', '620px');
            $("#fancybox-content").css('width', '610px');
            
        }
    });
    
    $("a.sign-up").fancybox({
        'transitionIn': 'fade',
        'transitionOut': 'fade',
        'speedIn': 500,
        'speedOut': 500,
        'padding': 0,
        'margin': 0,
        'autoDimensions': false,
        'width': 610,
        'height': 450,
        'overlayColor': '#000',
        'overlayOpacity': 0.7,
        'scrolling': 'no',
        'onComplete': function () {
            $("#fancybox-content").css('height', '450px');
            $("#fancybox-content").css('width', '610px');
            
        }
    });
    
    $("a.employment").fancybox({
        'transitionIn': 'fade',
        'transitionOut': 'fade',
        'speedIn': 500,
        'speedOut': 500,
        'padding': 0,
        'margin': 0,
        'autoDimensions': false,
        'width': 610,
        'height': 400,
        'overlayColor': '#000',
        'overlayOpacity': 0.7,
        'scrolling': 'no',
        'onComplete': function () {
            $("#fancybox-content").css('height', '400px');
            $("#fancybox-content").css('width', '610px');
            
        }
    });
    
    $("#menu-item-256 a").fancybox({
        'transitionIn': 'fade',
        'transitionOut': 'fade',
        'speedIn': 500,
        'speedOut': 500,
        'padding': 0,
        'margin': 0,
        'autoDimensions': false,
        'width': 610,
        'height': 550,
        'overlayColor': '#000',
        'overlayOpacity': 0.7,
        'scrolling': 'no',
        'onComplete': function () {
            $("#fancybox-content").css('height', '550px');
            $("#fancybox-content").css('width', '610px');
            
        }
    });
    
    $("#menu-item-307 a, a.apply-to").fancybox({
        'transitionIn': 'fade',
        'transitionOut': 'fade',
        'speedIn': 500,
        'speedOut': 500,
        'padding': 0,
        'margin': 0,
        'autoDimensions': false,
        'width': 610,
        'height': 650,
        'overlayColor': '#000',
        'overlayOpacity': 0.7,
        'scrolling': 'no',
        'onComplete': function () {
            $("#fancybox-content").css('height', '650px');
            $("#fancybox-content").css('width', '610px');
            
        }
    });

    $("a#form-request-wedding").fancybox({
        'transitionIn': 'fade',
        'transitionOut': 'fade',
        'speedIn': 500,
        'speedOut': 500,
        'padding': 0,
        'margin': 0,
        'autoDimensions': false,
        'width': 610,
        'height': 300,
        'overlayColor': '#000',
        'overlayOpacity': 0.7,
        'scrolling': 'no',
        'onComplete': function () {
            $("#fancybox-content").css('height', '300px');
            $("#fancybox-content").css('width', '610px');
            
        }
    });
    
    $("a#form-wedding-enquiry").fancybox({
        'transitionIn': 'fade',
        'transitionOut': 'fade',
        'speedIn': 500,
        'speedOut': 500,
        'padding': 0,
        'margin': 0,
        'autoDimensions': false,
        'width': 610,
        'height': 620,
        'overlayColor': '#000',
        'overlayOpacity': 0.7,
        'scrolling': 'no',
        'onComplete': function () {
            $("#fancybox-content").css('height', '620px');
            $("#fancybox-content").css('width', '610px');
            
        }
    });
    
    $(".side-gallery a.image-link").fancybox({
        'titleShow'     : false,
		'transitionIn'	: 'elastic',
		'transitionOut'	: 'elastic',
        'overlayColor'  : '#000',
        'overlayOpacity': 0.7,
		'easingIn'      : 'easeOutBack',
		'easingOut'     : 'easeInBack'
    });
    
    $(".post-image a.image-link").fancybox({
        'titleShow'     : false,
		'transitionIn'	: 'elastic',
		'transitionOut'	: 'elastic',
        'overlayColor'  : '#000',
        'overlayOpacity': 0.7,
		'easingIn'      : 'easeOutBack',
		'easingOut'     : 'easeInBack'
    });
    
    $(".ngg-gallery-thumbnail a.image-link").fancybox({
        'titleShow'     : false,
		'transitionIn'	: 'elastic',
		'transitionOut'	: 'elastic',
        'overlayColor'  : '#000',
        'overlayOpacity': 0.7,
		'easingIn'      : 'easeOutBack',
		'easingOut'     : 'easeInBack'
    });
    
    $("a.iframe-link").fancybox({
        'transitionIn': 'fade',
        'transitionOut': 'fade',
        'speedIn': 500,
        'speedOut': 500,
        'autoScale': false,
        'width': '75%',
        'height': '75%',
        'overlayColor': '#000',
        'overlayOpacity': 0.7,
        'type': 'iframe'
    });  
    
    $("#page").fadeIn(700); 
}); //document.ready function ends here


$(window).load(function() {
	
	$("#slider .nivo-controlNav a img").fadeTo(0, 0.5);
	 
    $("#slider .nivo-controlNav a").hover(function () {
        $(this).children("img").stop().fadeTo(300, 1);
        $(this).children(".arrow-left").next().stop().fadeTo(300, 1);
    }, function () {
        $(this).children("img").stop().fadeTo(300, 0.5);
        $(this).children(".arrow-left").next().fadeOut(0);
    });
    
});
