var loaded = 0;	// to avoid stupid errors of Microsoft browsers
var active=0;

function openURL(urlAdres) {
	window.location.href=urlAdres;
}

//Drop down menu by http://www.dynamicdrive.com
var isDropped = false;
var zindex=100
var ns6=document.getElementById
var ie4=document.all
var opr=navigator.userAgent.indexOf("Opera")
var IE = (document.all) ? 1 : 0;

var themenuStyle="";
var ident=0;
var obrazek=0;
var hiddenconst="hidden";

function dropit(e,whichone,obrazek,offL,offT) {
hidemenu();
clearTimeout(ident);
	curmenuID=ns6? document.getElementById(whichone).id : eval(whichone).id
	if (window.themenu&&themenu.id!=curmenuID)
		themenuStyle.visibility=hiddenconst;

	themenu=ns6? document.getElementById(whichone): eval(whichone);
	themenuStyle=(ns6)? themenu.style : themenu;

	themenuoffsetX=(ie4&&opr==-1)? document.body.scrollLeft : 0;
	themenuoffsetY=(ie4&&opr==-1)? document.body.scrollTop : 0;

var element=document.getElementById(obrazek);
var L=element.offsetLeft, T=element.offsetTop;
while(element.offsetParent){
	element=element.offsetParent;
	L+=element.offsetLeft;
	T+=element.offsetTop};
themenuStyle.left=L+offL;
themenuStyle.top=T+offT;
	
if (themenuStyle.visibility!="visible") {
	themenuStyle.visibility="visible"
	}
return false
}

function dropit2(e,whichone,obrazek,offL,offT) {
	banner=ns6? document.getElementById(whichone): eval(whichone)
	bannerStyle=(ns6||ie4)? banner.style : banner

var element=document.getElementById(obrazek);
var L=element.offsetLeft, T=element.offsetTop;
while(element.offsetParent){
	element=element.offsetParent;
	L+=element.offsetLeft;
	T+=element.offsetTop};
bannerStyle.left=L+offL;
bannerStyle.top=T+offT;
	
return false
}

function hidemenu() {
if (themenuStyle.visibility)
	themenuStyle.visibility=hiddenconst;
}
  
if (ie4||ns6) document.onmouseup=hidemenu

function validateNS() {
	if (document.newsletter.elements["form[EMAIL]"].value != "" && document.newsletter.elements["form[EMAIL]"].value.indexOf('@', 0) == -1 || document.newsletter.elements["form[EMAIL]"].value == "") {
	  alert ("B??dny adres e-mail");
     return false; 
	}
}

function loadimg(img) {		// loads a single image
	var a=new Image();
	a.src=img;
	return a;
}

var myimages= new Array();
function preload(links,path) {
	for (i=0;i<links.length;i++) {
		myimages[i]=loadimg(path + links[i]);
	}
}

var curr_menu=0;
var curr_menu_i=0;

function set_menu(imagename,i) {
if (curr_menu) {
	setImgSrc(curr_menu,curr_menu_i);
	}
setImgSrc(imagename,i+1);
curr_menu=imagename;
curr_menu_i=i;
}

function setImgSrc(imageName,i) {
	imageName.src = myimages[i].src;	
}
function setImgSrc2(imagename, imagesrc) {
document.getElementById(imagename).src=imagesrc;
}

function OpenWindow(url) {
	window.open (url,"okno_nowe","directories=no,top=10, left=320, width=600,height=390,location=no,menubar=no,resizable=no,scrollbars,status=no,toolbar=no"); 
	return "#";
}

