function ec_initCardSide(elem, name){
    $(elem).attr('loaded', 1);
    var f = $(elem).parent().find('>iframe');
    if ( f.eq(0).attr('loaded') && f.eq(1).attr('loaded') ) {
        $(elem).parent().find('.card_loading').remove().end()
        .find('>iframe:eq(0)').show().end()
        .find('>ul.card_tabs>li').bind('click', function(){
            if ( $(this).is(':not(.on)') ) {
                var side = $(this).attr('side');
                $(this).parent().find('>li').removeClass('on');
                $(this).addClass('on');
                $(this).parent().parent().find('iframe:not(.' + side + ')').hide().end()
                    .find('iframe.' + side).show();
            }
        });
        $(elem).contents().find('body')
        .bind('mousedown', function(){ return false; })
        .bind('mousemove', function(){ return false; })
        .bind('contextmenu', function(){ return false; });
    }

	$('.cardmenu_toggle').hover(function(e){
		$('>div.cardmenu_items', this).fadeIn('fast');
	}, function(e){
		if ($('>div.cardmenu_items>div[opened="1"]', this).size() == 0) {
			$('>div.cardmenu_items', this).hide();
			$('div.cm_info').hide();
		}
	});
	$('div.cardmenu_items>div').hover(function(){
		$(this).siblings().attr('opened', 0).find('>div.cm_info').css('display', 'none');
		if ($(this).attr('opened') == 0) {
			$('>div', this).css('display', 'block');
		}
	}, function(){
		if ($(this).attr('opened') == 0) {
			$('>div', this).css('display', 'none');
		}
	});
	$('div.cm_info').bind('click', function(e){
		$(this).parent().attr('opened', 1);
		e.stopPropagation();
	}).bind('mouseover', function(){ return false; });
	
	$(document).bind('click', function(e){
		if (e.button != 0) return false;
		$('.cardmenu_toggle>div').hide()
			.find('>div').attr('opened', 0).end()
			.find('div.cm_info').hide();
	});
};
