function showInvitation() {

	cookieValue = jQuery.cookie('euroSurvey');
	if (cookieValue == null) {
		jQuery.getJSON("/surveyTools.ltr", { action: "show_invitation", app_version: "old" }, function(json) {
			if (json.showInvitation == 'true') {
					urchinTracker('survey-invitation.ltr');
					var w=350;
					var h=130;
					if(jQuery.browser.version=='6.0')h=160;
					jQuery('body').append('<a/>').children('a:last').attr('href', '/survey-invitation.ltr?app_version=old').fancybox({frameWidth: w,frameHeight: h,hideOnContentClick:false}).click(); 
			}
		});
	}		
}

function checkEmailNewsletter(email) {
		
	var pattern1 = /^\w+([\.+-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/;
	if ( email==null || email=='' || !pattern1.test(email)) {
			alert('Proszę wpisać poprawny adres email.');
			return false;
	}
	return true;
}

function addBookmark(title,url) {
	if (window.sidebar) {
  		window.sidebar.addPanel(title, url,"");
 	} else if( document.all ) {
 		window.external.AddFavorite( url, title);
 	} else if( window.opera && window.print ) {
 		return true;
	}
}

function printPopup() {
		var printUrl=document.location.href;
		if (printUrl.indexOf('#') > 0) printUrl = printUrl.substring(0,printUrl.indexOf('#'));
		if (printUrl.indexOf('?') > 0) printpop(printUrl + "&print=1");
		
		else printpop(printUrl + "?print=1");
	}

function notifyFriend(params)
			{
				var sLocation = document.location.href;
				if( sLocation.indexOf("?") == -1 ) sLocation ;
				else sLocation;
				if (params==null) params="";
				var s = "/notify_friend_window.xml";
					s += "?document_href=" + escape( sLocation );
					s += "&amp;" + params;
				window.open(s, 'notify_friend', 'width=458,height=382,menubar=no,resizable=no,left=' + ((window.screen.width - 320)/2 ) + ',top=' + ((window.screen.height - 300)/2 )).focus();  
			 }
			 
	function printpop(url) {
				var Win;
				if(window.screen)
				{
				aw = screen.availWidth;
				ah = screen.availHeight;
				}
				else
				{
				aw=640;
				ah=480;
				}
				Win=window.open(url,'print',"width=600, height=600,left=" +(aw-590)/2+",top=" +(ah-600)/2 + ",toolbar=no,location=no,directories=no," +"status=no,menubar=no," +"scrollbars=yes,resizable=no");
								
			}

function winPromoOpen(url) 
{
	var Win;
	if (Win) Win.close();
	Win = window.open("/js/promo-view.html?"+url,"photo","width=800, height=600, scrollbars=yes,resizable=yes,menubar=no,status=no");
}

			

function openNewWindow(url)
{
	openNewWindow(url, 480, 120, 'no', 'no');
} 

function openNewWindow(url, x, y, scrollbars, resizable)
{
 	 aPopUp = window.open('','VALLIST');	
 	 aPopUp.close();
 	 var left = (screen.availWidth/2) - (x/2);
	 var top = (screen.availHeight/2) - (y/2);
 	
    aPopUp= self.window.open(url,'VALLIST','toolbar=no,location=no,directories=no,status=yes,scrollbars='+scrollbars+',resizable='+resizable+', copyhistory=no,width='+x+',height='+y+',top='+top+',left='+left);
    self.aNoteWin = aPopUp;
} 			
			
	
function readCookie(name)
{
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++)
	{
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}	
	
function createCookie(name,value)
{
	var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}
	
function addToCardWithServices(fAction,prodId,prodTitle, services, msg) {

		if (!document.getElementById('basket-small')) {
			document.location.href = '/add-to-cart.bhtml?prod_id='+prodId;
			return false;
		}
		
		new Ajax.Request('/add-and-refresh-cart.bhtml', 
		{ 
			method:'post', 
			parameters: {F_ACTION: fAction, productId: prodId, serviceItem: services},
			onSuccess: function(transport){
				document.getElementById('basket-small').innerHTML = transport.responseText;      				
  				showNotify(prodTitle, msg, false);  
  				document.getElementById('addToCartAlert').getElementsByTagName('p')[0].innerHTML='Dodałeś do koszyka:';  				  				
  				    				
			},
			onFailure: function() { 
				
			}
		});
	
	return false;
}	

function showAllAccessories(contentId, isSuite, groupId) {
	new Ajax.Request('/accessoriesForSelectedProductInCart-refresh.bhtml',
	{
		method: 'post',
		parameters: {showAll: 'true', contentId: contentId, isSuite: isSuite, groupId: groupId},
		onSuccess: function(transport) {
			document.getElementById('accessoryRefresh').innerHTML = transport.responseText;
			toCartHeight ('col2','ch_bloczki');
			document.getElementById('tocart_col_bottom').style.position='absolute';
		},
		onFailure: function() {
		
		}
	});
}
function addToCartSmsService() {
	//w nowej wersji jest nowa wersja
	var isSmsNotify = document.getElementById('smsNotification');
	if(isSmsNotify.checked) {
		var f_action = 'ADD_SMS_SERVICE';
	}
	else {
		var f_action = 'REMOVE_SMS_SERVICE';
	}
		
	new Ajax.Request('/add-and-refresh-cart.bhtml', 
			{ 
				method:'post',  
				parameters: {F_ACTION: f_action, inactive: true},
				onSuccess: function(transport){
					document.getElementById('basket-small').innerHTML = transport.responseText;      				
				},
				onFailure: function() { 
				
				}
			});
		
		return false;
}

function selectPaymentTypeInCart(paymentType) {
	//nowa funkcja w order-payment-view
	new Ajax.Request('/add-and-refresh-cart.bhtml', 
			{ 
				method:'post',  
				parameters: {F_ACTION: 'SELECT_PAYMENT_TYPE', paymentTypeCode: paymentType, inactive: true},
				onSuccess: function(transport){
					document.getElementById('basket-small').innerHTML = transport.responseText;      				
				},
				onFailure: function() { 
				
				}
			});
		
		return false;
}

function addToCard(prodId,prodTitle,toCart) {
		
		new Ajax.Request('/add-and-refresh-cart.bhtml', 
		{ 
			method:'post',  
			parameters: {F_ACTION: 'ADD_PRODUCT', productId: prodId, toCart: toCart},
			onSuccess: function(transport){
				document.getElementById('basket-small').innerHTML = transport.responseText;      				
  				showNotify(prodTitle, '',toCart);      				
			},
			onFailure: function() { 
			
			}
		});
	
	return false;
}

function addSuiteToCard(suiteId, prodId, suiteName) {
		msg  = new Array ('w wybranym zestawie');
		new Ajax.Request('/add-and-refresh-cart.bhtml', 
		{ 
			method:'post', 
			parameters: {F_ACTION: 'ADD_SUITE', productId: prodId, suiteId: suiteId},
			onSuccess: function(transport){

				document.getElementById('basket-small').innerHTML = transport.responseText;      				
  				showNotify(suiteName, msg);      				
				document.getElementById('addToCartAlert').getElementsByTagName('p')[0].innerHTML='Dodałeś do koszyka:';  				
			},
			onFailure: function() { 

			}
		});
	
	return false;
}

function addServiceAndRefresh(contentId, isSuite, serviceId, serviceName) {
	//nowa funkcja w script
	new Ajax.Request('/addServiceAndRefresh.ltr',
	{
		method: 'post',
		parameters: {contentId: contentId, isSuite: isSuite, serviceId: serviceId},
		onSuccess: function(transport) {
			
			document.getElementById('serviceArea').innerHTML = transport.responseText;
			toCartHeight('col2','ch_bloczki');
			refreshCart(true);	
			showNotify(serviceName, '',true);	
		},
		onFailure: function() { 

		}
	});
	
	return false;
}

function addServiceAndGoToCart(contentId, isSuite, serviceId, serviceName, whereToGo) {
	//nowa funkcja w script
	new Ajax.Request('/addServiceAndRefresh.ltr',
	{
		method: 'post',
		parameters: {contentId: contentId, isSuite: isSuite, serviceId: serviceId},
		onSuccess: function(transport) {
			
			document.getElementById('serviceArea').innerHTML = transport.responseText;
			toCartHeight('col2','ch_bloczki');
			refreshCart(true);	
			showNotifyAndGoToCart(serviceName, '',true, whereToGo);	
		},
		onFailure: function() { 

		}
	});
	
	return false;
}

function addWarrantyAndRefresh(contentId, warrantyId, warrantyName) {
	//nowy w script
	if(warrantyId) {
	
		new Ajax.Request('/addWarrantyAndRefresh.ltr',
			{
			method: 'post',
			parameters: {contentId: contentId, warrantyId: warrantyId},
			onSuccess: function(transport) {
			
				document.getElementById('warrantyArea').innerHTML = transport.responseText;
				refreshCart(true);	
				showNotify(warrantyName, '',true);	
				document.forms['cartForm'].elements['isWarrantyEncourage'].value = 0;
			},
			onFailure: function() { 
			
			}
		});
	}
	
	return false;
}

function refreshCart(toCart) {
	new Ajax.Request('/add-and-refresh-cart.bhtml', 
		{ 
			method:'post',  
			parameters: {F_ACTION: 'REFRESH_ONLY', toCart: toCart},
			onSuccess: function(transport){
				document.getElementById('basket-small').innerHTML = transport.responseText;
			},
			onFailure: function() { 
			
			}
		});
}

function addSuiteToCardWithServices(fAction,suiteId, prodId, suiteName, services, msg) {
		if(!msg) {
			var msg = new Array();
		}
		if (services.length!= 0)
			msg[0]='w wybranym zestawie wraz z usługami';
		else 
			msg[0]='w wybranym zestawie';
		new Ajax.Request('/add-and-refresh-cart.bhtml', 
		{ 
			method:'post', 
			parameters: {F_ACTION: fAction, productId: prodId, suiteId: suiteId, serviceItem: services},
			onSuccess: function(transport){

				document.getElementById('basket-small').innerHTML = transport.responseText;      				
  				showNotify(suiteName, msg); 
				document.getElementById('addToCartAlert').getElementsByTagName('p')[0].innerHTML='Dodałeś do koszyka:';  				  				
			},
			onFailure: function() { 

			}
		});
	
	return false;

}
	
function hideNotify() {
	node = document.getElementById('alertLayer')
	if (node) {
		document.getElementById("top").removeChild(node);
	}
}	
	
function showNotify(prodTitle, msg, toCart) {

	height = (navigator.appName.indexOf("Netscape") != -1) ? pageYOffset + (innerHeight/2) - 100 : document.body.scrollTop + (document.body.clientHeight/2) - 100;

	hideNotify();	
	notifyLayer = document.createElement('div')
	notifyLayer.id = "alertLayer";
	notifyLayer.onclick = function () {hideNotify();};
	notifyLayer.style.height =((navigator.appName.indexOf("Netscape") != -1) ? pageYOffset + innerHeight: document.body.scrollTop + document.body.clientHeight) +'px';

	notify = document.createElement('div')
	notify.id = "addToCartAlert";


	ifr = document.createElement('iframe');
	ifr.id = "alertIfr";
	ifr.frameBorder = "0";
	ifr.style.marginTop = height+'px';
	ifr.setAttribute('allowtransparency',true);

	pClose = document.createElement('img');
	pClose.src="/images/www/spacer.gif"
	pClose.onclick = function() {hideNotify();};
	
	
	pIntro = document.createElement('p');
	pIntroText = document.createTextNode('Dodałeś do koszyka:');
	//pIntroText.id="alertP";
	pIntro.appendChild(pIntroText);

	pContener = document.createElement('div');
	pContener.id="alertContener";
	
	pProd = document.createElement('h2');
	pProd.id = "alertProdTitle"
	pProd.innerHTML = prodTitle;
	
	pInputCont = document.createElement('span');
	pInputCont.className = 'kontynuuj';
	pInputCont.onclick=function() {hideNotify();};
	
	pInputOk = document.createElement('span');
	pInputOk.className = 'ok';
	pInputOk.innerHTML='<img src="/images/www/ok.gif" alt="ok"/>';
	pInputOk.onclick=function() {hideNotify();};
	
	pCartLink = document.createElement('a');
	pCartLink.className = 'zamawiam';
	pCartLink.href = '/cart.bhtml';

	
	notify.appendChild(pClose);
	notify.appendChild(pIntro);
//	notify.appendChild(pProd);
	pContener.appendChild(pProd);
	for(var j=0; j < msg.length; j++) {
		pService = document.createElement('h2');
		pService.id = "alertProdTitle"
		pServiceText = document.createTextNode(msg[j]);
		pService.appendChild(pServiceText);
		pContener.appendChild(pService);
	}	
	notify.appendChild(pContener);
	if (toCart) {
		notify.appendChild(pInputOk);
	}
	else {
		notify.appendChild(pInputCont);
		notify.appendChild(pCartLink);
	}
	notifyLayer.appendChild(ifr);
	notifyLayer.appendChild(notify);
	

	document.getElementById("top").appendChild(notifyLayer);	
	document.getElementById("container").onclick = function() {hideNotify();};
}

function toCartHeight (column,container) {
	if (!document.getElementById(column))
		return false;
	h=	document.getElementById(column).offsetHeight;
	kont = document.getElementById(container);
	if (kont.offsetHeight < h) 
		if (document.all){
			kont.style.height= h + 10; }
		else {kont.style.height= h ; }
	
}	
function changeInfo (msg){
	document.getElementById('addToCartAlert').getElementsByTagName('p')[0].innerHTML=msg;
	document.getElementById('addToCartAlert').style.background='url(/images/www/to_cart_warr.gif)';
}
function showInfoLayer (title,msg, toCart){
	setTimeout("showNotify('"+title+"', '',"+toCart+")",100);
	setTimeout("changeInfo('"+msg+"')",100);

		return false;
	

}




function showPhoto(midi, maxi, el, pict_nr) {
	jQuery.noConflict();
	var text  = "showGallery("+pict_nr+")";
	var ml = jQuery("#medium-link-href");
	ml.html('<a id="medium-link" href="/foto/'+midi+'" class="zoom" onclick="'+text+'; return false;">Powiększ</a>');
	/* ml.onclick=function() { return winGalleryOpen('/photo/'+maxi);}; */
	
	var mp = jQuery("#medium-photo");
	mp.attr("src","/foto/"+midi);
	
	//mp.attr("onclick",pict_nr);
	var mp_wrap = jQuery("#medium-photo-href"); 
	mp_wrap.html('<a href="javascript:void(0)" onclick="'+text+'"><img src="/images/www/blank.gif" width="190" height="169"/></a>');

	
	thumbs = document.getElementById('add-photos').childNodes;
	for (i=0; i<thumbs.length; i++) {
		if(thumbs[i]==el) thumbs[i].className='photoswitch  photoactive';
		else thumbs[i].className='photoswitch';
	}

	return false;

}
var newLayer = {
	msqUrl :null,
	className : null,
	evt :null,
	hide : null,
	content : null,
	marginTop : null,
	height : null,
	width : null,
	
	setupDimensions : function() {
		this.marginTop =(navigator.appName.indexOf("Netscape") != -1) ? pageYOffset + (innerHeight/2) - 100 : document.body.scrollTop + (document.body.clientHeight/2) - 100;
		this.height =(navigator.appName.indexOf("Netscape") != -1) ? pageYOffset + innerHeight: document.body.scrollTop + document.body.clientHeight;
		return true;
	},
	_killBubble : function (){
		(window.event)?window.event.cancelBubble = true:this.evt.cancelBubble = true;	
		return true;
	},
	

	initialize : function (){
		hideNotify();
		this._killBubble();	
		this.setupDimensions();
		notifyLayer = document.createElement('div');
		notifyLayer.id = "alertLayer";
		notifyLayer.className=this.className;
		notifyLayer.style.height=this.height+"px";
		(this.hide)?notifyLayer.onclick = function () {hideNotify();}:notifyLayer.onclick = function () {return;};
		document.getElementById("top").appendChild(notifyLayer);

		var notify = document.createElement('div')
		notify.id = "infoLayer";
		notify.className=this.className;
		notify.innerHTML='<div class="infoLayerTop" onclick="hideNotify();"> </div><div id="ifrPlace"> </div>';
		notify.style.marginTop=this.marginTop+"px";
		document.getElementById("alertLayer").appendChild(notify);

		var ifr = document.createElement('iframe');
		ifr.id=this.className;
		ifr.frameBorder = "0";
		ifr.setAttribute('allowtransparency',true);
		ifr.style.width=434+"px";
		document.getElementById("ifrPlace").appendChild(ifr);
		document.getElementById(this.className).src=this.msgUrl;

		return true;
	},
	
	createIframe : function (className, msgUrl, evt, hide){
		this.className=className;
		this.msgUrl=msgUrl;
		this.evt=evt;
		this.hide=hide;
		this.initialize();
	}	
}

function showAjaxIframeLayer(className, msgUrl, evt, hide) {
    if (window.event) 
        window.event.cancelBubble = true;
    else
        evt.cancelBubble = true;
    
	height = (navigator.appName.indexOf("Netscape") != -1) ? pageYOffset + (innerHeight/2) - 200 : document.body.scrollTop + (document.body.clientHeight/2) - 200;

	hideNotify();	
	notifyLayer = document.createElement('div')
	notifyLayer.id = "alertLayer";
	notifyLayer.className=className;
	if (hide) 
		notifyLayer.onclick = function () {hideNotify();};
	else 
		notifyLayer.onclick = function () {return;};
	notifyLayer.style.height =((navigator.appName.indexOf("Netscape") != -1) ? pageYOffset + innerHeight: document.body.scrollTop + document.body.clientHeight) +'px';
	var notify = document.createElement('div')
	notify.id = "infoLayer";
	notify.className=className;
	
	notify.innerHTML='<iframe src="'+msgUrl+'" width="99%" frameborder="0"></iframe>';
	notifyLayer.appendChild(notify);
   	document.getElementById("top").appendChild(notifyLayer);	     
}

function showAjaxInfoLayer (className, msgUrl, evt){
	showAjaxInfoLayer (className, msgUrl, evt, true);	
}

function showAjaxInfoLayer (className, msgUrl, evt, hide){
    if (window.event)
        window.event.cancelBubble = true;
    else
        evt.cancelBubble = true;

	height = (navigator.appName.indexOf("Netscape") != -1) ? pageYOffset + (innerHeight/2) - 200 : document.body.scrollTop + (document.body.clientHeight/2) - 200;

	hideNotify();
	
	var container = document.getElementById("container")?document.getElementById("container"):document.getElementById("smallContainer");
	if (container.id=="smallContainer") height=height+200;
		
	notifyLayer = document.createElement('div')
	notifyLayer.id = "alertLayer";
	notifyLayer.className=className;

	if (hide) notifyLayer.onclick = function () {hideNotify();};
	else notifyLayer.onclick = function () {return;};

	notifyLayer.style.height =((navigator.appName.indexOf("Netscape") != -1) ? pageYOffset + innerHeight: document.body.scrollTop + document.body.clientHeight) +'px';

	notify = document.createElement('div')
	notify.id = "infoLayer";
	notify.className=className;
	
	ifr = document.createElement('iframe');
	ifr.id = "alertIfr";
	ifr.frameBorder = "0";
	ifr.style.marginTop = height+'px';
	ifr.setAttribute('allowtransparency',true);
	ifr.style.display='none';
	
	pContener = document.createElement('div');
	pContener.id="alertContener";

	
	if (className=='usluga')
		notify.innerHTML='<img src="/images/www/layer440_top_usluga.gif" alt="Usługa" class="infoLayerTop" onclick="hideNotify();">';
	if (className=='gwarancja')
		notify.innerHTML='<img src="/images/www/layer440_top_gwarancja.gif" alt="Gwarancja" class="infoLayerTop" onclick="hideNotify();">';	
	if (className=='uslugi')
		notify.innerHTML='<img src="/images/www/layer440_top_uslugi.gif" alt="Usługi" class="infoLayerTop" onclick="hideNotify();">';
	if (className=='reklamacje')
		notify.innerHTML='<img src="/images/www/layer440_top_usluga.gif" alt="Usługa" class="infoLayerTop" onclick="hideNotify();">';	
	notify.appendChild(pContener);
	notify.innerHTML=notify.innerHTML+'<img src="/images/www/layer440_bottom.gif" class="infoLayerBottom">';
				
	notifyLayer.appendChild(ifr);
	notifyLayer.appendChild(notify);
	
	
	document.getElementById("top").appendChild(notifyLayer);	

	
	ifr.style.display='block';

	getInfoText (msgUrl,'alertContener');
}

/* warranty encouragement */
function showAjaxPopup (className, msgUrl, evt){
    if (window.event)
        window.event.cancelBubble = true;
    else
        evt.cancelBubble = true;

	height = (navigator.appName.indexOf("Netscape") != -1) ? pageYOffset + (innerHeight/2) - 200 : document.body.scrollTop + (document.body.clientHeight/2) - 200;

	hideNotify();	
	notifyLayer = document.createElement('div')
	notifyLayer.id = "alertLayer";
	notifyLayer.className=className;
	notifyLayer.style.height =((navigator.appName.indexOf("Netscape") != -1) ? pageYOffset + innerHeight: document.body.scrollTop + document.body.clientHeight) +'px';

	notify = document.createElement('div')
	notify.id = "infoLayer";
	notify.className=className;
	
	ifr = document.createElement('iframe');
	ifr.id = "alertIfr";
	ifr.frameBorder = "0";
	ifr.style.marginTop = height+'px';
	ifr.setAttribute('allowtransparency',true);
	ifr.style.display='none';
	
	pContener = document.createElement('div');
	pContener.id="alertContener";
	
	if (className=='uslugi')
		notify.innerHTML='<img src="/images/www/layer440_top_uslugi.gif" alt="Usługi" class="infoLayerTop" onclick="hideNotify();">';		
	if (className=='usluga')
		notify.innerHTML='<img src="/images/www/layer440_top_usluga.gif" alt="Usługa" class="infoLayerTop" onclick="hideNotify();">';
	if (className=='gwarancja')
		notify.innerHTML='<img src="/images/www/layer440_top_gwarancja.gif" alt="Gwarancja" class="infoLayerTop" onclick="hideNotify();">';		
		
	notify.appendChild(pContener);
	notify.innerHTML=notify.innerHTML+'<img src="/images/www/layer440_bottom.gif" class="infoLayerBottom">';
				
	notifyLayer.appendChild(ifr);
	notifyLayer.appendChild(notify);

	document.getElementById("top").appendChild(notifyLayer);	
	ifr.style.display='block';

	getInfoText (msgUrl,'alertContener');	
	document.getElementById('container').onclick='';
	
}

function showNotifyAndGoToCart(prodTitle, msg, toCart, whereToGo) {

	height = (navigator.appName.indexOf("Netscape") != -1) ? pageYOffset + (innerHeight/2) - 100 : document.body.scrollTop + (document.body.clientHeight/2) - 100;

	hideNotify();	
	notifyLayer = document.createElement('div')
	notifyLayer.id = "alertLayer";
	notifyLayer.onclick = function () {hideNotify(); 
		if (whereToGo !="goBack") {
			document.location.href = whereToGo;
		} else {
			goBack();
		}
	};
	notifyLayer.style.height =((navigator.appName.indexOf("Netscape") != -1) ? pageYOffset + innerHeight: document.body.scrollTop + document.body.clientHeight) +'px';

	notify = document.createElement('div')
	notify.id = "addToCartAlert";


	ifr = document.createElement('iframe');
	ifr.id = "alertIfr";
	ifr.frameBorder = "0";
	ifr.style.marginTop = height+'px';
	ifr.setAttribute('allowtransparency',true);

	pClose = document.createElement('img');
	pClose.src="/images/www/spacer.gif"
	pClose.onclick = function() {hideNotify(); 
		if (whereToGo !="goBack") {
			document.location.href = whereToGo;
		} else {
			goBack();
		}
	};
	
	
	pIntro = document.createElement('p');
	pIntroText = document.createTextNode('Dodałeś do koszyka:');
	//pIntroText.id="alertP";
	pIntro.appendChild(pIntroText);

	pContener = document.createElement('div');
	pContener.id="alertContener";
	
	pProd = document.createElement('h2');
	pProd.id = "alertProdTitle"
	pProd.innerHTML = prodTitle;
	
	pInputCont = document.createElement('span');
	pInputCont.className = 'kontynuuj';
	pInputCont.onclick=function() {hideNotify(); 
		if (whereToGo !="goBack") {
			document.location.href = whereToGo;
		} else {
			goBack();
		}
	};
	
	pInputOk = document.createElement('span');
	pInputOk.className = 'ok';
	pInputOk.innerHTML='<img src="/images/www/ok.gif" alt="ok"/>';
	pInputOk.onclick=function() {hideNotify(); 
		if (whereToGo !="goBack") {
			document.location.href = whereToGo;
		} else {
			goBack();
		}
	};
	
	pCartLink = document.createElement('a');
	pCartLink.className = 'zamawiam';
	pCartLink.href = '/cart.bhtml';

	
	notify.appendChild(pClose);
	notify.appendChild(pIntro);
//	notify.appendChild(pProd);
	pContener.appendChild(pProd);
	for(var j=0; j < msg.length; j++) {
		pService = document.createElement('h2');
		pService.id = "alertProdTitle"
		pServiceText = document.createTextNode(msg[j]);
		pService.appendChild(pServiceText);
		pContener.appendChild(pService);
	}	
	notify.appendChild(pContener);
	if (toCart) {
		notify.appendChild(pInputOk);
	}
	else {
		notify.appendChild(pInputCont);
		notify.appendChild(pCartLink);
	}
	notifyLayer.appendChild(ifr);
	notifyLayer.appendChild(notify);
	

	document.getElementById("top").appendChild(notifyLayer);	
	document.getElementById("container").onclick = function() {hideNotify(); 
		if (whereToGo !="goBack") {
			document.location.href = whereToGo;
		} else {
			goBack();
		}
	};
}

function addWarrantyAndGoToCart(contentId, warrantyId, warrantyName, whereToGo) {

	new Ajax.Request('/addWarrantyAndRefresh.ltr',
	{
		method: 'post',
		parameters: {contentId: contentId, warrantyId: warrantyId},
		onSuccess: function(transport) {
			
			document.getElementById('warrantyArea').innerHTML = transport.responseText;
			refreshCart(true);	
			showNotifyAndGoToCart(warrantyName, '',true, whereToGo);	
		},
		onFailure: function() { 

		}
	});
	
	return false;
}

function getInfoText (address, id) {
	//nowy w script.js
	height = (navigator.appName.indexOf("Netscape") != -1) ? pageYOffset + (innerHeight/2) - 200 : document.body.scrollTop + (document.body.clientHeight/2) - 200;
	ifr = document.getElementById('alertIfr');
	info = document.getElementById('infoLayer');
	new Ajax.Request(address, 
		{ 
			method:'post',  
			onSuccess: function(transport){
				
				document.getElementById(id).innerHTML=transport.responseText;     				
				ifr.style.height=info.clientHeight;
				info.style.marginTop='-'+ info.clientHeight;
				//info.style.display='block';
				return false;
			},
			onFailure: function() { 
				return false;	
			}
		});
		
}

// pobiera parametr URL o podanej nazwie, zwraca jego wartość lub pusty string gdy parametr nie istnieje
function getUrlParameter( name )
{
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );
  if( results == null )
    return "";
  else
    return results[1];
}

function get_cookie ( cookie_name )
{
 		var results = document.cookie.match ( '(^|;) ?' + cookie_name + '=([^;]*)(;|$)' );

  		if ( results )
    		return ( unescape ( results[2] ) );
  		else
   			return null;
}

function changeProductBlockSize (span,size)  {	
	var cookieProductSizeValue;
	var className=/product/;
	var classNameShort=/shortproduct/;
	var classNameLast=/last/;
	var list= document.getElementById ('products-list');	
	var divList = list.getElementsByTagName ('DIV');
	var divListCount=divList.length;
	
	if (divListCount > 0) {
		if (size==0){		
			span.parentNode.className="listaProsta"
			cookieProductSizeValue='smallProduct';
		} 
		else if  (size==1) {
			span.parentNode.className="listaSzcz"
			cookieProductSizeValue='bigProduct';
		}
	} else {
		//nie ma elementów na liście a więc przepisujemy wartość cookie
		cookieProductSizeValue = readCookie('euroProductSize');
		if (cookieProductSizeValue) {
			if (cookieProductSizeValue == 'bigProduct') {
				//sprawdzamy czy element jest wyświetlany (dla searchMode i empty productList nie jest wyświetlany)
				if (span) {
					span.parentNode.className="listaSzcz"
				}
				
			}
		} else {
			//pierwsza wizyta na stronie nie ma jeszcze cookie
			cookieProductSizeValue='bigProduct';
			if (span) {
				span.parentNode.className="listaSzcz"
			}
				
			
		}
	}
	
	for (i=0; i<divListCount; i++){
		if (size==1 && classNameShort.exec(divList[i].className) ){			
			if (classNameLast.exec(divList[i].className))
				divList[i].className='product last';
			else
				divList[i].className='product';				
		}
		else if  (size==0 && className.exec(divList[i].className)) {	
			if (classNameLast.exec(divList[i].className))
				divList[i].className='shortproduct last';
			else
				divList[i].className='shortproduct';
		}
	}
	
	
	createCookie('euroProductSize',cookieProductSizeValue);

}
function getElementsByClass2(){
	var tt=getElementsByClass('prices');
	var l=tt.length;
	for(var i=0;i<l;i++){
		tt[i].style.position="relative";
		tt[i].style.position="absolute";
	}
}

function getElementsByClass(searchClass,node,tag) {
	var classElements = new Array();
	if ( node == null )
		node = document;
	if ( tag == null )
		tag = '*';
	var els = node.getElementsByTagName(tag);
	var elsLen = els.length;
	var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)");
	for (i = 0, j = 0; i < elsLen; i++) {
		if ( pattern.test(els[i].className) ) {
			classElements[j] = els[i];
			j++;
		}
	}
	return classElements;
}

