var homepage_photos_total = 10;
var homepage_photos_directory = './images/homepage_photos/';
var homepage_photos_prefix = 'photo';
var homepage_photos_extension = '.jpg';

function chooseHomepagePhoto() {
	var photo = homepage_photos_directory + homepage_photos_prefix +  Math.ceil(homepage_photos_total * Math.random()) + homepage_photos_extension;
	document.getElementById('layout_homepage').style.backgroundImage = 'url(' + photo + ')';
}

var forcedRefresh = true;
var alreadyopen = new Array();
var newwin = new Array();

function openCenteredWindow(theURL, winName, features, w, h){
  var winl = parseInt((screen.width - w - 10) / 2);
  var wint = parseInt((screen.height - h - 29) / 2);
  var retval = openWindow(theURL, winName, features + ',height=' + h + ',width=' + w + ',top=' + wint + ',left=' + winl);
  if(!theURL) return retval;
}

function openWindow(theURL, winName, features){
  if(forcedRefresh == false && alreadyopen[winName] && !newwin[winName].closed){
    newwin[winName].focus();
  }
  else{
    alreadyopen[winName] = 1;	
    newwin[winName] = window.open(theURL, winName, features);
    newwin[winName].focus();
  }
  if(!theURL) return newwin[winName];
}