/**
 * @package GieldaWWW
 *
 * Proste skrypty pomocnicze do nice pages.
 * 
 * @author Kamil Sofowora
 */

	
//Wykonaj adjust_window_size_notmout 2 razy - pierwszy raz natychmiast, drugi z op�nieniem
function adjust_window_size(he_extrasize_type){
	adjust_window_size_notmout(he_extrasize_type);
	setTimeout("adjust_window_size_notmout("+he_extrasize_type+")", 50);
}

//Zmienia rozmiar okna przegl�darki dostosowuj�c je do rozmiaru contentu
function adjust_window_size_notmout(he_extrasize_type){

	//alert("adj");

	var wd1 = document.getElementById("sizecalc").offsetWidth;
	var he1 = document.getElementById("sizecalc").offsetHeight;
	
	var wd = wd1;
	var he = he1;

	var wd2 = document.getElementById("sizecalc2").offsetWidth;
	//var wd2 = 0;
	var he2 = document.getElementById("sizecalc2").offsetHeight;
	//var he2 = 0;

	var wd3 = document.getElementById("rst_menu_tab_main01").offsetWidth;
	var he3 = document.getElementById("rst_menu_tab_main01").offsetHeight;

	//alert(wd +"||"+ he +"--"+ wd2 +"||"+ he2 + "--" + wd3 +"||"+ he3);

	if (wd2 > wd) wd = wd2;
	if (he2 > he) he = he2;

	//if (wd3 > wd) wd = wd3;
	//if (he3 > he) he = he3;
	//alert(he);

	if (he_extrasize_type == 1) {he = he + Math.floor(he / 20);}
	else {he *= 2.1;}//he + Math.floor(he / 1.1); }
	wd = wd + Math.floor(wd / 5);

	//alert(wd+"||"+he);
	
	//wd = wd + parseInt(document.getElementById("sizecalc3").style.left);
	//var xy = parseInt(document.getElementById("sizecalc2").style.left) - parseInt(document.getElementById("sizecalc").style.left);
	//alert(document.getElementById("sizecalc2").offsetLeft + "||" + document.getElementById("sizecalc").offsetLeft);


	//document.getElementById("sizecalc").style.border = "1px solid mediumspringgreen";
	//document.getElementById("sizecalc2").style.border = "1px solid red";
	//alert(wd + "||" + he); 
	//alert(he);
	
	document.getElementById("rst_menu_tab_main02").style.width = parseInt(wd1) + parseInt(wd1)*0.1;
	document.getElementById("rst_menu_tab_main02").style.height = parseInt(he1);

	//alert(wd+"||"+he);
	
	if (he > 0.9 * screen.height) he = Math.floor(0.9 * screen.height);
	if (wd > 0.9 * screen.width) wd = Math.floor(0.9 * screen.width);

	//alert(wd+"||"+he);
	
	var posx = Math.floor((screen.width - wd) / 2);
	var posy = Math.floor((screen.height - he) / 2);

	try{
		//Je�eli okna r�zny URL (czyli s� to r�ne okna)
		if (window.opener.getMyURL() != getMyURL())	{} //OK, kontynuuj
		else {/*alert("dpp1");*/ return false;} //Brak okna nadrz�dnego, nie zmieniaj rozmiaru bo popsujesz okno otwarte przez u�ytkownika
	}catch(e){
		//alert("dpp2"); 
		return false;
	}
	

	window.resizeTo(wd, he);
	window.moveTo(posx, posy);
	
}

function open_in_nwindow_and_close(xurl){
	setTimeout("adv_close_window(0)", 100);
	window.open(xurl);
}
	


