var newWindow = null;

function closeWindow() {
	window.close();
}


function centerOnScreen() {			
		myH = screen.width / 2 - opener.wd / 2;		
		myV = screen.height / 2 - opener.wh / 2;		
		moveTo(myH,myV);		
}


function openWindow(contentURL,windowName,windowWidth,windowHeight) {	
	widthHeight = 'scrollbars=no,height=' + windowHeight + ',width=' + windowWidth;	
	newWindow = window.open(contentURL,windowName,widthHeight);	
	newWindow.focus();
	wd = windowWidth;
	wh = windowHeight;
}


function openWindowS(contentURL,windowName,windowWidth,windowHeight) {	
	widthHeight = 'scrollbars=yes,height=' + windowHeight + ',width=' + windowWidth;	
	newWindow = window.open(contentURL,windowName,widthHeight);	
	newWindow.focus();
	wd = windowWidth;
	wh = windowHeight;
}


function setWindow(contentURL,windowName,windowWidth,windowHeight,lft,tp) {
	livePageWidth = findLivePageWidth();
	lft = livePageWidth / 2  - windowWidth / 2 + 'px';
	tp = 320;
	newWindow = window.open(contentURL,windowName,"scrollbars=no,resizable=no,width=" + windowWidth + ",height=" + windowHeight + ",left=" + lft + ",top=" + tp);
}


//var qsParm = new Array();

function setPage() {
	var qsParm = new Array();
	var query = location.search.substring(1);
	var parms = query.split('&');
	for (var i=0; i<parms.length; i++) {
		var pos = parms[i].indexOf('=');
		if (pos > 0) {
			var key = parms[i].substring(0,pos);
			var val = parms[i].substring(pos+1);
			qsParm[key] = val;
		}
	}
	leftFrame.document.location = qsParm['pLoc'];
	docTit = qsParm['pName'];
	if (docTit == 'Penn%C3%A9%20Krol') {
		var newName = 'Penn&eacute; Krol';
		MM_changeProp('pname','','innerHTML',newName,'SPAN');
	}
	else if (docTit == 'Joan%20O%E2%80%99Beirne') {
		var newName = 'Joan O&rsquo;Beirne';
		MM_changeProp('pname','','innerHTML',newName,'SPAN');
	} 
	else if (docTit == 'Mika%C3%ABl%20Petraccia') {
		var newName = 'Mika&euml;l Petraccia';
		MM_changeProp('pname','','innerHTML',newName,'SPAN');
	} 
	else {
		docTemp = docTit.replace("%20"," ");
		docTemp2 = docTemp.replace("%20"," ");
		docTemp3 = docTemp2.replace("%20"," ");
		docTemp4 = docTemp3.replace("%20"," ");
		docTemp5 = docTemp4.replace("%20"," ");
		docTitle = docTemp5;
		MM_changeProp('pname','','innerHTML',docTitle);
	}
}

function MM_findObj(n, d) { //v4.01
  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);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}


function MM_changeProp(objName,x,theProp,theValue) {
  var obj = MM_findObj(objName);
  if (obj && (theProp.indexOf("style.")==-1 || obj.style)){
	eval("obj."+theProp+"='"+theValue+"'");
  }
}


function openGallery(contentURL,windowName,windowWidth,windowHeight)
{
	var widthHeight = 'height=' + windowHeight + ',width=' + windowWidth;	
	var wlp = window.screenX;
	var wtp = window.screenY;
	var wd=windowWidth;
	var hg=windowHeight;
	var hspace = window.outerWidth - wd; //- window width
	var vspace = window.outerHeight - hg; //- window height
	var lft = wlp + hspace / 2;
	var tp = wtp + vspace / 2;
	window.open(contentURL,windowName,widthHeight + ",left="+lft+",top="+tp+'status=no,location=no,menubar=no,resizable=no,scrollbars=no,toolbar=no');
}