
var openedWindow = null;

// Open win
function fnOpenWin(pstrUrl,pstrTitle,pstrParam){
    if (!openedWindow || openedWindow.closed){
        openedWindow = window.open(pstrUrl,pstrTitle,pstrParam);
        openedWindow.focus();
    } else {
        openedWindow.focus();
        openedWindow = null;
    }
}

function openCenteredWindow(sFile, iHeight, iWidth, sName) {
	vTop  = screen.availHeight/2 - iHeight/2;
	vLeft = screen.availWidth/2 - iWidth/2;
	vWin = window.open(sFile,sName,'width=' + iWidth + ',height=' + iHeight + ',left=' + vLeft + ',top=' + vTop);
	vWin.focus();
}

function openEmsPopup (eid, pid) {
    win = window.open('/shared/scripts/ems_popup.php?eid=' + eid + '&pid=' + pid, 'emsPopup', 'width=400,height=300,resizable=yes,scrollbars=yes');
    win.focus();
}

// Select continent for training
function fnSchedule(strURL){
	window.location = '?cont='+strURL;
}

// Pop-up window for imaghe enlargement
function enlargeImage (imgurl, xwidth, xheight) {
    win = window.open('/shared/scripts/enlargeimage.php?image=' + escape(imgurl), '', 'width=' + xwidth + ',height=' + xheight);
}

// Open a popup window for animated tutorials
function playAnimatedTutorial (tutorial, width, height) {
	if (!width) {
		width = 1024;
		height = 768;
	}
	var sw = screen.availWidth;
	var sh = screen.availHeight;
	if (sw >= width) {
		sw = width;
	}
	if (sh >= height) {
		sh = height;
	}
	win = window.open('/shared/tutorials/play.php?tutorial=' + tutorial + '&w=' + width + '&h=' + height, 'animatedTutorial', 'width=' + sw + ',height=' + sh);
}

// CSS:hover support for IE
function startList() {
	if (document.all && document.getElementById) {
   		/*
        navRoot = document.getElementById("mainmenu");
   		for (i=0; i < navRoot.childNodes.length; i++) {
    		node = navRoot.childNodes[i];
    		if (node.nodeName=="LI") {
       			node.onmouseover = function() {
        			this.className += " over";
       			}
       			node.onmouseout = function() {
           			this.className = this.className.replace(" over", "");
          		}
      		}
   		}
        */
	}
}

function openLicenseWizard (licno, version) {
    var wizard = "";
    switch (version) {
		case '35a':
            wizard = 'wizard3.5a';
            break;
		case 35:
            wizard = 'wizard3.5';
            break;
		case 34:
            wizard = 'wizard3.4';
            break;
        case 33:
            wizard = 'wizard3.3';
            break;
        case 32:
            wizard = 'wizard3.2';
            break;
        case 31:
            wizard = 'wizard3.1';
            break;
        default:
            wizard = 'wizard';
    }
	win = window.open('/secure/passcodes/' + wizard + '/index.php?start=1&license_number=' + licno, 'lic_wiz', 'height=400,width=500,left=20,top=20');
	win.focus();
}

window.onload=startList;

