// JavaScript Document

function wpop(url,prms,titre,loc,todo)
{	
	idd='D'+Math.floor(Math.random() * 1000)+1
	var div = new Element('div')
	div.style.position='absolute'
	div.className='cadre'
	div.observe('click',function (event) {toTop(this.id)})
	div.id=idd
	document.body.appendChild(div)

	if (!prms) {var prms = new Hash({ 'winid':idd });} else {var prms = new Hash(prms) }
	prms.set('winid',idd)
		
	new Ajax.Updater(div,url,
				{	method:'get',
					parameters:prms,
					onFailure:	function(d) 
								{alert(d.responseText) },
					onComplete:	function(transport) 
								{	
									var h3=new Element('H3')
									h3.insert(getBTClose(idd))
									h3.insert(titre)
									div.insert({top:h3})
									div.style.width="auto"
									posX= ((document.viewport.getWidth()+div.getWidth())/2)
									posY= document.viewport.getScrollOffsets().top + 120
									posX= (screen.availWidth/2)-(div.getWidth()/2)
									//toTop(idd)
									div.style.left=posX+'px'
									div.style.top=posY+'px'
									div.show()
								}
				}
		 )
}


function getBTClose(id)
{
	var a=new Element('a');a.href="javascript:$('"+id+"').remove();void(0)";var img=new Element('img');
	img.src='/images/icons/cross.png';
	img.height='13';
	img.width='13';
	img.border=0;
	img.vspace=3;
	img.style.margin='0px 0px 0px 10px'
	img.align='right';
	a.insert(img);
	return a;
}

function toTop(e)
{
	//v=$(e).siblings()
	v=$$('div')
	zi=0
	v.each(function(d){if (d.style.zIndex>zi) {zi=d.style.zIndex} })
	$(e).style.zIndex=zi+2
	currentwin=e
}
function getCadre(id){tbl=getTable(3,3);tbl.rows[1].cells[1].setAttribute('id','CONTENT'+id);classes="dpcoin dphgauche,dphaut,dpcoin dphdroite,dpgauche,dpcoeur,dpdroite,dpcoin dpbgauche,dpbas,dpcoin dpbdroite".split(',');for (i=0;i<3;i++) for (j=0;j<3;j++) {tbl.rows[i].cells[j].className=classes[i+j+(2*i)]};return tbl}
function getTable(nl,nc){var tbl = new Element('table');for (r=0;r<nl;r++){var row = tbl.insertRow(r);for (c=0;c<nc;c++) {row.insertCell(c)};};tbl.cellPadding=0;tbl.cellSpacing=0;tbl.className="ombre";return tbl}
