var imgSize;

window.onload = function(){
	$('background').style.display = 'block';
	$('scroller').style.display = 'block';
	$('scroller').style.overflow = 'hidden';
	$('loader').style.display = 'none';
	resizeBackgroundImg('load');
	$('scroller').style.overflow = 'auto';
	//startList();
	sfHover();
	var toH = document.getElementsByClassName("tohide");
	for(var i=0; i<toH.length; i++){
		toH[i].style.display = 'none';
	}
}
window.onresize = function(){
	resizeBackgroundImg('resize');
}

sfHover = function() {
	var sfEls = document.getElementById("nav").getElementsByTagName("LI");
	var flag = {};
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			$(this).addClassName("iehover");
		}
		sfEls[i].onmouseout=function() {
			$(this).removeClassName("iehover");
		}
	}
	/*var sfEls = document.getElementsByClassName("format_png", $("nav"));
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			sfEls.each(function(el){
				el.style.left = '0px';
			});
			
			var element = $(this);
			if((flag.elementOver && flag.elementOver.src != element.src)||(flag.elementOver === undefined)){
				flag.elementOver = element;
				new Effect.Move(element, {duration: 0.0, x:5, y:0, mode : 'absolute', queue : 'parallel'});
				return true;
			}
			
		}
	}*/
}

startList = function() {
	if (document.getElementById) {
		navRoot = document.getElementById("nav");
		for (i=0; i<navRoot.childNodes.length; i++) {
			node = navRoot.childNodes[i];
			if (node.nodeName=="LI") {
				node.onmouseover=function() {
					this.className+=" iehover";
				}
				node.onmouseout=function() {
				  this.className=this.className.replace(" iehover", "");
				}
			}
		}
	}
}

resizeBackgroundImg = function(action){
	var backgroundImg = $("background");
	var main = $("main");
	var body = $("body");
	var bodySize = body.getDimensions();
	if(action == 'load'){
		imgSize = backgroundImg.getDimensions();
	}
	
	/*$('loadertable').setStyle({
	  height: bodySize.height+'px',
	});*/
	
	if(bodySize.height > 550){
		main.setStyle({
		  top: ((bodySize.height-550)/2)+'px'
		});
	}else{
		main.setStyle({
		  top: '0px'
		});
	}
	
	imgSize = imgSize || {};
	imgSize.height = imgSize.height || 500;
	imgSize.width = imgSize.width || 1000;
	if(bodySize.height > imgSize.height*(bodySize.width / imgSize.width)){
		var w = imgSize.width*(bodySize.height / imgSize.height);
		backgroundImg.setStyle({
		  height: (bodySize.height)+'px',
		  width: Math.round(w)+'px'
		});
	}else{
		var h = imgSize.height*(bodySize.width / imgSize.width);
		backgroundImg.setStyle({
		  width: (bodySize.width)+'px',
		  height: Math.round(h)+'px'
		});
	}
	
	backgroundImg.setStyle({
	  bottom: '0px'
	});
}


function deplierarticle(id){
	Effect.toggle(id,'BLIND',{duration:0.3});
			
}





