var newWindow = null;

function popUpWin(projectW, projectH) {
	
	if (typeof(chrome) == 'undefined') chrome = 0;
	
	closeWin();  // check to see if there is an existing window
	
	if (projectW == 0 && projectH == 0) {
	  if (windowSameSize == '1') {
		  type = 'samesize';
		} else {
	    type = 'fullScreen';
		}
	}
	else {
	  type = 'console';
	}
	
	if (type == "fullScreen"){
		strWidth = screen.availWidth - 10;    // add a very small amount of wiggle room
		strHeight = screen.availHeight - 10;  // add a very small amount of wiggle room
	}
	
	var x = (screen.availWidth - projectW) /2;
	var y = (screen.availHeight - projectH)/3;
	
  var myChrome = (chrome == 1) ? 'yes' : 'no';
	var tools="toolbar="+myChrome+",statusbar="+myChrome+",location="+myChrome+",menubar="+myChrome+",";

	if (type == "fullScreen") {
	  tools += "scrollbars=yes,resizable=yes,width="+strWidth+",height="+strHeight+",top=0,left=0";

	} else if (type == "console") {
	  tools += "scrollbars=";
		tools += ('1' == scrollbars) ? 'yes' : 'no'; 
		tools += ",resizable=yes,width="+projectW+",height="+projectH+",left="+x+",top="+y+"";
	
	} else {
	  tools += "scrollbars=yes,resizeable=yes";
	}
	
	newWindow = window.open(projectUrl, '_blank', tools);
	newWindow.focus();
	
}

function popUpES() {
	
	var x = (screen.availWidth - 815) /2;
	var y = (screen.availHeight - 520)/3;

	tools = "resizable,toolbar=no,location=no,scrollbars=no,width="+815+",height="+520+",left="+x+",top="+y+"";
	newWindow = window.open('../editorialStatement.html', 'newWin', tools);
	newWindow.focus();
}

function popTester(url, width, height) {
	closeWin();  // check to see if there is an existing window
	
	var x = (screen.availWidth - width) /2;
	var y = (screen.availHeight - height)/3;

	tools = "resizable,toolbar=no,location=no,scrollbars=yes,width="+width+",height="+height+",left="+x+",top="+y+"";
	newWindow = window.open(url, 'testerWin', tools);
	//newWindow.focus();
}

function closeWin() {
	if (newWindow != null){
		if(!newWindow.closed)
			newWindow.close();
	}
}


function preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.p) d.p=new Array();
    var i,j=d.p.length,a=preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.p[j]=new Image; d.p[j++].src=a[i];}}
}
function mySwap (flag,to) {
  document.images[flag].src = 'images/headers/'+to; 
}



function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

function changeImages() {
	if (document.images && (preloadFlag == true)) {
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}

var pchoArr = new Array ("pchoA.gif","pchoB.gif","pchoC.gif","pchoD.gif","pchoE.gif","pchoF.gif",
"pchoG.gif","pchoH.gif","pchoI.gif","pchoJ.gif","pchoK.gif","pchoL.gif","pchoM.gif");
var totalPics = pchoArr.length;
var now = new Date()
var sec = now.getSeconds()
var pic = sec % totalPics;
pchoSrc = pchoArr[pic]; 


