//browser-check
var opera=(navigator.userAgent.indexOf('Opera') != -1) ? true:false;
var operaVer=0;
if (navigator.userAgent.indexOf('Opera ') != -1)
{
	operaSplit=navigator.userAgent.split('Opera ');
	operaVer=parseInt(operaSplit[1]);
}
else if (navigator.userAgent.indexOf('Opera/') != -1)
{
	operaSplit=navigator.userAgent.split('Opera/');
	operaVer=parseInt(operaSplit[1]);
}
var opera7=(opera && operaVer < 8) ? true:false;

var ie5mac=(navigator.platform.indexOf('Mac') != -1 && navigator.userAgent.indexOf('MSIE') != -1) ? true:false;
var dom=(document.getElementById && !opera7) ? true:false;


//linie um links ausblenden
function lw(ob) {
	if (ob.blur) ob.blur();
}

//popups
function screens_pop(id,skip) {
	breite = opera7?830:814;
  window.open('/gamespace/screenshots/screenpop/?id='+id+'&skip='+skip,'Screenshots','width='+breite+',height=626,scrollbars=no');
}

/* ersetzt durch bild_pop
function pic_pop(pic,width,height,text) {
	if(text)
		height = parseInt(height) + 22;
		
	var picpopup = window.open('/picpopup/?pic='+pic+'&text='+text,'PicPop','width='+width+',height='+height+',scrollbars=no');
}
*/

function im_pop(im,user_id) {
	var im_popup = window.open('/community/profil/im_pop/?im='+im+'&user_id='+user_id,'ImPop','width=423,height=320');
}

function gamesearch_pop(formname_profil) {
	var gamesearch_popup = window.open('/community/profil/gamesuche.php?formname_profil='+formname_profil,'GamesearchPop','width=430,height=320,scrollbars=yes');
}

function send_article(url,id) {
	var article_send_popup = window.open('/artikel/send/?url='+url+'&id='+id,'ArticleSendPop','width=423,height=430');
}

function com_karte_pop(showmap,infovar) {
	var com_karte_popup = window.open('/community/karte/karte.php?showmap='+showmap+'&infovar='+infovar,'comKartePop','width=430,height=495');
}

//bilder-popup
// Positioning Differences Between Browsers
var vertShift=100; // Default for IE/Win and Gecko
if (opera7) vertShift=200; // For Opera 7

function bild_pop(imageURL, imageTarget, text)
{
	// In case there is no target specified.
	imageTarget=(imageTarget) ? imageTarget:"_blank";

	if ((dom) && !ie5mac)
	{ 
		var imgWin = window.open('about:blank', imageTarget ,'width=200, height=200, left=0, top=0');
		
		with (imgWin.document) 
		{ 
			writeln('<html><head><title>Loading...</title>'); 
			writeln('<link rel="stylesheet" type="text/css" href="/css/styles.css" media="all" />'); 
			writeln('<style type="text/css"><!-- body { margin:0px; padding:0px; background-image: none; background-color: #DDF1F8; text-align: center; } --></style></head>'); 
			writeln('<body onload="self.focus();"><a href="javascript:self.close();"><img id="pic" style="display:none; border: 0px; margin: 0px auto;" title="klicken zum schließen" /></a>'); 
			if(text) writeln('<div class="text_11px col_1" style="margin: 0px auto; padding-top: 3px;">'+text+'</div>'); 
			writeln('</body></html>'); 
			close();		 
		} 

		var img = new Image(); 
		img.onload = function() { sizeImgWin2(imgWin, img, text); }; 
		
		img.src = imageURL; 
	} 

	else window.open(imageURL, imageTarget);
} 
	 
function sizeImgWin2(win, img , text) 
{ 
	var new_w = img.width; 
	var new_h = text?img.height+22:img.height; 
	var old_w = win.innerWidth || win.document.body.offsetWidth; 
	var old_h = win.innerHeight || win.document.body.offsetHeight; 

	
	if (!new_w) { new_w = old_w; } 
	if (!new_h) { new_h = old_h; } 

	new_w -= old_w; new_h -= old_h; 
	win.resizeBy(new_w,new_h); 
	//win.document.title = img.src.substring(img.src.lastIndexOf("/")+1); 
	win.document.title = 'Gamesmania'; 
	var pic = win.document.getElementById('pic'); 
	pic.src = img.src; 
	pic.style.display = 'block'; 

	sw=screen.width; 
	sh=screen.height; 

	var leftPos=((sw-new_w)/2)-100; // Exactly centered. 
	var topPos=((sh-new_h)/2)-(vertShift+(((sh-new_h)/2))*0.1); 
	win.moveTo(leftPos, topPos); 
} 


//remote-window
function remote() {	
	newwin = false;
	
	newfocus='';
	newtarget='';
	url=remote.arguments[0];
	
	if(remote.arguments.length>1)
		newtarget=remote.arguments[1];

	if(remote.arguments.length==3)
		newfocus=remote.arguments[2];
	
	if(newtarget=='_blank')
		window.open(url,'gmWin','');
	
	if(newtarget!='_blank') {
		if(top.opener==null || top.opener.closed==true){
			if(window.gmWin==null||window.gmWin.closed) {
				newwin = true;
			}else{
		  	gmWin.location.href=url;
				if(newfocus!="self")
					gmWin.focus();
			}
		}else{
    	if(top.opener.top.opener==null) {
				top.opener.top.location=url;
      		if(newfocus!="self")
					top.opener.top.focus();
			} else {
				newwin = true;
			}
		}
	}
	
	if(newfocus=="self")
		self.focus();
	
	if(newwin) {
		gmWin = window.open(url,'gmWin','');
		gmWin.moveTo(0,0);
		if (document.all) {
			gmWin.resizeTo(screen.availWidth,screen.availHeight);
		} else if (document.layers||document.getElementById) {
			if (gmWin.outerHeight<screen.availHeight||gmWin.outerWidth<screen.availWidth){
				gmWin.window.outerHeight = screen.availHeight;
				gmWin.window.outerWidth = screen.availWidth;
			}
		}
	}
}


//hilfe-div
function tooltip(elem) {
	if(document.getElementById(elem).style.display!="block") document.getElementById(elem).style.display = 'block';
	else document.getElementById(elem).style.display = 'none';
}