//<![CDATA[

function get_in(t) {
	//$('content').style.display = 'none';
	t = t.replace(/src=\"/gi, 'src="'+_path + '/');
	$('content').innerHTML = t;

	if ($('content').style.display == 'none') {
		//$('content').style.display = 'block';
		Effect.Appear('content',{duration:0.5});
		//Effect.MoveBy('content',moved,0, {duration:0.5, transition:function(pos) { return Math.cos(1-pos); }});
		
		//if($('content').style.top >= ($('right').getHeight() + 'px')) {
		//Effect.MoveBy('content',moved,0, {queue:'end',duration:2.9});
		
		//$('content').style.top = '-' + 400 + 'px';
		//$('content').style.display = 'none';
		//alert($('content').style.top);alert(new_height + 'px')
		display_ex('link', 0, 'img');	
	}		
}


function display_ex(id, idx, src) {
	j = 0;
	while ($(id + j)) {
		if($(id+j).className == 'link_sel') {
			$(id+j).className = 'linkone';
			$(src+j).style.display = 'none';
		}
		j++;
	}
	$(id+idx).className = 'link_sel';
	$(src+idx).style.display = 'block';
}

function contentUpdate() {
	ajaxUpdater(this);
	return false;
}

function manualUpdate(_inurl) {

	var a = $('mycustomscroll').getElementsByTagName('a');
	var j = 0;
	while (j < a.length) {
		if (a[j]._url != _inurl)
			j++;
		else 
			break;
	}
	ajaxUpdater(a[j]);
}

function ajaxUpdater(el) {  
	var a = $('mycustomscroll').getElementsByTagName('a');
	var j =0;
	while (j < a.length) {
			a[j].className = '';
		j++;
	}
	el.className = 'menu_sel';
	Effect.Fade(
		'content', 
		{
			duration: 0.5, 
			afterFinish:function(o) { 
				new Ajax.Request(
					el._url, {
					asynchronous:true,
					onComplete: function(r) {
						get_in(r.responseText);
						//$('loader').hide();
						}
					}
				);
			}
		}
	);
} 

function mainMenu() {
	var a = $('mycustomscroll').getElementsByTagName('a');
	var j = 0;
	var p = '';
	while (j < a.length) {
		a[j]._url = (a[j].href.charAt(a[j].href.length-1) == '/' ? a[j].href.slice(0, a[j].href.length-1) + '.html' : a[j].href + '.html');
		a[j].onclick = contentUpdate;
		j++;
	}
}

function init(mu) {
	res();
	mainMenu();
	$('right').style.visibility = 'hidden';
	if (mu != '') manualUpdate(mu);
	$('right').style.visibility = 'visible';
}

function res() {
	var page = {
		width: document.body.clientWidth, 
		height: document.body.clientHeight
	};
	////////////////////////////////////// set dimension ////////////////////////////////////////////
	var left_width = page.width / 2 + 175 - 18;
	
	$('left').style.width = left_width + 'px';
	$('left').style.height = page.height + 'px';
	
	$('right').style.width = (page.width / 2 - 175) + 'px';
	$('right').style.height = page.height + 'px';
	////////////////////////////////////// set scroll //////////////////////////////////////////////
	$('mycustomscroll').style.height = page.height - 110 + 'px';
	$('mycustomscroll').style.zIndex = 20;

	left_width = left_width - 620 - 25;
	$('content').style.left = left_width + 'px';
}

//]]>