function logoutOperatorCallback() {}

function logoutCustomerCallback() {}

function addServiceWithProductToCart(productId, serviceId, addedFrom) {
	document.location.href = '/add-to-cart.bhtml?productId='+productId+'&F_ACTION=ADD_SERVICES_WITH_PRODUCT&serviceIds=' + serviceId + '&addedFrom=' + addedFrom;
}

function addServiceWithSuiteToCart(productId, suiteId, serviceId, addedFrom) {
	document.location.href = '/add-to-cart.bhtml?productId='+productId+'&suiteId='+suiteId+'&F_ACTION=ADD_SERVICES_WITH_SUITE&serviceIds=' + serviceId + '&addedFrom=' + addedFrom;
}

function boksyPolecamy (contener) {
	var blockWidth = "";
	var divList = contener.getElementsByTagName("DIV");
	var divCount = divList.length;
	var regexp1 = /productShortBox/;
	var containerWidth=contener.clientWidth;
	var ieVer=IEversion();
	if (containerWidth==0) 
		containerWidth = contener.offsetWidth;
	if ( 764 > containerWidth  ){
		if (ieVer == 6)
			blockWidth="31%";
		else
			blockWidth="31.4%";
	}
	else {
		blockWidth="23%";
	}
	for (var i=0; i<divCount; i++){
		if (regexp1.exec(divList[i].className)){
			divList[i].style.width=blockWidth;
			
		}
	}


}

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 get_cookie(name) {
	return readCookie(name);
}
	
function createCookie(name,value)
{
	var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}
	
function createCookie(name,value,days)
		{
			if (days)
			{
				var date = new Date();
				date.setTime(date.getTime()+(days*24*60*60*1000));
				var expires = "; expires="+date.toGMTString();
			}
			else var expires = "";
			document.cookie = name+"="+value+expires+"; path=/";
}
function eraseCookie(name)
		{
			createCookie(name,"",-1);
}

function goBack() {
	value=readCookie('refpage');
	
	if (value!=null) document.location=value;
		else document.location="/";
}

function addToCard(prodId, prodTitle, addedFrom, toCart) {

		if (!document.getElementById('basket-small')) {
		
			document.location.href = '/'+'add-to-cart.bhtml?prod_id='+prodId+'&addedFrom='+addedFrom;
			return false;
		}
		
		new Ajax.Request('/'+'add-and-refresh-cart.bhtml', 
		{ 
			method:'post',  
			parameters: {F_ACTION: 'ADD_PRODUCT', productId: prodId, addedFrom: addedFrom, toCart: toCart},
			onSuccess: function(transport){
				document.getElementById('basket-small').innerHTML = transport.responseText;      				
  				
				// jesli dodawane jest akcesorium, nie chcemy wyskakujacego powiadomienia;
				// wprzypadku akcesoriow nie byla wykorzystywany argument toCart, wiec zaadaptowany zostal
				// do powyzszego celu
				if (toCart != "ole_acc")
					showNotify(prodTitle, '',toCart);   

			},
			onFailure: function() { 
			
			}
		});
	
	return false;
}



function addSuiteToCard(suiteId, prodId, suiteName, addedFrom) {
		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, addedFrom: addedFrom},
			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 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 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+'">'+mp_wrap.children('a').html()+'</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;

}

