if (self.innerWidth) {
	frameWidth = self.innerWidth;
	frameHeight = self.innerHeight;
} else if (document.documentElement && document.documentElement.clientWidth) {
	frameWidth = document.documentElement.clientWidth;
	frameHeight = document.documentElement.clientHeight;
} else if (document.body) {
	frameWidth = document.body.clientWidth;
	frameHeight = document.body.clientHeight;
} else {
	frameWidth = null;
	frameHeight = null
}

// 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;
}

// zoom
function cnZoom(url){
    i1 = new Image;
    i1.src = url;
    $('#cn-zoom').remove();

	html = '<div class="content">'
		+ '<p class="retour"><a href="#">fermer</a></p>'
		+ '<img src="' + url + '" alt="" />'
		+ '</div>';

    $("#footer").before("<div id=\"cn-zoom\"></div>");
    $("#cn-zoom").html(html);

    if ( typeof(decalageGauche) != 'undefined' ) { // ie
		decalageHaut = (Math.round(frameHeight * 0.4));
		decalageGauche = ( Math.round((804/2)) - 395 );
	} else {
	 $("#cn-zoom").css('top', (Math.round(frameHeight * 0.4)) + 'px');
	 $("#cn-zoom").css('left', (Math.round((804/2)) - 395) + 'px');// ... - largeur objet/2
	}

    $('#cn-zoom a').click(function(){
        $('#cn-zoom').remove();
        return false;
	});
}

// sur chargement...
$(document).ready(
    function(){
        // ie5.5+ png
        //$('img[@src$=.png],.fondpng').pngfix();
        // popup
        $('a.popup').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');
            }
        );
        // zoom
        $('.cn-zoom a').click(
            function() {
                cnZoom($(this).attr('href'));
            	return false;
            }
        );
        // suite
        $('a.suite').each(
            function() {
                var img = '<img class="suite" src="/style/lire-la-suite-it.gif" width="67" height="7" alt="lire la suite" />';
                $(this).html(img);
            }
        );
        // désactivation drapeau anglais
        $('#header a.lang:eq(2)').hide();
    }
);

/**
 *
 * @access public
 * @return void
 **/
function AddBookmark(url, title)
{
	if (!url) url = location.href;
	if (!title) title = document.title;

	if (window.external && !window.sidebar)// IE
		window.external.AddFavorite(url, title)
	else// firefox, opéra, safari
	   alert('cliquez sur les touches CTRL + D pour ajouter cette page à vos favoris');
}
