/**
 * Background position plugin
 * @author Alexander Farkas
 * v. 1.02
 */
(function($) {
	$.extend($.fx.step,{
	    backgroundPosition: function(fx) {
            if (fx.state === 0 && typeof fx.end == 'string') {
                var start = $.curCSS(fx.elem,'backgroundPosition');
                start = toArray(start);
                fx.start = [start[0],start[2]];
                var end = toArray(fx.end);
                fx.end = [end[0],end[2]];
                fx.unit = [end[1],end[3]];
			}
            var nowPosX = [];
            nowPosX[0] = ((fx.end[0] - fx.start[0]) * fx.pos) + fx.start[0] + fx.unit[0];
            nowPosX[1] = ((fx.end[1] - fx.start[1]) * fx.pos) + fx.start[1] + fx.unit[1];           
            fx.elem.style.backgroundPosition = nowPosX[0]+' '+nowPosX[1];
            
           function toArray(strg){
               strg = strg.replace(/left|top/g,'0px');
               strg = strg.replace(/right|bottom/g,'100%');
               strg = strg.replace(/([0-9\.]+)(\s|\)|$)/g,"$1px$2");
               var res = strg.match(/(-?[0-9\.]+)(px|\%|em|pt)\s(-?[0-9\.]+)(px|\%|em|pt)/);
               return [parseFloat(res[1],10),res[2],parseFloat(res[3],10),res[4]];
           }
        }
	});
})(jQuery);

$.fn.wait = function(time, type) {
	time = time || 1000;
	type = type || "fx";
	return this.queue(type, function() {
		var self = this;
		setTimeout(function() {
			$(self).dequeue();
		}, time);
	});
};

$(document).ready(function(){
	$('a[@rel*=lightbox]').lightBox();
	
	var services_thumbs = new Array();
	services_thumbs["services-01"] = "services_01.jpg";
	services_thumbs["services-02"] = "services_02.jpg";
	services_thumbs["services-03"] = "services_03.jpg";
	services_thumbs["services-04"] = "services_04.jpg";
	services_thumbs["services-05"] = "services_05.jpg";
	services_thumbs["services-06"] = "services_06.jpg";
	services_thumbs["services-07"] = "services_07.jpg";
	services_thumbs["services-08"] = "services_08.jpg";
	services_thumbs["services-09"] = "services_09.jpg";
	services_thumbs["services-10"] = "services_10.jpg";
	$("#block-services ul li a").mouseover( function() {
		//alert();
		var parent_li = $(this).parent();
		$(parent_li).append('<div class="thumb"><img src="http://www.stonek.sk/images/'+services_thumbs[$(this).attr("class")]+'" /></div>');
		$("div.thumb", parent_li).css("display", "none");
		$("div.thumb", parent_li).fadeIn("fast");
	});
	$("#block-services ul li a").mouseout( function() {
		var parent_li = $(this).parent();
		$("div.thumb", parent_li).remove();
	});

	if($("body").hasClass("kontakt")){
		// Create our "tiny" marker icon
		$("#map-stonek").googleMap(48.717172,21.268115, 15, { controls: ["GSmallMapControl", "GMapTypeControl"] }); //GPS: +48° 55' 51.00", +21° 54' 48.50"
		var marker_humenne = new GMarker(new GLatLng(48.716733,21.268094));
		$.googleMap.maps["map-stonek"].addOverlay(marker_humenne);
	}
});
