/* $Id: fonctions.js 457 2007-12-10 23:12:40Z foupoudave.devpwsphp $ */

function cachecache(variable,texte1,texte2)
{
	var bloc = document.getElementById(variable);
	var lien = document.getElementById(variable+"_lien");

	if(bloc.style.display=="none")
	{
		bloc.style.display = "block";
		if (texte2!="")
		{
			lien.innerHTML = texte2;
		}
		IE_CorrectAlpha_PNG(true);
	}
	else
	{
		bloc.style.display = "none";
		if (texte1!="")
		{
			lien.innerHTML = texte1;
		}
	}
}

//PopUp centre
function popupcentre(url,nom,width,height,scroll)
{
	window.open(url,nom,'width='+width+',height='+height+',top='+(screen.height-height)/2+',left='+(screen.width-width)/2+',scrollbar='+scroll+',titlebar=no,directories=no,status=no,toolbar=no,menubar=no,resizable=no,location=no',false);
}


//PopUp en haut à gauche
function popup(url,nom,width,height,scroll,arriereplan)
{
	window.open(url,nom,'width='+width+',height='+height+',top=0,left=0,scrollbar='+scroll+',titlebar=no,directories=no,status=no,toolbar=no,menubar=no,resizable=no,location=no');
	if (arriereplan)
	{
		self.focus(); 
	}
}

//********************************************************
//** Permettre de rendre la transparence au png sous ie **
//********************************************************
function IE_CorrectAlpha_PNG(traitement){
	if (traitement != true)
	{
		traitement = false;
	}

    for(i=0; i<document.images.length; i++){
        img    = document.images[i];
        imgExt  = img.src.substring(img.src.length-3, img.src.length);
        imgExt  = imgExt.toUpperCase();
        if (imgExt == "PNG" && (traitement || img.name.substr(0,17) != "pas_de_correction"))
        {
            imgID    = (img.id) ? "id='" + img.id + "' " : "";
            imgClass= (img.className) ? "class='" + img.className + "' " : "";
            imgTitle= (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' ";
            imgStyle= "display:inline-block;" + img.style.cssText;
            if (img.align == "left") {
                imgStyle = "float:left;"  + imgStyle;
            } else if (img.align == "right"){
                imgStyle = "float:right;" + imgStyle;
            }
            if (img.parentElement.href)   {
                imgStyle = "cursor:hand;" + imgStyle;
            }
            strNewHTML    = '<span '+imgID+imgClass+imgTitle+' style="width:'+img.width+'px; height:'+img.height+'px;'+imgStyle+';'+'filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\''+img.src+'\', sizingMethod=\'scale\');" ><\/span>';
            img.outerHTML = strNewHTML;
            i = i-1;
        }
    }
    if ( document.all )
    {
        var images_list = document.getElementsByTagName( '*' );
        for ( var i = 0 ; i < images_list.length; i++ )
        {
            var image_name = images_list[ i ].currentStyle.backgroundImage.replace( /url[s]*()+/, '' );
            image_name     = image_name.replace( /(")+/g, '' );
            image_name     = image_name.substr( 1, image_name.length - 1 );
            image_name     = image_name.substr( 0, image_name.length - 1 );
            imgExt         = image_name.toUpperCase();
            imgExt         = imgExt.substring( imgExt.length - 3, imgExt.length )
            if ( imgExt == "PNG" )
            {
                images_list[ i ].runtimeStyle.backgroundImage = "url( './correct_transparent_png.gif' )";
                images_list[ i ].runtimeStyle.filter          = "progid:DXImageTransform.Microsoft.AlphaImageLoader( src='" + image_name + "', sizingMethod='scale' )";
            }
        }
    }

    return true;
}

var arVersion = navigator.appVersion.split("MSIE")
var version = parseFloat(arVersion[1])
var is_msie = ((version >= 5.5) && (version < 7));
if ( is_msie ){
    window.attachEvent("onload", IE_CorrectAlpha_PNG);
}

