// *************************************************************************
// 'Javascript for Taalcursisten' 
// *************************************************************************

//LocHelp = 'help.aspx';
LocPrikbord = '/Xportal/Default/Taalcursisten/TC_Prikbord/Default.aspx';
LocContactInfo = '/Xportal/Default/Taalcursisten/TC_ContactInfo/Default.aspx';

function getXPostitie(breedte)
{
	// ophalen x positie op grond van 'scherm' breedte
	
	// todo:
	// ophalen op grond van de breedte van de parent window ??
	
	var x;
	x = ((screen.width)/2) - (breedte/2);
	return x;
	
}

function getYPostitie(hoogte)
{

	// ophalen y positie op grond van 'scherm' hoogte
	
	// todo:
	// ophalen op grond van de hoogte van de parent window ??

	var y;
	y = ((screen.height)/2) - (hoogte/2);
	return y;
}

function openWindowSameAsParent(loc,name)
{

	// dit werkt wel, maar eigenlijk niet: window.parent.height wordt niet begrepen !
	// (het werkt wel zo als bedoeld maar dat is dus toeval)

	try
	{

			var	args = "";
		
			args = args + "height=";
			args = args + window.parent.height;
			args = args + ",";

			args = args + "width=" 
			args = args + window.parent.width;
			args = args + ",";

			args = args + "top=";
			args = args + window.parent.top;
			args = args + ",";
		
			args = args + "left=";
			args = args + window.parent.left;
			args = args + ",";

			args = args + "toolbar=no,scrollbars=no,status=yes,resizable=yes";
			
			var w;
			w = window.open(loc,name,args);
			w.focus();
	}
	catch(e)
	{
		alert('fout bij willen openen ' + loc);
	}


}

function openWindow(loc,name,top,left,height,width)
{
	try
	{
	
			var	args = "";
			var w;
		
			args = args + "height=";
			args = args + height;
			args = args + ",";

			args = args + "width=" 
			args = args + width;
			args = args + ",";

			args = args + "top=";
			args = args + top;
			args = args + ",";
		
			args = args + "left=";
			args = args + left;
			args = args + ",";

			args = args + "toolbar=no,scrollbars=yes,status=no,resizable=yes";
			
			w = window.open(loc,name,args);
			w.focus();



	}
	catch(e)
	{
		alert('openWindow(): fout bij willen openen ' + loc);
	}


}


function StartupWindowSize(wnd)
{
	try
	{
		// dit geeft, het niet meteen willen verschijnden van verticale scrollbar, probleem
	
	//	wnd.moveTo(0,0);
		
	//	wnd.resizeTo(1028,0.95*768); // houdt rekening met de taskbar
		
		
	}
	catch(e)
	{
		alert('DefaultSize(): ' + e.message);
	}
	
}

function toonHelp()
{
	try
	{
	
			var	args = "";
			var name = "help";
			var loc = LocHelp;
			
//			openWindowSameAsParent(loc,name);

			// gecentreerd			
			x = getXPostitie(600);
			y = getYPostitie(500);
			
			openWindow(loc,name,y,x,500,600);

			
			

	}
	catch(e)
	{
		alert('fout bij willen openen helppagina');
	}
	
}

function toonPrikbord(studieID)
{
	try
	{

		var name = "prikbord";
		var loc = LocPrikbord;
		loc = loc + '?studieid=' + studieID;
		
		// gecentreerd			
		x = getXPostitie(500);
		y = getYPostitie(500);
		
		openWindow(loc,name,y,x,500,500);

			
	}
	catch(e)
	{
		alert('fout bij willen openen prikbord');
	}
	
}

function toonContactInfo(strSchoolID, strStudieID)
{
	try
	{
	
			var	args = "";
			var name = "contactinfo";
			var loc = LocContactInfo;
			loc = loc + '?';
			loc = loc + 'schoolid=' + strSchoolID;
			loc = loc + '&';
			loc = loc + 'studieid=' + strStudieID;
		
			x = getXPostitie(565);
			y = getYPostitie(270);
			
			openWindow(loc,name,y,x,270,565);


	}
	catch(e)
	{
		alert('fout bij willen tonen contact informatie');
	}
	
}


function Setfocus(id)
{
	// set focus op control met gegeven id
	try
	{

		var el;
		el = document.getElementById(id);
		
		if (el != null)
		{
			el.focus();

//          in eras was dit nodig ....			
//			try
//			{
//				// noodzakelijk?
//				document.focus();     
//			}
//			catch(e)
//			{
//				// voor netscape 
//			}
		}

	}
	catch(e)
	{
		alert('error Setfocus voor ' + id);
	}
		
}

function SetInView(id)
{
	// set control in view
	
	try
	{

		var el;
		el = document.getElementById(id);
		
		if (el != null)
		{
			el.scrollIntoView(true);
		}

	}
	catch(e)
	{
		alert('error SetInView voor ' + id);
	}
		
}

function toonXportalWinkelwagen(url)
{
	try
	{
		window.parent.window.location = url;
	}
	catch(e)
	{
		alert('fout bij weergeven url');
	}
}
