function str_replace(search,replace,subject){if(!(replace instanceof Array)){replace=new Array(replace);if(search instanceof Array){while(search.length>replace.length){replace[replace.length]=replace[0];}}}
if(!(search instanceof Array))search=new Array(search);while(search.length>replace.length){replace[replace.length]='';}
if(subject instanceof Array){for(k in subject){subject[k]=str_replace(search,replace,subject[k]);}
return subject;}
for(var k=0;k<search.length;k++){var i=subject.indexOf(search[k]);while(i>-1){subject=subject.replace(search[k],replace[k]);i=subject.indexOf(search[k],i);}}
return subject;}

function getClientHeight()
{
  return document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientHeight:document.body.clientHeight;
}

function popupWindow(fileUrl, winW, winH, winN, scrollB) 
{
	var def_winH = getClientHeight() - 200;
	
	var winWidth = (winW)? winW : 800;
	var winHeight = (winH)? winH : def_winH;
	var winName = (winN)? winN : 'popupWin'
	var scrollBars = (scrollB)? scrollB : 'yes'
	
	if (screen.width < winWidth + 50) { winWidth = screen.width - 50; scrollbars = 'yes' }
	if (screen.height < winHeight + 100) { winHeight = screen.height - 100; scrollbars = 'yes' }
	posX = Math.round((screen.width - winWidth)/2);
	posY = Math.round((screen.height - winHeight)/2);
	posCode = "left="+posX+",top="+posY;

	var popupWin = window.open(fileUrl, winName,"location=no,menubar=no,toolbar=no,scrollbars=" + scrollBars + ",status=yes,resizable=yes,width=" + winWidth + ",height=" + winHeight + "," + posCode);
	if (popupWin) popupWin.focus();
}
