function getOriginalWidthOfImg(img_element) {
    var t = new Image();
    t.src = (img_element.getAttribute ? img_element.getAttribute("src") : false) || img_element.src;
    return t.width;
}
function getOriginalHeightOfImg(img_element) {
    var t = new Image();
    t.src = (img_element.getAttribute ? img_element.getAttribute("src") : false) || img_element.src;
    return t.height;
}

// jQuery SWFObject v1.1.1 MIT/GPL @jon_neal
// http://jquery.thewikies.com/swfobject

(function($, flash, Plugin) {
	var OBJECT = 'object',
		ENCODE = true;

	function _compareArrayIntegers(a, b) {
		var x = (a[0] || 0) - (b[0] || 0);

		return x > 0 || (
			!x &&
			a.length > 0 &&
			_compareArrayIntegers(a.slice(1), b.slice(1))
		);
	}

	function _objectToArguments(obj) {
		if (typeof obj != OBJECT) {
			return obj;
		}

		var arr = [],
			str = '';

		for (var i in obj) {
			if (typeof obj[i] == OBJECT) {
				str = _objectToArguments(obj[i]);
			}
			else {
				str = [i, (ENCODE) ? encodeURI(obj[i]) : obj[i]].join('=');
			}

			arr.push(str);
		}

		return arr.join('&');
	}

	function _objectFromObject(obj) {
		var arr = [];

		for (var i in obj) {
			if (obj[i]) {
				arr.push([i, '="', obj[i], '"'].join(''));
			}
		}

		return arr.join(' ');
	}

	function _paramsFromObject(obj) {
		var arr = [];

		for (var i in obj) {
			arr.push([
				'<param name="', i,
				'" value="', _objectToArguments(obj[i]), '" />'
			].join(''));
		}

		return arr.join('');
	}

	try {
		var flashVersion = Plugin.description || (function () {
			return (
				new Plugin('ShockwaveFlash.ShockwaveFlash')
			).GetVariable('$version');
		}())
	}
	catch (e) {
		flashVersion = 'Unavailable';
	}

	var flashVersionMatchVersionNumbers = flashVersion.match(/\d+/g) || [0];

	$[flash] = {
		available: flashVersionMatchVersionNumbers[0] > 0,

		activeX: Plugin && !Plugin.name,

		version: {
			original: flashVersion,
			array: flashVersionMatchVersionNumbers,
			string: flashVersionMatchVersionNumbers.join('.'),
			major: parseInt(flashVersionMatchVersionNumbers[0], 10) || 0,
			minor: parseInt(flashVersionMatchVersionNumbers[1], 10) || 0,
			release: parseInt(flashVersionMatchVersionNumbers[2], 10) || 0
		},

		hasVersion: function (version) {
			var versionArray = (/string|number/.test(typeof version))
				? version.toString().split('.')
				: (/object/.test(typeof version))
					? [version.major, version.minor]
					: version || [0, 0];

			return _compareArrayIntegers(
				flashVersionMatchVersionNumbers,
				versionArray
			);
		},

		encodeParams: true,

		expressInstall: 'expressInstall.swf',
		expressInstallIsActive: false,

		create: function (obj) {
			var instance = this;

			if (
				!obj.swf ||
				instance.expressInstallIsActive ||
				(!instance.available && !obj.hasVersionFail)
			) {
				return false;
			}

			if (!instance.hasVersion(obj.hasVersion || 1)) {
				instance.expressInstallIsActive = true;

				if (typeof obj.hasVersionFail == 'function') {
					if (!obj.hasVersionFail.apply(obj)) {
						return false;
					}
				}

				obj = {
					swf: obj.expressInstall || instance.expressInstall,
					height: 137,
					width: 214,
					flashvars: {
						MMredirectURL: location.href,
						MMplayerType: (instance.activeX)
							? 'ActiveX' : 'PlugIn',
						MMdoctitle: document.title.slice(0, 47) +
							' - Flash Player Installation'
					}
				};
			}

			attrs = {
				data: obj.swf,
				type: 'application/x-shockwave-flash',
				id: obj.id || 'flash_' + Math.floor(Math.random() * 999999999),
				width: obj.width || 320,
				height: obj.height || 180,
				style: obj.style || ''
			};

			ENCODE = typeof obj.useEncode !== 'undefined' ? obj.useEncode : instance.encodeParams;

			obj.movie = obj.swf;
			obj.wmode = obj.wmode || 'opaque';

			delete obj.fallback;
			delete obj.hasVersion;
			delete obj.hasVersionFail;
			delete obj.height;
			delete obj.id;
			delete obj.swf;
			delete obj.useEncode;
			delete obj.width;

			var flashContainer = document.createElement('div');

			flashContainer.innerHTML = [
				'<object ', _objectFromObject(attrs), '>',
				_paramsFromObject(obj),
				'</object>'
			].join('');

			return flashContainer.firstChild;
		}
	};

	$.fn[flash] = function (options) {
		var $this = this.find(OBJECT).andSelf().filter(OBJECT);

		if (/string|object/.test(typeof options)) {
			this.each(
				function () {
					var $this = $(this),
						flashObject;

					options = (typeof options == OBJECT) ? options : {
						swf: options
					};

					options.fallback = this;

					flashObject = $[flash].create(options);

					if (flashObject) {
						$this.children().remove();

						$this.html(flashObject);
					}
				}
			);
		}

		if (typeof options == 'function') {
			$this.each(
				function () {
					var instance = this,
					jsInteractionTimeoutMs = 'jsInteractionTimeoutMs';

					instance[jsInteractionTimeoutMs] =
						instance[jsInteractionTimeoutMs] || 0;

					if (instance[jsInteractionTimeoutMs] < 660) {
						if (instance.clientWidth || instance.clientHeight) {
							options.call(instance);
						}
						else {
							setTimeout(
								function () {
									$(instance)[flash](options);
								},
								instance[jsInteractionTimeoutMs] + 66
							);
						}
					}
				}
			);
		}

		return $this;
	};
}(
	jQuery,
	'flash',
	navigator.plugins['Shockwave Flash'] || window.ActiveXObject
));



