function viewPix(pic){
	var w = parseInt(viewPix.arguments[1]);
	var h = parseInt(viewPix.arguments[2]);
	w = (w>0)?w:500;
	h = (h>0)?h:400;
	
	//neww = openCenteredWindow('viewpic/?'+pic, 'pic', w, h);
	neww=window.open('viewpic/?'+pic,'pic','status=1,top=1,left=1,toolbar=no,width='+w+',height='+h);

	neww.focus();
}

function Submenu(layer, mode) {
	var n = document.getElementById(layer);
	var style = mode ? 'block' : 'none';
	n.style.display = style;
	n.style.position = 'absolute';
	var parTop = findPos(n.parentNode);
	n.style.top = parTop[1]+16+'px';
	n.style.left = parTop[0]+2+'px';
}

function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	return [curleft,curtop];
	return curtop;
}

function placeBG() {
	var w = getWindowWidth(true);
	var contents = document.getElementById('contents');
    var contentsPos = findPos(contents);

    var elTop = contentsPos[1]+5;
    
    if (document.getElementById('titlePhoto')!=null) {
    	elTop = 300;
    } else {
    	elTop = 236;
    }
	var elLeft = w/2-45; //placing in the "middle"
	
	//placing ornament
	var bg = document.getElementById('bg');
	bg.style.display = 'block';
	bg.style.left = elLeft + 'px'; 
	bg.style.top = elTop + 'px'; 
	
	var bgHeight = bg.offsetHeight;

    //checking if the ornament is bigger than contents
    if ((contentsPos[1]+contents.scrollHeight)<(bgHeight+elTop)) {
      //contents.style.height = (bgHeight+elTop)-contentsPos[1]-40+'px';
    }
    
    var contents = document.getElementById('contents');
    var contentsContainer = document.getElementById('contentsContainer');
    var contentsContainerPos = findPos(contentsContainer);

    if ((contentsContainerPos[1]+contentsContainer.offsetHeight)>(bgHeight+elTop) && contents.offsetHeight<contentsContainer.offsetHeight) {
      //contentsContainer.style.height = bgHeight+elTop - contentsContainerPos[1] + 'px';
    }
	
}

window.onresize = function() { placeBG(); }

function loadMenu() {
	var el = document.getElementById("loading")
	if (el) el.style.display="none";
	new Effect.BlindDown($('menu'));
}

window.onload=loadMenu;
