$(document).ready(function() {
	
	$('div#szukajka select[name="w"]').change(function() {
		$('div#szukajka select[name="m"]').html('<option value="">- trwa ładowanie -</option>');
		$.ajax({
    		type: "POST",
    		url: '/index.php?module=ajaxrequest&ajax=1&akcja=miasto',
    		data: ({akcja: 'miasto', id: this.value}),
    		success: function(msg){
			   
			$('div#szukajka select[name="m"]').html(msg.substr(0, msg.indexOf('<script')));
    		}
    	});
	});
	
	$('div#losowe_zdjecie div#nav a').click(function () {
		var Arr = $(this).attr('class').split('_');
		$.ajax({
    		type: "POST",
    		url: '/index.php?module=ajaxrequest&ajax=1&akcja=random',
    		data: ({akcja: Arr[0], id: Arr[1]}),
    		success: function(msg){
				$('div#losowe_zdjecie').html(msg);
    		}
    	});
	});
	
	$('div#WhiteSklep a').click(function () {
		var str = '';
		
		if ($(this).attr('class')=='Prev') {
			str += '<img src="'+$('div#WhiteSklep div.GalPlay img')[$('div#WhiteSklep div.GalPlay img').length -1].src+'" alt="" />';
			for (a = 0; a < $('div#WhiteSklep div.GalPlay img').length-1; a++) {
				str = str + '<img src="'+$('div#WhiteSklep div.GalPlay img')[a].src+'" alt="" />';
			}
		} else {
			for (a = 1; a < $('div#WhiteSklep div.GalPlay img').length; a++) {
				str = str + '<img src="'+$('div#WhiteSklep div.GalPlay img')[a].src+'" alt="" />';
			}
			str += '<img src="'+$('div#WhiteSklep div.GalPlay img')[0].src+'" alt="" />';
		}
		
		$('div#WhiteSklep div.GalPlay').html(str);
	});
});

function Losuj(jak, co) {
	$.ajax({
		type: "POST",
		url: '/index.php?module=ajaxrequest&ajax=1&akcja=random',
		data: ({akcja:jak, id: co}),
		success: function(msg){
			$('div#losowe_zdjecie').html(msg);
		}
	});
}
function googleMap(x,y,s) {
	var latlng = new google.maps.LatLng(x,y);
	var myOptions = {
	  zoom: 14,
	  center: latlng,
	  mapTypeId: google.maps.MapTypeId.ROADMAP
	};
	var map = new google.maps.Map(document.getElementById("MapaHere"), myOptions);
	var marker = new google.maps.Marker({
        position: latlng, 
        map: map,
        title: s
    });
}