(function($) {
    /*
        Wyrównanie wysokości elementów do najwyższego z nich, przy czym można zadać także min i max wysokość.
        
        ciężko powiedzieć kto jest autorem - wzięte z internetu na licencji GPL i zmodyfikowane kilka razy do własnych potrzeb 
    */
$.fn.equalHeights = function(minHeight, maxHeight) {

	var tallest = (minHeight) ? minHeight : 0;
	function addSize(elem,baseHeight,operation) {
		var border_top = parseInt(elem.css('border-top-width'));
		var border_bottom = parseInt(elem.css('border-bottom-width'));
		var padding_top = parseInt(elem.css('padding-top'));
		var padding_bottom = parseInt(elem.css('padding-bottom'));
	if (operation == 'subtract') {
		if (!isNaN(padding_top)) baseHeight -= padding_top;
		if (!isNaN(padding_bottom)) baseHeight -= padding_bottom;
		if (!isNaN(border_top)) baseHeight -= border_top;
		if (!isNaN(border_bottom)) baseHeight -= border_bottom;
	} else {
		if (!isNaN(padding_top)) baseHeight += padding_top;
		if (!isNaN(padding_bottom)) baseHeight += padding_bottom;
		if (!isNaN(border_top)) baseHeight += border_top;
		if (!isNaN(border_bottom)) baseHeight += border_bottom;
	}
	return baseHeight;
}
this.each(function() {
	var height = $(this).height();
    height = height; //+ (19 - height%19); // wyrownanie do wysokosci ktora jest wielokrotnoscia 19! 
    
	height = addSize($(this),height);
	if (height > tallest) tallest = height;
});
if((maxHeight) && tallest > maxHeight) 
	tallest = maxHeight;
	return this.each(function() {
		tallest2 = addSize($(this),tallest,'subtract')
		$(this).height(tallest2);
	});
}
})(jQuery);