/*zerowy etap koszyka */
function addWarrantyAndRefresh(contentId, warrantyId, warrantyName, addedFrom) {

	if(warrantyId) {

		new Ajax.Request('/'+'addWarrantyAndRefresh.ltr',
			{
			method: 'post',
			parameters: {contentId: contentId, warrantyId: warrantyId, addedFrom: addedFrom},
			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 addServiceAndRefresh(contentId, isSuite, serviceId, serviceName, addedFrom) {
	new Ajax.Request('/'+'addServiceAndRefresh.ltr',
	{
		method: 'post',
		parameters: {contentId: contentId, isSuite: isSuite, serviceId: serviceId, addedFrom: addedFrom},
		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) {
	new Ajax.Request('/addServiceAndRefresh.ltr',
	{
		method: 'post',
		parameters: {contentId: contentId, isSuite: isSuite, serviceId: serviceId},
		onSuccess: function(transport) {
			
			document.getElementById('serviceArea').innerHTML = transport.responseText;
			refreshCart(true);	
			showNotifyAndGoToCart(serviceName, '',true, whereToGo);	
		},
		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() {
		
		}
	});
}

/*koniec zerowego etau */

function addToCartSmsService() {
	
	var isSmsNotify = document.getElementById('smsNotification');
	if(isSmsNotify.checked) {
		var f_action = 'ADD_SMS_SERVICE';
	}
	else {
		var f_action = 'REMOVE_SMS_SERVICE';
	}
		
	new Ajax.Request('/refresh-order-info.ltr', 
			{ 
				method:'post',  
				parameters: {F_ACTION: f_action, inactive: true, stage: 3},
				onSuccess: function(transport){
					document.getElementById('basket-small').innerHTML = transport.responseText;      				
				},
				onFailure: function() { 
				
				}
			});
		
		return false;
}

function selectPaymentTypeInCart(paymentType) {
	
	new Ajax.Request('/refresh-order-info.ltr', 
			{ 
				method:'post',  
				parameters: {F_ACTION: 'SELECT_PAYMENT_TYPE', paymentTypeCode: paymentType, inactive: true, stage: 4},
				onSuccess: function(transport){
					document.getElementById('basket-small').innerHTML = transport.responseText;      				
				},
				onFailure: function() { 
				
				}
			});
		
		return false;
}

/* wyskakujace warstwy z tekstem */
function topMargin() {
	var margin ='';
	if (document.documentElement && !document.documentElement.scrollTop)
	 	margin=250;
	else if (document.documentElement && document.documentElement.scrollTop)
		margin=150+document.documentElement.scrollTop;
	return margin;
}
function IEversion () {
	if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)){ //test for MSIE x.x;
 	var ieversion=new Number(RegExp.jQuery1) // capture x.x portion and store as a number
 	if (ieversion<7)
  		return 6;
 	else 
 		return null; 
	}
}


function showNotify(prodTitle, msg, toCart) {
	var marginTop =topMargin();
	var ieVer=IEversion();

	height = (navigator.appName.indexOf("Netscape") != -1) ? pageYOffset + (innerHeight/2) - 100 : marginTop + (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: marginTop + document.body.clientHeight) +'px';

	notify = document.createElement('div')
	notify.id = "addToCartAlert";

	if (ieVer ==6){
		ifr = document.createElement('iframe');
		ifr.id = "alertIfr";
		ifr.frameBorder = "0";
		ifr.style.top = marginTop;
		ifr.setAttribute('allowtransparency',true);
		ifr.style.zIndex=0;
	}
	var mainBlock = document.createElement('div');
	mainBlock.id="alertContener";
	mainBlock.className='mainBlock';
	mainBlock.innerHTML='<img src="/images/ole/mainBlockTL.gif" alt="" class="tl"/><img src="/images/ole/mainBlockTR.gif" alt="" class="tr"/><h1>Dodałeś do koszyka:</h1><h2>'+prodTitle+'</h2>';
	
	
	pClose = document.createElement('img');
	pClose.src="/images/www/spacer.gif"
	pClose.onclick = function() {hideNotify();};

	for(var j=0; j < msg.length; j++) {
		pService = document.createElement('h2');
		//pService.id = "alertProdTitle"
		pServiceText = document.createTextNode(msg[j]);
		pService.appendChild(pServiceText);
		mainBlock.appendChild(pService);
	}	
	//notify.appendChild(pContener);
	var buttons = document.createElement('div');
	if (toCart) {
		buttons.innerHTML ='<span onclick="hideNotify()" class="ok" onmouseover="this.className=\'okOver\'" onmouseout="this.className=\'ok\'"> </span>' ;
		mainBlock.appendChild(buttons);
	}
	else {
		buttons.innerHTML ='<span onclick="hideNotify()" class="kontynuuj" onmouseover="this.className=\'kontynuujOver\'" onmouseout="this.className=\'kontynuuj\'"> </span> <a href="/cart.bhtml" class="zamawiam"> </a> <br class="clear" />' ;
		mainBlock.appendChild(buttons);
	}
	

	notify.style.marginTop=marginTop +'px'; 
	mainBlock.innerHTML=mainBlock.innerHTML + '<img src="/images/ole/mainBlockBL.gif" alt="" class="bl"/><img src="/images/ole/mainBlockBR.gif" alt="" class="br"/>';
	notify.appendChild(mainBlock);
	notifyLayer.appendChild(notify);
	if (ieVer==6)
		notifyLayer.appendChild(ifr);

	document.getElementById("top").appendChild(notifyLayer);	
	document.getElementById("container").onclick = function() {hideNotify();};
	if (ieVer ==6) {
		notify.style.marginLeft='-' + notify.clientWidth/2 + 'px';
		ifr.style.marginLeft='-' + notify.clientWidth/2 + 'px';
		ifr.style.height=notify.clientHeight;
		ifr.style.width=notify.clientWidth;	
	}
}

var newLayer = {
	msqUrl :null,
	className : null,
	evt :null,
	hide : null,
	content : null,
	marginTop : null,
	height : null, 

	setMarginTop : function () {
		if (document.documentElement && !document.documentElement.scrollTop)
		 	this.marginTop=250;
		else if (document.documentElement && document.documentElement.scrollTop)
			this.marginTop=150+document.documentElement.scrollTop;
		},
		
	setupDimensions : function() {
		
		var height =(navigator.appName.indexOf("Netscape") != -1) ? pageYOffset + (innerHeight/2) : this.marginTop + (document.body.clientHeight/2)-200 +'px';
		document.getElementById('infoLayer').style.marginTop= this.marginTop +'px';
		document.getElementById('alertLayer').style.height= parseInt(height) + 'px';
		document.getElementById(this.className).style.width= document.getElementById('infoLayer').clientWidth - 24 +'px';
	},
	_killBubble : function (){
	    (window.event)?window.event.cancelBubble = true:this.evt.cancelBubble = true;	
	},
	initialize : function (){
		hideNotify();
		this.setMarginTop();
		this._killBubble();	
		notifyLayer = document.createElement('div');
		notifyLayer.id = "alertLayer";
		notifyLayer.className=this.className;
		(this.hide)?notifyLayer.onclick = function () {hideNotify();}:notifyLayer.onclick = function () {return;};
		var notify = document.createElement('div')
		notify.id = "infoLayer";
		notify.className=this.className;
		if (this.hide)
			notify.innerHTML='<div class="infoLayerTop tright" onclick="hideNotify();"></div><iframe id="'+this.className+'" frameborder="0"></iframe>';
		else
			notify.innerHTML='<div class="infoLayerTop infoLayerTopClose" onclick="hideNotify();" id="closeLayer"> zamknij X </div><iframe id="'+this.className+'" frameborder="0" ></iframe>';
		notifyLayer.appendChild(notify);
		document.getElementById("top").appendChild(notifyLayer);
		this.setupDimensions();	
		document.getElementById(this.className).src=this.msgUrl;	
	},

	createIframe : function (className, msgUrl, evt, hide){
		this.className=className;
		this.msgUrl=msgUrl;
		this.evt=evt;
		this.hide=hide;
		this.initialize();
	}	
}

function hideNotify() {
	node = document.getElementById('alertLayer')
	if (node) {
		document.getElementById("top").removeChild(node);
	}
}	

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;
        
	var marginTop =topMargin();
	var ieVer=IEversion();
	 
	height = (navigator.appName.indexOf("Netscape") != -1) ? pageYOffset + (innerHeight/2) : marginTop + (document.body.clientHeight/2)-200 +'px';
	
	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: marginTop + document.body.clientHeight -200) +'px';

	
	notify = document.createElement('div')
	notify.id = "infoLayer";
	notify.className=className;
	if (window.event && ieVer ==6){
		ifr = document.createElement('iframe');
		ifr.id = "alertIfr";
		ifr.frameBorder = "0";
		ifr.style.top = marginTop;
		ifr.setAttribute('allowtransparency',true);
		ifr.style.display='none';
	}	
	
	
	
	pContener = document.createElement('div');
	pContener.id="alertContener";

		
	notify.appendChild(pContener);
	if (window.event && ieVer ==6)			
		notifyLayer.appendChild(ifr);
	notifyLayer.appendChild(notify);

	var container = document.getElementById("container")?document.getElementById("container"):document.getElementById("smallContainer");
	
	document.getElementById("top").appendChild(notifyLayer);	
	/*if (hide) container.onclick = function() {hideNotify();};
	else container.onclick = function () {return;};*/
	//document.getElementById('infoLayer').style.display='none';
	if (window.event && ieVer ==6)
		ifr.style.display='block';

	getInfoText (msgUrl,'alertContener',marginTop, ieVer);	

	setTimeout(function() {jQuery('#infoLayer span.noThanks').click(function() {
		startTooltip2();
	})}, 50);
}

/* warranty encouragement */
function showAjaxPopup (className, msgUrl, evt){
    if (window.event)
        window.event.cancelBubble = true;
    else
        evt.cancelBubble = true;
        
	var marginTop =topMargin();
	var ieVer=IEversion();
	 
	height = (navigator.appName.indexOf("Netscape") != -1) ? pageYOffset + (innerHeight/2) : marginTop + (document.body.clientHeight/2)-200 +'px';
	
	hideNotify();	
	notifyLayer = document.createElement('div')
	notifyLayer.id = "alertLayer";
	notifyLayer.className=className;
	notifyLayer.style.height =((navigator.appName.indexOf("Netscape") != -1) ? pageYOffset + innerHeight: marginTop + document.body.clientHeight -200) +'px';

	
	notify = document.createElement('div')
	notify.id = "infoLayer";
	notify.className=className;
	if (ieVer ==6){
		ifr = document.createElement('iframe');
		ifr.id = "alertIfr";
		ifr.frameBorder = "0";
		ifr.style.top = marginTop;
		ifr.setAttribute('allowtransparency',true);
		ifr.style.display='none';
	}	
	
	
	
	pContener = document.createElement('div');
	pContener.id="alertContener";

		
	notify.appendChild(pContener);
	if (ieVer ==6)			
		notifyLayer.appendChild(ifr);
	notifyLayer.appendChild(notify);

	document.getElementById("top").appendChild(notifyLayer);	
	document.getElementById("container").onclick = function() {hideNotify();};
	//document.getElementById('infoLayer').style.display='none';
	if (window.event && ieVer ==6)
		ifr.style.display='block';

	getInfoText (msgUrl,'alertContener',marginTop, ieVer);	
	document.getElementById('container').onclick='';
	
}

function showNotifyAndGoToCart(prodTitle, msg, toCart, whereToGo) {

	var marginTop =topMargin();
	var ieVer=IEversion();

	height = (navigator.appName.indexOf("Netscape") != -1) ? pageYOffset + (innerHeight/2) - 100 : marginTop + (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: marginTop + document.body.clientHeight) +'px';

	notify = document.createElement('div')
	notify.id = "addToCartAlert";

	if (window.event && ieVer ==6){
		ifr = document.createElement('iframe');
		ifr.id = "alertIfr";
		ifr.frameBorder = "0";
		ifr.style.top = marginTop;
		ifr.setAttribute('allowtransparency',true);
	}
	var mainBlock = document.createElement('div');
	mainBlock.id="alertContener";
	mainBlock.className='mainBlock';
	mainBlock.innerHTML='<img src="/images/ole/mainBlockTL.gif" alt="" class="tl"/><img src="/images/ole/mainBlockTR.gif" alt="" class="tr"/><h1>Dodałeś do koszyka:</h1><h2>'+prodTitle+'</h2>';
	
	
	pClose = document.createElement('img');
	pClose.src="/images/www/spacer.gif"
	pClose.onclick = function() {hideNotify();
	if (whereToGo !="goBack") {
			document.location.href = whereToGo;
		} else {
			goBack();
		}};

	for(var j=0; j < msg.length; j++) {
		pService = document.createElement('h2');
		//pService.id = "alertProdTitle"
		pServiceText = document.createTextNode(msg[j]);
		pService.appendChild(pServiceText);
		mainBlock.appendChild(pService);
	}	
	//notify.appendChild(pContener);
	var buttons = document.createElement('div');
	if (toCart) {
		buttons.innerHTML ='<span onclick="function () {hideNotify(); if (whereToGo !="goBack") {	document.location.href = whereToGo;} else {	goBack();}};" class="ok" onmouseover="this.className=\'okOver\'" onmouseout="this.className=\'ok\'"> </span>' ;
		mainBlock.appendChild(buttons);
	}
	else {
		buttons.innerHTML ='<span onclick="hideNotify()" class="kontynuuj" onmouseover="this.className=\'kontynuujOver\'" onmouseout="this.className=\'kontynuuj\'"> </span> <a href="/cart.bhtml" class="zamawiam"> </a> <br class="clear" />' ;
		mainBlock.appendChild(buttons);
	}
	

	notify.style.marginTop=marginTop +'px'; 
	mainBlock.innerHTML=mainBlock.innerHTML + '<img src="/images/ole/mainBlockBL.gif" alt="" class="bl"/><img src="/images/ole/mainBlockBR.gif" alt="" class="br"/>';				
	notify.appendChild(mainBlock);
	notifyLayer.appendChild(notify);
	

	document.getElementById("top").appendChild(notifyLayer);	
	document.getElementById("container").onclick = function() {hideNotify();
		if (whereToGo !="goBack") {
			document.location.href = whereToGo;
		} else {
			goBack();
		}};
	
	if (ieVer ==6) {
		ifr.style.height=notify.clientHeight;
		ifr.style.width=notify.clientWidth;
		notify.style.marginLeft='-' + notify.clientWidth/2 + 'px';
		ifr.style.marginLeft='-' + notify.clientWidth/2 + 'px';
		notifyLayer.appendChild(ifr);
	}
}

function addWarrantyAndGoToCart(contentId, warrantyId, warrantyName, whereToGo, addedFrom) {

	new Ajax.Request('/'+'addWarrantyAndRefresh.ltr',
	{
		method: 'post',
		parameters: {contentId: contentId, warrantyId: warrantyId, addedFrom: addedFrom},
		onSuccess: function(transport) {
			
			document.getElementById('warrantyArea').innerHTML = transport.responseText;
			refreshCart(true);	
			showNotifyAndGoToCart(warrantyName, '',true, whereToGo);	
		},
		onFailure: function() { 

		}
	});
	
	return false;
}

function getInfoText (address, id,offsetTop, ieVer) {
	ifr = document.getElementById('alertIfr');
	info = document.getElementById('infoLayer');
	new Ajax.Request(address, 
		{ 
			method:'post',  
			onSuccess: function(transport){
				document.getElementById(id).innerHTML=transport.responseText;     				
				if (ieVer ==6) {
					ifr.style.height=info.clientHeight;
					ifr.style.width=info.clientWidth;
					info.style.marginLeft='-' + info.clientWidth/2 + 'px';
					ifr.style.marginLeft='-' + info.clientWidth/2 + 'px';
				}
				info.style.marginTop=offsetTop +'px'; 
				
			},
			onFailure: function() { 
				
			}
		});
}
/* koniec warstw */

/*zmiana i ustawienia wielkosci bloczka z widokow listowych produktow */
function changeProductBlockSize (selectSize)  {	
	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 (classNameShort.exec(divList[0].className)){
			document.getElementById('large').selected=true;
			cookieProductSizeValue='bigProduct';
		} 
		else if  (className.exec(divList[0].className)) {
			document.getElementById('small').selected=true;
			cookieProductSizeValue='smallProduct';
		}
	} else {
		//nie ma elementów na liście a więc przepisujemy wartość cookie
		cookieProductSizeValue = readCookie('euroProductSize');
		if (cookieProductSizeValue) {
			if (cookieProductSizeValue == 'bigProduct') {
				document.getElementById('large').selected=true;	
			}
		} else {
			//pierwsza wizyta na stronie nie ma jeszcze cookie
			cookieProductSizeValue='smallProduct mainBlock';
			document.getElementById('small').selected=true;
		}
	}
	
	for (i=0; i<divListCount; i++){
		if (classNameShort.exec(divList[i].className)){			
			if (classNameLast.exec(divList[i].className))
				divList[i].className='product last mainBlock';
			else
				divList[i].className='product mainBlock';				
		}
		else if  (className.exec(divList[i].className)) {	
			if (classNameLast.exec(divList[i].className))
				divList[i].className='shortproduct last mainBlock';
			else
				divList[i].className='shortproduct mainBlock';
		}
	}
	
	
	createCookie('euroProductSize',cookieProductSizeValue);

}

function checkProductSize() {
	productSize = readCookie('euroProductSize');
	if (productSize && productSize=='bigProduct') {
		changeProductBlockSize(document.getElementById('productBlockSize'));	
	}
}

/*koniec wielkosci bloczka */


/* funkcje dla selekcji */
function zaznacz(obj) {
	if (obj.className=='active')
		obj.className='';
	else 
		obj.className='active';
}
/* koniec funkcje dla selekcji */

function showHide(obj){
	if (obj.className=="hide")
		obj.className="show";
	else 
		obj.className="hide";
}
/* zawijanie menu coby nie wystawalo zbytnio na prawo */


moveToRight = function() {
	var winW ='';
	 if (navigator.appName.indexOf("Microsoft")!=-1) 
		  winW = document.body.offsetWidth;
 	 else 
		  winW = window.innerWidth;
	try {
		var sfEls = document.getElementById("nav").getElementsByTagName("LI"); 
		for (var i=0; i<sfEls.length; i++) {
			ul=sfEls[i].getElementsByTagName("UL");
			if (ul.length>0){
				var width='';
				var regexp1 = /col1/;
				var regexp2 = /col2/;				
				var regexp3 = /col3/;
				if 	(regexp1.exec(ul[0].className))			
					width="200";
				if 	(regexp2.exec(ul[0].className))			
					width="360";				
				if 	(regexp3.exec(ul[0].className))			
					width="540";				
			 	if (parseInt(sfEls[i].offsetLeft) > (winW - width) ){
					ul[0].className+=" fromRight"; 
				}
			}
		}
	}
	catch(err){
	}
		
}
	
	if (window.addEventListener){
		window.addEventListener('load', moveToRight, false);
	} else {
	if (window.attachEvent) {
		window.attachEvent("onload", moveToRight);
	}
}	
function notifyFriend1(params){
		
		var sLocation = document.location.href;
		if( sLocation.indexOf("?") == -1 ) sLocation ;
		else sLocation;
		if (params==null) params="";
		var s = "/ole_notify_friend_window_b24.xml";
			//s += "&amp;" + params;

			new Ajax.Request(s, {
				  method: 'get',
				  parameters: {document_href: escape( sLocation ), limit: 12},
				  onSuccess: function(transport){ 
                  document.getElementById('polec_error').innerHTML=transport.responseText;
                  },
				  onFailure: function(){ 
						  alert('Ładowanie przerwane');
						  document.getElementById('polec_error').className='';
						  document.getElementById('polec_green').className='zglos_blad';
					  }
				  });
			
		document.getElementById('polec_green').className='zglos_blad_grube';
		document.getElementById('polec_error').className='show';
		document.getElementById('zglos_error').className='';
		document.getElementById('zglos_blad').className='zglos_blad';
}
function notifyFriend(params,event)	{
		var sLocation = document.location.href;
		if( sLocation.indexOf("?") == -1 ) sLocation ;
		else sLocation;
		if (params==null) params="";
		var s = "/ole_notify_friend_window.xml";
			s += "?document_href=" + escape( sLocation );
			s += "&amp;" + params;
		newLayer.createIframe('notifyFriend',s,event,false);
	   }

/* musi byc synchronicznie */
function validateEmail(mail) {
	var returnValue = false;
	jQuery.ajax({
		  url: "/emailValidationTools.ltr",
		  dataType: 'json',
		  data: { email: mail},
		  async: false,
		  success:	function(data) {
			  if (data.correct == 'true') {
				  returnValue = true;
			  }
		  	},
		  error: function(e, xhr){
		  	}
		});
	return returnValue;
}

function logCustomerVisit(referer, currentUrl) {
	
	jQuery.ajax({
		url:'/log-customer-visit.ltr?type=CUSTOMER' + '&referer=' + referer + '&landing_page=' + currentUrl,
		method:'post', 
		cache:false,
		data: {},
		success: function(html){
		}
	});
}

function logProductVisit(productId, suiteId, referer, currentUrl) {
	
	jQuery.ajax({
		url:'/log-customer-visit.ltr?type=PRODUCT' + '&productId=' + productId + '&suiteId=' + suiteId +'&referer=' + referer
				+ '&landing_page=' + currentUrl,
		method:'post', 
		cache:false,
		data: {},
		success: function(html){
		}
	});
}	


function precartStart(){
	jQuery('input.acc').click(function(){
		if(jQuery(this).attr('checked')){
			//alert('usuwanie');
			addToCard(jQuery(this).val(),jQuery(this).parents('.accFancy').find('h4').text(), 'TO_CART', "ole_acc");
			jQuery('label[for=acc'+jQuery(this).val()+']').text("Dodano do koszyka");
		}else{
			//alert('dadawanie');
			removeFromCard(jQuery(this).val(),'');
			jQuery('label[for=acc'+jQuery(this).val()+']').text("Dodaj do koszyka");
		}
		setTimeout("countAccessories();",50); 
	});

	if (jQuery('input[name=isWarrantyEncourage]').val() == 0) {
		startTooltip2();
	}
	
	countAccessories();
} 

function countAccessories(){
	var c=jQuery('input.acc:checked').length;
	if(c==0){
		jQuery('#countAccessories').text('');
	}else if(c==1){
		jQuery('#countAccessories').text('Dodano ' +c+' akcesorium');
	}else if(c>1 && c<5){
		jQuery('#countAccessories').text('Dodano ' +c+' akcesoria');
	}
	else if(c>4){
		jQuery('#countAccessories').text('Dodano ' +c+' akcesoriów');
	}
} 





function removeFromCard(prodId, prodTitle) {

	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: 'REMOVE_PRODUCT', productId: prodId},
		onSuccess: function(transport){
			document.getElementById('basket-small').innerHTML = transport.responseText;      				
				//showNotify(prodTitle, '',toCart);      				
		},
		onFailure: function() { 
		
		}
	});

return false;
}

function startTooltip2(){
	var popupTimeToAutoClose='5000'; 
	jQuery('input.acc:checked').each(function(){
		 tooltipAccesory(jQuery(this).attr('id'));
	 });
	 setTimeout("jQuery('.tooltip2').fadeOut(100)",parseInt(popupTimeToAutoClose)); 
} 

function tooltipAccesory(id){

	var p=jQuery('#'+id).parent().parent().siblings();
	if (jQuery.browser.msie && jQuery.browser.version < 7)
		p.find('.tooltip2').css('left', 10);	
	p.find('.tooltip2').fadeIn();
}
