/*    autoHeight
 *    contournement du min-height.
 *    @param  target, referer : any DIV id
 */
function autoHeight(target, referer, collector){
    if(document.getElementById(target)) {
        var leDivReferer = document.getElementById(referer);
        var leDivTarget  = document.getElementById(target);
        var leDivConteneur  = document.getElementById(collector);
        if(leDivReferer.offsetHeight > leDivConteneur.offsetHeight) {
            leDivTarget.style.height = parseInt(leDivReferer.offsetHeight)+'px';
        } else{
            leDivTarget.style.height = parseInt(leDivConteneur.offsetHeight)+'px';
        }
    }
}

function articleWidthAuto() {
    var box = document.getElementById('boxArticle');
    var childs = box.getElementsByTagName('div');
    if ( childs.length>0 ) {
        document.getElementById('text').style.width = '570px';
        box.style.display = 'block';
        box.style.right = '20px';
       // document.getElementById('text').style.border = '1px solid #f0f';
     //   document.getElementById('text').style.height = '100%';
    //    autoHeight('contents', 'text', 'horizontalmenu');
    } else {
        document.getElementById('text').style.width = '100%';
    }
}

/**
 *  zommRecette
 */
function zoomRecette(path) {
    var target = document.getElementById('zoomRecette');
    if(path=='' || target.firstChild.src == path ) {
        if(navigator.appVersion.indexOf("MSIE") != -1){
            document.getElementById('recette_content').style.overflowY='auto';
            document.getElementById('recette_content').style.overflowX='hidden';
        } else {
            document.getElementById('recette_content').style.overflow='auto';        
        }
        target.firstChild.src = '/images/ico_coincoin.gif';
        target.style.display = 'none';
    } else {
        if(navigator.appVersion.indexOf("MSIE") != -1){
            document.getElementById('recette_content').style.overflowY='hidden';
            document.getElementById('recette_content').style.overflowX='hidden';
        } else {
            document.getElementById('recette_content').style.overflow='hidden';
        }
        target.style.top = target.parentNode.scrollTop+'px';
        target.firstChild.src = path;
        target.style.display = 'block';
    }
}

/**
 *  Survol carte du monde
 */
function swapCountry(country) {
	var countryCounter = document.getElementById('countriesContent').childNodes.length;
	for(i=0; i<countryCounter; i++) {
		if(document.getElementById('countriesContent').childNodes[i].nodeName=="P") {
			document.getElementById('countriesContent').childNodes[i].style.display = 'none';
			if(document.getElementById('countriesContent').childNodes[i].id == country+'Content') {
				document.getElementById('countriesContent').childNodes[i].style.display = 'block';
			}
		}
	}
}

window.onload = function() {
//    autoHeight('contents', 'horizontalmenu','contents');
    if( document.getElementById('boxArticle') ) {
        articleWidthAuto();
    }
}
