	var recommendedActivePageNumber = 1;
	var galleryActivePageNumber = 1;
	
	var duration = 15;
	var recommendedTimer;
	var galleryDuration = 5;
	var galleryTimer;

	
	function checkAjxResponse(transport){
		var responseString=transport.responseText;
		if(responseString.length>=13 && responseString.length<=255){
			var re = /\s*<!--\s*__[A-Za-z0-9_\/:.;?#&=]*__\s*-->/;
			if (re.exec(responseString)) {
		        var contentString = responseString.replace(/\s*<!--\s*___/i, "");
		        contentString = contentString.replace(/\s*___\s*-->/i, "");
		        contentString = contentString.replace("amp;", "");
		        window.location=contentString;
	        }
		}
	}

	
	function updateArticle (divName, jspName, pageNumber) {
		var myAjax = new Ajax.Updater(divName, '/ajax', {
			asynchronous: false,
			evalScripts:  true,
			method: 'get',
			parameters: {jsp: jspName, page: pageNumber},
			onComplete: checkAjxResponse
			});		
	}
	
	function updateAjxContent (divName, jspName, pageNumber, ajxLoc) {
		var myAjax = new Ajax.Updater(divName, '/ajax', {
			asynchronous: false,
			method: 'get',
			parameters: {jsp: jspName, page: pageNumber, ajxLoc: ajxLoc},
			onComplete: checkAjxResponse
			});		
	}	
	
	function updatePageProductImage(divName, jspName, pageNumber, productId) {
		var myAjax = new Ajax.Updater(divName, '/ajax', {
			asynchronous: false,
			method: 'get',
			parameters: {jsp: jspName, page: pageNumber, prdId: productId},
			onComplete: checkAjxResponse
			});		
	}
	
	function updatePageArticle (divName, jspName, articleId, pageNumber) {
		var myAjax = new Ajax.Updater(divName, '/ajax', {
			evalScripts:  true,
			asynchronous: false,
			method: 'get',
			parameters: {jsp: jspName, arId: articleId, page: pageNumber},
			onComplete: checkAjxResponse
			});		
	}
	
	function updatePageProduct (divName, jspName, productId, pageNumber, type) {
		var myAjax = new Ajax.Updater(divName, '/ajax', {
			asynchronous: false,
			method: 'get',
			parameters: {jsp: jspName, prdId: productId, page: pageNumber, boxType: type},
			onComplete: checkAjxResponse
			});		
	}
	
	function updatePageBlog (divName, jspName, expertId, pageNumber, month, year, sortType) {
		var myAjax = new Ajax.Updater(divName, '/ajax', {
			asynchronous: false,
			method: 'get',
			parameters: {jsp: jspName, exId: expertId, page: pageNumber, mth: month, yr: year, sort: sortType},
			onComplete: checkAjxResponse
			});		
	}
	
	function updateTreasurePageBlog (divName, jspName, treasureId, pageNumber, month, year, sortType) {
		
		var myAjax = new Ajax.Updater(divName, '/ajax', {
			asynchronous: false,
			method: 'get',
			parameters: {jsp: jspName, trId: treasureId, page: pageNumber, mth: month, yr: year, sort: sortType},
			onComplete: checkAjxResponse
			});		
	}
	function updateSearchCity (divName, jspName, pageNumber, prId) {
		
		var myAjax = new Ajax.Updater(divName, '/ajax', {
			asynchronous: false,
			method: 'get',
			parameters: {jsp: jspName, page: pageNumber, prId: prId},
			onComplete: checkAjxResponse
			});		
	}
	
	function updateCardPageBlog (divName, jspName, cardId, pageNumber, month, year, sortType) {
		
		var myAjax = new Ajax.Updater(divName, '/ajax', {
			asynchronous: false,
			method: 'get',
			parameters: {jsp: jspName, caId: cardId, page: pageNumber, mth: month, yr: year, sort: sortType},
			onComplete: checkAjxResponse
			});		
	}
	
	function updateFacetedDocs (divName, jspName, orderBy, docType, pageNumber) {
		var myAjax = new Ajax.Updater(divName, '/amg/Portal/ajax', {
			asynchronous: false,
			method: 'get',
			parameters: {jsp: jspName, orderBy: orderBy, docType: docType, page: pageNumber},
			onComplete: checkAjxResponse
			});		
	}
	
	function updateResultPanel (divName, jspName, orderBy, docType, pageNumber, ajxLoc) {
		var myAjax = new Ajax.Updater(divName, '/ajax', {
			asynchronous: false,
			method: 'get',
			parameters: {jsp: jspName, orderBy: orderBy, docType: docType, page: pageNumber, ajxLoc: ajxLoc},
			onComplete: checkAjxResponse
			});
	}
	
	function updateFacetAttribs(divName, jspName, boxNr, opened, init) {
		var myAjax = new Ajax.Updater(divName, '/ajax', {
			asynchronous: false,
			method: 'get',
			parameters: {jsp: jspName, boxNr: boxNr, opened: opened, init: init},
			onComplete: checkAjxResponse
			});
	}
	
	function updateAllFacetAttribs(divName, jspName, facetNr, ajxLoc) {
		var myAjax = new Ajax.Updater(divName, '/ajax', {
			asynchronous: false,
			method: 'get',
			parameters: {jsp: jspName, facetNr: facetNr, ajxLoc: ajxLoc},
			onComplete: checkAjxResponse
			});
		$('fall_div').style.display = 'inline';					
	}
	
	function updateRedaktorBox(divName, jspName, display, quId, auId, page) {
		var myAjax = new Ajax.Updater(divName, '/ajax', {
			asynchronous: false,
			method: 'get',
			parameters: {jsp: jspName, display: display, quId: quId, auId: auId, page: page},
			onComplete: checkAjxResponse
		});					
	}
	
	function chgRedaktorBox(display, quId, auId, page) {
		updateRedaktorBox('redaktor_box_ajx', 'redaktorBoxAjx', display, quId, auId, page);
	}

	function updateModeratorBox(divName, jspName, contest, display, page) {
		var myAjax = new Ajax.Updater(divName, '/ajax', {
			asynchronous: false,
			method: 'get',
			parameters: {jsp: jspName, contest: contest, display: display, page: page},
			onComplete: checkAjxResponse
		});					
	}
	
	function chgModeratorBox(contest, display, page) {
		updateModeratorBox('moderator_box_ajx', 'moderatorBoxAjx', contest, display, page);
	}	
	
	
	function updateThreadAttribs(divName, jspName, attribId, operation, role) {
		var myAjax = new Ajax.Updater(divName, '/ajax', {
			asynchronous: false,
			method: 'get',
			parameters: {jsp: jspName, attribId: attribId, operation: operation, role: role},
			onComplete: checkAjxResponse
		});					
	}
	
	function getThreadAttribs(attribId, operation, role) {		
		updateThreadAttribs('forum_thread_attribs_ajx', 'forumThreadAttribsAjx', attribId, operation, role);
		if( role==null || role != 'red' ) {
			opener.getThreadAttribsList();
		}		
	}
	
	function getThreadAttribsList() {
		updateThreadAttribs('forum_thread_attribs_ajx', 'forumThreadAttribsListAjx', null, null);
	}
		
	function allFacetAttribsClose() {		
		$('fall_div').style.display = 'none';	
	}
	
	function topicsOfTheWeekSelectPage (nr, ajxLoc) {
		updateAjxContent('topicsOfTheWeekAjx', 'topicsOfTheWeekAjx', nr, ajxLoc);
	}
	
	function recommendedSelectPage (nr, ajxLoc) {
		clearInterval(recommendedTimer);
		updateAjxContent('recommendedAjx', 'recommendedAjx', nr, ajxLoc);
	}
	
	function newProductsSelectPage (nr, ajxLoc) {
		updateAjxContent('newProductsAjx', 'newProductsAjx', nr, ajxLoc);
	}
	
	function newBargainsSelectPage (nr, ajxLoc) {
		updateAjxContent('bargainsAjx', 'bargainsAjx', nr, ajxLoc);
	}
	
	function newProductContentImagesPage(nr, prdId) {
		updatePageProductImage('div_prod_foto', 'productContentPhotoAjx', nr, prdId);
	}
	
	function mostPopularOnWebsiteSelectPage (nr) {
		updateArticle('mostPopularOnWebsiteAjx', 'mostPopularOnWebsiteAjx', nr);
	}
	
	function newsSelectPage (nr) {
		updateArticle('newsAjx', 'newsAjx', nr);
	}
	
	
	function newArticleIndexedPage(id, maxPageNr){		
		if(window.location.hash==""){
			var nr = 1;
        }else{        	
    		var hashValue = window.location.hash;
            var nr = hashValue.replace("#","");  
            if(!nr.match(/^\d+$/)){
            	nr = 1;
            }
            if(nr > maxPageNr){
            	nr = 1;
            }
        }
		if(maxPageNr > 1){
			window.location.hash = nr;
		}
		updatePageArticle('articleAjx', 'articleAjx', id, nr);
	}
	
	function newArticlePage (id, nr) {
		window.location.hash = nr;
		updatePageArticle('articleAjx', 'articleAjx', id, nr);
	}
	
	function newSimProd (id, nr, type) {
		updatePageProduct('similarProdAjx', 'similarProdAjx', id, nr, type);
	}
	
	function newRelProd (id, nr, type) {
		updatePageProduct('relatedProdAjx', 'similarProdAjx', id, nr, type);
	}
	
	function newPopProd (nr) {
		updateArticle('popularProdAjx', 'popularProdAjx', nr);
	}
	
	function newBlgPage (id, nr, m, y, sort) {		
		updatePageBlog('expBlgAjx', 'expBlgAjx', id, nr, m, y, sort);
	}
	
	function entriesBlgAjx (id, nr, m, y) {
		updatePageBlog('entriesBlgAjx', 'expBlgAjx', id, nr, m, y);
	}
	
	function newTrBlgPage (id, nr, m, y, sort) {		
		updateTreasurePageBlog('trBlgAjx', 'trBlgAjx', id, nr, m, y, sort);
	}
	
	function newCaBlgPage (id, nr, m, y, sort) {		
		updateCardPageBlog('caBlgAjx', 'caBlgAjx', id, nr, m, y, sort);
	}
	
	function newClassicPage (nr, ajxLoc) {
		updateAjxContent('classicPagingAjx', 'classicPagingAjx', nr, ajxLoc);
	}
	
	function newPicturePage (nr, ajxLoc) {
		clearInterval(galleryTimer);
		updateAjxContent('pictureGalleryAjx', 'pictureGalleryAjx', nr, ajxLoc)
	}
	
	function newGratisListPage(nr) {
		updateArticle('gratis_list_box_ajx', 'gratisListBoxAjx', nr);
	}
	
	function newGratisSmallListPage(nr) {
		updateArticle('gratis_product_rc_ajx', 'gratisSmallListBoxAjx', nr);
	}
	
	function gratisSelectCity(nr) {
		updateArticle('gratis_city_select_ajx', 'gratisSelectCityAjx', nr);
	}
	
	function gratisSelectCitySmall(nr, prId) {
		updateSearchCity('gratis_city_select_ajx', 'gratisSelectCityBottomAjx', nr, prId);
	}
	
	function recommendedChangePage (recommendedPageCount, ajxLoc) {
	
		var pageCount = recommendedPageCount;
		
		if (pageCount > 1)
		{
			recommendedActivePageNumber = (recommendedActivePageNumber % pageCount) + 1;
			updateAjxContent('recommendedAjx', 'recommendedAjx', recommendedActivePageNumber, ajxLoc);
		} 
		else
		{
			recommendedSelectPage(1, ajxLoc);
		}
	}
	
	function galleryChangePage (galleryPictureCount,ajxLoc) {
	
		var pageCount = galleryPictureCount;
		
		if (pageCount > 1)
		{
			galleryActivePageNumber = (galleryActivePageNumber % pageCount) + 1;
			updateAjxContent('pictureGalleryAjx', 'pictureGalleryAjx', galleryActivePageNumber,ajxLoc);
		} 
		else
		{
			newPicturePage(1, ajxLoc);
		}
	}	
	
	function changeResultPanel(order, docType, page, ajxLoc) {
		updateResultPanel('result_panel', 'resultPanelAjx', order, docType, page, ajxLoc);	
		
	}
	
	function changeSearcherResultPanel(order, docType, page) {
		updateResultPanel('result_panel', 'resultSearcherPanelAjx', order, docType, page);	
		
	}
	
	/* Do przeniesienia do commonowego js */
	function goToLocation(id){		
		var fixUrl=location.href.replace(/(.*)#.*/,"$1");
		location.href=fixUrl+'#'+id;
	}
	
	function showFacetAttribs(boxNr, opened) {
		var divName = '';
		switch(boxNr) {
			case(1):
			 	divName = 'faset_group_div1';			 	
				break;
			case(2):
			 	divName = 'faset_group_div2';			 	
				break;
			case(3):
			 	divName = 'faset_group_div3';			 	
				break;
			case(4):
			 	divName = 'faset_group_div4';			 	
				break;
		}
		updateFacetAttribs(divName, 'attribsPanelAjx', boxNr, opened, 0);
	}
	
	function showAllFacetAttribs(facet, ajxLoc) {
		updateAllFacetAttribs('fall_div','attribsPopUpAjx',facet, ajxLoc);
	}
	
	function initRecommendedAndTopicsAjx (recommendedPageCount, ajxLoc) {
		updateAjxContent('topicsOfTheWeekAjx', 'topicsOfTheWeekAjx', 1, ajxLoc);
		if (recommendedPageCount >= 1)
		{
			updateAjxContent('recommendedAjx', 'recommendedAjx', 1, ajxLoc);
			if (recommendedPageCount >= 2)
			{
				recommendedTimer=setInterval(function(){recommendedChangePage(recommendedPageCount, ajxLoc)},(duration*1000));
			}
		}
		
	}
	
	function init_ajax_gallery (galleryPictureCount, ajxLoc) {
		if (galleryPictureCount >= 1)
		{
			updateAjxContent('pictureGalleryAjx', 'pictureGalleryAjx', 1, ajxLoc);
			if (galleryPictureCount >= 2)
			{
				galleryTimer=setInterval(function(){galleryChangePage(galleryPictureCount,ajxLoc)},(galleryDuration*1000));
			}
		}
	}
	
	function init_ajax_facet () {
		updateFacetedDocs('c4', 'facetetTestShowDocs');
	}	
	
	function init_facet_attribs () {		
		updateFacetAttribs('faset_group_div1', 'attribsPanelAjx', 1, 1, 1);
		updateFacetAttribs('faset_group_div2', 'attribsPanelAjx', 2, 1, 1);
		updateFacetAttribs('faset_group_div3', 'attribsPanelAjx', 3, 1, 1);
		updateFacetAttribs('faset_group_div4', 'attribsPanelAjx', 4, 1, 1);		
	}
	
	function init_result_panel (ajxLoc) {
		updateResultPanel('result_panel', 'resultPanelAjx', null,null,null,ajxLoc);
	}
	
	function init_searcher_result_panel () {
		updateResultPanel('result_panel', 'resultSearcherPanelAjx');		
	}
	
	function initMovieItemsPage(galleryId, movieId) {
		updateMovieItemsPage('galleryMovieItemAjx', 'galleryMovieItemAjx', galleryId, movieId, '1');
	}
	
	function newMovieItemsPage(galleryId, movieId, pageNr) {
		updateMovieItemsPage('galleryMovieItemAjx', 'galleryMovieItemAjx', galleryId, movieId, pageNr);
	}
	
	function updateMovieItemsPage (divName, jspName, galleryId, movieId, pageNumber) {
		var myAjax = new Ajax.Updater(divName, '/ajax', {
			asynchronous: false,
			method: 'get',
			parameters: {jsp: jspName, gaId: galleryId, moId:movieId, page: pageNumber},
			onComplete: checkAjxResponse
			});
	}
	
	function initMovieItemsProductPage(galleryId, productId, movieId) {
		updateMovieItemsProductPage('galleryMovieProductItemAjx', 'galleryMovieProductItemAjx', galleryId, productId, movieId, '1');
	}
	
	function newMovieItemsProductPage(galleryId, productId, movieId, pageNr) {
		updateMovieItemsProductPage('galleryMovieProductItemAjx', 'galleryMovieProductItemAjx', galleryId, productId, movieId, pageNr);
	}
	
	function updateMovieItemsProductPage (divName, jspName, galleryId, productId, movieId, pageNumber) {
		var myAjax = new Ajax.Updater(divName, '/ajax', {
			asynchronous: false,
			method: 'get',
			parameters: {jsp: jspName, gaId: galleryId, prdId:productId, moId:movieId, page: pageNumber},
			onComplete: checkAjxResponse
			});
	}
	
	function initAdvertMovieItemsProductPage(galleryId, productId, movieId, cId, lId) {
		updateAdvertItemsProductPage('galleryMovieProductItemAjx', 'advertMovieProductItemAjx', galleryId, productId, movieId, '1', cId, lId);
	}
	
	function newAdvertMovieItemsProductPage(galleryId, productId, movieId, pageNr, cId, lId) {
		updateAdvertItemsProductPage('galleryMovieProductItemAjx', 'advertMovieProductItemAjx', galleryId, productId, movieId, pageNr, cId, lId);
	}
	
	function updateAdvertItemsProductPage (divName, jspName, galleryId, productId, movieId, pageNumber, catId, lvlId) {
		var myAjax = new Ajax.Updater(divName, '/ajax', {
			asynchronous: false,
			method: 'get',
			parameters: {jsp: jspName, gaId: galleryId, prdId: productId, moId:movieId, page: pageNumber, cId: catId, lId: lvlId},
			onComplete: checkAjxResponse
			});
	}
	
	function initIndexedPhotoPage(galleryId, maxPageNr) {
		if(window.location.hash==""){
			var nr = 1;
        }else{        	
    		var hashValue = window.location.hash;
            var nr = hashValue.replace("#","");  
            if(!nr.match(/^\d+$/)){
            	nr = 1;
            }
            if(nr > maxPageNr){
            	nr = 1;
            }
        }
		if(maxPageNr > 1){
			window.location.hash = nr;
		}
		if(nr>1){
			var pageIndex = nr - 1;
			updatePhotoPage('galleryPhotoItemAjx', 'galleryPhotoItemAjx', galleryId, nr, pageIndex);
		}else{
			updatePhotoPage('galleryPhotoItemAjx', 'galleryPhotoItemAjx', galleryId, '0', '0');
		}
	}
	
	
	function initPhotoPage(galleryId) {
		updatePhotoPage('galleryPhotoItemAjx', 'galleryPhotoItemAjx', galleryId, '0', '0');
	}
	
	function newPhotoPage(galleryId, pageNr) {
		window.location.hash = pageNr;
		var pageIndex = pageNr-1;
		updatePhotoPage('galleryPhotoItemAjx', 'galleryPhotoItemAjx', galleryId, pageNr, pageIndex);
	}
	
	function updatePhotoPage (divName, jspName, galleryId, pageNumber, pageIndex) {
		var myAjax = new Ajax.Updater(divName, '/ajax', {
			asynchronous: false,
			method: 'get',
			parameters: {jsp: jspName, gaId: galleryId, page: pageNumber, pageIndex:pageIndex},
			onComplete: checkAjxResponse
			});
	}
	
	
	
	function initPresentationItemsPage(galleryId, presentationId) {
		updatePresentationItemsPage('galleryPresentationItemAjx', 'galleryPresentationItemAjx', galleryId, presentationId, '1');
	}
	
	function newPresentationItemsPage(galleryId, presentationId, pageNr) {
		updatePresentationItemsPage('galleryPresentationItemAjx', 'galleryPresentationItemAjx', galleryId, presentationId, pageNr);
	}
	
	function updatePresentationItemsPage (divName, jspName, galleryId, presentationId, pageNumber) {
		var myAjax = new Ajax.Updater(divName, '/ajax', {
			asynchronous: false,
			method: 'get',
			parameters: {jsp: jspName, gaId: galleryId, prId:presentationId, page: pageNumber},
			onComplete: checkAjxResponse
			});
	}
	
	function initPresentationItemsProductPage(galleryId, productId, presentationId) {
		updatePresentationItemsProductPage('galleryPresentationProductItemAjx', 'galleryPresentationProductItemAjx', galleryId, productId, presentationId, '1');
	}
	
	function newPresentationItemsProductPage(galleryId, productId, presentationId, pageNr) {
		updatePresentationItemsProductPage('galleryPresentationProductItemAjx', 'galleryPresentationProductItemAjx', galleryId, productId, presentationId, pageNr);
	}
	
	function updatePresentationItemsProductPage (divName, jspName, galleryId, productId, presentationId, pageNumber) {
		var myAjax = new Ajax.Updater(divName, '/ajax', {
			asynchronous: false,
			method: 'get',
			parameters: {jsp: jspName, gaId: galleryId, prdId: productId, prId:presentationId, page: pageNumber},
			onComplete: checkAjxResponse
			});
	}
	
	
	
	function initAudioItemsPage(galleryId, audioId) {
		updateAudioItemsPage('galleryAudioItemAjx', 'galleryAudioItemAjx', galleryId, audioId, '1');
	}
	
	function newAudioItemsPage(galleryId, audioId, pageNr) {
		updateAudioItemsPage('galleryAudioItemAjx', 'galleryAudioItemAjx', galleryId, audioId, pageNr);
	}
	
	function updateAudioItemsPage (divName, jspName, galleryId, audioId, pageNumber) {
		var myAjax = new Ajax.Updater(divName, '/ajax', {
			asynchronous: false,
			method: 'get',
			parameters: {jsp: jspName, gaId: galleryId, auId:audioId, page: pageNumber},
			onComplete: checkAjxResponse
			});
	}
	
	function initAudioItemsProductPage(galleryId, productId, audioId) {
		updateAudioItemsProductPage('galleryAudioProductItemAjx', 'galleryAudioProductItemAjx', galleryId, productId, audioId, '1');
	}
	
	function newAudioItemsProductPage(galleryId, productId, audioId, pageNr) {
		updateAudioItemsProductPage('galleryAudioProductItemAjx', 'galleryAudioProductItemAjx', galleryId, productId, audioId, pageNr);
	}
	
	function updateAudioItemsProductPage (divName, jspName, galleryId, productId, audioId, pageNumber) {
		var myAjax = new Ajax.Updater(divName, '/ajax', {
			asynchronous: false,
			method: 'get',
			parameters: {jsp: jspName, gaId: galleryId, prdId: productId, auId:audioId, page: pageNumber},
			onComplete: checkAjxResponse
			});
	}
	
	
	
	function initRelatedGalleriesPage(galleryId) {
		updateRelatedGalleriesPage('galleryRelatedGalleriesAjx', 'galleryRelatedGalleriesAjx', galleryId, '1');
	}
	
	function newRelatedGalleriesPage(galleryId, pageNr) {
		updateRelatedGalleriesPage('galleryRelatedGalleriesAjx', 'galleryRelatedGalleriesAjx', galleryId, pageNr);
	}
	
	function updateRelatedGalleriesPage (divName, jspName, galleryId, pageNumber) {
		var myAjax = new Ajax.Updater(divName, '/ajax', {
			asynchronous: false,
			method: 'get',
			parameters: {jsp: jspName, gaId: galleryId, page: pageNumber},
			onComplete: checkAjxResponse
			});
	}
	
	
	
	function upadteThreadsList(divName,jspName,withExp,sort,pageThr,threadId, token){
			var myAjax = new Ajax.Updater(divName, '/ajax', {
			asynchronous: false,
			method: 'get',
			parameters: {jsp: jspName, carer: withExp, sort: sort, pageThr: pageThr,threadId: threadId, token:token},
			onComplete: checkAjxResponse
			});
	}
	
	function upadteExpertThreadsList(divName,jspName,withExp,sort,pageThr,threadId,expId){
			var myAjax = new Ajax.Updater(divName, '/ajax', {
			asynchronous: false,
			method: 'get',
			parameters: {jsp: jspName, carer: withExp, sort: sort, pageThr: pageThr,threadId: threadId, exId: expId},
			onComplete: checkAjxResponse
			});
	}
	
	function initTreadsList(withExp,sort,pageThr,threadId,token){
		upadteThreadsList('threadsListAjx','threadsListAjx',withExp,sort,pageThr,threadId,token);
	}
	
	function sortTreadsList(withExp,sort,page,threadId,showTabs,token){
		upadteThreadsList('threadsListAjx','threadsListAjx',withExp,sort,'1','',token);
		updateTreadTree('threadTreeAjx','threadTreeAjx','','','','false',showTabs,token);
	}
	
	function changeThreadsType(withExp,sort,threadId,token){
		upadteThreadsList('threadsListAjx','threadsListAjx',withExp,sort,'1',threadId,token);
	}
	
	function changeExpertThreadsType(withExp,sort,threadId,expId){
		upadteExpertThreadsList('expertForumsAjx','expertForumsAjx',withExp,sort,'1',threadId,expId);		
	}

	function newForumPage(withExp,sort,pageThr,threadId,token){
		upadteThreadsList('threadsListAjx','threadsListAjx',withExp,sort,pageThr,threadId,token);
	}
	
	function updateTreadTree(divName,jspName,threadId,page,withExp,moderation, showTabs, token){
		var myAjax = new Ajax.Updater(divName, '/ajax', {
			evalScripts:  true,
			asynchronous: false,
			method: 'get',
			parameters: {jsp: jspName, threadId : threadId, page : page, carer : withExp, moderation : moderation, showTabs : showTabs, token : token},
			onComplete: checkAjxResponse
			});
	}
	
	
	function newPostPage(withExp, page, threadId, moderation, showTabs, token){
		updateTreadTree('threadTreeAjx','threadTreeAjx',threadId,page,withExp,moderation,showTabs,token);		
	}
	
	
	
	function updateMyProfile(divName,jspName,tab,data,photoId,photoPageNr,animals){		
		var myAjax = new Ajax.Updater(divName, '/ajax', {
			evalScripts:  true,
			asynchronous: false,
			method: 'get',
			parameters: {jsp: jspName, tab: tab, data: data, photoId: photoId, photoPageNr: photoPageNr, animals: animals},
			onComplete: checkAjxResponse
			});
	}
	
	function updateMyPhotoProfile(divName,jspName,photoId,photoPageNr){		
		
		var myAjax = new Ajax.Updater(divName, '/ajax', {
			evalScripts:  true,
			asynchronous: false,
			method: 'get',
			parameters: {jsp: jspName, photoId: photoId, photoPageNr: photoPageNr},
			onComplete: checkAjxResponse
			});
	}
	
	function updateMyPhoto(divName,jspName,photoId,photoPageNr){		
		
		var myAjax = new Ajax.Updater(divName, '/ajax', {
			evalScripts:  true,
			asynchronous: false,
			method: 'get',
			parameters: {jsp: jspName, photoId: photoId, photoPageNr: photoPageNr},
			onComplete: checkAjxResponse
			});
	}
	
	
	
	function initMyProfile(tab){
		updateMyProfile('myProfileAjx','myProfileAjx',tab, 'general','','1','');
	}
	
	function changeTab(tab){		
		updateMyProfile('myProfileAjx','myProfileAjx',tab);
	}
	
	//funkcja obslugujaca stronicowanie zdjec do profilu;
	function newMyProfilePhotoPage(photoId, photoPageNr) {
		updateMyPhoto('myPhotoAjx', 'myPhotoAjx',photoId, photoPageNr);
	}
	
	//funkcja przelaczajaca na widok panelu ogolnego mojego profilu; 
	function myProfileShowGeneralDataPanel(){
		updateMyPhotoProfile('myDataPhotoAjx', 'myDataPhotoAjx','', '');
	}
	
	//funkcja przelaczajaca na widok panelu zdjec uzytkownika w moim profilu; 
	function myProfileShowPhotoPanel(photoId, photoPageNr){
		if (photoPageNr == null || photoPageNr == '') {
			photoPageNr = 1;
		}
		updateMyPhoto('myPhotoAjx', 'myPhotoAjx',photoId, photoPageNr);
	}
	
	//funkcja obslugujaca mechanizm wybrania zdjecia do mojego profilu;
	function myProfileSelectPhoto(photoId,photoPageNr) {
	
		var chosenPhotoId = document.getElementById('my_profile_photo_'+photoId);
		var otherPhotos = document.getElementsByClassName('my_profile_photo');
	
		//zmiana ramek wszystkich fotek na szare;
		for (var i=0; i<otherPhotos.length; i++) {
			
			otherPhotos[i].style.border = '1px solid #D9D9D9';
		}	
		//zmiana ramki na czerwona tylko wybranej foty;
		chosenPhotoId.style.border = '1px solid red';
		
		//wywoluje funkcje z updaterem aby wrzucic paramy do requestu;
		updateMyPhotoProfile('myDataPhotoAjx', 'myDataPhotoAjx',photoId, photoPageNr);
		updateMyPhoto('myPhotoAjx','myPhotoAjx',photoId, photoPageNr);
		
	}
	
	function myProfileShowPetsPanel(photoId,photoPageNr,animals){
		updateMyProfile('myProfileAjx', 'myProfileAjx', 'md', 'pets',photoId, photoPageNr,animals);
	}
	
	function myProfileSelectPets(photoId,photoPageNr){		
		var animals = selectedAnimals;		
		updateMyProfile('myProfileAjx', 'myProfileAjx', 'md', 'general',photoId, photoPageNr,animals);
	}
	function updateMyBookmarksPage (divName, jspName, pageNumber,currentLocation,userFacetContext,paramsFromUrl) {
		var myAjax = new Ajax.Updater(divName, '/ajax', {
			asynchronous: false,
			method: 'get',
			parameters: {jsp: jspName, page: pageNumber, currentLocation : currentLocation, userFacetContext : userFacetContext, paramsFromUrl : paramsFromUrl},
			onComplete: checkAjxResponse
			});
	}
	function updateBookmarks (divName, jspName, pageNumber, cPage) {
		var myAjax = new Ajax.Updater(divName, '/ajax', {
			asynchronous: false,
			method: 'get',
			parameters: {jsp: jspName, page: pageNumber, cPage: cPage},
			onComplete: checkAjxResponse
			});
	}
	function initMyBookmarkPage() {
		updateMyBookmarksPage('myBookmarksAjx', 'myBookmarksAjx','1');
	}
	function newMyBookmarkPage(pageNr,currentLocation,userFacetContext,paramsFromUrl) {
		updateMyBookmarksPage('myBookmarksAjx', 'myBookmarksAjx', pageNr, currentLocation, userFacetContext,paramsFromUrl);
	}
	function newHistoryPage(nr) {
		updateMyBookmarksPage('myHistoryAjx', 'myHistoryAjx',nr);
	}
	function newBookmarkFromHistory(nr,cPage) {
		updateBookmarks('addBookmarkFromHistory', 'addBookmarkFromHistory',nr,cPage);
	}
	/*
	function newHistoryPage(pageNr,currentLocation,userFacetContext,paramsFromUrl) {
		updateMyBookmarksPage('myHistoryAjx', 'myHistoryAjx', pageNr, currentLocation, userFacetContext,paramsFromUrl);
	}
	*/
	function updateProductTree(divName, jspName, level1, level2, level3, tabNr){
		var myAjax = new Ajax.Updater(divName, '/ajax', {
			evalScripts:  true,
			asynchronous: false,
			method: 'get',
			parameters: {jsp: jspName, level1: level1, level2: level2, level3: level3, tabNr: tabNr},
			onComplete: checkAjxResponse
			});
	}
	function expandLevel(levelNr, value, tabNr, ajxLoc) {
		var l1 = null;
		var l2 = null;
		var l3 = null;
		switch(levelNr) {
			case 1:
				l1 = value;
			break;
			case 2:
				l2 = value;
			break;
			case 3:
				l3 = value;
			break;
		}
		updateProductTree('treeDiv','productTreeAjax',l1,l2,l3,tabNr,ajxLoc);
	}
	function gratisExpandLevel(levelNr, value, tabNr) {
		var l1 = null;
		var l2 = null;
		var l3 = null;
		switch(levelNr) {
			case 1:
				l1 = value;
			break;
			case 2:
				l2 = value;
			break;
			case 3:
				l3 = value;
			break;
		}
		updateProductTree('gratisTreeDiv','gratisTreeAjax',l1,l2,l3,tabNr);
	}
	function updateProductTreePages(divName, jspName, pageNr, parentId, level) {
		var myAjax = new Ajax.Updater(divName, '/ajax', {
			asynchronous: false,
			method: 'get',
			parameters: {jsp: jspName, page: pageNr, parentId: parentId, level: level},
			onComplete: checkAjxResponse
			});
	}
	function chgPTnewProductPage(pageNr, parentId, level) {
		updateProductTreePages('pt_show_product', 'ptNewProductAjx', pageNr, parentId, level);
	}
	function chgPTpromotionProductPage(pageNr, parentId, level) {
		updateProductTreePages('pt_show_product', 'ptPromotionProductAjx', pageNr, parentId, level);
	}
	function chgPTpopularProductPage(pageNr, parentId, level) {
		updateProductTreePages('pt_show_product', 'ptPopularProductAjx', pageNr, parentId, level);
	}
	
	function updateMyQuestionsPage(divName, jspName, pageNumber) {
		var myAjax = new Ajax.Updater(divName, '/ajax', {
			asynchronous: false,
			method: 'get',
			parameters: {jsp: jspName, page: pageNumber},
			onComplete: checkAjxResponse
			});
	}
	
	function initMyQuestionsPage() {
		updateMyQuestionsPage('myQuestionsAjx', 'myQuestionsAjx','1');
	}
	
	function newMyQuestionsPage(pageNr) {
		updateMyQuestionsPage('myQuestionsAjx', 'myQuestionsAjx', pageNr);
	}
	
	function showLoader(elementId) {
		if(document.getElementById(elementId)){
			var el = document.getElementById(elementId);
			el.innerHtml = "<img src='/images/common/small_loader.gif'>";
		}
	}
	function selectAnswer(divId) {		
		if($('select'+divId).checked == true) {
			$('select'+divId).checked = false;
		}
		else {
			$('select'+divId).checked = true;
		}
	}
	function selectNewsletterAllow(obj) {		
		if($('agrEcomm').checked == false && obj.checked == true) {
			$('agrEcomm').checked = true;
		}
	}
	
	function updateProductsZoneBox(divName, jspName, pageNumber, activeTab, token, cId, lId) {
		var myAjax = new Ajax.Updater(divName, '/ajax', {
			asynchronous: false,
			evalScripts:  true,
			method: 'get',
			parameters: {jsp: jspName, page: pageNumber, activeTab: activeTab, token: token, cId: cId, lId: lId},
			onComplete: checkAjxResponse
			});
	}
	
	function updateProductsZoneTabs(divName, jspName, cId, lId, activeTab, prId) {
		window.location.hash = activeTab;
		var myAjax = new Ajax.Updater(divName, '/ajax', {
			asynchronous: false,
			evalScripts:  true,
			method: 'get',
			parameters: {jsp: jspName, cId: cId, lId: lId, activeTab: activeTab, prId: prId},
			onComplete: checkAjxResponse
			});
		switch(parseFloat(activeTab)) {
			default:
				document.getElementById("pz_title_bg").style. backgroundImage = "url('/images/products_zone/header_all.gif')";
			break;
			case 1:
				document.getElementById("pz_title_bg").style. backgroundImage = "url('/images/products_zone/header_all.gif')";
			break;
			case 2:
				document.getElementById("pz_title_bg").style. backgroundImage = "url('/images/products_zone/header_top.gif')";				
			break;
			case 3:
				document.getElementById("pz_title_bg").style. backgroundImage = "url('/images/products_zone/header_nowosci.gif')";				
			break;
			case 4:
				document.getElementById("pz_title_bg").style. backgroundImage = "url('/images/products_zone/header_promocje.gif')";
			break;
		}
	}
	
	function initPZProductTabs(cId, lId, activeTab, prId) {
		if(window.location.hash == "") {
			window.location.hash = activeTab;
		}
		else {
			var hashValue = window.location.hash;
            var activeTab = hashValue.replace("#","");  
            if(!activeTab.match(/^\d+$/)){
            	activeTab = 1;
            }
            if(activeTab > 4){
            	activeTab = 1;
            }
		}
		updateProductsZoneTabs("pz_products_box_tabs_ajx", "productsZoneTabsAjx", cId, lId, activeTab, prId);
	}
	
	function newProductsZoneBox(pageNumber, activeTab, token, cId, lId) {
		window.location.hash = activeTab;
		updateProductsZoneBox("pz_products_box_ajx", "productsZoneBoxAjx", pageNumber, activeTab, token, cId, lId);
		updateProductsZoneTabs("pz_products_box_tabs_ajx", "productsZoneTabsAjx", cId, lId, activeTab, null);
	}
	
	function initProductsZoneBox(pageNumber, activeTab, token, cId, lId) {
		if(window.location.hash == "") {
		}
		else {        	
    		var hashValue = window.location.hash;
            var activeTab = hashValue.replace("#","");  
            if(!activeTab.match(/^\d+$/)){
            	activeTab = 1;
            }
            if(activeTab > 4){
            	activeTab = 1;
            }
        }
        newProductsZoneBox(pageNumber, activeTab, token, cId, lId);
	}
	function updateProductsZoneDocs(divName, jspName, pageNumber) {
		var myAjax = new Ajax.Updater(divName, '/ajax', {
			asynchronous: false,
			evalScripts:  true,
			method: 'get',
			parameters: {jsp: jspName, page: pageNumber},
			onComplete: checkAjxResponse
			});
	}
	
	function newProductsZoneDocsPage(pageNumber) {
		updateProductsZoneDocs("pz_related_docs_ajx", "productsZoneDocsAjx", pageNumber);
	}
	
	function updatePZProductAdditionalPage(divName, jspName, page, boxType, prId) {
		var myAjax = new Ajax.Updater(divName, '/ajax', {
			asynchronous: false,
			evalScripts:  true,
			method: 'get',
			parameters: {jsp: jspName, page: page, boxType: boxType, prId: prId},
			onComplete: checkAjxResponse
			});
	}
	
	function newPZProductRelatedPage(page, prId) {
		updatePZProductAdditionalPage("pz_product_related_ajx","productsZoneAdditionalProductsAjx", page, 1, prId);
	}
	
	function newPZProductSimilarPage(page, prId) {
		updatePZProductAdditionalPage("pz_product_similar_ajx","productsZoneAdditionalProductsAjx", page, 0, prId);
	}
	
	function newPZProductComplementaryPage(page, prId) {
		updatePZProductAdditionalPage("pz_product_complementary_ajx","productsZoneAdditionalProductsAjx", page, 2, prId);
	}
	
	function newPZProductAlternativePage(page, prId) {
		updatePZProductAdditionalPage("pz_product_alternative_ajx","productsZoneAdditionalProductsAjx", page, 3, prId);
	}
	
	
	function updatePZTopProducts(divName, jspName, page) {
		var myAjax = new Ajax.Updater(divName, '/ajax', {
			asynchronous: false,
			evalScripts:  true,
			method: 'get',
			parameters: {jsp: jspName, page: page},
			onComplete: checkAjxResponse
			});
	}
	
	function newPZTopProductsPage(page) {
		updatePZTopProducts("pz_product_top_products_ajx","productsZoneTopProductsAjx", page);
	}
	
	function updatePZProductPhoto(divName, jspName, page, miniPage, prId) {
		var myAjax = new Ajax.Updater(divName, '/ajax', {
			asynchronous: false,
			evalScripts:  true,
			method: 'get',
			parameters: {jsp: jspName, page: page, miniPage: miniPage,  prId: prId},
			onComplete: checkAjxResponse
			});
	}
	
	function productPhotoPopup(prId) {
		if(prId != null) {
			$('pz_products_photo_ajx').style.display = 'block';
			$('pz_products_photo_ajx').style.top = document.viewport.getScrollOffsets()[1]-370+'px';
			updatePZProductPhoto('pz_products_photo_ajx', 'productsZoneProductPhotoAjx', 1, 1, prId);
			$('search_input_small_div_inner').style.display = 'none';
			showShadowLayer();
		}
		else {
			$('pz_products_photo_ajx').style.display = 'none';
			hideShadowLayer();
			$('search_input_small_div_inner').style.display = 'block';
		}
	}
	
	function newPZProductPhotoPage(page, miniPage,  prId) {
		updatePZProductPhoto('pz_products_photo_ajx', 'productsZoneProductPhotoAjx', page, miniPage, prId);
	}
	
	function updatePZProductDetailsTab(divName, jspName, prId, tab) {
		var myAjax = new Ajax.Updater(divName, '/ajax', {
			asynchronous: false,
			evalScripts:  true,
			method: 'get',
			parameters: {jsp: jspName, prId: prId, tab: tab },
			onComplete: checkAjxResponse
			});
	}
	
	function newPZProductDetailsTab(prId, tab) {
		updatePZProductDetailsTab('pz_pd_bottom_tabs_box_ajx', 'productsZoneProductDetailsTabs', prId,  tab);
	}
	
	function updatePZProductDetailsAdvertTab(divName, jspName, prId, tab, galId, movId, cId, lId) {		
		var myAjax = new Ajax.Updater(divName, '/ajax', {
			asynchronous: false,
			evalScripts:  true,
			method: 'get',
			parameters: {jsp: jspName, prId: prId, tab: tab, gaId: galId, moId: movId, cId: cId, lId: lId },
			onComplete: checkAjxResponse
			});
	}
	
	function newPZProductDetailsAdvertTab(prId, tab, galId, movId, cId, lId) {
		updatePZProductDetailsAdvertTab('pz_pd_bottom_tabs_box_ajx', 'productsZoneProductDetailsTabs', prId,  tab, galId, movId, cId, lId);
	}
	
	
	
	function updateEventTimeBoxes(divName, jspName, eventId, choosePos) {
		var myAjax = new Ajax.Updater(divName, '/ajax', {
			asynchronous: false,
			evalScripts:  true,
			method: 'get',
			parameters: {jsp: jspName, eventId: eventId, choosePos: choosePos},
			onComplete: checkAjxResponse
			});
	}
	
	function newEventTimeBoxes(eventId, choosePos) {
		updateEventTimeBoxes('event_time_boxes_ajx', 'eventTimeBoxesAjx', eventId, choosePos);
	}