$(function() {
    // fix ie z-index
    var zIndexNumber = 10000;
    $('div').each(function() {
        $(this).css('zIndex', zIndexNumber);
        zIndexNumber -= 10;
    });
    // dropdown menu
    $("#mainmenu li").hover(function() {
        $(this).addClass("hover");
        $('ul:first', this).css('visibility', 'visible');
    }, function() {
        $(this).removeClass("hover");
        $('ul:first', this).css('visibility', 'hidden');
    });
    $("#mainmenu li ul li:has(ul)").find("a:first").append(" &raquo; ");

    // home page cycle
    $('#teaserarea').cycle({
        fx: 'scrollRight',
        next: '#teaserarea',
        pager: '#teasernav',
        after: function() { replaceCufon(' #teasernav a, #teasernav a.activeSlide'); }
    });

    // cufon font replacement
    replaceCufon('#homeleft #events, .boxes h3, .boxes p a, #bigbox a, #teasernav a, #teasernav a.activeSlide, #contentinner .header h1')
    replaceCufon('#contentinner h3, #contentinner h4, #contentinner .h3,  #contentinner  #childcount, .contenttab li a, .paging a, .paging span, .gridd th')
    replaceCufon('#contentinner .eventlist')
    
    // player
    $('.player').click(function() {
    $('#playerarea').remove();
        filepath = $(this).find('input').eq(0).val();
        $(this).html('<a class="playerarea" href="' + filepath + '" id="playerarea"></a>');
        $(this).append('<input type="hidden" value="' + filepath + '" name="videopath" /></a>'); 
        flowplayer("playerarea", "flowplayer/flowplayer-3.1.5.swf");
    });

});

function replaceCufon(list) { 
	Cufon.replace(list, {
        fontFamily: 'Myriad Pro',
		hover: true,
		forceHitArea: true
	});
}

var win = null;
function newWindow(mypage, myname, w, h, features) {
    var winl = (screen.width - w) / 2;
    var wint = (screen.height - h) / 2;
    if (winl < 0) winl = 0;
    if (wint < 0) wint = 0;
    var settings = 'height=' + h + ',';
    settings += 'width=' + w + ',';
    settings += 'top=' + wint + ',';
    settings += 'left=' + winl + ',';
    settings += features;
    win = window.open(mypage, myname, settings);
    win.window.focus();
}

