/*
function ustawTyp(typ) {
	if (typ > 0) {
		var search = document.getElementById('typ');
		search.innerHTML = "<option value=\"0\">- wybierz -</option>";
		search.disabled = true;
		advAJAX.post({
			url : "/index/search",
			parameters : { typ: typ },
			tag : "typ",
			onInitialization : function(obj) { if(window.opera) obj.url += "/l/1"; },
			onSuccess : function(obj) {
				search.innerHTML = obj.responseText;
				search.disabled = false;
			},
			onError : function(obj) { search.innerHTML = "Error"; }
		});
	}
}
*/

function ustawTyp(kategoria) {
	if (kategoria > 0) {
		sg_kategoria = kategoria;
		if(sg_kategoria == 1)
			document.getElementById('flash_mapa').innerHTML = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" height="180" width="180"><param name="movie" value="mapa.swf" /><param name="bgcolor" value="#577BAB"><param name="quality" value="high"><param name="menu" value="false"><param name="devicefont" value="true"><param name="wmode" value="transparent"><param name="allowscriptaccess" value="samedomain"><embed src="mapa.swf" quality="high" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" height="180" width="180" bgcolor="#577BAB" quality="high" menu="false" wmode="transparent" swliveconnect="true" allowscriptaccess="samedomain" /></object>';
		else if(sg_kategoria == 2)
			document.getElementById('flash_mapa').innerHTML = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" height="180" width="180"><param name="movie" value="mapa.swf?conf=mapa_2.xml" /><param name="bgcolor" value="#577BAB"><param name="quality" value="high"><param name="menu" value="false"><param name="devicefont" value="true"><param name="wmode" value="transparent"><param name="allowscriptaccess" value="samedomain"><embed src="mapa.swf?conf=mapa_2.xml" quality="high" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" height="180" width="180" bgcolor="#577BAB" quality="high" menu="false" wmode="transparent" swliveconnect="true" allowscriptaccess="samedomain" /></object>';
		else if(sg_kategoria == 6)
			document.getElementById('flash_mapa').innerHTML = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" height="180" width="180"><param name="movie" value="mapa.swf?conf=mapa_6.xml" /><param name="bgcolor" value="#577BAB"><param name="quality" value="high"><param name="menu" value="false"><param name="devicefont" value="true"><param name="wmode" value="transparent"><param name="allowscriptaccess" value="samedomain"><embed src="mapa.swf?conf=mapa_6.xml" quality="high" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" height="180" width="180" bgcolor="#577BAB" quality="high" menu="false" wmode="transparent" swliveconnect="true" allowscriptaccess="samedomain" /></object>';
							
		document.getElementById('search_typ').innerHTML = '<span class="label">Typ obiektu</span><select name="typ" id="typ" tabindex="2"><option value="0">-- pobieranie --</option></select>';
		document.getElementById('typ').disabled = true;
		advAJAX.post({
			url : "/index/ustawtyp/k/"+kategoria,
			onInitialization : function(obj) { if(window.opera) obj.url += "/l/1"; },
			onSuccess : function(obj) {
				document.getElementById('search_typ').innerHTML = obj.responseText;
				document.getElementById('typ').disabled = false;
			},
			onError : function(obj) { document.getElementById('search_typ').innerHTML = "Error"; }
		});
	}
}

function show(elem,opac) {
	new Fx.Style(elem, 'opacity').set(0);
	elem.style.display = 'block';
	var myFx = new Fx.Style(elem, 'opacity', {duration:500, transition: Fx.Transitions.quartOut})._start(0,opac);
	return myFx;	
}

var main_select = -1;

function pokaz_obiekt(ob) {
	if(main_select != ob) {
		var x = 0;
		var xx = 0;
		while(document.getElementById('oferta_'+x)) {
			if(x != ob) {
				document.getElementById('oferta_'+x).style.marginLeft = "-2000px";
				document.getElementById('obiekt_'+x).style.border='2px solid #267AC2';	
			} else {
				document.getElementById('oferta_'+x).style.marginLeft = "0px";
				document.getElementById('obiekt_'+x).style.border='2px solid #61B05D';
			}
			x++;
		}
/*
		var es = new Array(x)
		for(xx;xx<x;xx++)
			es[xx] = document.getElementById('oferta_'+xx);

		es.each(function(e,i) {
			if(ob != i) {
				e.style.display = 'none';
				document.getElementById('obiekt_'+i).style.border='2px solid #267AC2';
			} else {
				show(e,1);
				document.getElementById('obiekt_'+i).style.border='2px solid #61B05D';
			}
		});
*/
		main_select = ob;
	}
}

function print_r(theObj){
  if(theObj.constructor == Array ||
     theObj.constructor == Object){
    document.write("<ul>")
    for(var p in theObj){
      if(theObj[p].constructor == Array||
         theObj[p].constructor == Object){
document.write("<li>["+p+"] => "+typeof(theObj)+"</li>");
        document.write("<ul>")
        print_r(theObj[p]);
        document.write("</ul>")
      } else {
document.write("<li>["+p+"] => "+theObj[p]+"</li>");
      }
    }
    document.write("</ul>")
  }
}

// What is $(document).ready ? See: http://flowplayer.org/tools/documentation/basics.html#document_ready
$(document).ready(function() {

	// main vertical scroll
	$("#obiekty").scrollable({

		// basic settings
		vertical: true,

		// up/down keys will always control this scrollable
		keyboard: 'static',

		// assign left/right keys to the actively viewed scrollable
		onSeek: function(event, i) {
			horizontal.eq(i).data("scrollable").focus();
		}

	// main navigator (thumbnail images)
	}).navigator("#main_navi");

	// horizontal scrollables. each one is circular and has its own navigator instance
	var horizontal = $(".scrollable").scrollable({ circular: true }).navigator({navi:'ul.tabs'});

	// when page loads setup keyboard focus on the first horizontal scrollable
	horizontal.eq(0).data("scrollable").focus();
});