hs.registerOverlay({
	html: '<div class="closebutton" onclick="return hs.close(this)" title="Close"></div>',	
	position: 'top right', 
	fade: 4 // fading the semi-transparent overlay looks bad in IE
});

hs.graphicsDir = 'skrypty/highslide/highslide/graphics/';
hs.wrapperClassName = 'borderless';
hs.align = 'center';
hs.fadeInOut = false;
hs.dimmingOpacity = 0.50;

window.addEvent('domready', function() {
	
	
	
	emenuA = new Array();
	current = 2;
	allfotos = 0;
	gallfotos = 0;
	zdjecia = new Array();
	zdjecia2 = new Array();
	var myTimer = '';
	
	$$('.plinks').each(function(el, i) {
		emenuA[el.id] = new Element('img', {'src': el.href});
	});
	
	var galeria = function( fotoid, linki ) {
		var fx = new Fx.Morph($( fotoid ), {duration: 300, transition: Fx.Transitions.Sine.easeOut});
		prodchange = function( img, imgbig, id, user ){
			obraz = emenuA[id];
			//tutaj przy przewijaniu nie wchodzi
			if( user )
			{
				myid = id.substr(fotoid.length, id.length);
				current = parseInt(myid) + 1;
				if( current > allfotos ) current = 1;
				myTimer = $clear(myTimer);
				startgaleria();
			}
			if( imgbig )
			{
				zz_s = '';
				jj = 0;
				ss_start = 0;
				zdjecia2.each(function(e) {
					var myString = new String( e ); 
					zz = myString.split(',');
					zz_s = zz_s + '["' +zz[1]+ '", "' +zz[2]+ '"], ';
					if( imgbig == zz[1] )
					{
						ss_start = jj;
					}
					jj = jj + 1;
				});
				zz_s = zz_s.substr(0, zz_s.length-2);
				//alert(zz_s);
				if(zz_s)
				{
					//var link = new Element('a', {'href': imgbig, 'onclick': 'Slimbox.open([' + zz_s + '], ' + ss_start + '); alert("hoho"); return false;' });
					var link = new Element('a', {'href': imgbig, 'class': 'highslide', 'onclick': 'return hs.expand(this)' });
					
					//alert(link);
				}
				else
				{
					alert("oik4");
					var link = new Element('a', {'href': imgbig, 'onclick': 'Slimbox.open(\'' + imgbig + '\'); return false;' });	
				}
			}
			
			$$('.' + linki).removeClass('active');
			$(id).addClass('active');
			fx.start({ 'opacity' : 0 }).chain(function(){
				$(fotoid).erase('html');
				if( imgbig )
				{
					link.inject( $(fotoid) );
					obraz.inject( link );
				}
				else
				{
					obraz.inject( $(fotoid) );
				}
				
				fx.start({ 'opacity' : 1 });
			});
		};
	};
	
	galeria( 'foto', 'plinks');
	
	startgaleria = function(){
		/*myTimer = $clear(myTimer);*/
		if( allfotos > 1 )
		{
			var delayed_func = function(){
				/*alert( zdjecia[current][0] );*/
				prodchange( zdjecia[current][0], zdjecia[current][1], 'foto'+current );
				
				current = current + 1;
				if( current > allfotos ) current = 1;
				startgaleria();
			};
			myTimer = delayed_func.delay(6000);					
		}
	};
	
	pushfoto = function( img, imgbig, id ){
		zdjecia[id] = new Array(img, imgbig);
	};
	
	pushallfoto = function( img, imgbig, opis, id ){
		zdjecia2[id] = new Array(img, imgbig, opis);
	};
	

	
});

function blurall() {
	var links = document.getElementsByTagName('a');
	for (var i=0;i<links.length;i++){
		links[i].onfocus = blurme;
	}
}

function blurme()
{
	this.blur();
}

//funkcja do wyswietlania popupu
var okno_pop='';
function popup(wi,he,uerel,alignx,aligny,scrol)
{
  // 20.04.2006
  // Opera 8.x nie obsluguje !okno_pop.closed
	if(okno_pop && okno_pop.closed==false) {
  	okno_pop.close()
  }
	if(wi=='100%'){wi=screen.availWidth-30}
	if(he=='100%'){he=screen.availHeight-0}
	if(alignx=='left'){xx=0}
	else if(alignx=='right'){xx=(screen.availWidth-wi)-10}
	else{xx=(screen.availWidth-wi)/2}
	if(aligny=='top'){yy=0}
	else if(aligny=='bottom'){yy=(screen.availHeight-he)}
	else{yy=(screen.availHeight-he)/2}
	okno_pop=window.open(uerel, '_blank', 'menubar=no, toolbar=no, location=no, scrollbars=no, resizable=no, status=no ,scrollbars='+scrol+',height='+he+',width='+wi+',top='+yy+',left='+xx);
}


/*
foto=new Array('pl','en');
menuA=new Array();menuB=new Array();
for(n=0;n<foto.length;n++){
	menuA[n]=new Image();
	menuA[n].src='grafika/'+foto[n]+'.gif';
	menuB[n]=new Image();
	menuB[n].src='grafika/'+foto[n]+'1.gif';
}
*/
 
/*function load(adresin) {
	var geo = new GClientGeocoder(); 
	var adres = adresin; //'Szczecin, Krzywoustego 23';  
	geo.getLatLng(adres,function(punkt)  
			{  
			    if (!punkt)  
			    {  
			        // kod z tego miejsca zostanie wykonany, jeśli adres nie został odnaleziony  
			    	null;
			    }  
			    else  
			    {  
			        // jeśli adres znaleziono, to w tym miejscu stworzymy kod, który wyświetli punkt na mapie  
			    	    // centrujemy na znalezionym punkcie (lekcja nr 1)
			    		var mapa = new GMap2(document.getElementById("map"));
			        	mapa.addControl(new GLargeMapControl());
			    	    mapa.setCenter(punkt, 15);  
			    	      
			    	    // dodajemy w tym miejscu marker (lekcja nr 2,3)  
			    	    //var ikona = new GIcon();  
			    	    //ikona.image='http://maps.google.com/mapfiles/kml/pal3/icon52.png';  
			    	    //ikona.shadow='';  
			    	    //ikona.iconSize=new GSize(32,32);  
			    	    //ikona.iconAnchor=new GPoint(16,16);  
			    	    //ikona.infoWindowAnchor=new GPoint(16,16);  
			    	     
			    	   var marker = new GMarker(punkt);  
			    	   mapa.addOverlay(marker);  
			    	     
			    	   // i otwieramy dymek z adresem (lekcja 5)  
			    	   marker.openInfoWindowHtml('<strong>Apartament</strong><br>'+adresin);  
			    }  
			});
	
}*/
