// setting variables

if(!getCookie('scr_width')){
//    alert("Setting cookies");
    setCookie('scr_width', screen.width);
    setCookie('scr_height', screen.height);
}

var serwer_img="http://mycha/~gwarki/";
var serwer_php="http://mycha/~gwarki/";

function click(e) {  
    if (e.button==2) {
        alert('Copyright by Gwarki Górskie. \n Jeśli chcesz wykorzystać materiały zawarte na tej witrynie, skontaktuj się z autorami strony.')  
    }
}

doc=document;
doc.onmousedown=click
var ns4=doc.layers
var ie4=doc.all
var n6=doc.getElementById?doc.getElementsByTagName('div'):0;
var ns6=n6&&!ie4;
var agent = navigator.userAgent.toLowerCase();
var konq = (agent.indexOf('konqueror')!= -1)?1:0;

// rozmiary
var scX = screen.width;
var scY = screen.height;
var picX =  0.2 * scX;


//var pos = window.pageYOffset;
//setInterval("MoveTitle()",500);

o=[];

function setDiv(ident){ dd = doc.getElementById(ident); with(dd){ assignDiv(dd,id); } }

function assignDiv(dd,ident){ o[ident]=dd; if(ns4){dd.style=dd;}
    dd.dr=droz;
    dd.dp=dpos;
    dd.dc=ns4?dclip:Dclip;
    dd.dk=dkill;
    dd.dh=ns4?dhtml:Dhtml;
    dd.ds=ns4?dshow:Dshow;
}

