
MOOdalBox.loadContentsInPlace = function(sLinkHref, sLinkTitle, sLinkRel) {		
		//if(this.step) return false;
		this.step = 1;
		
		//alert("Loading in place: "+this.href+" "+this.title+" "+this.rel);
		
		this.href = sLinkHref;
		this.title = sLinkTitle;
		this.rel = sLinkRel;
		
		// check to see if there are specified dimensions
		// if not, fall back to default values
		//var aDim = this.rel.match(/[0-9]+/g);
		//this.options.contentsWidth = (aDim && (aDim[0] > 0)) ? aDim[0] : this.options.defContentsWidth;
		//this.options.contentsHeight = (aDim && (aDim[1] > 0)) ? aDim[1] : this.options.defContentsHeight;
		
		// Marking coming animation as in place loaded
		this.bLoadInPlace = true;
						
		//this.bottom.setStyles({opacity: '0', height: '0px', display: 'none'});
		this.center.className = 'mb_loading';
		
		//this.bottom.setStyles({opacity: '0', height: this.bottom.scrollHeight+'px'});
		this.fx.contents.hide();
		
		//this.bLoadContentInline = true;
		
		// AJAX call here
		var nextEffect = this.nextEffect.bind(this);
		var ajaxFailure = this.ajaxFailure.bind(this);
		
		var ajaxOptions = {
			method: 		'get',
			update: 		this.contents, 
			evalScripts: 	this.options.evalScripts,
			evalResponse: 	this.options.evalResponse,
			onComplete: 	nextEffect, 
			onFailure: 		ajaxFailure
			};
		this.ajaxRequest = new Ajax(sLinkHref, ajaxOptions).request();
				
		//return false;
	};
	


// Adding a new function to hold the overridden nextEffect
// to make shure not to touch too much of the code
MOOdalBox.oldNextEffect = function(){ };
MOOdalBox.bLoadInPlace = false;
if (typeof(MOOdalBox.nextEffect) === 'function')
{
	MOOdalBox.oldNextEffect = MOOdalBox.nextEffect;
}
MOOdalBox.nextEffect = function()
{
	// Calling the old nextEffect function
	this.oldNextEffect();
	
	if (this.bLoadInPlace === true && this.step === 4)
	{
		// Load in place is done ...
		this.bLoadInPlace = false;
		
		// Preventing the caption to be animated ...
		this.bottom.setStyles({opacity: '1', height: this.bottom.scrollHeight+'px'});
		this.step = 5;
	}
	
	// After animation has finished we can now manipulate
	// the content links of the moodalbox to open 
	// marked links within the content box
	if (this.step === 0)
	{
		// Have to do this the old fashioned way since
		// $$('#mb_content a') doesn't act as expected
		var loInlineLinks = this.contents.getElementsByTagName('A');
		
		i = 0;
		while (loInlineLinks && loInlineLinks[i])
		{
			elem = loInlineLinks[i];
			//if (elem.rel && elem.href && elem.rel.test('^moodalbox', 'i'))
			//if (elem.rel && elem.href)
			//{
			elem.href = "javascript:MOOdalBox.loadContentsInPlace(\'"+elem.href+"\', \'"+elem.title+"\', \'"+elem.rel+"\')";
			//loInlineLinks[i].onclick = this.loadContentsInPlace(loInlineLinks[i].href+'');
			/*elem.onclick = function(){
				//MOOdalBox.loadContentsInPlace(this.href+'');
				//alert(this.href+" "+this.title+" "+this.rel);
				MOOdalBox.loadContentsInPlace(this.href+'', this.title+'', this.rel+'');
			};*/
			//}
			
			i++;
		}
		
		var loFormButtons = this.contents.getElementsByTagName('FORM');
		
		i = 0;
		while (loFormButtons && loFormButtons[i])
		{
			elem = loFormButtons[i];
			
			if (elem.action)
			{
				elem.action = "javascript:MOOdalBox.loadContentsInPlace(\'"+elem.action+"\', \'\', \'\')";
			}
			
			i++;
		}
	}
};

