
//---------------- PLATFORM DETECT --------------//

navigator.OS = '';
var platform;
platform = window.navigator.platform.toLowerCase();
if (platform.indexOf('win') != -1) {
      navigator.OS = 'win';
} else if (platform.indexOf('mac') != -1) {
      navigator.OS = 'mac';
}

//---------------- POP-UP WINDOWS ----------------//


function showTour(url){
	var w = checkWidth(770);
	var h = checkHeight(420);

	var features = "width=" + w + ",height=" + h + ",scrollbars,resizable,menubar,status" + getCenterStage(w,h);
	openCenteredWin(url,"tour",features);
}

// Resources window
function showResources(url) {
	var width = 780;
	var height = 450;
	
	if (navigator.OS == 'mac') {
		width = 770;
		height = 500;
	}
	
	var w = checkWidth(width);
	var h = checkHeight(height);
	
	var features = "width=" + w + ",height=" + h + ",scrollbars,resizable,menubar,status" + getCenterStage(w,h);
	openCenteredWin(url,"resources",features);
}

function getPath(k){
	var p = "";
	for(i=0; i < k; i++){
		p += "../"
	}
	return p;
}

function showPeerReview(url, name){
	var w = checkWidth(600);
	var h = checkHeight(420);
	if(!name) name = "peerreview";
	
	var features = "width=" + w + ",height=" + h + ",scrollbars,resizable,menubar,status" + getCenterStage(w,h);
	openCenteredWin(url,name,features);
}

function showOHS(url){
	var w = checkWidth(700);
	var h = checkHeight(430);
	var name = "ohs";
	
	var features = "width=" + w + ",height=" + h + ",scrollbars,resizable,menubar,status" + getCenterStage(w,h);
	openCenteredWin(url,name,features);
}

function showOHSimg(url){
	var w = checkWidth(450);
	var h = checkHeight(390);
	var name = "ohsimg";
	
	var features = "width=" + w + ",height=" + h + ",scrollbars,resizable,menubar,status" + getCenterStage(w,h);
	openCenteredWin(url,name,features);
}

function textPUP(url, name, w, h){
	if(!w) w = 450;
	if(!h) h = 400;
	if(!name) name = "tbooksub";
	
	w = checkWidth(w);
	h = checkHeight(h);
	
	var features = "width=" + w + ",height=" + h + ",scrollbars,resizable,menubar,status" + getCenterStage(w,h);
	openCenteredWin(url,name,features);
}

// Standard window function
function openWin(url,name,buffer) {
	var w = checkWidth(620);
	var h = checkHeight(420);
	if(!name) name = "taapup";
	
	var features = "width=" + w + ",height=" + h + ",scrollbars,resizable,menubar,status" + getCenterStage(w,h,buffer);
	openCenteredWin(url,name,features);
}

function showSR(url){
	openWin(url,"skills")
}

function showSR2(url){
	openWin(url,"skills2",20)
}

function showPC(url, oset){
	if(!oset){
		oset = 0;
	}
	openWin(url,"criteria", oset)
}

function showEGuide(url){
	openWin(url,"eguide",20)
}

function showWPP(url){
	openWin(url,"wpp")
}

function showTools(url){
	openWin(url,"tools")
}

// Any link that ends with .doc .xls (text alts, text transcripts and other docs)
function showDOC(url, name) {
	var w = checkWidth(620);
	var h = checkHeight(420);
	if(!name) name = "xta";
	
	var features = "width=" + w + ",height=" + h + ",scrollbars,resizable,menubar,status" + getCenterStage(w,h);
	openCenteredWin(url,name,features);
}

// External URL window
function showURL(url, name, buffer) {
	var w = checkWidth(620);
	var h = checkHeight(420);
	if(!name) name = "http";
	if(!buffer) buffer = 0;
	var features = "width=" + w + ",height=" + h + ",scrollbars,resizable,menubar,location,status,toolbar" + getCenterStage(w,h,buffer);
	openCenteredWin(url,name,features);
}

// opens any page in planner
function showPlanner(frameSet, mainFrame){
	url = frameSet + "?mainframe=" + mainFrame;

	if(window.screen) {
		var aH = screen.availHeight;
		var h = 420;
		var cY = ((aH - h)/2) - 50;
	}
	var plannerwindow = window.open(url, 'planwin', 'width=610,height='+ h +',left=0,top='+ cY +',scrollbars,resizable,menubar,status');	
	if (window.focus) plannerwindow.focus();
}

function noFlashWin(url){
	var w = checkWidth(640);
	var h = checkHeight(160);
	var name = "nfwin";
	
	var features = "width=" + w + ",height=" + h + ",scrollbars,resizable,menubar,status" + getCenterStage(w,h);
	openCenteredWin(url,name,features);
}

function openCenteredWin(url,name,features) {
	myWindow = window.open(url,name,features);
	if (window.focus) myWindow.focus();
}

function checkHeight(h){
	// windows open smaller on NETSCAPE so make bigger
	if (navigator.appName == 'Netscape'){
		h += 19;
	}
	// windows open smaller on MAC IE so make bigger
	if (navigator.OS == 'mac' && navigator.appName != 'Netscape'){
		h = h + 25;
	}
	return h;
}

function checkWidth(w){
	// windows open smaller on MAC IE so make bigger
	if (navigator.OS == 'mac' && navigator.appName != 'Netscape'){
		w = w + 5;
	}
	return w;
}

function getCenterStage(w,h,buffer){
	if(!buffer) buffer = 0;
	if(window.screen) {
		var s = "";
		var aH = screen.availHeight;
		var aW = screen.availWidth;
		var cY = (aH - h)/2;
		var cX = (aW - w)/2;
		s += ",left=" + ((cX-12) + buffer);
		s += ",top=" + ((cY-50) + buffer);
		return s
	}
}