
function openWindow(file,tx,ty) {
		 myWindow= open(file, "newWindow", "width="+tx+",height="+ty+",left=0, top=0, menubar=no,resizable=no,scrollbars=no,status=no,toolbar=no");
}




//-----------------------------------------------------------------
// systeme de changement de fond sur le click des sous menu

// Atteint une Url après une confirmation par boîte de dialogue...
// <a href="javascript:conf('message','url');>
// préférer la syntaxe suivante
// <a href="url" onclick="return confirm('message');>
// => l'url n'est atteinte que si message validé
// => si pas javascript, url atteinte sans confirmation
function conf(m,u)
 {
	if( confirm(m) )	window.location.href=u; //'http://www.google.fr'; //u;
 }
 
 
/* Permet d'ajuster  la taille de la fenêtre en fct de la taille d'une image 
@param str, id de l'élément img
@param int marge horizontale à rajouter
@param int marge verticale à rajouter
@param int largeur minimale
@param int hauteur minimale
*/
function fitPic( idImage , margeW , margeH ,  minW, minH ) {
	if (margeW == null){ margeW = 0;}
	if (margeH == null){ margeH = 0;}
	if (idImage == null){ idImage = "image";}
	if (minW == null){ minW = 100;}
	if (minH == null){ minH = 100;}
//	window.alert('resize, margeW '+margeW+' - margeH '+margeH);
	var aWidth = 0;
	var aHeight = 0;
	var cWidth = 0;
	var cHeight = 0;
	if (window.innerWidth){
		if (window.innerWidth > window.outerWidth) { // bug sous firefox ???
		    aWidth = window.outerWidth;
		} else {
		    aWidth = window.innerWidth;
		}
	    aHeight = window.innerHeight;
	}else{
	    aWidth = document.body.clientWidth;
	    aHeight =document.body.clientHeight;
	}
//	window.alert('actuel, W '+aWidth+' - H '+aHeight);
	cWidth = document.getElementById(idImage).width + margeW;
	cHeight = document.getElementById(idImage).height + margeH;
//	window.alert('resizeby, W '+cWidth - aWidth+' - H '+cHeight - aHeight);
	if (cWidth < minW) { cWidth = minW;}
	if (cHeight < minH) { cHeight = minH;}
	window.resizeBy(cWidth - aWidth, cHeight - aHeight);
	window.focus();
};


function zoomimage(src,largeur,hauteur) 
{
	popUp = window.open(src,'zoomimage','width=' + largeur + ',' + 'height=' + hauteur  + ' ,left=20,top=20,resizable=yes,scrollbars=no,toolbars=no,menubars=no,location=no');
	popUp.focus();
}
function zoomimage2(src,largeur,hauteur,x,y) 
{
	popUp = window.open('/zoom.php?img='+src,'zoomimage','width=' + largeur + ',' + 'height=' + hauteur  + ' ,left=' + x + ',top=' + y + ',resizable=yes,scrollbars=no,toolbars=no,menubars=no,location=no');
	popUp.focus();
}

/* Change la visibilité d'un élément 
  style display none ou paramètre 2
  si param2=undefined, on prend block
 @param string id de l'élément
 */
function showhide(idelement,display)
{
	if (typeof(display)=="undefined" || display=="") display="block";
	var el = document.getElementById(idelement);
	if (el)
	{
		if (el.style.display == "none") {
			el.style.display = display;
		} else {
			el.style.display = "none";
		}
	}
}
function debug(message){
	if(typeof console == 'object') console.log(message);
		//else window.alert(message);
}


// Cherche remlace en RegExp
function chercheRemplace( texte, stringToFind, stringRemplacement )
{
var text = texte.toString(); var maReg = new RegExp( stringToFind, "gi") ;
var resultat = text.replace( maReg, stringRemplacement ) ;
if ( text.search( maReg ) == -1 ) { return text;} else {return resultat ;}
}
function is_empty(variable){
	if(typeof(variable)=='undefined') return true;
	if(!variable) return true;
	if(variable=='') return true;
	return false;
}

function is_numeric( mixed_var ) {
    // http://kevin.vanzonneveld.net
    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: David
    // *     example 1: is_numeric(186.31); returns 1: true
    // *     example 2: is_numeric('Kevin van Zonneveld'); returns 2: false
    // *     example 3: is_numeric('+186.31e2'); returns 3: true
     return !isNaN( mixed_var );
}
function in_array(needle, haystack, strict) {
    // http://kevin.vanzonneveld.net
    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // *     example 1: in_array('van', ['Kevin', 'van', 'Zonneveld']);
    // *     returns 1: true
 
    var found = false, key, strict = !!strict;
 
    for (key in haystack) {
        if ((strict && haystack[key] === needle) || (!strict && haystack[key] == needle)) {
            found = true;
            break;
        }
    }
 
    return found;
}
/*function tooltipOnclick(element)
{
	var t=$(element).attr('title');
	$.get("tooltip.php",{id=t},function(){});
	
}*/

function surscroll () { 
//debug("position "+$("#cadre_gauche").css("position"));  
//if($("#cadre_droite").css("position") == "static") return; // pas de CSS...
	var scroll = $(window).scrollTop();      //debug("SCROLL "+scroll); 
//	alert(scroll);
	var scrollmin = $("#top_pub_droite").offset().top + $("#top_pub_droite").innerHeight();//debug("pub top "+scrollmin); 
	var wh=window.innerHeight;
	//alert(wh);
	var hpgauche = $("#cadre_pub_droite").innerHeight();
	var hgauche = $("#cadre_gauche").innerHeight() + 20;
	var hcontent = $("#content_sous").innerHeight();
	//alert(hcontent);
	if(hpgauche > wh && hgauche + 200 > hcontent)var diff=hpgauche-wh+100;
	else diff = 0;
	//alert(diff);
	if(scroll > scrollmin) 
	{
		var marg = scroll - scrollmin - diff;
		
	} else {var marg = 0;}
	//alert(marg);
	 $("#cadre_pub_droite").stop();
	 $("#cadre_pub_droite").animate({marginTop:marg},0);
}


