function isIE6 () {
	return navigator.userAgent.indexOf("MSIE 6.")>0;
}

// Parameter defines if it must take the vertical scrollar into account.
function common_getWindowSize(csb) {
    var x,y;
    if (self.innerHeight) // all except Explorer
    {
        x = self.innerWidth;
        if (csb) x -= 20;// Account for the scrollbar
        y = self.innerHeight;
    }
    else if (document.documentElement && document.documentElement.clientHeight)
        // Explorer 6 Strict Mode
    {
        x = document.documentElement.clientWidth;
        y = document.documentElement.clientHeight;
    }
    else if (document.body) // other Explorers
    {
        x = document.body.clientWidth;
        y = document.body.clientHeight;
    }
    return [x,y];
}

var anime_opacity_op;
var anime_opacity_el;
function setOpacity(elmt,op) {
   elmt.style.filter="alpha(opacity="+Math.round(op*100)+")";
   elmt.style.opacity=op;
}

function anime_opacity() {
	setOpacity(anime_opacity_el,anime_opacity_op);
	anime_opacity_op += 0.1;
	if (anime_opacity_op<0.5) setTimeout("anime_opacity()",10);
}

function common_show_veil() {
	var ifr = document.createElement("div");
	ifr.src = location.href.replace("album.ftl","chooseFolder.ftl");
	ifr.style.position="fixed";
	if (isIE6()) {
		ifr.style.position="absolute";
	}
	ifr.style.margin="0";
	ifr.style.width="100%";
	ifr.style.height="100%";
	ifr.style.left="0";
	ifr.style.top="0";
	ifr.id = "common_popup";
	//ifr.style.opacity = 0.5;
	ifr.style.backgroundColor = "#888";
	document.body.appendChild(ifr);
	//setOpacity(ifr,0.5);
    anime_opacity_op=0;
    anime_opacity_el=ifr;
    anime_opacity();
}

function common_open_popup(url,width,height) {
	var out = common_popup_div(width,height)
	out.innerHTML = '<div class="common_popup_titlebar" align=right><a href="" onclick="common_close_popup();return false;"><img border=0 src="/album/theme/0,fr/icons/slideshow/close.png"></a></div>';
	
	var ifr = document.createElement("iframe");
	ifr.src = url;
//	ifr.style.position="fixed";
	ifr.style.margin="0px";
	ifr.style.width="100%";
	ifr.style.height="100%";
	ifr.style.borderWidth="0px";
	
	ifr.id = "common_popup_iframe"
	out.appendChild(ifr);
	return ifr;
}

function common_close_popup() {
	while (common_removeElement("common_popup"));
	while (common_removeElement("common_popup_iframe"));
}

function common_removeElement(id) {
	var el = document.getElementById(id);
	if (el) el.parentNode.removeChild(el);
	return el;
}

function common_popup_div(w,h) {
	var screen = common_getWindowSize(true);
	var x = (screen[0] - w) / 2;
	var y = (screen[1] - h) / 2;
	
	common_show_veil();
	
	var ifr = document.createElement("div");
	ifr.style.position="fixed";
	if (isIE6()) {
		ifr.style.position="absolute";
		scroll(0,0);
	}
	ifr.style.margin="0px";
	ifr.style.width=w+"px";
	ifr.style.height=h+"px";
	ifr.style.left=Math.round(x)+"px";
	ifr.style.top=Math.round(y)+"px";
	ifr.style.backgroundColor="black";
	
	ifr.id = "common_popup_iframe"
	document.body.appendChild(ifr);
	return ifr;
}

function common_alert(msg) {
	var d = common_popup_div(400,200);
	d.innerHTML = '<table width="100%" height="100%"><tr><td><center>' + msg + '<hr><button onclick="common_close_popup();return false;">OK</button></center></table>'
}



var langMenuTO = new Object();
function cancelMenuTO(id) {
	if (langMenuTO[id]) {
		clearTimeout(langMenuTO[id]);
	}
	langMenuTO[id]=null;
}
function setMenuTO(id) {
	if (!langMenuTO[id]) {
		langMenuTO[id] = setTimeout('document.getElementById("'+id+'").style.visibility="hidden"',500);
	}
}
function overLink(id) {
	cancelMenuTO(id);
	document.getElementById(id).style.visibility="visible";
}
function outLink(id) {
	setMenuTO(id);
}
function overMenu(id) {
	cancelMenuTO(id);
	document.getElementById(id).style.visibility="visible";
}
function outMenu(id) {
	setMenuTO(id);
}
