var NS = (document.layers) ? 1 : 0;
var IE = (document.all && document.getElementById) ? 1 : 0;
var N6 = (!document.all && document.getElementById) ? 1 : 0;

function MM_findObj(n, d) { //v3.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); return x;
}
/* Functions that swaps images. */
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

/* Functions that handle preload. */
function MM_preloadImages() { //v3.0
 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
   var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
   if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

MM_preloadImages(
  '/images/menu_home_off.jpg','/images/menu_home_on.jpg',
  '/images/menu_about_off.jpg','/images/menu_about_on.jpg',
  '/images/menu_exhibitions_off.jpg','/images/menu_exhibitions_on.jpg',
  '/images/menu_events_off.jpg','/images/menu_events_on.jpg',
  '/images/menu_artists_off.jpg','/images/menu_artists_on.jpg',
  '/images/submenu_fineart_off.jpg','/images/submenu_fineart_on.jpg',
  '/images/submenu_atelier_off.jpg','/images/submenu_atelier_on.jpg',
  '/images/submenu_annex_off.jpg','/images/submenu_annex_on.jpg',
  '/images/submenu_villa_off.jpg','/images/submenu_villa_on.jpg'
  );

function bioPop(theURL) {
	msgWindow = window.open(theURL,'','left=100,top=100,width=400,height=450,resizable=no,scrollbars=yes');
	if (msgWindow.opener == null) msgWindow.opener = self;
}

function pressPop(theURL) {
	msgWindow = window.open(theURL,'','left=100,top=50,width=765,height=530,resizable=no,scrollbars=yes');
	if (msgWindow.opener == null) msgWindow.opener = self;
}

function imgPop(theURL) {
        msgWindow = window.open(theURL,'','left=100,top=50,width=600,height=600,resizable=no,scrollbars=yes');
        msgWindow.location.href = theURL;
        if (msgWindow.opener == null) msgWindow.opener = self;
}

function showimg(title,image,width,height) {
        nwidth = width + 4;
        nheight = height + 40;
        var str = "scrollbars=no,width="+nwidth+",height="+nheight+",status=no,left=100,screenX=0,top=100,screenY=0";
        str += ",resizable"; // so the user can resize the newwindow manually
        var newwin = window.open('','', str);
        var content = "";
        content += "<html>\n\r";
        content += "<title>Sin Sin Annex - "+ title+"</title>\n\r";
        content += "<head>\n\r";
        content += "<script language=javascript src=\"/common_new.js\"></script>\n\r";
        content += "<link href=\"/common.css\" rel=\"stylesheet\" type=\"text/css\">\n\r";
        content += "</head>\n\r";
        content += "<body cellspacing=0 cellpadding=0 topmargin=0 leftmargin=0 marginheight=0 marginwidth=0>\n\r";
        content += "<center>\n\r";
        content += "<tr><td><img src=\""+image+"\" width=\""+width+"\" height=\""+height+"\" border=\"0\"></td></tr>";
        content += "<tr><td><img src=\"/images/blank.gif\" width=1 height=16 border=0></td></tr>\n\r";
        content += "<tr><td align=middle valign=top><a href=\"javascript:selfclose()\">close</a></td></tr>\n\r";
        content += "<tr><td><img src=\"/images/blank.gif\" width=1 height=16 border=0></td></tr>\n\r";
        content += "</table>\n\r";
        content += "</center>\n\r";
        content += "</body>\n\r";
        content += "</html>\n\r";

        newwin.document.write(content);
}

function selfclose() {
        opener.focus();
        window.close();
}

var msgWindow;
function WinOpen(theURL) {
	if(msgWindow && msgWindow.opened && !msgWindow.closed) {
		msgWindow.focus();
	}
	else {
	msgWindow = window.open('','targetname','left=400,top=50,width=620,height=440');
	msgWindow.location.href = theURL;
	if (msgWindow.opener == null) msgWindow.opener = self;
	}
}
