
$(document).ready( function() {
     
    $('#popup-wrapper').cycle({
        fx: 'fade' ,
        speed: 200,
        next:    '#but1',
        prev:    '#but2',
        timeout: 0
    });
     
    // open external link in new tab/window
    // use rel="external" instead of target="_blank"
    $('a[rel="external"]').click( function() {
        this.target = "_blank";
    });
    
    //email replacement
    $("span.mailto").each(function(){
        exp = $(this).text().search(/\((.*?)\)/) != -1 ? new RegExp(/(.*?) \((.*?)\)/) : new RegExp(/.*/);
        match = exp.exec($(this).text());
        addr = match[1] ? match[1].replace(/ at /,"@").replace(/ dot /g,".") : match[0].replace(/ at /,"@").replace(/ dot /g,".");
        emaillink = match[2] ? match[2] : addr;
        subject = $(this).attr('title') ? "?subject="+$(this).attr('title').replace(/ /g,"%20") : "";
        $(this).after('<a href="mailto:'+addr+subject+'">'+ emaillink + '</a>');
        $(this).remove();
    });
   
    $("ul.sf-menu").superfish();
    
    $('body#p-events ul#eventlist li:first, body#p-news ul#news_items li:first').css('border-top', 'none');
    
    $('body#p-news ul#news_items li.item:odd').addClass('odd');
    
    $('body#p-pouring table.locations caption').hide();

    $('ul.clickable li').click(function() {
        window.location.href = $(this).children('a:first').attr('href');
    });
    
    $('ul.clickable li').hover(function() {
        $(this).css('cursor', 'pointer');
        $(this).children('a:first').css('text-decoration', 'underline');
    }, function() {
        $(this).css('cursor', 'default');
        $(this).children('a:first').css('text-decoration', 'none');
    });
      
    // works in modern browsers only (IE7+/gecko/webkit)
    $('a#nav-home')
    .css('background-position', '0 -43px')
    .hover(function() {
        $(this).stop().animate({
            backgroundPosition:"(0 0)"
        }, {
            duration:200
        })
    }, function() {
        $(this).stop().animate({
            backgroundPosition:"(0 -43px)"
        }, {
            duration:200
        })
    });
   
    $("#banner").css("overflow", "hidden");
	
    $("ul#slides").cycle({
        fx: 'fade',
        pause: 1,
        prev: '#prev',
        next: '#next'
    });

    $("banner").hover(function() {
        $("ul#nav").fadeIn();
    },
    function() {
        $("ul#nav").fadeOut();
    });
	
    $(".banner_images").cycle();
	

	
    $("img.first").click(function() {
        $(".others").style.display = "block !important";
    },
    function() {
        $(".others").style.display = "none !important";
    });
	
//$(".colorbox").colorbox();
	
	
});

// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults

$(document).ready(function(){
    Cufon.replace('h1, .cufon');
});

