
var	AlreadyTestedUrl	= "http://ustools.you-niversity.com/youtools/wizard/alreadytested.asp";
var	ArchiveWizardUrl	= "http://webcast.you-niversity.com/youtools/wizard/live/default.asp";
 var	LiveWizardUrl	= "http://webcast.you-niversity.com/youtools/wizard/live/default.asp";

 var	ytLiveWindow	= "http://ustools.you-niversity.com/youtools/ndstudent/default.asp";
 var	ytArchiveWindow	= "http://www.you-niversity.com/youtools/ndarchive/default.asp";
 
 if (typeof(thisIsAnArchive)=="undefined")
 	eval ("var thisIsAnArchive=true");
 
 var serverWin;

OsError			= "This e-Learning class features technologies supported by Windows OS. \n" +
				  "Please use a Windows OS to access this class.";
IEError			= "This e-Learning class features technologies not supported by the browser you are currently using.\n\n" +
				  "This e-Learning class can be viewed only with Internet Explorer 5.0 or later. \n" +
				  "Please access this page again in Internet Explorer and launch the e-Learning class. \n\n" +
				  "Please do: \n" +
				  "  1.  Copy the address of this page \n" +
				  "  2.  Click on the Start button and select:  Programs Internet Explorer to launch IE \n" +
				  "  3.  Paste the address into the address bar of the Internet Explorer. \n" +
				  "  4.  Launch the e-Learning class again \n\n" +
				  "Thank you!";
MPError			= "These e-Learning class features technologies supported by Windows Media Player 6.4 or later.\n\n" +
				  "Please install the suitable Windows Media Player before attending this class. \n\n" +
				  "You can download a free version of the Windows Media Player from the following Microsoft site: " +
				  "http://www.microsoft.com/windows/windowsmedia/download/default.asp";


var mailDebug = false;		// if set to "true" emails are sent to Eran


// If set to "true" showArchive will ask for user details
// Override inside page (to "false") in order to disable this feature
var loginNeeded = true;
var loginDone = false; // Will be set to "true" once the user send his details
var loginCounter=-1;
var courseInfo="";
var Delimiter = "^";

var recipient;
if (mailDebug)
	recipient = "eran@sela.co.il";
else
	recipient = "caros@va.you-niversity.com";

var channelAfterLogin=null, nameAfterLogin="Guest", affiliateName="unknownAff";
var emailAfterLogin="", phoneAfterLogin=""; // "" for Didi


if (typeof(clientIP)=="undefined")
	eval ("var clientIP='unknownIP'");




function	getX() {
  return top.screen.availWidth;
}


function	getY() {
  return top.screen.availHeight;
}





// Open an archive class (login is not mandatory)
function	showArchiveDemos(channel, name, email, program, server) {
			
	YtHeight	= 575;		
	YtWidth 	= 800;

	var ytLeft = (screen.width - YtWidth)/2;
	var ytTop = (screen.height - YtHeight)/2;

	var YtOpts		= "'toolbar=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes," +
					  "left=" + ytLeft + ",top=" + ytTop + ",width="+YtWidth + ",height="+YtHeight + "'";

	  if( navigator.platform != "Win32" ) {
			alert(OsError);
	  } else if( !checkBrowser() || !checkVersion() )	 {
			alert(IEError);
	  } else if( !checkMediaPlayer() ) {
			alert(MPError);
	  } 
	  else {					// Browser and Media Player OK
				var originalUrl =  "?track=true&StudentName=" + name + "&CourseName=" + channel + "&EMail=" + email+"&ArchiveCode=" + channel;
				var url	= ytArchiveWindow + originalUrl;
				if (server!=null && server!="null")
					url = server + originalUrl;
					
				var attendUrl = "http://ustools.you-niversity.com/youtools/companies/saveAttendance.asp" + originalUrl + "&program=" + program + "&affiliateName=" + affiliateName + "&EMail=" + email + "&redirectUrl=http://www.you-niversity.com/demos.asp";

				if( serverWin == null || serverWin.closed ) 
					serverWin	= window.open(url, 'YouToolsWin', YtOpts);
				
				location.href=attendUrl;
				serverWin.focus();
	  }	// End of else
}




