var win= null;
//this.movieOpen=false;
var source;
var w;
var h;
function NewWindow(imageFileName,myname,w,h,scroll){
  //var winl = (screen.width-w)/2;
 // var wint = (screen.height-h)/2;
  var suffixeImgs= new Array('jpg','jpeg','png','gif');
  var suffixeQT= new Array('mpeg','mov');
  var suffixeWin= new Array('wmv','asf');
  //var suffixeRm= new Array('fffff');
  var winl = 100;
  var wint = 100;
  var settings  ='height='+h+',';
      settings +='width='+w+',';
      settings +='top='+wint+',';
      settings +='left='+winl+',';
      settings +='scrollbars='+scroll+',';
	  settings +='status=no'+',';
      settings +='resizable=yes';	  
  
 // if ((win!=null) && (!win.closed)) this.exist=true;
  win=window.open("","viewer",settings);//alert(win.document.all.length);
  win.document.close();//blanks the document
  
  	suffixe=imageFileName.substr(imageFileName.lastIndexOf(".")+1);
   	platform=false;
  	for (i=0;i<suffixeImgs.length;i++) {if (suffixe==suffixeImgs[i]) {platform="image";break;}}	
	if (!platform)
		for (i=0;i<suffixeImgs.length;i++) {if (suffixe==suffixeQT[i]) {platform="QT";break;}}
	if (!platform)
		for (i=0;i<suffixeImgs.length;i++) {if (suffixe==suffixeWin[i]) {platform="Win";break;}}
	switch(platform)
	{	case('image'):
			resize(win,w,h);doFocus(win);
			writeImage(w,h,imageFileName);win.document.title=imageFileName;
		break;
		case('QT'): //QT video in our case
			h=h+15;//add 15px only if controller=true
			resize(win,w,h);doFocus(win);
			writeMovie(win,w,h,imageFileName);win.document.title=imageFileName;
		break;
		case('Win'):
			h=h+45;//add 30px only if controller=true
			resize(win,w,h);doFocus(win);
			writeMovie(win,w,h,imageFileName);win.document.title=imageFileName;		
		break;
	}
}

function doFocus(win)
	{if (parseInt(navigator.appVersion) >= 4) win.window.focus();}
function writeImage(w,h,imageFileName)
	{
	path="/pictures/events/actual/";
	source=path+imageFileName;;	
	win.document.writeln('<html><body style="position:absolute;top:0;margin:0;padding:0"><img width="'+w+'" height="'+h+'" src="'+source+'"/></body></html>');
	}
	
function writeMovie(win,w,h,imageFileName)
	{
	path="/videos";
	source=path+imageFileName;
	win.document.URL="/movie.html?pf="+platform+"&w="+w+"&h="+h+"&source="+source;
	}

function resize(win,w,h)
	{
	offSetW=win.document.body.clientWidth-w;offSetH=win.document.body.clientHeight-h;
	win.resizeBy(-offSetW,-offSetH);
	}