function droz(x,y)  {with(this.style){width=x;height=y}}
function dpos(l,t)   {with(this.style){left=l;top=t}}
function Dclip(t,r,b,l) {this.style.clip='rect('+t+' '+r+' '+b+' '+l+')'}
function dclip(t,r,b,l) {with(this.clip){top=t;right=r;bottom=b;left=l}}
function dkill()        {this.style.visibility='hidden'}
function dhtml(dd)      {with(this.document){write(dd);close()}}
function Dhtml(dd)      {this.innerHTML=dd}
function Dshow(s,w,src,t,d){
    with(this){ style.height='';
        if(t==d) 
            code1 = '<h3>'+t+'</h3>';
        else
            code1 = '<h3>'+t+'</h3><div class=\"tiny\" style=\"font-wight:bold\">'+d+'</div>';

        if(ie4 && !konq){
            var y=window.innerHeight?innerHeight:document.body.clientHeight;
            layw = w + 120;
            style.bottom=(y-layw)+'px';
        }else{
            style.top=pageYOffset;
            layw = w + 120;
        }
        lays= s + 80;
        textpos = w + 60;
        innerHTML='<div style="cursor:hand;z-index:32;position:absolute;top:5;right:5;background-color:black"><img src="artwork/close.gif" class="bol_none" align="right" onclick="javascript:o.pd.dk()"></div>\
                   <div style="z-index:31;width:'+lays+';height:'+layw+';position:absolute;top:0;left:0"></div>\
                   <div style="z-index:30;position:absolute;top:30;left:40" align="center">\
                   <img src='+src+' width='+s+' height='+w+'></div>\
                   <div style="z-index:32;position:absolute;top:'+textpos+';width:'+lays+';left:0px;">'+code1+'</div>';
        style.height= layw + 'px';
        style.width= lays + 'px';
        style.left= 0 + 'px';
        //var vScroll = pageYOffset;
        style.visibility='visible'
    }
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////


function Show(ident) {
    if(ns4) {
        document.layers[ident].visibility = "show";
    } else if(ns6){
        document.getElementById(ident).style.visibility="visible";
    }else if(ie4) {	
        document.all[ident].style.visibility = "visible";
    }
}

function Hide(ident) {
    if(ns4) {
        document.layers[ident].visibility = "hide";
    } else if(ns6){
        document.getElementById(ident).style.visibility= "hidden";
    }else if(ie4) {
        document.all[ident].style.visibility = "hidden";
    }
}

function plotlabel(x,y,text){
    x+=5;
    y-=5;
    document.write("<div id='Div1' style='left:"+x+";top:"+y+";'>"+text+"</div>");
}


function PrImg( link, href, destination)
{
    if(destination=="php")
        document.write("<a href=" + serwer_php + href + "><img src=\"" + serwer_img +"images/" +link + "\"></a>");
    else
        document.write("<a href=" + href + "><img src=\"" + serwer_img +"images/" +link + "\"></a>");

}


function InsImg( w, h, iw, ih, filename, title, align )
{
    document.write("<a href=\"javascript:Pokaz("+w+","+h+",'"+filename+"')\"><img src=\"" + serwer_img + filename + "\" title='"+title+"' width="+iw+" height="+ih+" align="+align+"></a>");  
}

function PrScr(w,h,link,align)
{
    document.write("<img src=\"" + serwer_php +link + "\" width="+w+" height="+h+" align=\""+align+"\">");
}



function PrHref(link,href)
{
    document.write("<a href=\"" + serwer_php + link +"\" target=\"_self\">"+href+"</a>");
}


Nowe=null;
function Otworz(s,w,src,Id,Pg) {
    var link = "slide_show.php?Id="+Id+"&Pg="+Pg+"&Img="+src;

    if (Nowe) {
        if (!ns4) Nowe.close();
        else if (ns4) Nowe.closed;

        Nowe=null
    };

    Nowe=open("","","toolbar=no,menubar=no,location=no,left=0,top=0,personalbar=no,scrollbars=no,status=no,directories=no,resizable=no,left=0,top=0,height="+w+",width="+s);
    Nowe.location.href=link;
    Nowe.focus();
};

function Pokaz(s,w,src) {

    if (Nowe) {
        if (ie4) Nowe.close();
        else if (ns4) Nowe.closed;
        Nowe=null;
    };
    src = serwer_img + src;
    Nowe=open("","","toolbar=no,menubar=no,location=no,left=0,top=0,personalbar=no,scrollbars=no,status=no,directories=no,resizable=no,left=0,top=0,height="+w+",width="+s);
    Nowe.document.write("<HTML><HEAD><meta http-equiv='Content-Type' content='text/html; charset=iso-8859-2'><STYLE>BODY{BACKGROUND-REPEAT:no-repeat}</STYLE><title>Gwarki Górskie</title></HEAD><BODY BACKGROUND="+src+"></BODY></HTML>");
    Nowe.focus();
};

//function MoveTitle(){
//    vHold=0;
//    yscr = window.pageYOffset;
//    if(vHold==0 && yscr!=pos){
//        o.titleBar.dp(0,pos);
//        o.rogDol.dp(0,pos+72);
//        pos+=4;
//        if (pos<yscr) {
//            setTimeout("MoveTitle()",10)
//        }else{
//            pos=yscr;
//            o.titleBar.dp(0,pos);
//            o.rogDol.dp(0,pos+72);
//        }
//    }
//}


// Sets cookie values. Expiration date is optional
function setCookie(name, value, expire) {
    document.cookie = name + "=" + escape(value) + ((expire == null) ? "" : ("; expires=" + expire.toGMTString()));
}

function getCookie(Name) {
    var search = Name + "="
    if (document.cookie.length > 0) { // if there are any cookies
         offset = document.cookie.indexOf(search)
         if (offset != -1) { // if cookie exists
            offset += search.length
            // set index of beginning of value
            end = document.cookie.indexOf(";", offset)
            // set index of end of cookie value
            if (end == -1)
               end = document.cookie.length
            return unescape(document.cookie.substring(offset, end))
         }
    }
}

function Chmurka(T,t){
 T.title=''
 T.parentNode.lastChild.style.display=t?'block':'none'
}

function replace(t){
    document['mapa'].innerHTML = "<h1>HURRRRRAA</h1>";
}
