// ini
var _POPUP_FEATURES = '';

// popup
function rawPopup(url,target,features){
    if(typeof(features) == 'undefined')
        features = _POPUP_FEATURES;
    if(typeof(target) == 'undefined')
        target = '_blank';
    var popup = window.open(url,target,features);
    if (popup) {
        popup.focus();
        return popup;
    };
    return false;
}

// sur chargement...
$(document).ready(
    function(){
        // popup
        $('a.externe').click(
            function(){
                if (rawPopup($(this).attr('href'),'_blank')) {
                    return false;
                };
                return true;
            }
        );
        // safeAddress
        $('span.safeAddress').each(
            function(){
                var title = $(this).attr('title');
                var mail = $(this).text();
                $(this).empty();
                $(this).append('<a href="mailto:' + mail + '">' + title + '</a>');
                $(this).removeAttr('title');
                $(this).removeAttr('class');
            }
        );
        $('img.safeAddress').each(
            function(){
                var mail = $(this).attr('title');
                $(this).wrap('<a href="mailto:' + mail + '"></a>');
                $(this).removeAttr('title');
                $(this).removeAttr('class');
            }
        );
        // pdf
        $('a.pdf').each(
            function(){
                $(this).prepend('<img src="/style/pdf.gif" alt="pdf" style="vertical-align: bottom;" />');
            }
        );
    }
);

function popUpImage(url){
    i1=new Image;
    i1.src=url;
    html="<html>"+"<head>"+"<title>image</title>"+"</head>"+"<body style=\"margin: 0;padding: 0;text-align: center;\">"+"<img src=\""+url+"\" style=\"margin: 0;border: none;padding: 0;\" name=\"imageTest\" "+"onLoad=\"window.resizeTo(document.imageTest.width+14,document.imageTest.height+38)\">"+"</body>"+"</html>";
    if(window.popupimg){
        popupimg.close();
    }
    var popupimg=window.open("","image","toolbar=0,location=0,directories=0,menuBar=0,scrollbars=0,resizable=1");
    popupimg.document.open();
    popupimg.document.write(html);
    popupimg.document.close();
    popupimg.focus();
}

// pour ie6 ou inf seulement...
/*@cc_on
    @if (@_jscript_version <= 5.6)
        $(document).ready(
            function(){
                // png-transparency
                $(document).pngFix();
                // label
                $('input+label').each(
                    function() {
                        $(this).width('auto');
                    }
                )
            }
        );
    @end
@*/
