function open_popup(url, post, el)
{
    var url2 = el;
    if(el !== undefined)
        {
           url2 = el;
        }
        else
            {
                url2 = url;

            }

	open_loading();

		new Request.HTML({
			url: url2,
			 onComplete: function(a,b,c){
				close_loading();
				 var temp=new Element('div', {'id' : 'ajax-container'});
				 temp.set('html',c);
				// temp.getFirst('#popup-box').hide();
				// temp.getFirst('#screen').hide();
				 $$('#popup-content').set('html', '');
				 $$('#popup-content').grab(temp);
				// function(){ 
				// 				 open_popup(); }).delay(2);
				
				pscrollFx = new Fx.Scroll(window, {duration: 1000});
				pscrollFx.toTop();
				$$('#screen').setStyles({
				display:'block',
				opacity: 0
				});

				$$('#screen').fade(0.7);

				$$('#popup-box').setStyles({
				display:'block',
				opacity: 0
				});

//				$('popup-box').fade(1);
				
				$$('#popup-box').set('morph', {link: 'chain'}).morph({'opacity': 1, onComplete: function(){
					if (typeof runme === 'function') {	
						runme();
				}
					}});
				
				
				 }}).post(post);
	
                                 return false;
	
}

function close_popup()
{
	new Fx.Tween('popup-box', {onComplete : function(){
		$$('#popup-content').set('html','');
		}}).start('opacity', '1', '0');
	new Fx.Tween('screen', {onComplete : function(){
		// $('screen').dispose()
		}}).start('opacity', '1', '0');
}

function open_loading()
{
		
	$$('#loading-screen').setStyles({
	display:'block',
	opacity: 0
	});
	
	$$('#loading-screen').fade(0.7);
	
	$$('#loading-bar').setStyles({
	display:'block',
	opacity: 0
	});
	$('loading-bar').fade(1);
	
}

function close_loading()
{
	new Fx.Tween('loading-screen', {onComplete : function(){
	$$('#loading-screen').setStyles({
	display:'none',
	opacity: 0
	});}}).start('opacity', '1', '0');
	
	new Fx.Tween('loading-bar', {onComplete : function(){
	$$('#loading-bar').setStyles({
	display:'none',
	opacity: 0
	});}}).start('opacity', '1', '0');
}



