var global_id;


function CById(href,id) {
	global_id=id;

	var sf=( function() {
		$(global_id).innerHTML=this.response.text;
	});

	var myRequest = new Request({method: 'get', url: href, onSuccess: sf, evalScripts: true }).send();
}

function findPosX(obj) {
		var curleft = 0;
		if (obj.offsetParent) {			
			while (obj.offsetParent) {
				curleft += obj.offsetLeft;
				obj = obj.offsetParent;
			}
		}
		else if (obj.x) curleft += obj.x;
		return curleft;
}

function findPosY(obj) {
		var curtop = 0;
		if (obj.offsetParent) {
			while (obj.offsetParent) {
				curtop += obj.offsetTop;
				obj = obj.offsetParent;
			}
		}
		else if (obj.y)	curtop += obj.y;
		return curtop;
}

function mOv(obj,id,off_x,off_y) {
	$(id).style.display='';
	
	$(id).style.left=(findPosX(obj)+off_x)+'px';
	$(id).style.top=(findPosY(obj)+off_y)+'px';
}

function mOu(id) {
	$(id).style.display='none';
}

function createOverlay(div_id) {
	var size_arr=getPageSize();
	var off=0;
	
	if (document.getElementById(div_id)) {
		var ov = document.getElementById(div_id);
		ov.style.display='';
		ov.style.visibility='visible';
		ov.style.height=(size_arr[1]-off+scrollTop())
		ov.style.filter=' alpha(opacity = 0)';
		ov.style.opacity=0;
		var myEffect = new Fx.Tween(div_id, {fps:30, duration: 700, transition: Fx.Transitions.Quad.easeOut});
		myEffect.start('opacity','0', '0.8');
		return true;
	}
	
	var body = document.getElementsByTagName('body').item(0);	
	var overlay = document.createElement("div");
	
	overlay.setAttribute('id',div_id);
	overlay.style.height=(size_arr[1]-off+scrollTop())+ 'px';
	overlay.style.width=size_arr[0]+ 'px';
	overlay.style.display = '';
	overlay.style.position='absolute';
	overlay.style.top=off + 'px';
	overlay.style.zIndex=2;
	overlay.style.backgroundColor='#bbbbbb';
	//overlay.style.opacity=0.8;
	overlay.style.filter=' alpha(opacity = 0)';
	overlay.style.opacity=0.3;
			
	body.appendChild(overlay);
	
	//new Effect.Morph(div_id, {	style:{opacity:'0.8'},duration: 0.5});
	
	var myEffect = new Fx.Tween(div_id, {fps:30, duration: 700, transition: Fx.Transitions.Quad.easeOut});
    myEffect.start('opacity','0', '0.8');
	return overlay;
}

function scrollTop() {
	return f_filterResults (
		window.pageYOffset ? window.pageYOffset : 0,
		document.documentElement ? document.documentElement.scrollTop : 0,
		document.body ? document.body.scrollTop : 0
	);
}

function f_filterResults(n_win, n_docel, n_body) {
	var n_result = n_win ? n_win : 0;
	if (n_docel && (!n_result || (n_result > n_docel)))
		n_result = n_docel;
	return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;
}

function getPageSize(){
	var x, y, pageX, pageY, winX, winY;
	
	if (window.innerHeight && window.scrollMaxY) {
		y = window.innerHeight + window.scrollMaxY;
		x = document.body.scrollWidth;
	} 
	else if (document.body.scrollHeight > document.body.offsetHeight) {
		y = document.body.scrollHeight;
		x = document.body.scrollWidth;
	} 
	else {
		y = document.body.offsetHeight;
		x = document.body.offsetWidth;
	}
	
	if (self.innerHeight) {	
		winX = self.innerWidth;
		winY = self.innerHeight;
	} 
	else if (document.documentElement && document.documentElement.clientHeight) { 
		winX = document.documentElement.clientWidth;
		winY = document.documentElement.clientHeight;
	} 
	else if (document.body) { 
		winX = document.body.clientWidth;
		winY = document.body.clientHeight;
	}	
	
	if(y < winY){
		pageY = winY;
	} 
	else { 
		pageY = y;
	}

	if(x < winX){	
		pageX = winX;
	} 
	else {
		pageX = x;
	}

	return new Array(pageX,pageY,winX,winY);
}
