﻿/* if (top.location != self.location) { top.location = self.location } */

function wopen( url, target, w, h, asize, title, res, rett ) {
	if( !url ) {
		event.cancelBubble = true;
		event.returnValue = false;
		return;
	}
	if( !target ) target = '_blank';
	if( !w ) w = 500;
	if( !h ) h = 400
	if( !title ) title = '';

	w = parseInt( w, 10 );
	h = parseInt( h, 10 );
	if( asize ) asize = true;
	else asize = false;

	var aw = screen.availWidth;
	var ah = screen.availHeight;
	if( w > aw ) w = aw;
	if( h > ah ) h = ah;

	var left = Math.round( ( aw - w ) / 2 );
	var top = Math.round( ( ah - h ) / 2 );

	var wd = window.open( url, target, 'channelmode= 0, directories=0, height='+h+'px, width='+w+'px, location=0, menubar=0, resizable='+res+', scrollbars=0, status=0, toolbar=0, top='+top+'px, left='+left+'px' );
	if ( !asize ) { 
		if( rett )return wd; 
		else return false;
	}

	if( url.indexOf( window.location.host ) != -1 || url.indexOf( 'http://' ) == -1  ) wd.attachEvent( "onload", function() {resize_new_win( wd, asize, title )	} );
	//if( rett )return wd; 
}