
//=============================================================================

// The Central Randomizer 1.3 (C) 1997 by Paul Houle (houle@msc.cornell.edu)
// See:  http://www.msc.cornell.edu/~houle/javascript/randomizer.html

var _TNO_Randomizer = (new Date()).getTime();

function TNO_Random() {
	_TNO_Randomizer = ( _TNO_Randomizer * 9301 + 49297 ) % 233280;
	return _TNO_Randomizer / ( 233280.0 );
};

function TNO_RandomInt( Max ) {
	return Math.ceil( TNO_Random() * Max );
};

// end central randomizer. -->

//=============================================================================

// A simple function to generate a string of random numbers.
function RandomTag() {
	var Tag = "" + TNO_Random();
	return Tag.substring( 2, Tag.length );
}

//=============================================================================

// Standard Initialization Function for .NET Popup Forms.
// It gives the window a random name, and changes the default postback form to
// target it. Then it checks if the window needs to be closed.
// CloseWindow should be a boolean value (true/false).
// ReturnValue should be an integer value.
function TNO_PopupInitialize( CloseWindow, ReturnValue ) {

	// Fetch a Tag for naming the Window.
	var Tag = RandomTag();

	// Set the Window Name for PostBacks.
	window.name = Tag;

	// Set the form Target for PostBacks.
	document.all.Form1.target = Tag;

	// Check if we're allowed to go away.
	if (CloseWindow) {

		// Set the Return Value and close the window.
		window.returnValue = ReturnValue;
		window.top.close();
	}

	// Always return True.
	return true;
}

//=============================================================================

function TNO_PopupClose( ReturnValue ) {

	// Set the Return Value and close the window.
	window.returnValue = ReturnValue;
	window.top.close();
}

//=============================================================================

function TNO_PopupWindow( Url ) {
	var ReturnValue;
	
	// Show the Modal Popup window.
	ReturnValue = window.showModalDialog(
		Url
	, 0
	, "dialogWidth:750px;dialogHeight:550px;help:no;resizable:yes;status:no;"
	);
	
	// Always return True.
	return ReturnValue;

	/* truc om popup in het hoofdscherm te laten zien (voor view source)
	this.document.location = Url;
	return true;
	*/
}


//=============================================================================

function TNO_PopupPictureBaseSelectWindow( Type, ReturnInput ) {
	var ReturnValue;
	
	// Show the Modal Popup window.
	ReturnValue = TNO_PopupWindow(
		"/Algemeen/Pages/PictureBaseSelectWindow.aspx"
	+ "?Type=" + Type
	+ "&Tag=" + RandomTag()
	);
	
	var Input = document.all[ ReturnInput ];
	Input.value = ReturnValue;
}

//=============================================================================

function TNO_PopupQuadImageEditWindow( Guid, Placeholder ) {

	// Show the Modal Popup window.
	var ReturnValue = TNO_PopupWindow(
		"/Algemeen/Pages/QuadImageEditWindow.aspx"
	+ "?Guid=" + Guid
	+ "&Placeholder=" + Placeholder
	+ "&Tag=" + RandomTag()
	);
}

//=============================================================================

function TNO_PopupQuadImageViewWindow( Guid, Titel, Tooltip, Omschrijving, Bron, Site ) {
	
	// Show the Modal Popup window.
	return TNO_PopupWindow(
		"/Algemeen/Pages/QuadImageViewWindow.aspx"
	+ "?Guid=" + Guid
	+ "&Titel=" + Titel
	+ "&Tooltip=" + Tooltip
	+ "&Omschrijving=" + Omschrijving
	+ "&Bron=" + Bron
	+ "&Site=" + Site
	+ "&Tag=" + RandomTag()
	);
}

//=============================================================================

function TNO_PopupPostingPropertyEditWindow( Guid, Property ) {
	
	// Show the Modal Popup window.
	return TNO_PopupWindow(
		"/Algemeen/Pages/PostingPropertyPopup.aspx"
	+ "?Guid=" + Guid
	+ "&Property=" + Property
	+ "&Tag=" + RandomTag()
	);
}

//=============================================================================

function TNO_PopupPostingSource( Guid, Site ) {
	
	// Show the Modal Popup window.
	return TNO_PopupWindow(
		"/Algemeen/Pages/PostingSourcePopup.aspx"
	+ "?Guid=" + Guid
	+ "&Site=" + Site
	+ "&Tag=" + RandomTag()
	);
}

//=============================================================================

function TNO_PopupMenuLinkSelectWindow() {
	
	// Show the Modal Popup window.
	return TNO_PopupWindow(
		"/Algemeen/Pages/MenuLinkSelectWindow.aspx"
	+ "?Tag=" + RandomTag()
	);
}

//=============================================================================

function TNO_PopupSubmitPictureWindow() {
	
	// Show the Modal Popup window.
	return TNO_PopupWindow(
		"/Algemeen/Pages/SubmitPicture.aspx"
	+ "?Tag=" + RandomTag()
	);
}

//=============================================================================

function TNO_SubmitSearchBoxForm() {
	var searchForm;
	
	if (document.getElementById) {
		searchForm = document.getElementById( 'searchForm' );
	} else {
		searchForm = document.all.searchForm;
	}
	searchForm.submit();
}

//=============================================================================

