boxes = new Array();

function showBox(url,params, onclose, width, height, ident){
	if (!Object.isUndefined(ident) && $('popup_box'+ident)){
		return;
	}
	
/*	try{
		for(var i=0,box;box=boxes[i++];){
			closeBox($(box).down('div'));
			//alert(box.className);
		}
		
	}catch(e){}*/
	
	var popups = document.body.select('.popup_box');
	var uj_box = popups[0].cloneNode(true);
	if (Object.isUndefined(ident)){
		uj_id = 'popup_box'+boxes.length;
	}else{
		uj_id = 'popup_box'+ident;
	}
	boxes.push(uj_id);
	Element.setStyle(uj_box,{ width: width+'px', height: height+'px' });
	var top = (-1*height/2);
	if (height>350){
		top = top-(height-350)/2;
	}
	Element.setStyle(uj_box,{ marginLeft: (-1*width/2)+'px', marginTop: top+'px', zIndex: (400+(boxes.length*10)) });

	Element.writeAttribute(uj_box,'id',uj_id);
	//uj_box.id = uj_id;

	params += "&ajax=1";
	
	//tartalom beletoltese
	new Ajax.Request(url,{
		method: 'post',
		parameters: params,
		onFailure: function(trans){
			alert('hiba');
		},
		onSuccess: function(trans){
			uj_box.down('.popup_content').update(trans.responseText);
		}
	
	});

	
	Event.observe(uj_box.down('.popup_close'),'click',function(event){ onclose(); closeBox(this); });

	Element.up(popups[0]).appendChild(uj_box);

	//alert($(uj_box).getStyle('marginLeft'));
	
	corner_obj = new curvyCorners({
		tl: { radius: 10 },
		tr: { radius: 10 },
		bl: { radius: 10 },
		br: { radius: 10 },
		antiAlias: true
		
	},uj_box);
	
	setTimeout("corner_obj.applyCornersToAll();",10); 

	Element.show(uj_box);
	
}



/*function showBox(title,lead,but1_title,but1_func,but2_title,but2_func,onclose,width,height,ident){
	
	if (!Object.isUndefined(ident) && $('popup_box'+ident)){
		return;
	}
	var popups = document.body.select('.popup_box');
	var uj_box = popups[0].cloneNode(true);
	if (Object.isUndefined(ident)){
		uj_id = 'popup_box'+boxes.length;
	}else{
		uj_id = 'popup_box'+ident;
	}
	Element.setStyle(uj_box,{ width: width+'px', height: height+'px' });
	
	uj_box.id = uj_id;

	uj_box.down('.popup_title').update(title);
	uj_box.down('.popup_lead').update(lead);

	Event.observe(uj_box.down('.popup_close'),'click',function(event){ onclose(); closeBox(this); });

	if (but1_title.length >0){
		var but1 = new Element('input',{ type: 'button', 'class': 'button1', value: but1_title });
		Event.observe(but1,'click',but1_func);
		uj_box.down('.popup_buttons').appendChild(but1);
	}
	if (but2_title.length >0){
		var but2 = new Element('input',{ type: 'button', 'class': 'button1', value: but2_title });
		Event.observe(but2,'click',but2_func);
		uj_box.down('.popup_buttons').appendChild(but2);
	}
	//alert(uj_box.innerHTML);
	
	popups[0].up().appendChild(uj_box);
	Element.show(uj_box);
	
	corner_obj = new curvyCorners({
		tl: { radius: 10 },
		tr: { radius: 10 },
		bl: { radius: 10 },
		br: { radius: 10 },
		antiAlias: true
		
	},uj_box);
	
	corner_obj.applyCornersToAll(); 
	
}*/


function closeBox(node){
	try{
		if (node){
		var box = Element.up(node,'.popup_box');
		Element.remove(box);
	}	
	}catch(e){}
}
