function open_gallery(pic_id) {
	w=screen.availWidth-25;
	h=screen.availHeight-25;
	var scrnx = screen.availWidth/2 - w/2;
	var scrny = screen.availHeight/2 - h/2;
	window.open("image_viewer.php?pic_id=" + pic_id,"image_viewer",'width=780,height=585,scrollbars=no,menubar=no,toolbar=no,status=no,left='+scrnx+',top='+scrny);
}

function blog_gallery(pic_id) {
	w=screen.availWidth-25;
	h=screen.availHeight-25;
	var scrnx = screen.availWidth/2 - w/2;
	var scrny = screen.availHeight/2 - h/2;
	window.open("blog_image_viewer.php?pic_id=" + pic_id,"image_viewer",'width=780,height=585,scrollbars=no,menubar=no,toolbar=no,status=no,left='+scrnx+',top='+scrny);
}

function mehr(id) {
  blah=( document.getElementById(id).style.display == 'none' ) ? 'block' : 'none';
  document.getElementById(id).style.display = blah;
}

function showpic(pic,width,height) {
    var pic=encodeURIComponent(pic);
    var w=(width/1)+50;
    var h=(height/1)+50;
	if(w>=screen.availWidth) { w=screen.availWidth-60; }
	if(h>=screen.availHeight) { h=screen.availHeight-60; }
	var links = (screen.availWidth/2) - (w/2);
	var oben = (screen.availHeight/2) - (h/2);
	
	window.open('showpic.php?pic='+pic+'&width='+width+'&height='+height,'_blank','width='+w+',height='+h+',status=no,scrollbars=yes,menubar=no,toolbar=no,left='+links+',top='+oben);
} 
 

function createRankingSwitcher() {
	var ranking, release, coming;
	
	
	if  (navigator.userAgent.toLowerCase().indexOf("opera")+1) {
		var visible = "block !important";
		var hidden = "none !important";
	} else {
		var visible = "block";
		var hidden = "none";
	}

	ranking = document.getElementById("rank");
	release = document.getElementById("released");
	coming  = document.getElementById("coming");
	
	
	document.getElementById("link_rank").onclick = function() {
		ranking.style.display = visible;
		release.style.display = hidden;
		coming.style.display = hidden;
		return false;
	}
	
	document.getElementById("link_rel").onclick = function() {
		ranking.style.display = hidden;
		release.style.display = visible;
		coming.style.display = hidden;
		return false;
	}

	document.getElementById("link_soon").onclick = function() {
		ranking.style.display = hidden;
		release.style.display = hidden;
		coming.style.display = visible;
		return false;
	}
	
	
	return true;
}

function createDisplaySwitcher(button, theElement) {
	
	var oldStatus;
	
	if  (navigator.userAgent.toLowerCase().indexOf("opera")+1) {
		var visible = "block !important";
		var hidden = "none !important";
	} else {
		var visible = "block";
		var hidden = "none";
	}

	button.onclick = function() {
		oldStatus = theElement.style.display;
		if (!oldStatus)
			oldStatus = "none";

		theElement.style.display = (oldStatus.substr(0,4) == hidden.substr(0,4)) ? visible : hidden;
	}
}	

function loaddone() {
	var checkId;

	if (document.getElementById("link_rank")) {
		createRankingSwitcher();
	}
	

	if (checkId = document.getElementById("switch_relnotes")) {
		createDisplaySwitcher(checkId, document.getElementById("release_notes"));
	}

	if (document.getElementById("filetype"))
		document.getElementById("filetype").onchange = new Function("document.getElementById(\"browsing_form\").submit();");

}
