var slideshowSpeed = 4000;

var photos = [ {
		
		"image" : "/images/log_1.jpg"
		
	}, {
		"image" : "/images/log_2.jpg"
	}, {
		"image" : "/images/log_3.jpg"
	}, {
		"image" : "/images/log_4.jpg"
	}, {
		"image" : "/images/log_5.jpg"
	}
];

var interval;

 $(document).ready(function() {



	//create scroller for each element with "horizontal_scroller" class...

	$('.horizontal_scroller').SetScroller({	velocity: 	 60,

											direction: 	 'horizontal',

											startfrom: 	 'right',

											loop:		 'infinite',

											movetype: 	 'linear',

											onmouseover: 'pause',

											onmouseout:  'play',

											onstartup: 	 'play',

											cursor: 	 'pointer'

										});
});
function show_fullscreen(co,obj)
{
	if(obj=='off')
	{
		document.getElementById(co).style.display='none';
	}
	else
	{
		document.getElementById(co).style.display='block';
	}
}

function pobierz(url,target,jezyk,city)
{
document.getElementById('load_ajax').style.display='block';

if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }

var jezyk_ok="";
var city_ok="";
if(jezyk!='')
{
	jezyk_ok="jezyk="+jezyk;	
}  

if(city!='')
{
	city_ok="&city="+city;	
}  
  
xmlhttp.open("GET","ajax_src/"+url+".php?"+jezyk_ok+city_ok,false);
xmlhttp.send(null);
document.getElementById(target).innerHTML=xmlhttp.responseText;
document.helper_position.page.value=url;
document.helper_position.miasto.value=city;
document.page_helper.active.value=url;
document.helper_position.id.value=jezyk;
//alert(document.helper_position.page.value+" -> "+document.helper_position.id.value);
document.getElementById('load_ajax').style.display='none';
}


$(document).ready(function() {
		
	
	
	
	
	
	
	var activeContainer = 1;	
	var currentImg = 0;
	var animating = false;
	var navigate = function(direction) {
		// Check if no animation is running. If it is, prevent the action
		if(animating) {
			return;
		}
		
		// Check which current image we need to show
		if(direction == "next") {
			currentImg++;
			if(currentImg == photos.length + 1) {
				currentImg = 1;
			}
		} else {
			currentImg--;
			if(currentImg == 0) {
				currentImg = photos.length;
			}
		}
		
		// Check which container we need to use
		var currentContainer = activeContainer;
		if(activeContainer == 1) {
			activeContainer = 2;
		} else {
			activeContainer = 1;
		}
		
		showImage(photos[currentImg - 1], currentContainer, activeContainer);
		
	};
	
	var currentZindex = -1;
	var showImage = function(photoObject, currentContainer, activeContainer) {
		animating = true;
		
		// Make sure the new container is always on the background
		currentZindex--;
		
		// Set the background image of the new active container
		$("#logo" + activeContainer).css({
			"background-image" : "url(" + photoObject.image + ")",
			"display":"block",
			"z-index" : currentZindex
		});
		
	
		$("#logo" + currentContainer).fadeOut(function() {
			setTimeout(function() {
				
				animating = false;
			}, 500);
		});
	};
	
	
	
	
	navigate("next");
	
	// Start playing the animation
	interval = setInterval(function() {
		navigate("next");
	}, slideshowSpeed);
	
});

function change_city_js(obj)
{
	document.miasto_helper.miasto_change.value=obj;
	document.miasto_helper.last_page.value=document.page_helper.active.value;
	document.miasto_helper.submit();
	}



function zm_city()
{
	$("#overlay").animate({ height: 'show', opacity: 'show' }, 'slow');
}

function zm_city_off()
{
	$("#overlay").animate({ height: 'hide', opacity: 'hide' }, 'slow');
}


$(function() {

    var marquee = $("#marquee"); 
    marquee.css({"overflow": "hidden", "width": "73%"});

    // wrap "My Text" with a span (IE doesn't like divs inline-block)
    marquee.wrapInner("<span>");
    marquee.find("span").css({ "width": "50%", "display": "inline-block", "text-align":"center" }); 
    marquee.append(marquee.find("span").clone()); // now there are two spans with "My Text"

    marquee.wrapInner("<div>");
    marquee.find("div").css("width", "200%");

    var reset = function() {
        $(this).css("margin-left", "0%");
        $(this).animate({ "margin-left": "-100%" }, 15000, 'linear', reset);
    };

    reset.call(marquee.find("div"));

});



function show(target)
{
	if(document.getElementById(target).style.display=='none')
	{
		document.getElementById(target).style.display='block';
	}
	else
	{
		document.getElementById(target).style.display='none';
	}
}