function checkProductSize() {
	
	var boxsize = '';

	boxsize = getUrlParameter("listType");
	
	if (boxsize == "detailed"){

		createCookie('euroProductSize','bigProduct');
	}
	else if (boxsize == "simple"){

		createCookie('euroProductSize','smallProduct');
	}
	
	productSize = readCookie('euroProductSize');
	if (productSize && productSize=='smallProduct') {
		changeProductBlockSize(document.getElementById('productBlockSize').childNodes[0],0);
	}
	else {
		changeProductBlockSize(document.getElementById('productBlockSize').childNodes[0],1);
	}
	
	if(navigator.appVersion.indexOf("MSIE")>=0){setTimeout("getElementsByClass2()",1000);}
}

function hideBadWordAlerts() {
	for ( var i = 1; i <= 4; i++) {
		document.getElementById('badWordAlert' + i).style.display = 'none';
	}
}

function addOpinionAttribute(type, value, number, identifier) {
	new Ajax.Request('/add-opinion-attribute.ltr',
		{
			method:'post',
			parameters: {type: type, value: value, number: number, identifier: identifier},
			onSuccess: function(transport){
				reWhiteSpace = new RegExp(/^\s+$/);
				if(!reWhiteSpace.test(transport.responseText)) {
					hideBadWordAlerts();
					document.getElementById('usersAttributes' + type).innerHTML += transport.responseText;
					numOfAttributes = document.getElementById('numOfAttr').value = parseInt(number) + 1;
				}
				else {
					hideBadWordAlerts();
					document.getElementById('badWordAlert' + type).style.display = 'block';
				}
			},
			onFailure: function() {
			}
		});
}