function preload_animuj(lang) {
obrazki1 = new Array();
obrazki1[0]=loadimg("images/imgrotate/home_1_1.jpg")
obrazki1[1]=loadimg("images/imgrotate/home_1_2.jpg");
obrazki1[2]=loadimg("images/imgrotate/home_1_3.jpg");

obrazki2 = new Array();
obrazki2[0]=loadimg("images/imgrotate/home_2_1.jpg");
obrazki2[1]=loadimg("images/imgrotate/home_2_2.jpg");
if (lang == '_ru' || lang == '_pl' || lang == '_ee' || lang == '_lt') {
obrazki2[2]=loadimg("images/imgrotate/home_2_3"+lang+".jpg");
}
else if (lang == '_ka') {
obrazki2[2]=loadimg("images/imgrotate/home_2_3_ru.jpg");
}
else {
obrazki2[2]=loadimg("images/imgrotate/home_2_3.jpg");
}

obrazki3 = new Array();
obrazki3[0]=loadimg("images/imgrotate/home_3_1.jpg");
obrazki3[1]=loadimg("images/imgrotate/home_3_2.jpg");
obrazki3[2]=loadimg("images/imgrotate/home_3_3.jpg");
}
/*
function preload_animuj(lang) {
obrazki1 = new Array();
obrazki1[0]=loadimg("images/home_1_1"+lang+".jpg")
obrazki1[1]=loadimg("images/home_1_2"+lang+".jpg");
obrazki1[2]=loadimg("images/home_1_3"+lang+".jpg");

obrazki2 = new Array();
obrazki2[0]=loadimg("images/home_2_1"+lang+".jpg");
obrazki2[1]=loadimg("images/home_2_2"+lang+".jpg");
obrazki2[2]=loadimg("images/home_2_3"+lang+".jpg");

obrazki3 = new Array();
obrazki3[0]=loadimg("images/home_3_1"+lang+".jpg");
obrazki3[1]=loadimg("images/home_3_2"+lang+".jpg");
obrazki3[2]=loadimg("images/home_3_3"+lang+".jpg");
}*/

//licznik=new Array(0,0,0,0);
var iloscobrazkow=3;
var licznik=0;

var moveupvar;
function animuj() {
document.getElementById('b1').src = obrazki1[licznik].src;
document.getElementById('b2').src = obrazki2[licznik].src;
document.getElementById('b3').src = obrazki3[licznik].src;
setTimeout("animuj()",4000);
licznik=(licznik+1)%3;
}

function clk(n) {
if(document.images){
	(new Image()).src="count.php?banner_id="+n;
	}
return true;
}

function open_anim(seria,lang)
{
w=window.open('popups/anim.php?s='+seria+'&lang='+lang,'ww', 'toolbar=no,menubar=no,scrollbars=no, resizable=no,status=no,location=no,directories=no,top=10, left=510,height=450,width=380');
w.focus();
}

function switch_block2(whichone) {
thetr=ns6? document.getElementById(whichone): eval(whichone)
thetrStyle=ns6? thetr.style : thetr

if (thetrStyle.display=="none") {
	thetrStyle.display=IE?"block":"table-row"
	}
else {
	thetrStyle.display="none"
	}
return false
}

function hide_fly() {
document.getElementById('flybanner').style.display='none';
}
function banner() {
if (getCookie('banner')!=1) {
	document.write('<div style="z-index:100;position:absolute; left:500px; top:40px;" id="flybanner"><OBJECT codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="220" height="441">');
	document.write('<PARAM NAME=movie VALUE="banners/letnia_promocja.swf">');
	document.write('<PARAM NAME=quality VALUE=high>');
	document.write('<PARAM NAME=wmode VALUE=transparent>');
	document.write('<div style="display: none"></div>');
	document.write('<object type="application/x-shockwave-flash" data="banners/letnia_promocja.swf" width="220" height="441">');
	document.write('<PARAM NAME=movie VALUE="banners/letnia_promocja.swf">');
	document.write('<PARAM NAME=quality VALUE=high>');
	document.write('<PARAM NAME=wmode VALUE=transparent>');
	document.write('</object>');
	document.write('</OBJECT></div>');
	}
document.cookie='banner=1';
}
function getCookie(name) {
    var dc = document.cookie;
    var prefix = name + "=";
    var begin = dc.indexOf("; " + prefix);
    if (begin == -1) {
        begin = dc.indexOf(prefix);
        if (begin != 0) return null;
    } else {
        begin += 2;
    }
    var end = document.cookie.indexOf(";", begin);
    if (end == -1) {
        end = dc.length;
    }
    return unescape(dc.substring(begin + prefix.length, end));
}

