/*
pvp

Author: Jonathan Mangano
Dependencies: FastcastMedia.js
*/

/*
 * Opens the legend window
 */
function legend() {
	w=520;
	h=400;
	leftPosition = (screen.width) ? (screen.width-w)/2 : 0;
	topPosition = (screen.height) ? (screen.height-h)/2 : 0;
	aWindow = window.open("/legend.jsp","_blank","width="+w+",height="+h+",scrollbars=no,menubar=no,status=no,resizable=yes,top="+topPosition+",left="+leftPosition+",screenX=0,screenY=60");
	aWindow.focus();
}

/*
 * Opens the content window 
 */
function openContent(id, index, type, sequence, playerType, fcu, ru, windowHeight, baseUrl) {
	w=700;
	h=540;
	if (type == 'dgdispatch') {
		leftPosition = (screen.width) ? (screen.width-w)/2 : 0;
		topPosition = (screen.height) ? (screen.height-h)/2 : 0;
		aWindow = window.open("/loadContent.do?id=" + id + "&index=" + index,"inCongress","width="+w+",height="+h+",screenX="+leftPosition+",screenY="+topPosition+",top="+topPosition+",left="+leftPosition+",scrollbars=yes,menubar=no,status=yes,resizable=yes");
		aWindow.focus();
	}
	else if (type == 'fastcastitem') {
		getFastcast(index, sequence, playerType, fcu, ru, windowHeight, baseUrl);
	}
	else if (type == 'report') {
		leftPosition = (screen.width) ? (screen.width-w)/2 : 0;
		topPosition = (screen.height) ? (screen.height-h)/2 : 0;
		aWindow = window.open("/loadWork.do?id=" + id + "&index=" + index + "&report=" + sequence,"Work","width="+w+",height="+h+",screenX="+leftPosition+",screenY="+topPosition+",top="+topPosition+",left="+leftPosition+",scrollbars=yes,menubar=no,status=yes,resizable=yes");
		aWindow.focus();
	}
	else if (type == 'inbrief') {
		leftPosition = (screen.width) ? (screen.width-w)/2 : 0;
		topPosition = (screen.height) ? (screen.height-h)/2 : 0;
		aWindow = window.open("/loadInBrief.do?id=" + id + "&index=" + index + "&report=" + sequence,"Work","width="+w+",height="+h+",screenX="+leftPosition+",screenY="+topPosition+",top="+topPosition+",left="+leftPosition+",scrollbars=yes,menubar=no,status=yes,resizable=yes");
		aWindow.focus();
	}
	else if (type == 'external') {
		leftPosition = (screen.width) ? (screen.width-w)/2 : 0;
		topPosition = (screen.height) ? (screen.height-h)/2 : 0;
		aWindow = window.open(index,"External","width="+w+",height="+h+",screenX="+leftPosition+",screenY="+topPosition+",top="+topPosition+",left="+leftPosition+",scrollbars=yes,menubar=no,status=yes,resizable=yes");
		aWindow.focus();		
	}
}

function acronym() {
	w=520;
	h=450;
	leftPosition = (screen.width) ? (screen.width-w)/2 : 0;
	topPosition = (screen.height) ? (screen.height-h)/2 : 0;
	aWindow = window.open("/acronym.jsp","_blank","width="+w+",height="+h+",scrollbars=yes,menubar=no,status=no,resizable=yes,top="+topPosition+",left="+leftPosition+",screenX=0,screenY=60");
	aWindow.focus();
}

function openInParentWindow(loc){
	if (self.opener != null) {
		self.opener.document.location = loc;
		self.opener.focus();
	} else {
		self.document.location = loc;
	}
}

function openWindow(url, attribs) {
	var newWind = window.open(url, '', attribs);
	if (newWind.opener == null) {
		window.opener = self
	}
}