HP_host = 'http://laboprint.pl';
$(document).ready(function(){	
	$('input:text, textarea, button')
		.focus(function(){$(this).addClass('focus');})
		.blur(function(){$(this).removeClass('focus');
	});
	$('button').mouseover(function(){
		$(this).addClass('focus');}).mouseout(function(){$(this).removeClass('focus');
	});
	if (($('#article .portfolio-gallery a').size() < 2) && ($('#article .sOverlibDiv').size() < 1))
		$('#article .portfolio-gallery').before('<div id="portfolio-img"><img src="' + $('#article .portfolio-gallery a').attr('href') + '" /></div>').remove();
	$('#article .portfolio-gallery a').click(function(){
		$('#portfolio-img').remove();
		$(this).parent().parent().before('<div id="portfolio-img"><img src="' + this.href + '" /></div>');
		return false;
	});
});

$.fn.saveInfo = function(options){
	return this.each(function(){
		var $this = $(this);
		var startVal = $this.val();
		$this.focus(function(){
			(this.value == startVal) && $this.val('');
		})
		.blur(function(){
			this.value || $this.val(startVal);
		});
	});
};
$(function(){

	$('#mail').saveInfo();
	if ($('#laboprint_map').size() > 0) {
		var map = new GMap2(document.getElementById("laboprint_map"));
		map.addControl(new GSmallMapControl());
		map.addControl(new GMapTypeControl());
		center = new GLatLng('52.445718', '16.885386');
		marker = new GMarker(center);
		map.setCenter(center, 15);
		map.addOverlay(marker);
	}
	if ($('#g-map').size() > 0) {
		var map = new GMap2(document.getElementById("g-map"));
		map.addControl(new GSmallMapControl());
		map.addControl(new GMapTypeControl());
		var gmarkers = [];
		bounds = new GLatLngBounds();
		$('.latlang').each(function(index){
			var center = GLatLng.fromUrlValue($(this).val().slice(1, -1));
			marker = new GMarker(center);
			gmarkers.push(marker);
			GEvent.addListener(marker, "click", function() {
				that = this;
				this.openInfoWindowHtml('<h3>' + $('.entry h3:eq("' + index + '")').text() + '</h3>' + $('.entry .info:eq("' + index + '")').html());
			});
			$('.entry h3:eq("' + index + '")').wrapInner('<a href="#g-map"></a>').find('a').click(function() {
				GEvent.trigger(gmarkers[index], 'click');
			});
			bounds.extend(marker.getPoint());
			map.setCenter(center);
			map.addOverlay(marker);
		});
		map.setZoom(map.getBoundsZoomLevel(bounds));
		map.setCenter(bounds.getCenter());
	}
		swfobject.embedSWF(HP_host + '/pub/uploadflash/clients.swf','adv','234','126','8.0.0','',{HP_host: HP_host, xml_path: HP_host + '/pub/xml/clients.xml'});
});

$(document).unload(function() {
	GUnload();
});