$(document).ready(function(){
/*$('.contentMediumArticle a img.contentImg').remove();  --- to działa, obraz znika*/
  
    $('#header > *').equalHeights();
    $('#contentNews > div').equalHeights();
  /*    
    var el = $('ul#navlist');
    var navlistChildrenSize = 91;
    var navlistVector = 1; // wektor przesuniecia menu.
    var navlistVectorSize = navlistChildrenSize * navlistVector;
    var navlistSize = $(el).children().length * navlistChildrenSize;
    $(el).css('width',navlistSize + 'px').css('left','0px');
    var navlistContainerSize = parseInt($(el).parent().css('width'));
    var navlistLeft = 0; 
     
    $('#menuArrowRight, #menuArrowLeft').mouseover(function() { $(this).click(); });
 
    $('#menuArrowRight').click(function() {
        if($(el).queue('fx').length > 0) return false;
        navlistLeft = parseInt($(el).css('left'),10);
        if(navlistSize > navlistContainerSize + (-1 * navlistLeft) ) {
            //alert('navlistVectorSize: ' + navlistVectorSize + ', navlistLeft: ' + navlistLeft);
            $(el).animate({'left':  '-=' + navlistVectorSize +'px'}, 'normal');
            return false;
        }
        return false;
    });
    $('#menuArrowLeft').click(function() {
        //alert('navlistVectorSize: ' + navlistVectorSize + ', navlistLeft: ' + navlistLeft);
        if($(el).queue('fx').length > 0) return false;
        navlistLeft = parseInt($(el).css('left'),10);
        if(navlistLeft <= (-1*navlistVectorSize)) {
            $(el).animate({'left':  '+=' + navlistVectorSize +'px'}, 'normal');
            return false;
        } 
        return false;
    });
 */
    $('h2, h3').each(function()
        {
            if($(this).hasClass('jqBelka')) {
                $(this).prepend('<span class="jqBelkaBackground"></span>');
                $(this).prepend('<span class="jqBelkaLeft"></span>');
                $(this).prepend('<span class="jqBelkaRight"></span>');
                if($(this).hasClass('jqBelkaGreen')) {$(this).append('<span class="jqBelkaGreen"></span>');}
                if($(this).hasClass('jqBelkaRed')) {$(this).append('<span class="jqBelkaRed"></span>');}
                if($(this).hasClass('jqBelkaBlue')) {$(this).append('<span class="jqBelkaBlue"></span>');}
                if($(this).hasClass('jqBelkaYellow')) {$(this).append('<span class="jqBelkaYellow"></span>');}
                
                if($(this).hasClass('jqBelkaArrow')) {$(this).append('<a class="jqBelkaArrowHide" href="#"></a>');}
                if($(this).hasClass('jqBelkaArrow')) {$(this).append('<a class="jqBelkaArrowShow" href="#"></a>');}
                if($(this).children('span').hasClass('bigIcoCenter')) {
   
                    var telw = parseInt($(this).children('span.bigIcoCenter').css('width'));
                    var pelw = parseInt($(this).css('width'));
                    
                    var leftfortelw = (pelw - telw)/2;

                    $(this).children('span.bigIcoCenter').css('left',leftfortelw +'px');
                }
                

                
            }
        }
    );
    

    
    $('a.jqBelkaArrowHide').click(function(){var el = $(this).parent().next('div'); el.fadeOut('fast');$(this).parent().css('margin-bottom','50px');return false;});
    $('a.jqBelkaArrowShow').click(function(){var el = $(this).parent().next('div'); el.fadeIn('fast');$(this).parent().css('margin-bottom','20px');return false;});
    
    $('.contentMediumLeft div:last').css('border-bottom','0 none');
    $('.contentNewsWholeArea').hover(
    function() {
        var el = $(this).parent();
        $(el).children('ul').children('li').children('a').addClass('contentNewsUnderline'); 
        $(el).children('a').addClass('contentNewsUnderline'); 
        },
    function() {
        var el = $(this).parent();
        $(el).children('ul').children('li').children('a').removeClass('contentNewsUnderline'); 
        $(el).children('a').removeClass('contentNewsUnderline'); 
        }
    );
    $('.contentMediumLeftWholeArea').hover(
    function() {
        var el = $(this).parent();
        $(el).children('ul').children('li').children('a').addClass('contentMediumLeftWholeAreaHover'); 
        $(el).children('a').addClass('contentMediumLeftWholeAreaHover'); 
        },
    function() {
        var el = $(this).parent();
        $(el).children('ul').children('li').children('a').removeClass('contentMediumLeftWholeAreaHover'); 
        $(el).children('a').removeClass('contentMediumLeftWholeAreaHover'); 
        }
    );
    $('.contentBoxHover').hover(
    function() { $(this).addClass('contentBoxHoverActive'); $(this).children('h5').children('a').addClass('aHover'); $(this).children('p').children('a').addClass('aHover');},
    function() { $(this).removeClass('contentBoxHoverActive'); $(this).children('h5').children('a').removeClass('aHover'); $(this).children('p').children('a').removeClass('aHover');} 
    );





$('a.contentHref').hover(function() {$(this).parent().addClass('contentHrefH'); }, function() {$(this).parent().removeClass('contentHrefH');});


$('form#headerSearchForm').submit(function() {
  var $searchWord = $(this).children('input#searchWord').val();
  $searchWord = $searchWord + ' site:www.sluzbazdrowia.com.pl';
  $(this).children('input#searchWord').val($searchWord);
  return true;
});



$('.contentBox td img.contentImg, .contentImgR, .contentBox a img.contentImg, .contentMediumArticle a img.contentImg').one('load',
    function() {
        var $imgHeight = $(this).height();
        var $imgWidth = $(this).width();
        var $imgSrc = $(this).attr('src');
        //console.log($(this).attr('src') + ': ' + $(this).width() +' x ' + $(this).height());
        if($(this).hasClass('contentImg'))
            $(this).parent().css('width',($imgWidth+20) +'px');
            
        if(!$(this).hasClass('contentImgWithoutBorders')) {
            if($(this).hasClass('contentImgR'))
                $(this).wrap('<div class="contentImgDiv" style="float:right;margin-right:20px;'+
                'height:'+ $imgHeight +'px; '+
                'width:'+ $imgWidth +'px;  '+
                'background-image:url(' + $imgSrc + ');" />');
            else
                $(this).wrap('<div class="contentImgDiv" style="'+
                'height:'+ $imgHeight +'px; '+
                'width:'+ $imgWidth +'px;  '+
                'background-image:url(' + $imgSrc + ');" />');
            $(this).css('opacity','0').css('margin-right','0');
        }
    }).each(function() { 
        
          if(this.complete) $(this).trigger("load");

        
    });    

$('#navlist li:has(ul)').addClass('parent');
$('#navlist > li:last').addClass('last');
$('#navlist ul').css({display: "none"}); // Opera Fix
$('#navlist li').hover(function(){
        $(this).addClass('hover');
		$(this).find('ul:first').css({visibility: "visible",display: "none"}).show();
		},function(){
        $(this).removeClass('hover');
		$(this).find('ul:first').css({visibility: "hidden"});
		});





$('#facebook_widget').append('<iframe src="http://www.facebook.com/plugins/likebox.php?href=http%3A%2F%2Fwww.facebook.com%2Fpages%2FPortal-czasopisma-Sluzba-Zdrowia%2F153805884652856&amp;width=200&amp;connections=10&amp;stream=false&amp;header=false&amp;height=225" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:200px; height:240px;" allowTransparency="true"></iframe>');





});   // koniec document.ready function()





