﻿
  function GET_URL(urlVarName) {
   var urlHalves = String(document.location).split('?');
   var urlVarValue = '';
   if(urlHalves[1]){
      var urlVars = urlHalves[1].split('&');
      for(var i=0; i<=(urlVars.length); i++){
         if(urlVars[i]){
            var urlVarPair = urlVars[i].split('=');
            if (urlVarPair[0] && urlVarPair[0] == urlVarName) {
              return  urlVarValue = urlVarPair[1];
            }
         }
      }
   }
   return urlVarValue;
}


function open_year(y){
if(!o("year"+y).style.display){
o("year"+y).style.display="block";
return false;
}
if(o("year"+y).style.display=="none"){
o("year"+y).style.display="block";
return false;
}
if(o("year"+y).style.display=="block"){
o("year"+y).style.display="none";
return false;
}

}



function encode(arg){
if(encodeURIComponent)
return encodeURIComponent(arg);
return escape(arg)

}

function ajax(met,url,func,params)
  {
  //alert("METHOD="+met+"\nURL="+url+"\nCALLBACK="+func+"\nPARAMS="+params);
  var xmlHttp;
  try
    {
    // Firefox, Opera 8.0+, Safari
    xmlHttp=new XMLHttpRequest();
    }
  catch (e)
    {
    // Internet Explorer
    try
      {
      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      }
    catch (e)
      {
      try
        {
        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
      catch (e)
        {
        alert("Your browser does not support AJAX!");
        return false;
        }
      }
    }
    xmlHttp.onreadystatechange=function()
      {
      if(xmlHttp.readyState==4)
        {
	
        func(xmlHttp.responseText);
        }
      }
	if(met=="get"||met=="GET"){
	
	xmlHttp.open(met,url,true);
	xmlHttp.send(null);
    
	}
    	if(met=="post"||met=="POST"){
	//alert("METHOD="+met+"\nURL="+url+"\nCALLBACK="+func+"\nPARAMS="+params);
	xmlHttp.open(met,url,true);
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttp.setRequestHeader("Content-length", params.length);
	xmlHttp.setRequestHeader("Connection", "close");
	
	xmlHttp.send(params);
    
	}
    
	return xmlHttp;
  }



function o(a){
return document.getElementById(a)
}
function center(arg){
var t=document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop; 
var l=document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft; 
arg.style.left=((window.innerWidth||document.body.clientWidth)-arg.offsetWidth)/2+"px";
arg.style.top=(100+t)+'px'
}

function middle(arg){
var t=document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop; 
var l=document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft; 
arg.style.left=((window.innerWidth||document.body.clientWidth)-arg.offsetWidth)/2+"px";
arg.style.top=((window.innerHeight||document.body.clientHeight)-arg.offsetHeight)/2+"px";
}







function startList() {

var i;

	var navRoot = document.getElementById("menu").getElementsByTagName('li');
	for (i=0; i<navRoot.length; i++) {
		node = navRoot[i];
		
		node.onmouseover=function() {this.className+=" over";}
		node.onmouseout=function() {this.className=this.className.replace(/over/gi, "");}
		
		//addEventSimple(node,'mouseover',over);
		//addEventSimple(node,'mouseout',function() {node.className=node.className.replace(" over", "");});
	  }
 
}


function startList2() {

var i;
	if(!document.getElementById("menu2"))
	return;
	
	var navRoot = document.getElementById("menu2").getElementsByTagName('li');
	for (i=0; i<navRoot.length; i++) {
		node = navRoot[i];
		
		node.onmouseover=function() {this.className+=" over";}
		node.onmouseout=function() {this.className=this.className.replace(/over/gi, "");}
		
		//addEventSimple(node,'mouseover',over);
		//addEventSimple(node,'mouseout',function() {node.className=node.className.replace(" over", "");});
	  }
 
}

// do galerii
function disp(arg,s,h,obi,pokaz,ukryj){
 
 
 
arg=document.getElementById(arg)
	if(!arg.className){
		if(ukryj != '') obi.innerHTML=ukryj
		arg.className=s;
	}else if(arg.className==s){
		if(pokaz != '') obi.innerHTML=pokaz
		arg.className=h;
	}else{
		if(pokaz != '') obi.innerHTML=ukryj
		arg.className=s;
		}
		return false;
}

onload = function(){
//dragDrop.initElement('a1',0);
startList()
startList2();







animki['next'] = new Anim('next');
animki['next'].speed=5;
animki['next'].cur=0;
animki['next'].end=100;
animki['next'].obj=o('results').style;
animki['next'].prop='left';
animki['next'].ofWhat='%';
try{
if(initLightbox)
initLightbox();
}catch(err){}

}
	

function szukaj(obj){

	var la="";
		if(GET_URL('lang')!="")
		la='&lang='+GET_URL('lang');
	

o('searchJS').style.display='block'

o('searchJS').style.width=((window.innerWidth||document.body.clientWidth)/2) + 'px'
o('searchJS').style.height=((window.innerHeight||document.body.clientHeight)/2) + 'px'

middle(o('searchJS'))

o('results').innerHTML="...";
ajax('GET',obj.action+'?q='+encode(o('query').value)+'&js=1'+la,function(arg){o('results').innerHTML=arg;middle(o('searchJS'));},"")


return false;

}
function  close_search(){
animki['close'] = new Anim('close');
animki['close'].speed=10;
animki['close'].cur=o('searchJS').offsetTop;
animki['close'].end=-400;
animki['close'].obj=o('searchJS').style;
animki['close'].prop='top';
animki['close'].ofWhat='px';

animki['close'].onDone=function(){
o('searchJS').style.display='none'
o('results').innerHTML="";
}

animki['close'].animate();

return false;
}
	
/////////////////////////////////ANIMATOR //////
var animki=[];
function Anim(i) {
this.index=i;
this.speed = null;
this.begin = null;
this.cur=null;
this.end = null;
this.prop=null;
this.obj=null;
this.timer=null;
this.onDone=null;
this.onActive=null;
this.ofWhat="px"
this.animate = function () {
	
	

	if(Math.round(this.cur)!=this.end){
		this.cur+=(this.end-this.cur)/this.speed;
		this.cur=this.cur
		if(this.obj)
		this.obj[this.prop] =this.cur + this.ofWhat
		
		if(this.onActive)
		this.onActive(this.cur)
		this.timer=setTimeout('animki["'+this.index+'"].animate()',1);
	}else{
		if(this.obj)
		this.obj[this.prop] =this.end + this.ofWhat
		if(this.onDone)
		this.onDone();
	}

}
this.actual=function (){
var r=parseInt(this.obj[this.prop]);
return isNaN(r)?this.begin:r;
}

return this;
}
////////////////////////////////////////





function nextPage(obj){
ajax("GET",obj.href+"&js=1",function(arg){ 
						
						
						animki['next'].cur=0;
						animki['next'].end=-100;
						animki['next'].animate();
						animki['next'].onDone=function(){
											o('results').innerHTML=arg;
											animki['next'].cur=100;
											animki['next'].end=0;
											animki['next'].onDone=null;
											animki['next'].animate();
											}  
						} )


return false;
}

function previousPage(obj){


ajax("GET",obj.href+"&js=1",function(arg){
						animki['next'].cur=0;
						animki['next'].end=100;
						animki['next'].animate();
						animki['next'].onDone=function(){
											o('results').innerHTML=arg;
											animki['next'].cur=-100;
											animki['next'].end=0;
											animki['next'].onDone=null;
											animki['next'].animate()
											}  
						} )


return false;
}



