// ensure a proper context (frame/javascript) for all pages 
function ensureContext() {
  // use dynamic frameset if no frameset present
  if (window==top) {
//    var pname = top.location.pathname;
//    top.location.href="/index.php"+pname;
  }
//  if  ((top.location.protocol=="http:") && (pname!="") && (pname!="/") && (top.location.hostname!="localhost") && (pname.indexOf('index.php')==-1)) {
//      top.location.href="/index.php"+pname;
//  }
  // prevent from stilling image
  document.onmousedown = noclick;
  // update frameset title with content title (IE)
//  if (window.name == 'content') {
//   top.document.title=window.document.title;
// }
  
}

// Display a back button on a page 
// this used the mime header and  works only within a web server
function GoBack(msg) {
    if (document.referrer.length!=0) {
	document.write('<a href="'+document.referrer+'">'+msg+'</a>');
	}
}

// zoom on an jpg image that has the same name as the page and is embeded in the page
function ZoomImage() {
    var ref = location.href+'';
    if (ref.lastIndexOf('.')!=-1) {
      ref = ref.substring(0,ref.lastIndexOf('.'))+'.jpg';
	  if (ref.lastIndexOf('/')!=-1) {
		  ref = ref.substring(ref.lastIndexOf('/')+1);
	  }
    }
    h = 400; w=600;
    for (i=0; i<document.images.length;i++) {
	    src = document.images[i].src+'';
        if (src.indexOf(ref)!=-1) {
		    ref = src;
            h = document.images[i].height;
            w = document.images[i].width;
        }
    }
    // ie and opera
    if (typeof innerHeight != "undefined") {
        availHeight = innerHeight;
        availWidth = innerWidth;
    } else {   
        availHeight=document.body.clientHeight;
        availWidth=document.body.clientWidth;
    } 
	var buf = "<HTML><HEAD><TITLE>"+document.title+"</TITLE>\n";
	buf += "<script language='JavaScript'>\n";
    buf += "function noclick(scx) {\n";
	buf += "if (navigator.appName == 'Netscape' && scx.which == 3) {alert('Not Available');return false;}\n";
    buf += "if (navigator.appVersion.indexOf('MSIE') != -1 && event.button == 2){alert('Not Available');return false;}\n";
	buf += "}\n";
	buf += "</script>\n";
	buf += "<script language='JavaScript'>document.onmousedown = noclick;</script>\n";
	buf += "</HEAD>\n";
	buf +="<BODY BGCOLOR=WHITE leftMargin=0 topMargin=0 marginwidth=0 marginheight=0>\n";
	buf +="<table width='100%' border=0 height='99%'><tr><td align='center' valign='middle'>\n";
	buf+="<a href='"+location.href+"'><img border=0 src='"+ref+"\n";
	if ((h*availWidth) > (availHeight*w)) {
    	buf+="' height="+(availHeight-50);
    } else {
    	buf+="' width="+(availWidth-50);
    }
	buf+=" alt='continuer la visite'></a></td></tr></table></BODY></HTML>\n";
	document.write(buf);
	document.close();
}

function TextPopup(win,text) {
	var w=open("",'image','width='+(450)+',height='+(120)+',toolbar=no,scrollbars=no,resizable=no');
	var buf = "<HTML><HEAD><TITLE>"+win.document.title+"</TITLE>";
	buf += '<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></HEAD>';
	buf +='<BODY bgcolor=WHITE onBlur="window.close()"><font size=2 face="Verdana, Arial, Helvetica, sans-serif">';
	for (i=0; i<text.length;i++) {
		buf+=(text.charAt(i)=='\n')?"<BR>":text.charAt(i);
	}
	buf+="<br><br><font size=1>Cliquer sur l'image pour poursuivre la visite</font>";
	buf+="</font></BODY></HTML>\n";
	w.document.write(buf);
	w.document.close();	
	ZoomImage();
}

/*
SCRIPT EDITE SUR L'EDITEUR JAVASCRIPT
http://www.editeurjavascript.com
add the following script in document head:
document.onmousedown = noclick; 
*/
function yaunclick()
	{
	alert("Entire contents copyright 1998, FORUMdesARTS.com. All rights reserved.\nReproduction of this publication in any form without prior written permission\nis forbidden");
	}
function noclick(scx)
	{
	// does not work very well with netscape 4.77
	if (navigator.appName == "Netscape" && scx.which == 3) 
		{
		yaunclick();
		return false; 
		}
    if (navigator.appVersion.indexOf("MSIE") != -1 && event.button == 2)
		{
		yaunclick();
		return false; 
		}
	}

function accesBoutiquePro(){
  var ret  = prompt("Veuillez entrer votre mot de passe","");
  if ((ret!=null) && (ret!='')) {
    	open("http://www.wistiti.fr/Albums/Inscription.asp?reference=art.batisseurs.com&mdp="+ret,"_blank");
  }
}
	
/* for doc - not tested
function PopupImage(name) {
    img = document[name];
    availHeight=screen.availHeight-10;
    availWidth=screen.availWidth-10;
	w=open("",'image','width='+(availWidth)+',height='+(availHeight)+',toolbar=no,scrollbars=no,resizable=no');
	w.moveTo(5,5);
	w.document.write("<HTML><HEAD><TITLE>"+document.title+"</TITLE></HEAD>");
	w.document.write("<SCRIPT language=javascript>function checksize()  { window.resizeTo(availWidth,availHeight); window.focus(); }</"+"SCRIPT>");
	w.document.write("<BODY onload='checksize()' bgcolor=#000000 leftMargin=0 topMargin=0 marginwidth=0 marginheight=0>");
	w.document.write("<table width='95%' border=0 height='95%'><tr><td align='center' valign='middle'><A HREF='javascript:window.close()'><img border=0 src='"+img.src);
	if ((img.height/img.width) > (availHeight/availWidth)) {
    	w.document.write("' height="+(img.height+(availHeight-img.height)/2));
    } else {
    	w.document.write("' width="+(img.width+(availWidth-img.width)/2));
    }
	w.document.write(" alt='continuer la visite'></td></tr></table></a></BODY></HTML>");
	w.document.close();
}
*/