// 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').livequery(function(){
			$(this).prepend('<img src="/style/download.png" width="17" height="17" alt="document à télécharger" style="vertical-align: bottom;" />');
		});
		
		
        // actu dynamique
		$('a.suite_article').click(function(){
			var href = $(this).attr('href');
			var idArticle = href.substring(1);
			$.ajax({
				type: 'GET',
			   url: '/inc/actu.php',
			   data: '&idArticle='+idArticle,
			   dataType: "html",
			   success: function(data){
			   		if ($('#articles').length == 0) {
			   			$('#infos_pratiques').before('<div id="articles"><div>');	
			   		}
					$('#articles').html(data);
					$('#articles').append('<a id="retour" href="#">[retour]</a>');
					$('#infos_pratiques').hide();
					$('a#retour').click(function(){
					 	$('#infos_pratiques').show();
					 	$('#articles').remove();
					 	return false;
					});
			   }
			});
			return false;
		});
    }
);

// 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
@*/
