// JavaScript Document
screenSizeMod = 1;

certPath = "/creditrecovery/certificate.html";	
pdfPath = "/creditrecovery/pdf.html";
vidPath = "/creditrecovery/vid.html";

function checkForIE() {
	if (navigator.appName.toUpperCase() == 'MICROSOFT INTERNET EXPLORER') { 
		return true;
	}
	else { 
		return false; 
	} 
}

function getWindowWidth() {
	if (checkForIE) {
		return document.documentElement.clientWidth * screenSizeMod;		
	}
	else {	
		return window.innerWidth * screenSizeMod;
	}
}

function getWindowHeight() {
	if (checkForIE) {
		return document.documentElement.clientHeight * screenSizeMod;		
	}
	else {
		return window.innerHeight * screenSizeMod;
	}
}

function pdf(fileName) {
	var topPos = (screen.availHeight - 480) / 2;
	var leftPos = (screen.availWidth - 640) / 2;
	var url = pdfPath + "?fileName='" + fileName + "'";
	if (typeof(win_pdf) != "undefined") win_pdf.close();
	eval("win_pdf = window.open(url, 'win_pdf', 'toolbar=0,scrollbars=0,location=0,status=1,menubar=0,resizable=0,width=640,height=450,left=" + leftPos + ",top=" + topPos + "');");
	win_pdf.focus();
}

function challenge(fileName) {
	var width = screen.availWidth - 10;
	var height = screen.availHeight - 50;
	var leftPos = 2;
	var topPos = 0;
	var url = fileName;
	if (typeof(win_challenge) != "undefined") win_challenge.close();
	eval("win_challenge = window.open(url, 'win_challenge', 'toolbar=0,scrollbars=1,location=0,status=1,menubar=0,resizable=0,width=" + width + ",height=" + height + ",left=" + leftPos + ",top=" + topPos + "');");
	win_challenge.focus();
}

function vid(fileName, size) {
	var width = 700;
	var height = 580;
	var leftPos = (screen.availWidth - width) / 2;
	var topPos = (screen.availHeight - height) / 2;
	if (typeof(size) == "undefined") var size = "large";
	var url = vidPath + "?fileName='" + fileName + "'&size='" + size + "'";
	if (typeof(win_vid) != "undefined") win_vid.close();
	eval("win_vid = window.open(url, 'win_vid', 'toolbar=0,scrollbars=0,location=0,status=0,menubar=0,resizable=0,width=" + width + ",height=" + height + ",left=" + leftPos + ",top=" + topPos + "');");
	win_vid.focus();
}


function www(address) {
	var topPos = screen.availHeight / 2 - 300;
	var leftPos = screen.availWidth / 2 - 400;	
	var url = address;
	if (typeof(win_www) != "undefined") win_www.close();
	eval("win_www = window.open(url, 'win_www', 'toolbar=1,scrollbars=1,location=1,status=1,menubar=1,resizable=1,width=800,height=480,left=" + leftPos + ",top=" + topPos + "');");
	win_www.focus();
}

function cert(assignment, lesson, score)
{
	var width = 800;
	var height = 600;
	var topPos = (screen.availHeight - height) / 2;
	var leftPos = (screen.availWidth - width) / 2;
	var url = certPath + "?assignment='" + escape(assignment) + "'&score='" + escape(score) + "'&lesson='" + escape(lesson) + "'";
	if (typeof(win_certificate) != "undefined") win_certificate.close();
	eval("win_certificate = window.open(url, 'win_certificate', 'toolbar=0,scrollbars=0,location=0,status=0,menubar=0,resizable=0,width=" + width + ",height=" + height + ",left=" + leftPos + ",top=" + topPos + "');");
	window.close();
	win_certificate.focus();
}

function cert2(assignment, lesson, score, name)
{
	var width = 800;
	var height = 600;
	var topPos = (screen.availHeight - height) / 2;
	var leftPos = (screen.availWidth - width) / 2;
	var url = "certificate2.html?assignment='" + assignment + "'&score='" + score + "'&name='" + escape(name) + "'&lesson='" + lesson + "'";
	if (typeof(win_certificate2) != "undefined") win_certificate2.close();
	eval("win_certificate2 = window.open(url, 'win_certificate2', 'toolbar=0,scrollbars=0,location=0,status=0,menubar=0,resizable=0,width=" + width + ",height=" + height + ",left=" + leftPos + ",top=" + topPos + "');");
	window.close();
	win_certificate2.focus();
}
