﻿/*******************************************************************/
function nl_popupWindow(url,target,width,height,opts)
/*
	Returns: (nothing)

	Required parameters:
	·	url: address of page to load in popup window, usually: this.href
	·	target: the name to give to the new window (for reusing windows)

	Optional parameters:
	·	width: (integer) only used if height is also specified
	·	height: (integer)
	·	opts: (string) specify which elements to display in the window:
			l - location (or address) bar
			m - menu bar (useful for access to the file menu for printing)
			r - resizable (usually this should be specified)
			s - scroll bars (usually this should be specified)
			t - tool bar (back, forward, reload, stop, etc)
			x - status bar

			e.g. 'mrs' means display menu bar, allow window to be resized
			and display scrollbars if content is too big for window
********************************************************************/
{
	var p = null;
	if (width == null || height == null) {
		p = null
	}
	else if (opts == null) {
		p = "width="+width+",height="+height
	}
	else
	{
		p = "width="+width+",height="+height

		opts = opts.toString().toLowerCase();

		if (opts.indexOf("l") >= 0) p += ",location=1"
		if (opts.indexOf("m") >= 0) p += ",menubar=1"
		if (opts.indexOf("r") >= 0) p += ",resizable=1"
		if (opts.indexOf("s") >= 0) p += ",scrollbars=1"
		if (opts.indexOf("t") >= 0) p += ",toolbar=1"
		if (opts.indexOf("x") >= 0) p += ",status=yes"
	}

	var x = window.open(url,target,p)
	if (x.focus) x.focus();
}
/*******************************************************************/

function nl_popupContactUs(url) { nl_popupWindow(url,'contactus',650,450,'rs'); }
function nl_popupTechnical(url) {
	if (document.location.host == "difusion") {
		url = url.replace("/www.netlanguages.com/","/sol/");
	}
	nl_popupWindow(url,'techinfo',500,600,'rs');
}
function nl_popupPurchase() {
	var url;
	switch(CURRENT_LANG) {
		case "english": url = "english"; break;
		case "deutsch": url = "german"; break;
		case "espanol": url = "spanish"; break;
		case "francais": url = "french"; break;
		default: url = "english";
	}

	if (document.location.host == "difusion") {
		url = "http://sol/information/"+url+"/purchase/start.asp?id=1604&custom=difusion";
	} else {
		url = "https://www.netlanguages.com/information/"+url+"/purchase/start.asp?id=3441&custom=difusion";
	}
	nl_popupWindow(url,'purchase',620,450,'mrlsx');
}

/*
	Opens a popup window to display scorm content:
    lang:				the language of the sample course pages (to determine in which language to display the interface in)
    scormID:		the ID of the scorm package to display
    levelName:	the title bar text, normally the level of the course
    courseType:	the type of course, used by the player to display different interfaces (defaults to a standard English player)
*/
function nl_popupSample(lang,scormID,levelName,courseType) {
	var url = document.location.href;
	url = url.substring(0,url.indexOf("/information/"));

	// Have to hard code this until constants.asp is available on all mirror sites
	if (document.location.hostname == "sol") {
		url = "http://sol";
	} else if (document.location.hostname == "difusion") {
		url = "http://sol";
	} else {
		url = "http://www.netlanguages.com";
	}

	url += "/information/player/start.htm";
	url += "?sco=" + scormID;
	url += "&interface=difusion";

	// guess the name of the course from the scormID if level name is not supplied
	if (levelName == null) {
		if (scormID.indexOf("es-gen-l1-") == 0) {
			url += "&level=PreElemental";
		} else if (scormID.indexOf("es-gen-l2-") == 0) {
			url += "&level=Elemental";
		} else if (scormID.indexOf("es-gen-l3-") == 0) {
			url += "&level=Intermedio Bajo";
		} else if (scormID.indexOf("es-gen-l4-") == 0) {
			url += "&level=Intermedio";
		} else if (scormID.indexOf("es-gen-l5-") == 0) {
			url += "&level=Intermedio Alto";
		} else if (scormID.indexOf("es-gen-l6-") == 0) {
			url += "&level=PreAvanzado";
		} else if (scormID.indexOf("es-gen-l7-") == 0) {
			url += "&level=Avanzado";
		}
	} else {
		url += "&level=" + levelName;
	}

	url += "&logout=&returnto="; // is a sample so pass these empty to ensure these links just close the window
	if (lang == "es") {
		url += "&lang=es&sample=Material%20de%20muestra";
	} else {
		url += "&sample=Sample%20Material";
	}
//	url += "&topimage="; // deprecated
	url += "&root=samples";
	url += "&path=/information/"; // the location within the URL where the root of the scorm content can be found

	if (courseType == null) {
		// use the id of the SCORM sample to guess the top image required
		if (scormID.indexOf("efd-") == 0) {
			// English for Doctors
			url += "&topimage=englishfordoctors.jpg";
		} else if (scormID.indexOf("ge-") == 0) {
			// General English
			url += "&topimage=ge.jpg";
		} else if ((scormID.indexOf("vocpt-") == 0) || (scormID.indexOf("grpt-") == 0) || (scormID.indexOf("lspt-") == 0) || (scormID.indexOf("prpt-") == 0)) {
			// Practice Courses
			url += "&topimage=practicecourses.jpg";
		}
	} else {
		switch(courseType) {
			case "practicecourse":
				url += "&topimage=practicecourses.jpg";
				break;
		}
	}

	nl_popupWindow(url,'sample',840,540,'rsx')
}

function nl_frameMePlease(lang,title)
{
	if (parent != self) return;

	var newURL;
	var pathToLang = document.location.href;

	if (pathToLang.indexOf("/difusion/orgs/difusion/") >= 0) {
		pathToLang = pathToLang.substring(0,pathToLang.lastIndexOf("/difusion/orgs/difusion/"+lang+"/"));
		pathToLang += "/difusion/orgs/difusion/"+lang

	} else {
		return;
	}

	newURL = pathToLang + "/popup/index.htm?l="+escape(document.location)+"&t="+escape(document.title);
	document.location = newURL;
}

var rolloverCurrent = undefined;

function rolloverWriteStyles() {
	if (!document.getElementById) return;
	document.write('<style type="text/css" media="screen">\n');
	document.write('div.content h2 { margin-top: 0px !important; }\n');
	document.write('.rollover-section {\n');
	document.write('display:none;\n');
	document.write('margin: 10px 0px 0px 0px;\n');
	document.write('}\n');
	document.write('</style>\n');
}

function rolloverSectionOver(s) {
	if (!document.getElementById) return;
	if (rolloverCurrent != undefined) rolloverCurrent.style.display = "none";
	rolloverCurrent = document.getElementById(s);
	document.getElementById(s).style.display = "block";
}
