// JavaScript Document
window.onload = initAll;

function initAll(){
	if (document.getElementById("verifier")!=null){
		document.getElementById("verifier").innerHTML = "scriptul merge";
	}
	
	initButtons();
	
	preLoadImages();
	
	if (typeof(initAll2) == "function"){
		initAll2();
	}
	
	//window.onscroll = window_on_scroll;
	//document.getElementById("celulaMeniuStangaLung").style.height = document.documentElement.clientHeight-300;
	//document.getElementById("verifier").innerHTML += "<br/>Browser height: " + screen.availHeight;
		
}

function window_on_scroll(){
	if (document.getElementById("layerSuggestions")!=null){
		scrollXY = getScrollXY();
		document.getElementById("layerSuggestions").style.top = (scrollXY[1] + 218) + "px";
	}
	if (document.getElementById("adsenseLayerA")!=null){
		scrollXY = getScrollXY();
		document.getElementById("adsenseLayerA").style.top = (scrollXY[1] + 318) + "px";
	}
	
	function getScrollXY() {
	  var scrOfX = 0, scrOfY = 0;
	  if( typeof( window.pageYOffset ) == 'number' ) {
		//Netscape compliant
		scrOfY = window.pageYOffset;
		scrOfX = window.pageXOffset;
	  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
		//DOM compliant
		scrOfY = document.body.scrollTop;
		scrOfX = document.body.scrollLeft;
	  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
		//IE6 standards compliant mode
		scrOfY = document.documentElement.scrollTop;
		scrOfX = document.documentElement.scrollLeft;
	  }
	  return [ scrOfX, scrOfY ];
	}
}

function initButtons(){
	var butoane = Array("celMeniuSus1","celMeniuSus2","celMeniuSus3","celMeniuSus4","celMeniuSus5","celMeniuSus6","celMeniuSus7","celMeniuSus8","celMeniuStanga1","celMeniuStanga5");
	var butoaneStanga = Array("celMeniuStanga2","celMeniuStanga3","celMeniuStanga4","celMeniuStanga6","celMeniuStanga7","celMeniuStanga8","celMeniuStanga9","celMeniuStanga10");
	
	var ptClick = Array("celMeniuSus1","index.php");
	
	for (var i=0;i<butoane.length;i++){
		if (document.getElementById(butoane[i])!=null){
			document.getElementById(butoane[i]).onmouseover = meniuSusMouseOver;
			document.getElementById(butoane[i]).onmouseout = meniuSusMouseOut;
		}
	}
	
	for (var i=0;i<butoaneStanga.length;i++){
		if (document.getElementById(butoaneStanga[i])!=null){
			document.getElementById(butoaneStanga[i]).onmouseover = meniuStangaMouseOver;
			document.getElementById(butoaneStanga[i]).onmouseout = meniuStangaMouseOut;
		}
	}
	
	/*for (var i=0;i<ptClick.length;i=i+2){
		document.getElementById(ptClick[i]).onclick = clickPe(ptClick[i+1]);
	}*/
	
	
	

	function meniuSusMouseOver(){
		this.style.backgroundImage = "url(images/baraMeniuSusPe.gif)";
		document.getElementById("verifier").innerHTML = "mouse pe";
	}
	
	function meniuSusMouseOut(){
		this.style.backgroundImage = "url(images/baraMeniuSus.gif)";
		document.getElementById("verifier").innerHTML = "mouse out";
	}
	
	function meniuStangaMouseOver(){
		this.style.backgroundColor = "#ffcc99";
		document.getElementById("verifier").innerHTML = "mouse pe";
	}
	
	function meniuStangaMouseOut(){
		this.style.backgroundColor = "#ff6600";
		document.getElementById("verifier").innerHTML = "mouse out";
	}
	
	function clickPe(urlTemp){
		window.location = (urlTemp);
	}
}

function preLoadImages(){
	var imaginiDeIncarcat = new Array("images/baraMeniuSusPe.gif");
	
	preload_image = new Image(25,25); 
	for (var i=0;i<imaginiDeIncarcat.length;i++){	
		preload_image.src=imaginiDeIncarcat[i];
	}
}
