

function getAjaxmodal(url){
	var arrPos = Position.CenterOffset($('modal_container'),500);
	m = new Control.Modal(false,{ 
		width: 500,
		position: 'relative',
		offsetTop: 150,
		offsetLeft: arrPos[1],			
		contents: function(){  
			new Ajax.Request(url,{  
				onComplete: function(request){  
					//this.update(request.responseText);  
					$('modal_container').update(request.responseText); 
				}.bind(this)  
			});  
			return 'Loading<br /><img src="../images/smallloader.gif" />';  
		}  
	}); 
	return m;
}

Position.CenterOffset = function(element,inwidth,inheight,parent) {
		var w, h, pw, ph;
		var retArr = new Array();
		if(element==null){
			if (!inwidth) {
				w = 100;
			}
			else{
				w = inwidth;
			}
			if (!inheight) {
				h = 100;
			}
			else{
				h = inheight;	
			}
		}
		else{
			var d = Element.getDimensions(element);
			if (!inwidth) {
				w = d.width;
			}
			else{
				w = inwidth;
			}
			if (!inheight) {
				h = d.height;
			}
			else{
				h = inheight;	
			}
		}
		Position.prepare();
		if (!parent) {
				var ws = Position.GetWindowSize();
				pw = ws[0];
				ph = ws[1];
		} else {
				pw = parent.offsetWidth;
				ph = parent.offsetHeight;
		}
		retArr[0]=(ph/2) - (h/2) -  Position.deltaY
		retArr[1]=(pw/2) - (w/2) -  Position.deltaX;
		return retArr;
}		
Position.Center = function(element, parent) {
		var w, h, pw, ph;
		var d = Element.getDimensions(element);
		w = d.width;
		h = d.height;
		Position.prepare();
		if (!parent) {
				var ws = Position.GetWindowSize();
				pw = ws[0];
				ph = ws[1];
		} else {
				pw = parent.offsetWidth;
				ph = parent.offsetHeight;
		}
		element.style.top = (ph/2) - (h/2) -  Position.deltaY + "px";
		element.style.left = (pw/2) - (w/2) -  Position.deltaX + "px";
}
Position.GetWindowSize = function(w) {
		w = w ? w : window;
		var width = w.innerWidth || (w.document.documentElement.clientWidth || w.document.body.clientWidth);
		var height = w.innerHeight || (w.document.documentElement.clientHeight || w.document.body.clientHeight);
		return [width, height]
}
function closeModal(){
	Control.Modal.close();			
}