//facebook widget
$(document).ready(function(){
	$(".trigger").click(function(){
			$(".FBpanel").toggle("fast");
			$(this).toggleClass("active");
			$(".trigger").toggle();
			return false;
	});
	$(".FBCloseButton").click(function(){
		$(".FBpanel").toggle("fast");
		$(".trigger").toggle();
	});
});

var tt;

function showPrice(wariant_id)
{
	if (ceny[wariant_id])
	{
		document.getElementById('brutto').innerHTML = ceny[wariant_id][1];
		document.getElementById('netto').innerHTML = ceny[wariant_id][0];
	}
}

function rozwinWysylkoweDane(elem)
{
	var tbl = document.getElementById('tabelaWysylki');
	var elementy = tbl.getElementsByTagName('tr');

	if (elem.checked == true)
	{

		for (var i=0; i<elementy.length; i++)
		{
			if (elementy[i].id != 'aaa')
				elementy[i].style.display = '';
		}
	}
	else
	{

		for (var i=0; i<elementy.length; i++)
		{
			if (elementy[i].id != 'aaa')
				elementy[i].style.display = 'none';
		}
	}
}

function hsd(string) {
    string = string.replace(/&amp;/g, '&');
    return string;
}

function pokazDaneWysylkowe(elem)
{
	if (elem.checked)
	{
		document.getElementById('daneWysylkowe').style.display = 'block';
	}
	else
	{
		document.getElementById('daneWysylkowe').style.display = 'none';
	}
}

function ppSelectTab(tab)
{
	var i = 0;
	for(i=1;i<3;i++)
	{
		if(i==tab)
		{
			document.getElementById('tab'+i).style.display = 'block';
			document.getElementById('pptab'+i).className = 'active';
		}
		else
		{
			document.getElementById('tab'+i).style.display = 'none';
			document.getElementById('pptab'+i).className = '';
		}
	}
	
}

function showBasket()
{
 $('#fullBasket').fadeIn();
 window.clearTimeout(tt);
 tt = window.setTimeout("doHideBasket()",5000);
}


function hideBasket()
{
	tt = window.setTimeout("doHideBasket()",2000);
}

function cancelHide()
{
	window.clearTimeout(tt);
}
function doHideBasket()
{
 $('#fullBasket').fadeOut();
}
function verticalAlign (){
		$('#menuContainer a').each (function() {
			$(this).height()  <20? $(this).css({lineHeight:'36px',display:'block'}): $(this).css({lineHeight:'17px',display:'block'});
			})
		$('#menuContainer li li a').each (function() {
			$(this).css({lineHeight:'16px'})
			})			
}
exiting = true;

function setCookie(c_name,value,exdays)
{
	var exdate=new Date();
	exdate.setDate(exdate.getDate() + exdays);
	var c_value=escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString());
	document.cookie=c_name + "=" + c_value;
}

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 unloadHandler(e)
{
	//e.stopPropagation works in Firefox.
	//if(exiting) alert(readCookie('laloluSession'));
	if(exiting && readCookie('laloluSession')==null) 
	{
		if(confirm('Lalalu.pl: Poczekaj! Masz szansę na skorzystanie z niezwykłej okazji. Tylko teraz, jeśli zrobisz zakupy za minimum 50zł otrzymasz darmową wysyłkę! Kliknij OK jeśli chcesz dowiedzieć się więcej (lub wróć na www.lalalu.pl jeśli przeglądarka Cię nie przeniesie).'))
		{	
			setCookie('doLeavePromo','92839823s98d920e9d08e',1);
			setCookie('laloluSession','34rfdfpo32909rw-0fwr32o40-r#64',10);
			window.location.replace('http://www.lalalu.pl/zakup-niepowtarzalnej-szansy.html');
			
			return false;
		}
	}
}

$(document).ready(function() {
$('a').bind('click', function() {
	  exiting = false;
	});
$('input[type="submit"]').bind('click', function() {
	  exiting = false;
	});
$('input[type="image"]').bind('click', function() {
	  exiting = false;
	});

} );


