function dodajIframe1(elementId){

       var IE = (document.all && document.getElementById && !window.opera );
       var FF = (!document.all && document.getElementById && !window.opera);
       var OP = (document.all && document.getElementById && window.opera);
	   
		if(IE){
			var pom1 = document.getElementById(elementId);
			pom1.innerHTML += '<iframe style="position: absolute; display: block; z-index: -1; width: 100%; height: '+pom1.clientHeight+'px; top: 0; left: 0; filter: mask(); border:1px solid #333333;"></iframe>';
		}
}
function showhide_layer2(elementId, akcja){
    
	var mouseX = 0;
	var mouseY = 0;
	
	var IE = (document.all && document.getElementById && !window.opera );
    var FF = (!document.all && document.getElementById && !window.opera);
    var OP = (document.all && document.getElementById && window.opera);
	
    var pom = document.getElementById(elementId);
	
	if(akcja){
			
		pom.style.display = 'block';
		scrolling(elementId,pom.clientWidth);
		
	    window.onscroll = function(){
			scrolling(elementId,pom.clientWidth);
		};	
		
		window.onresize = function(){
			scrolling(elementId,pom.clientWidth);
		};
		
		
	}else{
		window.onscroll = function() {};
		window.onresize = function() {};
		pom.style.display = 'none';
	}
	
	return false;
}


function ShowEffect(element1, element2){
	   
	   //if(!getCookie('bartek_ankieta') && !getCookie('bartek_ankieta_nie')){
		   
		   el = document.getElementById(element1);
		   el.style.display='block'; 
		   if(document.getElementById('master').offsetHeight){
			   
			   el.style.height = document.getElementById('master').offsetHeight+'px';
		   }
		   dodajIframe1(element1);
		   new Effect.Opacity(element1, 
		   {duration:2, from:0, to:0.7});
			setTimeout('showhide_layer2(\''+element2+'\', 1)',1800);
	  // }
	   
	 return true;
}

function HideEffect(element1, element2){
       new Effect.Opacity(element1, 
       {duration:2, from:0.7, to:0});
	   setTimeout('showhide_layer2(\''+element1+'\', 0)',500);
	   el = document.getElementById(element2);
	   el.style.display='none'; 
	   return true;
 }
 function wyslijZapytanie(url, user, email, msg){
	$('msg-komunikat').innerHTML = '';
	wyswietlObiektOId('msg-loading');
	new Ajax.Request('/ajax_powiadom.php', {
		method: 'post', 
		//parameters:'url='+escape(url)+'&user='+escape(user)+'&email='+escape(email)+'&msg='+escape(msg)+'',
		parameters:'url='+url+'&user='+user+'&email='+email+'&msg='+msg,
		onComplete:function(request){
			var xmlResponse = request.responseXML;
			$('msg-komunikat').innerHTML = xmlResponse.getElementsByTagName('msg').item(0).firstChild.data;
			ukryjObiektOId('msg-loading');
		}
	});
	return true;
}

function ukryjObiektOId(elId){
	elObject = document.getElementById(elId);
	elObject.style.display = 'none';
}

function wyswietlObiektOId(elId){
	elObject = document.getElementById(elId);
	elObject.style.display = 'block';
}

var IE = (document.all && document.getElementById && !window.opera );
var FF = (!document.all && document.getElementById && !window.opera);
var OP = (document.all && document.getElementById && window.opera);

