title="";
newwin=0;
np=0;
function pre(photo,w,h,ttl,nnp,path){
    if(nnp>0){
	h=parseInt(h)+20;
    }
    delay  = "";
    clearTimeout(delay);
    params = "'directories=0,location=0,menubar=0,resizable=0,scrollbars=0,status=0,toolbar=0,width="+w+",height="+h+"'";
    if(newwin) newwin.close();
    newwin = window.open('','',params);
    title  = ttl;
    np=nnp;
    newwin.document.write("<html><head>\n"+
"<style>body {margin:0px;background:#1E445F;} a {font-family:Verdana;font-size:9pt;color:white;text-decoration:none;} td {color:white}</style>"+
"<META http-equiv=pragma content=nocache>\n<title>"+ttl+"</title>\n</head>\n<body leftmargin=0 topmargin=0 rightmargin=0 bottommargin=0 marginwidth=0 marginheight=0><img style=\"filter:progid:DXImageTransform.Microsoft.Fade(Duration=1,overlap=1.0)\" name=photo title='click on photo to close window' border=0 src='"+photo+
"' onclick='newwin=0;self.close();'>\n");
    if(nnp>0){
        newwin.document.write("<table border=0 cellspacing=0 cellpadding=0 width=100%><tr><td align=center>click on number (&nbsp;&nbsp;<a href=# onclick='photo.src=\""+photo+"\";return false;'>1</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
	    for(i=1;i<=np;i++){
		rn=Math.round(Math.random()*100000);
		if (navigator.appName.indexOf("Explorer") != -1){
		    newwin.document.write("<a href=# onclick='photo.filters[0].apply();photo.src=\""+path+i+".jpg?"+rn+"\";photo.filters[0].play();return false;'>"+(i+1)+"</a>&nbsp;&nbsp;");
		} else {
		    newwin.document.write("<a href=# onclick='photo.src=\""+path+i+".jpg?"+rn+"\";return false;'>"+(i+1)+"</a>&nbsp;&nbsp;");
		}
	    }
	    newwin.document.write(") to see another photo</td></table>");
    }

    newwin.document.write("</body></html>\n");
    newwin.document.close();
}

// new preview style
var posx = 0;
var posy = 0;
var mv = 0;
var padx=0;
var pady=0;
var newdiv;
var basetop=0;

function coords(e) {
    posx = 0;
    posy = 0;
    if (!e) var e = window.event;
    if (e.pageX || e.pageY) 	{
	posx = e.pageX;
	posy = e.pageY;
    }
    else if (e.clientX || e.clientY) 	{
	posx = e.clientX + document.body.scrollLeft
	    + document.documentElement.scrollLeft;
	posy = e.clientY + document.body.scrollTop
	    + document.documentElement.scrollTop;
    }
//alert(posx +"/" + posy);
}

function setcur() {
    padx=posx-newdiv.offsetLeft;
    pady=posy-newdiv.offsetTop;
}

function drag() {
    newdiv.style.left=posx-padx;
    newdiv.style.top=posy-pady;
    basetop=posy-pady-document.body.scrollTop;
}

function showimg(path,item,np,hs,vs,Y,X){
    var selector="";
    if(np>0){
	    selector="<div style='margin-top:285px'>";
            rn=Math.round(Math.random()*100000);
            selector+="<a class=grelnk href=# onclick='newdiv.style.background=\"url("+path+item+"?"+rn+")\";return false;'><img class=ppict src=img/pict.gif></a>&nbsp;&nbsp;";
            for(i=1;i<=np;i++){
                rn=Math.round(Math.random()*100000);
                    selector+="<a class=grelnk href=# onclick='newdiv.style.background=\"url("+path+i+".jpg?"+rn+")\";return false;'><img class=ppict src=img/pict.gif></a>&nbsp;&nbsp;&nbsp;";
            }
	    selector+="</div>";
    }

    if(!newdiv){newdiv = document.createElement("div");}; 
    newdiv.className = "virtwin"; 
    newdiv.innerHTML = "<div style='height:"+vs+"px;width:"+hs+"px;position:absolute;z-index:10;left:0px;top:0px;background-image:url(img/e.gif)'><img src=img/cancl_24.gif style='float:right' onclick='document.body.removeChild(newdiv);'>"+selector+"</div>"; 
    document.body.appendChild(newdiv);
    newdiv.onmousedown=function(event){coords(event);setcur(null);mv=1;};
    newdiv.onmousemove=function(event){if(mv==1){coords(event);drag();}};
    newdiv.onmouseup  =function(){mv=0;};
    newdiv.onmouseout =function(){mv=0;};
    if(hs) newdiv.style.height=vs;
    if(vs) newdiv.style.width=hs;
    if(Y | X) {
	newdiv.style.top=Y;
	newdiv.style.left=X;
    }
    newdiv.style.background="url('" + path + item + "')";
    document.body.appendChild(newdiv);

    if(!window.innerHeight){
    if(!newdiv.style.top) newdiv.style.top = document.body.scrollTop;
    newdiv.style.position='absolute';
    document.body.onscroll=function(){newdiv.style.top=basetop+document.body.scrollTop;};
    } else {
    newdiv.style.position='fixed';
    }
}

