var numWnds = 0;

function ShowPopUpWnd (url, width, height, scrollbar, resizeable, name) {
    if (! name) {
	 name = "fenster";
    }

    if (scrollbar == 1) {
		scrollbar = "yes";
	} else if (scrollbar == 0) {
		scrollbar = "no";
    } else if (scrollbar == 2) {
	   scrollbar = "auto";
    }
    definition = "status=no,toolbar=no,width=" + width +",height=" + height + ",scrollbars=" + scrollbar + ",resizable=" + resizeable;
    numWnds++;
    return open(url,name,definition);
}

function ShowPopUpWndEx (url, top, left, width, height, scrollbar, resizeable, name) {
    if (! name) {
	 name = "fenster";
    }

    if (scrollbar == 1) {
		scrollbar = "yes";
	} else if (scrollbar == 0) {
		scrollbar = "no";
    } else if (scrollbar == 2) {
        scrollbar = "auto";
    }
	
	definition = "";
	if (top >= 0) {
	  definition = "top=" + top + ",";
	}
	if (left >= 0) {
	  definition = definition + "left=" + left + ",";
	}
	if (width >= 0) {
	  definition = definition + "width=" + width + ",";
	}
	if (height >= 0) {
	  definition = definition + "height=" + height + ",";
	}
    definition = definition + "status=no,toolbar=no,scrollbars=" + scrollbar + ",resizable=" + resizeable;
    numWnds++;
    return open(url, name, definition);
}
//width=" + width +",height=" + height + ",

function CreatePopUp(url, width, height, scrollbar, resizeable, name)
{
	fenster = ShowPopUpWnd (url, width, height, scrollbar, resizeable, name);
	fenster.focus();
}

function DisplayScreenshot (url) 
{   	
    fenster = ShowPopUpWndEx (url, 5, 5, -1, -1, 1, 'yes', 'screenshot');
    fenster.focus();
}

function DisplayBildershow (url) 
{   	
    fenster = ShowPopUpWnd (url, 605, 630, 0, 'no', 'bildergalerie');
    fenster.focus();
}

function DisplayShopImages (url) 
{   	
    fenster = ShowPopUpWnd (url, 605, 480, 0, 'no', 'shopimages');
    fenster.focus();
}

function DisplayBildershowShots (url) 
{   	
    fenster = ShowPopUpWnd (url, 825, 610, 1, 'no', 'bildergalerie');
    fenster.focus();
}

function DisplayPopUp (url) {
    fenster = ShowPopUpWnd (url, 850, 680, 1, 'yes', 'popup');
    fenster.focus();
}

function DisplayRate (url) {
    fenster = ShowPopUpWnd (url, 440, 150, 0, 'no', 'rate');
    fenster.focus();
}

function DisplayObscure (url) {
    fenster = ShowPopUpWnd (url, 420, 620, 0, 'no', 'rate');
    fenster.focus();
}

// Funktionen für Streaming
var streamingwidth = 450;
var streamingheight = 400;

function DisplayStreaminghelp (url) {
    fenster = ShowPopUpWnd (url, 800, 500, 1, 'yes', 'streaminghelp');
    fenster.focus();
}

function DisplayStreaming (url, faktor) {
    url = url.replace('runmod.php', 'rendersite.php');
    url = url.replace('streamingpopup', 'playstream&SYSTEM=Downloads');
    url = url.replace('streamingid', 'STREAMINGID');
    
    document.location.href = url;
    return;



	if (faktor) {
		streamingwidth = streamingwidth * faktor;
		streamingheight = streamingheight * faktor;
	}
	
    fenster = ShowPopUpWnd (url, streamingwidth, streamingheight, 0, 'yes', 'streaming');
    fenster.focus();
}

function resizeWindow(faktor, videosizeorgw, videosizeorgh)
{
    var neww = streamingwidth + (faktor - 1) * videosizeorgw;
    var newh = streamingheight + (faktor - 1) * videosizeorgh;
    if (faktor < 1) {    // höher, da Text umbricht und daher mehr Platz braucht
	   newh += 40;
	   neww += 20;
    }

    window.resizeTo (neww, newh);
    var newlocation = document.location.href;
    var pos = newlocation.indexOf("&faktor=");
    if (pos > 0) {
	   newlocation = newlocation.substring(0, pos) + '&faktor=' + faktor;
    }
    else {
	   pos = newlocation.indexOf("#");
	   if (pos > 0) {
		  newlocation = newlocation.substring(0, pos) + '&faktor=' + faktor;
	   }
	   else {
		  newlocation += '&faktor=' + faktor;
	   }
    }

    document.location.replace(newlocation);
}

function DisplayShuttlePC (url) {
    fenster = ShowPopUpWnd (url, 600, 300, 0, 'no', 'shuttlepc');
    fenster.focus();
}

function DisplayVipAGB (url) {
    fenster = ShowPopUpWnd (url, 800, 600, 1, 'no', 'vipagb');
    fenster.focus();
}

function DisplayPic (url) {
    fenster = ShowPopUpWndEx (url, 5, 5, -1, -1, 1, 'yes', 'displaypic');
    fenster.focus();
}

function DisplayDownloadBill4Net (url) {
	var transID = Math.round(Math.random() * 314159265);	
	fenstername = 'downloadbill4net'+transID;
    fenster = ShowPopUpWnd (url, 800, 500, 0, 'no', fenstername);
    fenster.focus();
}

function DisplayDownloadBill4NetInfo (url) {
	var transID = Math.round(Math.random() * 314159265);	
	fenstername = 'downloadbill4net'+transID;
    fenster = ShowPopUpWnd (url, 510, 370, 0, 'no', fenstername);
    fenster.focus();
}

function DisplayGamesuche (url) {
    fenster = ShowPopUpWndEx(url, 50, 50, 550, 525, 0, 'no', 'displaygamesuche');
    fenster.focus();
}
