var zakladka = 0;

function printPage(link)
{
	window.open(link+","+zakladka);
}

function flash(nazwa,width,height,tryb,bgcolor)
	{
	if (AC_FL_RunContent == 0) 
		{
		alert("This page requires AC_RunActiveContent.js.");
		} 
	else 
		{
		AC_FL_RunContent(
			'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0',
			'width', width,
			'height', height,
			'src', 'flash/'+nazwa,
			'quality', 'high',
			'pluginspage', 'http://www.macromedia.com/go/getflashplayer',
			'align', 'middle',
			'play', 'true',
			'loop', 'true',
			'scale', 'showall',
			'wmode', tryb,
			'bgcolor', bgcolor,
			'devicefont', 'false',
			'id', nazwa,
			'name', nazwa,
			'menu', 'false',
			'allowFullScreen', 'false',
			'allowScriptAccess','sameDomain',
			'movie', 'flash/'+nazwa,
			'salign', ''
			); //end AC code
		}
	}


function OtworzMapke(ID)
{
	window.open("http://www.balex.eu/map.php?gps="+ID+"", "myWindow", "status = 1, height = 400, width = 400, resizable = 0" );
}
function SendLink(ID)
{
	window.open("http://www.balex.eu/source/sendtofriend.php?www="+ID+"", "sendFile", "status = 1, height = 350, width = 600, resizable = 0" );
}
function Kalkulacja(ID)
{
	window.open("http://www.balex.eu/source/kalkulacja_1.php?id="+ID+"", "kalkulacja", "status = 1, height = 550, width = 800, resizable = 0" );
}

function write_mhref(user, domain, text)
{
	var at = '@';
	var mail = user + at + domain;
	document.write("<a href='mailto:" + mail + "' title='Napisz do nas'>" + ( text == undefined ? mail : text ) + "</a>");
}

function submit_newsletter()
{
	var mail = document.newsletter.newsletter_mail.value;
	document.newsletter.newsletter_mail.value = '';
	makeHttpRequest('source/newsletter.php?add=mail&mail='+mail,'newsletter');
}


//SuckerTree Horizontal Menu (Sept 14th, 06)
//By Dynamic Drive: http://www.dynamicdrive.com/style/

var menuids=["treemenu1","treemenu2"] //Enter id(s) of SuckerTree UL menus, separated by commas

function zwin(id)
{
	id.style.visibility="hidden"
}

function buildsubmenus_horizontal(){
for (var i=0; i<menuids.length; i++){
  var ultags=document.getElementById(menuids[i]).getElementsByTagName("ul")
    for (var t=0; t<ultags.length; t++){
		if (ultags[t].parentNode.parentNode.id==menuids[i]){ //if this is a first level submenu
			ultags[t].style.top=ultags[t].parentNode.offsetHeight+"px" //dynamically position first level submenus to be height of main menu item
			ultags[t].parentNode.getElementsByTagName("a")[0].className="mainfoldericon"
		}
		else{ //else if this is a sub level menu (ul)
		  ultags[t].style.left=ultags[t-1].getElementsByTagName("a")[0].offsetWidth+"px" //position menu to the right of menu item that activated it
    	ultags[t].parentNode.getElementsByTagName("a")[0].className="subfoldericon"
		}
    ultags[t].parentNode.onmouseover=function(){
    this.getElementsByTagName("ul")[0].style.visibility="visible"
    }
    ultags[t].parentNode.onmouseout=function()
    {
    	/*var czas = setTimeout(zwin(this.getElementsByTagName("ul")[0]),5000);*/
    	this.getElementsByTagName("ul")[0].style.visibility="hidden";
		/*clearTimeout(zmienna);*/
    }
    }
  }
}

if (window.addEventListener)
window.addEventListener("load", buildsubmenus_horizontal, false)
else if (window.attachEvent)
window.attachEvent("onload", buildsubmenus_horizontal)








function closePopup()
{
	closebar();
}

/***********************************************
* Floating Top Bar script- � Dynamic Drive (www.dynamicdrive.com)
* Sliding routine by Roy Whittle (http://www.javascript-fx.com/)
* This notice must stay intact for legal use.
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/

var persistclose=1 //set to 0 or 1. 1 means once the bar is manually closed, it will remain closed for browser session
var startX = ((screen.width/2)-240) //set x offset of bar in pixels
var startY = 215 //set y offset of bar in pixels
var verticalpos="fromtop" //enter "fromtop" or "frombottom"

function iecompattest(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function get_cookie(Name) {
var search = Name + "="
var returnvalue = "";
if (document.cookie.length > 0) {
offset = document.cookie.indexOf(search)
if (offset != -1) {
offset += search.length
end = document.cookie.indexOf(";", offset);
if (end == -1) end = document.cookie.length;
returnvalue=unescape(document.cookie.substring(offset, end))
}
}
return returnvalue;
}

function closebar()
{
	if(persistclose)
	{
		document.cookie="remainclosed=1";
		document.getElementById("popup").style.visibility="hidden";
		document.getElementById("popup").style.display="none";
	}
}

function staticbar(){
	barheight=document.getElementById("popup").offsetHeight
	var ns = (navigator.appName.indexOf("Netscape") != -1) || window.opera;
	var d = document;
	function ml(id){
		var el=d.getElementById(id);
		if (!persistclose || persistclose && get_cookie("remainclosed")=="")
		el.style.visibility="visible"
		if(d.layers)el.style=el;
		el.sP=function(x,y){this.style.left=x+"px";this.style.top=y+"px";};
		el.x = startX;
		if (verticalpos=="fromtop")
		el.y = startY;
		else{
		el.y = ns ? pageYOffset + innerHeight : iecompattest().scrollTop + iecompattest().clientHeight;
		el.y -= startY;
		}
		return el;
	}
	window.stayTopLeft=function(){
		if (verticalpos=="fromtop"){
		var pY = ns ? pageYOffset : iecompattest().scrollTop;
		ftlObj.y += (pY + startY - ftlObj.y)/8;
		}
		else{
		var pY = ns ? pageYOffset + innerHeight - barheight: iecompattest().scrollTop + iecompattest().clientHeight - barheight;
		ftlObj.y += (pY - startY - ftlObj.y)/8;
		}
		ftlObj.sP(ftlObj.x, ftlObj.y);
		setTimeout("stayTopLeft()", 10);
	}
	ftlObj = ml("popup");
	stayTopLeft();
}

//if(window.addEventListener) window.addEventListener("load", staticbar, false)
//else if (window.attachEvent) window.attachEvent("onload", staticbar)
//else if (document.getElementById) window.onload=staticbar