var main = '/'
$(document).ready(function() {
	$('#print').click(function() {
		var id = $(this).attr('class').substr(1);
		if ($(this).find('img').hasClass('newsprint')) {
			var news = '&news=1';
		} else {
			var news = '';
		}
		window.open(main+'index.php?mod=drukuj&ajax=1&id='+id+news, 'win1', 'width=600,height=600,scrollbars=yes');
	});
	$('#closepopupbtn').click(function() {
		$('#popup').slideUp();
	});
	/*
	$('#slides').nivoSlider({
		effect: 'sliceDownRight',
		controlNav: true,
		slices: 35,
		animSpeed: 500,
		pauseTime: 9000,
		directionNav: false
	});
	*/
	
	if ($('#slides').length > 0)
		swfobject.embedSWF("/static/flash/anim.swf", "slides", "960", "290", "9.0.0", false, '', {
			allowscriptaccess: 'sameDomain',
			wmode: 'transparent'
		});
	
	$('.vdisappear').focus(function() {
		if (this.value == this.defaultValue)
			this.value = '';
	});
	$('.vdisappear').blur(function() {
		if (this.value == '')
			this.value = this.defaultValue;
	});
	$('#login_form input:text, #login_form input:password').focus(function() {
		if (this.value == this.defaultValue)
			this.value = '';
	});
	$('#login_form input[name="login"]').blur(function() {
		if (this.value == '') {
			if ($('#login_form input[name="pass"]').val() == $('#login_form input[name="pass"]')[0].defaultValue)
				this.value = this.defaultValue;
		}
	});
	
	$('#login_form input[name="pass"]').blur(function() {
		if (this.value == '') {
			if ($('#login_form input[name="login"]').val() == $('#login_form input[name="login"]')[0].defaultValue)
				this.value = this.defaultValue;
		}
	});
	$('.country').mouseenter(function() {
		var idnum = $(this).attr('id').substr(1);
		$('#c'+$(this).attr('id')).show();
		$(this).unbind('mouseenter');
		$('#l'+idnum).parent().addClass('active');
	});
	
	$('.country_img').mouseleave(function() {
		var idnum = $(this).attr('id').substr(2);
		$('#l'+idnum).parent().removeClass('active');
		$(this).hide();
		$('#'+$(this).attr('id').substr(1)).mouseenter(function() {
			$('#c'+$(this).attr('id')).show();
			$('#l'+idnum).parent().addClass('active');
			$(this).unbind('mouseenter');
		});
	});
	
	$('.tekst_menu #male').click(function() {
		$('.text').css('font-size', '11px');
	});
	
	$('.tekst_menu #srednie').click(function() {
		$('.text').css('font-size', '13px');
	});
	
	$('.tekst_menu #duze').click(function() {
		$('.text').css('font-size', '15px');
	});
	
	$('.country_img').parent().tooltip({
		showURL: false,
		delay: 0,
		extraClass: 'shadow',
		fixPNG: true,
		top: -20, 
    	left: -270
	});
	
	if ($('#map_').length > 0) {
		var geocoder = new google.maps.Geocoder();
	    var myOptions = {
	        zoom: 15,
	        mapTypeId: google.maps.MapTypeId.ROADMAP,
			disableDefaultUI: true,
	
	    };
		map = new google.maps.Map(document.getElementById("map_"), myOptions);
	
		
		var address = 'Warszawa, ul. Zlota 59';
		var class_ = $('#map_').attr('class');
		switch(class_) {
			case 'warsaw_':
				address = 'Warsaw, ul. Zlota 59';
				break;
			case 'prague_': 
				address = 'Prague, Na Prikope 15, Prague 1';
				break;
			case 'zurich_':
				address = 'Zurich, Dufourstrasse 107';
				break;
		}
	    geocoder.geocode({
	        'address': address
	    }, function(results, status){
	        if (status == google.maps.GeocoderStatus.OK) {
	            map.setCenter(results[0].geometry.location);
	            var marker = new google.maps.Marker({
	                map: map,
	                position: results[0].geometry.location
	            });
	        }
	        else {
	            alert("Geocode was not successful for the following reason: " + status);
	        }
	    });
	}
});