function mMoveXY(event){
	if(mBoxBgImageIsLoaded){
		mouseX = 0;
		mouseY = 0;
		if(!event){
			var event = window.event;
		}
		if(IE){
			mouseX = event.clientX + document.documentElement.scrollLeft;
			mouseY = event.clientY + document.documentElement.scrollTop;
		}else{ 
			mouseX = event.pageX;
			mouseY = event.pageY;
		}
		mouseX -= $(mContainerId).offsetLeft;
		mouseY -= $(mContainerId).offsetTop;
	
		mFrameOffsetX = parseFloat(mFrameWidth / 2);
		mFrameOffsetY = parseFloat(mFrameHeight / 2);
	
		mBoxBgX = parseInt((-imagesWidthRatio * mouseX) + parseFloat(mBoxWidth / 2));
		mBoxBgY = parseInt((-imagesHeightRatio * mouseY) + parseFloat(mBoxHeight / 2));
	
		if(mBoxBgX > 0){
			mBoxBgX = 0;
		}else if(mBoxBgX < -(mBoxBgImageWidth - mBoxWidth)){
			mBoxBgX = -(mBoxBgImageWidth - mBoxWidth); 
		}
		if(mBoxBgY > 0){
			mBoxBgY = 0;
		}else if(mBoxBgY < -(mBoxBgImageHeight - mBoxHeight)){
			mBoxBgY = -(mBoxBgImageHeight - mBoxHeight); 
		}
		
		setCssBackgroundPosition(mBoxId, mBoxBgX, mBoxBgY);
		
		mFrameY = mouseY - mFrameOffsetY;
		mFrameX = mouseX - mFrameOffsetX;
	
		if(mouseX + mFrameOffsetX > mBaseWidth){
			mFrameX = mBaseWidth - (2 * mFrameOffsetX);
		}else if(mFrameX < 0){
			mFrameX = 0;
		}
			
		if(mouseY + mFrameOffsetY > mBaseHeight){
			mFrameY = mBaseHeight - (2 * mFrameOffsetY);
		}else if(mFrameY < 0){
			mFrameY = 0;
		}
	
		setCssPosition(mFrameId, mFrameY, mFrameX);
	}
	return true;
}

function calculatemFrameSize(objId, width1, height1, width2, height2){
	width = Math.floor(parseInt(width2) / parseInt(width1));
	height = Math.floor(parseInt(height2) / parseInt(height1));
	setCssSize(objId, height * mFrameRatio, width * mFrameRatio);
	return true;
}

function setCssBackgroundPosition(objId, x, y){
	$(objId).style.backgroundPosition = ''+x+'px '+y+'px';
}

function setCssPosition(objId, top, left){
	$(objId).style.top = parseInt(top)+'px';
	$(objId).style.left = parseInt(left)+'px';
}

function setCssSize(objId, width, height){
	$(objId).style.width = parseInt(width)+'px';
	$(objId).style.height = parseInt(height)+'px';
}

function mBoxHide(){
	$(mBaseId).className ='';
	$(mFrameId).style.display = 'none';
	$(mBoxId).style.display = 'none';
	return true;
}
function mBoxShow(){
	$(mFrameId).style.display = 'block';
	//calculatemFrameSize(mFrameId, mBaseWidth, mBaseHeight, mBoxBgImageWidth, mBoxBgImageHeight);
	mFrameWidth = parseInt(getCssStyleProperties($(mFrameId), 'width'));
	mFrameHeight = parseInt(getCssStyleProperties($(mFrameId), 'height'));
	$(mBaseId).className = 'trans';	
	$(mBoxId).style.display = 'block';
	$(mBoxId).style.backgroundPosition = '50% 50%';
	$(mBoxId).style.backgroundImage = 'url(/img/loading.gif)';
	if(mBoxBgImageIsLoaded){
		$(mBoxId).style.backgroundImage = 'url('+mBoxBgImage+')';
		$(mBoxId).style.backgroundPosition = '0 0';
	}else{
		var pomImg = new Image();
		pomImg.src = mBoxBgImage;
		pomImg.onload = function(){
			mBoxBgImageIsLoaded = true;
			$(mBoxId).style.backgroundImage = 'url('+mBoxBgImage+')';
			$(mBoxId).style.backgroundPosition = '0 0';
		}
	}
	return true;
}

function getCssStyleProperties(objId,styleProperties){
	if ($(objId).currentStyle){
		return $(objId).currentStyle[styleProperties];
	}else if (window.getComputedStyle){
		return document.defaultView.getComputedStyle($(objId),null).getPropertyValue(styleProperties);
	}
}

function addToAddFavorite(url, title){
	if (window.sidebar) {
		window.sidebar.addPanel(title, url,"");
	}else if(window.external) {
		window.external.AddFavorite(url, title); 
	}else if(window.opera && window.print) {
		return true; 
	}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

