function onLoadFrame(idLoader){
    if ($(idLoader) != null){
            $(idLoader).style.display = "none";
    } else {
        setTimeout("onLoadFrame('loaderID')", 1000);
    }
}

function popup_ajax(link, width, height) {
    var frameID = 'popup_ajax';
    var loaderDiv = new Element('div', {
        id: 'loaderID',
        style:''
    });

    var frameDiv = new Element('div',{
        id: 'frameID',
        style: ''
    });

    var loader = new Element('img',{
		src:"/images/popup-loader.gif",
        id:"popupLoader",
        style:"position:absolute;left:50%;"
    });

    var iframe = new Element('iframe',
        {
			style:'z-index:1000;padding:0;margin:0; background:white; width:' + width + 'px;height:' + height + 10 + 'px;overflow: hidden;',
			src: link,
			id: frameID,
			name: frameID,
			border: '0',
			frameborder: '0',
			scrolling: 'no',
			marginwidth: '0',
			marginheight: '0',
            onload: onLoadFrame('loaderID')
    });

    loaderDiv.appendChild(loader);
    frameDiv.appendChild(loaderDiv);
    frameDiv.appendChild(iframe);

    Modalbox.show(frameDiv, {width: width+6, height: height});
    $('MB_header').className = "popup_header";
    $('MB_overlay').className = "popup_overlay";
    $('MB_close').className = "popup_close";
	$('MB_content').setStyle({width: width + 'px'});
	return false;
}

