/*
* Pops a window up.
* Parameters:
* URL: Where to go
* size: how big?
*/
function newWin( pWindowUrl, sizeX, sizeY ){

	if( !( sizeY > 0 ) ) sizeY = ( sizeX / 4 ) * 3;

	win = open( 
		pWindowUrl, 
		"newWin", 
		"width=" + sizeX + ",height=" + sizeY + ",screenX=0,screenY=0,resizeable=no,dependent=yes,hotkeys=no,scrollbars=yes" 
	);

	win.focus();

	return;
}

/*
* Replaces all links with an popup Target with javascriptcode to popup
*/
function replaceLinks() {

	for( i=0; i < document.links.length; i++ ){

		target = document.links[ i ].target;

		if( target.substr( 0, 5 ) == "popup" ){

			sizestr = target.substr( 5, target.length -1 ).split( "x" );

			sizeX = parseInt( sizestr[ 0 ] );
			if( !( sizeX > 0 ) ) sizeX = 600;

			if( sizestr.length > 1 ){
				sizeY = parseInt( sizestr[ 1 ] );
			} else {
				sizeY = 0;
			}


			document.links[ i ].target = "";
			document.links[ i ].href   = "javascript: newWin( '" + document.links[ i ].href + "', " + sizeX + ", " + sizeY + ");";
		}
	}
}
