var done = false;
var test;
var host = 'http://www.geronimo-lg.com'

Event.observe(window, 'load', 
	function(){
		
		var mFullH = $('leftPart').getHeight();
		$$('ul.collectionList').each(
			function(el){
				if(el.lang == 'arch'){
					el.hide();
					done = true;
				}
			}
		);
		
		Event.observe($('click'), 'click', 
			function(){
				$('leftPart').style.overflow = 'hidden';
				$$('ul.collectionList').each(
					function(el){
						if(el.lang == 'arch'){
							test = el.toggle();
						}
					}
				);
				//alert($('click').firstChild.src.indexOf('open'));
					if($('click').firstChild.src.indexOf('open') > 0){
						$('click').firstChild.src = host+'/images/marrow-close.jpg';
					}else{
						$('click').firstChild.src = host+'/images/marrow-open.jpg';
					}
				//alert($('click').innerHTML);
			}
		)
		
		
		if($('linksUL')){
			$$('a.linksLink').each(
				function(e){
					Element.observe(e, 'click',
						function(){
							doFade('itemPicImg', 'out');
							setTimeout('doPicChange("'+e.lang+'", "'+e.innerHTML+'")', 200);
							setTimeout('doFade(\'itemPicImg\' ,\'in\');', 1000);
						});
				}
			);
		}
	}
);



function doPicChange(item, picNo){
	var url = host+'/ajaxpic.php?id='+item+'&pic='+picNo;
	new Ajax.Request(url, {
			method: 'get',
			onSuccess: function(transport){
				//$('itemPicLink').href = $('itemPicImg').src = host+'/files/'+transport.responseText;
				$('itemPicImg').src = host+'/files/'+transport.responseText;
			}
		}
	);
}
function doFade(id, dir){
	var isIE = false;
	
	if(navigator.appVersion.indexOf('MSIE 6') > -1) isIE = true;
	
	
	if($(id).style.opacity == '' ){
		if(isIE)	$(id).filters.alpha.opacity = 100;
		else $(id).style.opacity = 1;
	}

	if(dir == 'out'){
		if(isIE) $(id).filters.alpha.opacity = parseInt($(id).filters.alpha.opacity) - 5;
		else $(id).style.opacity = parseFloat($(id).style.opacity) - 0.05;
	}
	if(dir == 'in'){
		if(isIE) $(id).filters.alpha.opacity = parseInt($(id).filters.alpha.opacity) + 5;
		else $(id).style.opacity = parseFloat($(id).style.opacity) + 0.05;
	}
	if(isIE){
		if(($(id).filters.alpha.opacity < 1 && $(id).filters.alpha.opacity > 0)){
			setTimeout('doFade(\''+id+'\', \''+dir+'\')', 20);
		}
	}else{
		if(($(id).style.opacity < 1 && $(id).style.opacity > 0)){
			setTimeout('doFade(\''+id+'\', \''+dir+'\')', 20);
		}
	}
}

function slideMenu(item, dir){
	//dir == '' ? slideOpen(item.id) : slideClose(item.id);
	if(dir == '') slideOpen(item.id);
}

function slideOpen(id){
	elem = $(id);
	alert(elem.style.overflow);
	elem.style.height = elem.getHeight() + 5 + 'px';
	if(elem.getHeight() < 900) setTimeout('slideOpen(\''+elem.id+'\')', 20);
}