// window_operation.js

//



var flash_newWindows = new Array();

var flash_index      = 0;


//function flash_windowOpen( targetObject, width, height )
function flash_windowOpen( locuri, width, height )

{

	//var uri  = targetObject.href;
	//var name = targetObject.target;

	var uri  = locuri
	var name = this.target;

	var defaultOptions = 'menubar=yes,toolbar=yes,location=yes,status=yes,scrollbars=yes,resizable=yes';

	var comma          = ',';

	var widthOption    = 'width=' + width;

	var heightOption   = 'height=' + height;

	var sizeOption     = ( width ? widthOption : '' ) + ( width && height ? comma : '' ) + ( height ? heightOption : '' );

	var options        = defaultOptions + comma + sizeOption;




	if(width && height)	{



		if( flash_newWindows.length == 0 ) {

			newflash_windowOpen(uri, name, options);

		} else {

			var windowCondition  = false;

			var nullWindowflash_index  = new Array();

			var count            = 0;



			for( var i = 0; i < flash_newWindows.length; i++ ){

				if( flash_newWindows[i].closed == false )

				{

					if( flash_newWindows[i].name == name )

					{

						windowCondition = true;

						flash_index           = i;

						break;

					}

				} else {

					nullWindowflash_index[count] = i;

					count++;

				}

			}



			if( windowCondition ) {

				var newWindow         = flash_newWindows[flash_index];

				var windowInnerWidth  = 0;

				var windowInnerHeight = 0;



				if( newWindow.innerWidth && newWindow.innerHeight )	{

					windowInnerWidth  = newWindow.innerWidth;

					windowInnerHeight = newWindow.innerHeight;

				} else if( newWindow.document.body ) {

					if( newWindow.document.body.clientWidth && newWindow.document.body.clientHeight ){

						windowInnerWidth  = newWindow.document.body.clientWidth;

						windowInnerHeight = newWindow.document.body.clientHeight;

					}

				}



				var methodType   = typeof newWindow.resizeBy;

				var noMethod     = ( methodType == 'undefined' || methodType == 'unknown' ) ? true : false;

				newWindow.focus();

				if( !noMethod )	{

					var w = width  ? ( width - windowInnerWidth )   : 0;

					var h = height ? ( height - windowInnerHeight ) : 0;

					newWindow.resizeBy( w, h );

				}

			} else {

				if( nullWindowflash_index.length > 0 ){

					flash_index = nullWindowflash_index[0];

				} else {

					flash_index++;

				}

				newflash_windowOpen(uri, name, options);

			}

		}

	

	} else {

		nsflash_windowOpen(uri, name, options);

	}

	

}



function newflash_windowOpen(uri, name, options) {

	flash_newWindows[flash_index] = window.open( uri, name, options );

	flash_newWindows[flash_index].name = name;

	flash_newWindows[flash_index].focus();

}



function nsflash_windowOpen(uri, name, options) {

	var nswindow = window.open( uri, name, options );

	nswindow.focus();

}


/*
var eventFlag = true;

function getKeyCode( targetObject, eventObject )

{

	var eventType;

	var keycode;



	if( window.event )

	{

		eventType = window.event.type;

		keycode   = window.event.keyCode;

	}

	else if( eventObject )

	{

		eventType = eventObject.type;

		keycode   = eventObject.which;

	}



	if( eventType == 'keypress' && keycode == 13)

	{

		var _f = targetObject.attributes['onclick'].nodeValue;

		var f  =  _f.replace( 'this', 'targetObject' );

		eval( f );

		eventFlag = false;

	}

}
*/
