function biginit()
{
	self.y_center=(parseInt(screen.height/2));
	self.x_center=(parseInt(screen.width/2));
	self.pop_stack=Array();
}

function get_center(size, side)
{
	center = eval('self.'+side+'_center-('+size+'/2);');
	return(parseInt(center));
}

function close_pop(pop_name)
{
	eval ('pop_'+pop_name+'.close()');
}

function build_pop(url, pop_name, pop_width, pop_height, pop_left, pop_top, pop_status, pop_resizable, pop_directories, pop_toolbar, pop_scrollbars, pop_reload)
{
	if (typeof(pop_width) == 'string'){	pop_width=parseInt((pop_width.substr(0, pop_width.indexOf('P')-1))*(screen.width/10));	} 
	if (pop_width<100) { alert('ancho invalido: '+pop_width); pop_width=100; }
	
	if (typeof(pop_height) == 'string'){ pop_height=parseInt((pop_height.substr(0, pop_height.indexOf('P')-1))*(screen.height/10)); }
	if (pop_height<100) { alert('alto invalido: '+pop_height); pop_height=100; }
	
	if (!pop_left){ pop_left=get_center(pop_width,'x');	}
	if (!pop_top){ pop_top=get_center(pop_height,'y'); }

	window_opts = 'width='+pop_width+',height='+pop_height+',left='+pop_left+',top='+pop_top;
	if (pop_status!=1) { window_opts+= ',status=no'; } else { window_opts+= ',status=yes'; }
	if (pop_resizable!=1) { window_opts+= ',resizable=no'; } else { window_opts+= ',resizable=yes';}
	if (pop_directories!=1) { window_opts+= ',directories=no'; } else { window_opts+= ',directories=yes'; }
	if (pop_toolbar!=1) { window_opts+= ',toolbar=no'; } else { window_opts+= ',toolbar=yes'; }
	if (pop_scrollbars==0) {
		window_opts+= ',scrollbars=no';
	} else if (pop_scrollbars==1) {
		window_opts+= ',scrollbars=yes';
	} else {
		window_opts+= ',scrollbars=auto';
	}
   eval('self.pop_it=1;\n'+
   		'if (self.pop_'+pop_name+' && !pop_'+pop_name+'.closed) {\n'+
			'self.pop_it=0;\n'+
			'if (pop_reload){\n'+
				'if (pop_reload==\'R\') {\n'+
					'pop_'+pop_name+'.reload();\n'+
				'} else if(pop_reload==\'C\') {\n'+
					'pop_'+pop_name+'.close();\n'+
					'self.pop_it=1;\n'+
				'} else {\n'+
					'pop_'+pop_name+'.location="'+url+'";\n'+
				'}\n'+
			'}\n'+
		'}'+
		'if (self.pop_it==1) {\n'+
			'pop_'+pop_name+' = window.open ("'+url+'", "pop_'+pop_name+'", "'+window_opts+'");\n'+
			'var set_stack=true;\n'+
		'}\n'+
		'pop_'+pop_name+'.focus();');

	
	if (set_stack || (pop_reload && (pop_reload!='R' || pop_reload!='C')))
	{
		self.pop_stack[pop_name]=new Array();
		self.pop_stack[pop_name]["url"]=url;
		self.pop_stack[pop_name]["pop_width"]=pop_width
		self.pop_stack[pop_name]["pop_height"]=pop_height
		self.pop_stack[pop_name]["pop_left"]=pop_left
		self.pop_stack[pop_name]["pop_top"]=pop_top
		self.pop_stack[pop_name]["pop_status"]=pop_status
		self.pop_stack[pop_name]["pop_resizable"]=pop_resizable
		self.pop_stack[pop_name]["pop_directories"]=pop_directories
		self.pop_stack[pop_name]["pop_toolbar"]=pop_toolbar
		self.pop_stack[pop_name]["pop_scrollbars"]=pop_scrollbars
	}
}

