function ShowPreview(Container,imageURL)
{
	var PreviewDIV = document.getElementById("PreviewDIV");
	if(!PreviewDIV)
	{
		CreatePreviewDIV(Container);
	}
	ShowPreviewDIV(imageURL);
}

function ShowPreviewDIV(imageURL)
{
	self.document.PreviewLoaderLoading=1;
	self.document.PreviewLoaderAbort=0;
	var PreviewDIV = document.getElementById("PreviewDIV");
	PreviewDIV.style.width = WindowWidth();
	PreviewDIV.style.height = WindowHeight();
	PreviewDIV.style.top=0;
	PreviewDIV.style.left=0;
	PreviewDIV.style.display='block';
	
	var PreviewLoader = document.getElementById("PreviewLoader");
	PreviewLoader.style.left=0;//(WindowWidth()/2) - (PreviewLoader.clientWidth/2);
	PreviewLoader.style.width=WindowWidth()+"px";
	PreviewLoader.style.top=(WindowHeight()/2) - (48/2) + "px";	
	PreviewLoader.style.display='block';

	
	var PreviewIMG = document.getElementById("PreviewIMG");
	LoadPreviewImage(PreviewIMG,imageURL);

}
function CheckImageSize()
{
	if(self.document.PreviewLoaderAbort==1)
	{
		ClosePreview();
		return;
	}
	
	var PreviewIMG = document.getElementById("PreviewIMG");
	if( (PreviewIMG.width == self.document.LoadingImageWidth)
	&&  (PreviewIMG.height == self.document.LoadingImageHeight))
	{
		var t=setTimeout("CheckImageSize()",100);
	}
	else
	{
		PreviewIMG.style.visibility = 'hidden';
		PreviewIMG.style.zIndex=90000;
		PreviewIMG.style.display = 'inline';
		PreviewIMG.style.left=(WindowWidth()/2) - (PreviewIMG.clientWidth/2) +"px";
		PreviewIMG.style.top=(WindowHeight()/2) - (PreviewIMG.clientHeight/2) +"px";
		PreviewIMG.style.visibility = 'visible';
		
		
		var PreviewLoader = document.getElementById("PreviewLoader");
		PreviewLoader.style.display='none';
		PreviewLoader.style.left=-1000 +"px";
		PreviewLoader.style.top=-1000 +"px";
		
		self.document.PreviewLoaderLoading=0;
	}
}
function LoadPreviewImage(PreviewIMG,imageURL)
{
	self.document.LoadingImage = 1;
	self.document.LoadingImageWidth  = PreviewIMG.width;
	self.document.LoadingImageHeight = PreviewIMG.height;
	PreviewIMG.src = imageURL;
	var t=setTimeout("CheckImageSize()",100);
}
function ClosePreview()
{
	if(self.document.PreviewLoaderLoading==1)
	{
		self.document.PreviewLoaderAbort=1;
	}
	
	var PreviewDIV = document.getElementById("PreviewDIV");
	PreviewDIV.style.display='none';
	PreviewDIV.style.left=-1000;
	PreviewDIV.style.top=-1000;
	
	var PreviewIMG = document.getElementById("PreviewIMG");
	PreviewIMG.style.display = 'none'
	PreviewIMG.style.left=-1000;
	PreviewIMG.style.top=-1000;	
	
	var PreviewLoader = document.getElementById("PreviewLoader");
	PreviewLoader.style.display='none';
	PreviewLoader.style.left=-1000;
	PreviewLoader.style.top=-1000;	
}

function CreatePreviewDIV(Container)
{
	Container.innerHTML+="<div id='PreviewDIV' style='background-image:url(images/closeInfo.gif);display:none;z-Index:100;opacity:0.6;position:absolute;left:0px;top:0px;width:100%;height:100%;' onclick='ClosePreview()'></div><div id='PreviewLoader' style='background:black;display:none;z-Index:200;position:absolute;'><center><img src='images/gui/ajax-loader.gif'></div><img style='display:none;position:absolute;z-Index:1000;' id='PreviewIMG' onclick='ClosePreview()'>";
}



function WindowWidth()
{
  var myWidth = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
  } else if( document.documentElement && ( document.documentElement.clientWidth ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
  } else if( document.body && ( document.body.clientWidth ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
  }
  return myWidth;
}	

function WindowHeight()
{
  var myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientHeight ) ) {
    //IE 4 compatible
    myHeight = document.body.clientHeight;
  }
  return myHeight;
}