// Redirect to Didi's page (which then redirects to the given url)
function openAlreadyTested(name, email, url) {
	if (email=="")
		email=" ";
	var theUrl = AlreadyTestedUrl + "?name=" + name + "&email=" + email + "&url="+url;
	location.replace(theUrl);
}


// Open the wizard for the LIVE lectures
function openNewWizard(userName, userEmail) {
	var fullWizard = LiveWizardUrl + "?name=" + userName + "&email=" + userEmail;
	var wWidth=750;
	var wHeight=600;
	var wTop = ((getY()-wHeight)/2);
	var wLeft = ((getX()-wWidth)/2);
	
	if (getX()<700) {
		wWidth = getX()-10;
		wHeight = getY()-30;
		wTop=0;
		wLeft=0;
	}
	
	var	opts	= 'top=' +wTop+ ',left=' +wLeft + ',scrollbars=yes,resizable=yes,width=' + wWidth + ',height=' + wHeight;
    serverWin	= window.open(fullWizard, 'wizardWin', opts);
}


// Open the wizard for the ARCHIVED lectures
function openYTWizard() {
	var fullWizard = ArchiveWizardUrl;
	var wWidth=751;
	var wHeight=600;
	var wTop = ((getY()-wHeight)/2);
	var wLeft = ((getX()-wWidth)/2);
	
	if (getX()<700) {
		wWidth = getX()-10;
		wHeight = getY()-30;
		wTop=0;
		wLeft=0;
	}
	
	var	opts	= 'top=' +wTop+ ',left=' +wLeft + ',scrollbars=yes,resizable=yes,location=no,directories=no,status=no,menubar=no,width=' + wWidth + ',height=' + wHeight;
    serverWin	= window.open(fullWizard, 'wizardWin', opts);
}


// Check browser's type
function	checkBrowser() {
	return (navigator.appName.indexOf('Netscape') < 0);
}


// Check browser's version
function	checkVersion() {
	var	v	= navigator.appVersion;
	if( navigator.appName.indexOf('Explorer') >= 0 ) {
		if( v.indexOf('MSIE 3') >= 0 || v.indexOf('MSIE 4') >= 0 )
			return false;
	}
	return true;						// No browser error
}


function getMPVersion()
{
	var pWMP=null;
	try
	{
		pWMP=new ActiveXObject("WMPlayer.OCX")
		if (pWMP != null)
		{
			if (pWMP.versionInfo.indexOf("11") == 0)
			{
				return 11;
			}
			if (pWMP.versionInfo.indexOf("10") == 0)
			{
				return 10;
			}
			if (pWMP.versionInfo.indexOf("9") == 0)
			{
				return 9;
			}
			if (pWMP.versionInfo.indexOf("8") == 0)
			{
				return 8;
			}
			if (pWMP.versionInfo.indexOf("7") == 0)
				return 7;
		}
	}
	catch (Error)
	{
		alert(Error.message);
		return 6;
	}
	return 6;
}


// Check if Media player is installed
function	checkMediaPlayer() {
	var WMplayer = getMPVersion();
	if (WMplayer>6)
		return true;		
	
	if( navigator.appName.indexOf('Explorer') >= 0 ) {
		var	objPlayer	= null;
		eval('try { objPlayer = new ActiveXObject("MediaPlayer.MediaPlayer.1"); } catch(ex) {}');
		if( objPlayer != null )
			return true;
	}
	return false;
}



// Pop up the Firewall considerations page (from requirements)
function showFirewalls() {
	window.open("http://www.you-niversity.com/help/youtoolsNewGUI/help80.html", "newWin", "resizable=yes,scrollbars=yes,toolbar=no,location=no,directories=no,status=no,menubar=no");
}


// Open the wizard for the LIVE lectures
function openTechSupport() {
	var wWidth=750;
	var wHeight=500;
	var wTop = ((getY()-wHeight)/2);
	var wLeft = ((getX()-wWidth)/2);
	
	if (getX()<700) {
		wWidth = getX()-10;
		wHeight = getY()-30;
		wTop=0;
		wLeft=0;
	}
	
	var	opts	= 'top=' +wTop+ ',left=' +wLeft + ',scrollbars=no,resizable=yes,width=' + wWidth + ',height=' + wHeight;
    serverWin	= window.open("http://www.you-niversity.com/mail/technicalSupport.asp", 'techsupport', opts);
}
