$(document).ready( function(){
	TopMenu();
	//podswietlMenu();
	
	//$('#search_input').inputHint();		
		
	//facebook widget
	$(".widget_social").hover(function(){
		$(".widget_social").stop(true, false).animate({right:"0"},"medium");
	},function(){
		$(".widget_social").stop(true, false).animate({right:"-205"},"medium");
	},500);
	
	// klikniecie entera w polu wyszukiwarki
	$('#search_frase').bind('keypress',function(e){
		if($.browser.msie && (window.event && window.event.keyCode == 13)){
			document.getElementById('form_wyszukiwarka').submit();
		}
	});		
	
	
	$('#polec_znajomemu_a666').bind('click',function(){						
		komunikaty.pokaz('polec-znajomemu', '', '');
		$('#polecenie .button').bind('mouseover',function(){ $(this).addClass('hover'); }).bind('mouseout',function(){ $(this).removeClass('hover'); });
		$('#polecenie .button a').bind('click', polec_znajomemu);
		return false;
	});			

	$('#polec_produkt_znajomemu').bind('click',function(){						
		komunikaty.pokaz('polec-produkt-znajomemu', '', '');
		$('#polecenie .button').bind('mouseover',function(){ $(this).addClass('hover'); }).bind('mouseout',function(){ $(this).removeClass('hover'); });
		$('#polecenie .button a').bind('click', polec_produkt_znajomemu);
		return false;
	});				
	
	$('#zapytaj_o_produkt').bind('click',function(){		
		komunikaty.pokaz('zapytaj-o-produkt', '', '');
		$('#polecenie .button').bind('mouseover',function(){ $(this).addClass('hover'); }).bind('mouseout',function(){ $(this).removeClass('hover'); });
		$('#polecenie .button a').bind('click', zapytaj_o_produkt);
		return false;
	});				
	
	//$('.link_do_zmiany').bind('mouseover',function(){ $(this).addClass('klasa_zastepcza');alert('a'); }).bind('mouseout',function(){ $(this).removeClass('klasa_zastepcza'); });
	//$(".link_do_zmiany").mouseover({"opacity": "0.7"}, "fast");
	
	$('#chce_informacje').bind('click',function(){		
		var action = '';		
		if ($('#chce_informacje').is(':checked')){			
			action = 'add';		
		}
		else{	
			action = 'dell';			
		}	
			if((email(document.getElementById('email_mailpro').value))){
				//http://www.mailpro.pl/mailpro/ajaxact.php?mail=lp@positive-power.pl&grup=1&ip=1.1.1.1&sesja=08ddbe61f374676d26d505755ea9a7a7&userid=53&action=add

					var dane = {
						 'mail'		: document.getElementById('email_mailpro').value
						,'grup'		: '2'
						,'userid'	: '138'
						,'ip'		: null
						,'sesja'	: null
						,'action'	: action
					};			


					// wywolujemy funckję mailproFeedback z obiektu _main
					//$.getJSON( 'http://www.mailpro.pl/mailpro/ajaxact.php?call=?', dane );							
					$.getJSON( 'http://www.mailpro.pl/mailpro/ajaxMailpro.php?mF=1&call=?', dane );
			}
			else{
				
			}
				
	});				
	
	/*
	swfobject.embedSWF('template/flash/main.swf', "lo", "100%", "100%", "8.0.0", "expressInstall.swf",	
			{  }, // FLASHVARS
			{ swliveconnect: true, wmode: "transparent", scale: "noScale" }, // PARAMS
			{ id: "main", name: "main" } //ATTRIBUTES
	);
	*/

});

var _lang = {
	trwa_ladowanie : 'Aktualnie trwa ładowanie danych...'
}




	function newsletter(akcja){
		/*if (akcja==1)
			action = 'add';
		else
			action = 'dell';
		if((email(document.getElementById('mailfield').value))){
			//http://www.mailpro.pl/mailpro/ajaxact.php?mail=lp@positive-power.pl&grup=1&ip=1.1.1.1&sesja=08ddbe61f374676d26d505755ea9a7a7&userid=53&action=add

				var dane = {
					 'mail'		: document.getElementById('mailfield').value
					,'grup'		: '2'
					,'userid'	: '138'
					,'ip'		: null
					,'sesja'	: null
					,'action'	: action
				};			


				// wywolujemy funckję mailproFeedback z obiektu _main
				//$.getJSON( 'http://www.mailpro.pl/mailpro/ajaxact.php?call=?', dane );
				$.getJSON( 'http://www.mailpro.pl/mailpro/ajaxMailpro.php?mF=1&call=?', dane );
				//alert(dane);
				
		}else{
			$('#newsletter_komunikat').css('display','none').text('Błędny email!').show('slow').animate({opacity:1.0},2000).hide('slow');
		}*/
		
		return false;
	}
	
	function mailproFeedback(data){
	/*
		Informacje zwrotne:
		  bledna_grupy
		  bledny_userid
		  bledny_email
		 
		  Dodwawanie:
		  email_czeka
		  email_istnieje
		  dodano
		  blad_zapisu
		 
		 
		  Usuwanie:
		  brak_emaila - nie ma takiego w bazie mailowej
		  brak_tresci - nie mozna wyslac potwierdzenia
		  brak_userid - nie ma takiego klienta
		  potwierdzenie_wyslane	
	*/
		var komunikat = '';
		if (data.komunikat=='dodano')
			komunikat = 'Email został dodany';
		if (data.komunikat=='email_istnieje')
			komunikat = 'Email istnieje już w bazie';		
		if (data.komunikat=='potwierdzenie_wyslane')
			komunikat = 'Został wysłany email z potwierdzeniem rezygnacji.';					
		if (data.komunikat=='brak_emaila')
			komunikat = 'Brak emaila w bazie.';								
		if (data.komunikat=='brak_tresci')
			komunikat = 'Nie można wysłać potwierdzenia.';											
		if (data.komunikat=='brak_userid')
			komunikat = 'Podany klient nie istnieje.';														
		if (data.komunikat=='blad_zapisu')
			komunikat = 'Błąd zapisu.';																	
		if (data.komunikat=='email_czeka')
			komunikat = 'Został wysłany email z potwierdzeniem subskrypcji.';																				
		if (data.komunikat=='bledny_email')
			komunikat = 'Został podany błędny email.';																							
		if (data.komunikat=='bledny_userid')
			komunikat = 'Został podany błędny identyfikator klienta.';																										
		if (data.komunikat=='bledna_grupy')
			komunikat = 'Została podana błędna grupa.';																													
		//alert(data.komunikat);	
		komunikat = komunikat || 'brak tlumaczenia'
		$('#newsletter_komunikat').css('display','none').text(komunikat).show('slow').animate({opacity:1.0},2000).hide('slow');
	}
	
	// email validation
	function email(value, element) {
		// contributed by Scott Gonzalez: http://projects.scottsplayground.com/email_address_validation/
		return /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i.test(value);
	}












function mapaStart(powiekszenie){
	if(GBrowserIsCompatible())  
    { 	
	

		var mapa = new GMap2(document.getElementById("g_mapka"));    
		mapa.addControl(new GLargeMapControl()); //wstawienie mozliwosci powiekszania i pomniejszania mapy z graficznego interfejsu		
		mapa.setCenter(new GLatLng(50.040,19.977,14.58160400390625),powiekszenie);    		  		
		var punkt = new GLatLng(50.040956,19.977277); // definiujemy punkt o współrzędnych 53.400,14.400  
		var marker = new GMarker(punkt,{title: 'Megaoutdoor.pl - siedziba firmy'}); // drugi argument (opcje) można pominąć, tak jak tutaj  
		GEvent.addListener(marker,'click',function()  
		{  		   
		   this.openInfoWindowHtml("<div style='float:left;text-align:left;color:#676767;'>Megaoutdoor.pl <br/>Kraków, ul.Gromadzka 46, <br/>tel. 012 423 61 88, <br/>fax: 012 656 46 41</div>");  
		});  					
		mapa.addOverlay(marker);  								

		//mapa.setCenter(new GLatLng(x,y,14.58160400390625),8);    		  						
		
	}
}


function TopMenu() {
	// IE Hack :]
	$('div#menu > ul > li').mouseenter(function(){
		$(this).css({'background':'#263c4d'});		
		$(this).children('a').css({'color':'white'});
		$(this).find('ul').css({'display':'block'});
		out = false;
	});

	$('div#menu > ul > li').mouseleave(function(){
		$(this).css({'background':'white'});
		$(this).children('a').css({'color':'black'});
		$(this).find('ul').css({'display':'none'});
		out = true;
	});
}


/**
 * Komunikaty
 */
var komunikaty = {
	/* inicjalizacja komunikatu wyświetlonego przez skrypt po stronie serwera */
	init : function(){
		this.ustaw_przyciski();
	},

	/* wyświetla komunikat danego rodzaju */
	pokaz : function(rodzaj, tytul, tresc, link_ok, link_anuluj){
		//alert("rodzaj="+rodzaj+"\n"+tytul+"\n"+tresc);		
		
		
		if (document.komunikaty_tpl[rodzaj]) {
			if (typeof (link_ok) == "undefined") {
				link_ok = location.href;
			}
			if (typeof (link_anuluj) == "undefined") {
				link_anuluj = location.href;
			}			
			/* pobranie szablonu komunikatu */			
			var komunikat = document.komunikaty_tpl[rodzaj];			
			//var komunikat = document.komunikaty_tpl['polec-znajomemu'];			
			/* ustawienie treści */
			komunikat = komunikat.replace('{TYTUL}', tytul).replace('{TRESC}',
					tresc).replace('{LINK_OK}', link_ok).replace(
					'{LINK_ANULUJ}', link_anuluj);

			/* usunięcie poprzedniego komunikatu, jeśli istnieje */
			if ($('#warstwa')[0]) {
				komunikaty.usun();
			}

			/* wyświetlenie komunikatu */			
			$("body").prepend('<div id="over" class="overlay"></div>');
			$("#all").prepend(komunikat);
			//$("#warstwa").pngfix();

			$('#over').css({'height':$(document).height(), 'opacity':'0.4' });
			scrollToTop();
			var szerokosc = ( $(document).width() - $('#warstwa').width() ) / 2;
			$('#warstwa').css({'left':szerokosc});

			/* oprogramowanie przycisków */
			komunikaty.ustaw_przyciski();					
			return true;
		}
		
		return false;
	},

	/* zamyka komunikat */
	usun : function(){
		if (o = document.getElementById('warstwa')) $(o).remove();
		if (o = document.getElementById('warstwa_')) $(o).remove();
		if (o = document.getElementById('over')) $(o).remove();
	},

	/* domyślne ustawienie przycisków */
	ustaw_przyciski : function(){
		if (!$(".kom_anuluj")[0]) {
			$('.kom_close,.kom_ok').each( function(i){
				this.onclick = function(e){
					if(typeof this.href != undefined && this.href != location.href){
						//alert(location.href+"\n"+this.href);
						location.href = this.href;
					}
					komunikaty.usun();
					return false;
				};
			});
		} else {
			$('.kom_anuluj').each( function(i){
				this.onclick = function(){
					komunikaty.usun();
					return false;
				};
			});
		}
	}
};


	thickboxClose = "zamknij";
	thickboxNext = "Następne";
	thickboxPrev = "Poprzednie";
	thickboxImage = "zdjęcie";
	thickboxOf = "z";	
	var Translator = {		
		'forms': {
			'zamknij'				: 'zamknij'
		},
		
		'newsletter': {
			 'naglowek'				: 'Newsletter'
			,'email'				: 'twój e-mail'
			,'dodaj'				: 'dodaj'
			,'usun'					: 'usuń'
			// komunikaty z mailPRO
			,'email_istnieje'		: 'podany adres email znajduje się już w naszej bazie'
			,'bledna_grupa' 		: 'nieprawidłowy numer grupy'
			,'bledny_userid' 		: 'nieprawidłowy identyfikator klienta'
			,'bledny_email' 		: 'nieprawidłowy adres email'
			,'dodano' 				: 'email został pomyślnie dodany do newslettera'
			,'blad_zapisu' 			: 'wystąpił błąd w trakcie zapisu do newslettera'
			,'brak_emaila' 			: 'podanego adresu email nie ma w naszej bazie'
			,'brak_tresci' 			: 'nie można wysłać potwierdzenia'
			,'brak_userid' 			: 'błędny identyfikator klienta'
			,'potwierdzenie_wyslane': 'na podany adres email wysłano potwierdzenie wypisania z newslettera'
			,'button'				: 'button'			
		},
		
		'polec': {
			 'naglowek'				: 'Poleć znajomemu'
			,'dane_znajomego'		: 'Podaj dane znajomego'
			,'email_znajomego'		: 'e-mail znajomego'
			,'podaj_dane'			: 'Podaj swoje dane'
			,'imie_nazwisko'		: 'imię i nazwisko'
			,'tresc'				: 'treść wiadomości'
			,'tresc_pytania' 		: 'treść pytania'			
			,'pola_wymagane'		: ''
			,'wyslij'				: 'wyślij'
			,'email'				: 'e-mail'
			,'dodaj'				: 'dodaj'
			,'usun'					: 'usuń'
			,'bledny_email'	 		: 'nieprawidłowy adres email'
			,'istnieje_email'	 	: 'email już jest zapisany'
			,'button'				: 'button'			
			,'dziekujemy'			: 'Dziękujemy za polecenie naszej strony'									
			,'dziekujemy2'			: 'Dziękujemy za wysłanie zapytania.'												
			,'dziekujemy3'			: 'Dziękujemy za polecenie produktu znajomemu.'															
			,'wyslana'				: 'Wiadomość wysłana pomyślnie'	
				
		}
	}



var _brakujace_tlumaczenia = {};
function _t( lang_key, change ){
	change = change || {};

	var splitted = lang_key.split('.');
	if (Translator[splitted[0]] && Translator[splitted[0]][splitted[1]]) {
		lang_key = Translator[splitted[0]][splitted[1]];
	
		if( change ) {
			// Transform arguments before inserting them.
			for (var key in change) {
				lang_key = lang_key.replace(key, change[key]);
			}
		}
	}else{
		if(!_brakujace_tlumaczenia[lang_key]){
			_brakujace_tlumaczenia[lang_key] = true;
			!$.browser.msie && console.error( 'brak tlumaczenia: ' + lang_key );
		}
	}
	
	return lang_key;
}



	// przewija stronę na samą górę (bez użycia "#")
	function scrollToTop(){
		$(document).scrollTop(0);
	}

	function polec_znajomemu(){					
		var dane = {
			 'rodzaj_akcji'		: 'polec-znajomemu'
			,'email_odbiorcy'	: document.getElementById('email_odbiorcy').value
			,'imie_nazwisko'	: document.getElementById('imie_nazwisko').value
			,'email_nadawcy'	: document.getElementById('email_nadawcy').value
			,'tresc'			: document.getElementById('tresc').value
		}						
		$.post("page,polec.html", dane, function(data){
			
			
			if(!data.ok){			
				for(x in data.bledy){
					//alert( x + ': ' + data.bledy[x] );
					$('#'+x+'_error').css('display','block').text(data.bledy[x]);
				}
			}else{				
				$('#polecenie span').not('.button').html('').css('display','none');
				//document.getElementById('polec-naglowek').innerHTML = _t('polec.wyslana'); //'Wiadomość wysłana pomyślnie';
				document.getElementById('polecenie').innerHTML = '<p style="text-align:left;padding-left:44px;margin-top:8px;">'+_t('polec.dziekujemy')+'</p>';
			}
		}, 'json');
		return false;
	}

	function polec_produkt_znajomemu(){
		var dane = {
			 'rodzaj_akcji'		: 'polec-produkt-znajomemu'
			,'email_odbiorcy'	: document.getElementById('email_odbiorcy').value
			,'imie_nazwisko'	: document.getElementById('imie_nazwisko').value
			,'email_nadawcy'	: document.getElementById('email_nadawcy').value
			,'tresc'			: document.getElementById('tresc').value
			,'produkt'			: document.getElementById('productname').innerHTML			
			,'adres'			: window.location.toString().substring(0,window.location.toString().length-1)
		}						
		$.post("page,polec.html", dane, function(data){
			
			
			if(!data.ok){			
				for(x in data.bledy){
					//alert( x + ': ' + data.bledy[x] );
					$('#'+x+'_error').css('display','block').text(data.bledy[x]);
				}
			}else{				
				$('#polecenie span').not('.button').html('').css('display','none');
				//document.getElementById('polec-naglowek').innerHTML = _t('polec.wyslana'); //'Wiadomość wysłana pomyślnie';
				document.getElementById('polecenie').innerHTML = '<p style="text-align:left;padding-left:44px;margin-top:8px;">'+_t('polec.dziekujemy3')+'</p>';
			}
		}, 'json');
		return false;
	}	
	
	function zapytaj_o_produkt(){			
		var dane = {
			 'rodzaj_akcji'		: 'zapytaj-o-produkt'			
			,'imie_nazwisko'	: document.getElementById('imie_nazwisko').value
			,'email_nadawcy'	: document.getElementById('email_nadawcy').value
			,'tresc'			: document.getElementById('tresc').value
			,'produkt'			: document.getElementById('productname').innerHTML
		}						
		$.post("page,polec.html", dane, function(data){
			
			
			if(!data.ok){			
				for(x in data.bledy){
					//alert( x + ': ' + data.bledy[x] );
					$('#'+x+'_error').css('display','block').text(data.bledy[x]);
				}
			}else{				
				$('#polecenie span').not('.button').html('').css('display','none');
				//document.getElementById('polec-naglowek').innerHTML = _t('polec.wyslana'); //'Wiadomość wysłana pomyślnie';
				document.getElementById('artykul').innerHTML = _t('polec.dziekujemy2');			
				document.getElementById('polecenie').innerHTML = '';
			}
		}, 'json');
		return false;
	}	
	
	
function zmienOnPage(onPage){	

	var adres_pierwotny = window.location.toString();
	var firma = '';
	var sort = '';
	var koncowka = '';
		
	if ((adres_pierwotny.lastIndexOf('.')!=-1)&&(adres_pierwotny.lastIndexOf('nowosci.')==-1)&&(adres_pierwotny.lastIndexOf('promocje.')==-1)&&(adres_pierwotny.lastIndexOf('lista.')==-1)&&(($('.depth1 .on').html()!=null)&&(adres_pierwotny.lastIndexOf($('.depth1 .on').html().toLowerCase()+'.')==-1))){
		koncowka = adres_pierwotny.substring(adres_pierwotny.lastIndexOf('.'),adres_pierwotny.length);
		adres_pierwotny = adres_pierwotny.substring(0,adres_pierwotny.lastIndexOf('.'));
		
	} else if (adres_pierwotny.lastIndexOf(',')!=-1){
		koncowka = adres_pierwotny.substring(adres_pierwotny.lastIndexOf(','),adres_pierwotny.length);
		adres_pierwotny = adres_pierwotny.substring(0,adres_pierwotny.lastIndexOf(','));			
	}	
	
	if (adres_pierwotny.indexOf(',sort')!=-1){
		if (adres_pierwotny.indexOf(',firm')!=-1)
			sort = adres_pierwotny.substring(adres_pierwotny.indexOf(',sort'),adres_pierwotny.indexOf(',firm'));						
		else
			sort = adres_pierwotny.substring(adres_pierwotny.indexOf(',sort'),adres_pierwotny.lastIndexOf(','));						
	}					
	if (adres_pierwotny.indexOf(',firm')!=-1){
		firma = adres_pierwotny.substring(adres_pierwotny.indexOf(',firm'),adres_pierwotny.length);						
	}					
	if (adres_pierwotny.indexOf(',onPage')!=-1)
		adres_pierwotny = adres_pierwotny.substring(0,adres_pierwotny.indexOf(',onPage'));
	//if ((firma!= '')&&(sort!=''))
	//alert(onPage);
	//alert(sort);
	//alert(firma);
	//alert(koncowka);
	window.location = adres_pierwotny+',onPage,'+onPage+sort+firma+koncowka; 
	
	//window.location = adres_pierwotny+',onPage,'+onPage+'.html'; 

}


function zmienStroneProduktowa(adres){	

	window.location = adres; 

}

function zmienSortowanie(id){	

	var adres_pierwotny = window.location.toString();
	var firma = '';
	var koncowka = '';
	var onPage='';
	var temp = '';
	if (adres_pierwotny.indexOf(',onPage')!=-1){			
		temp = adres_pierwotny.substring(adres_pierwotny.lastIndexOf(',onPage'),adres_pierwotny.length);
		temp = temp.substring(temp.indexOf(',onPage')+1,temp.length);
		onPage=temp.substring(0,temp.indexOf(','));		
		temp = temp.substring(temp.indexOf(',')+1,temp.length);
		onPage= onPage + ',' + temp.substring(0,temp.indexOf(','));		
		onPage = ','+onPage;
		//alert(onPage);
	}
	if (adres_pierwotny.lastIndexOf(',')!=-1){
		koncowka = adres_pierwotny.substring(adres_pierwotny.lastIndexOf(','),adres_pierwotny.length);
		adres_pierwotny = adres_pierwotny.substring(0,adres_pierwotny.lastIndexOf(','));	
	}	
	if (adres_pierwotny.indexOf(',firm')!=-1){
		firma = adres_pierwotny.substring(adres_pierwotny.indexOf(',firm'),adres_pierwotny.length);						
	}	
	if (adres_pierwotny.indexOf(',sort')!=-1)
		adres_pierwotny = adres_pierwotny.substring(0,adres_pierwotny.indexOf(',sort'));				
	if (firma != '')
		window.location = adres_pierwotny+',sort,'+id+firma+onPage+koncowka; 
	else
		window.location = adres_pierwotny+',sort,'+id+onPage+koncowka; 

}

function zmienFirme_old_unused(id){	
	var adres_pierwotny = window.location.toString();
	var koncowka = '';
	if (adres_pierwotny.lastIndexOf(',')!=-1){
		koncowka = adres_pierwotny.substring(adres_pierwotny.lastIndexOf(','),adres_pierwotny.length);
		adres_pierwotny = adres_pierwotny.substring(0,adres_pierwotny.indexOf('.html'));	
	}	
	if (adres_pierwotny.indexOf(',firm')!=-1)
		adres_pierwotny = adres_pierwotny.substring(0,adres_pierwotny.indexOf(',firm'));
	window.location = adres_pierwotny+',firm,'+id+koncowka; 

}



function zmienFirme(id){	
	var adres_pierwotny = window.location.toString();
	var koncowka = '';
	
	adres_pierwotny =  adres_pierwotny.substring(0, adres_pierwotny.lastIndexOf(','));
	/*
	if (adres_pierwotny.lastIndexOf('.')!=-1){
		koncowka = adres_pierwotny.substring(adres_pierwotny.lastIndexOf(','),adres_pierwotny.length);
		adres_pierwotny = adres_pierwotny.substring(0,adres_pierwotny.lastIndexOf('.'));	
	}
	*/	
	if (adres_pierwotny.indexOf(',firm')!=-1)
		;//adres_pierwotny = adres_pierwotny.substring(0,adres_pierwotny.indexOf(',firm'));
	if ((adres_pierwotny.indexOf('nr')!=-1)&&((adres_pierwotny.indexOf('nr,1')==-1)&&(adres_pierwotny.indexOf('nr,2')==-1)&&(adres_pierwotny.indexOf('nr,3')==-1))){
		adres_pierwotny=adres_pierwotny+',1';		
	}	
	else{		
	}
	window.location = adres_pierwotny+',firm,'+id+',lista.html';//+koncowka; 

}

function zmienFirme_oldzik(id){	
	var adres_pierwotny = window.location.toString();
	var koncowka = '';
	if (adres_pierwotny.lastIndexOf(',')!=-1){
		koncowka = adres_pierwotny.substring(adres_pierwotny.lastIndexOf(','),adres_pierwotny.length);
		adres_pierwotny = adres_pierwotny.substring(0,adres_pierwotny.lastIndexOf(','));	
	}	
	if (adres_pierwotny.indexOf(',firm')!=-1)
		adres_pierwotny = adres_pierwotny.substring(0,adres_pierwotny.indexOf(',firm'));
	window.location = adres_pierwotny+',firm,'+id+koncowka; 

}


function zmienFirme2(id){	
	var adres_pierwotny = window.location.toString();
	var koncowka = '';
	
	if (adres_pierwotny.lastIndexOf('.')!=-1){
		koncowka = adres_pierwotny.substring(adres_pierwotny.lastIndexOf('.'),adres_pierwotny.length);
		adres_pierwotny = adres_pierwotny.substring(0,adres_pierwotny.lastIndexOf('.'));	
	} else if (adres_pierwotny.lastIndexOf(',')!=-1){
		koncowka = adres_pierwotny.substring(adres_pierwotny.lastIndexOf(','),adres_pierwotny.length);
		adres_pierwotny = adres_pierwotny.substring(0,adres_pierwotny.lastIndexOf(','));	
	}
	
	if (adres_pierwotny.indexOf(',firm')!=-1)
		adres_pierwotny = adres_pierwotny.substring(0,adres_pierwotny.indexOf(',firm'));
	window.location = adres_pierwotny+',firm,'+id+koncowka; 

}




function podswietlMenu(){
		
	$("li").hover( 
		function () { 
			//if ($(this).css('background-color')!='rgb(238, 238, 238)')
				//alert($(this).css('background-color'));
			if (($(this).attr('class')!='MenuActiveCategories')&&($(this).css('background-color')=='rgb(238, 238, 238)'))
				$(this).css('background','#FF3101');
			//$(this).append($("<span> ***</span>")); 
		}, 
		function () { 
			if (($(this).attr('class')!='MenuActiveCategories')&&($(this).css('background-color')=='rgb(255, 49, 1)')){				
				$(this).css('background','#EEEEEE');
			}
			//$(this).find("span:last").remove(); 
		} 
	); 	
	
}




//DODAJ DO ULUBIONYCH
function addToBookmarks( sTitle, sHref )
	{
	//Wersja skryptu 1.0
	//Modyfikacji dokonał: Krzysztof Samelko
	//Data: 2008-05-12

	if( window.sidebar && window.sidebar.addPanel )
		{
		//Gecko (Netscape 6 etc.) - add to Sidebar
		window.sidebar.addPanel( sTitle, sHref, '' );
		}
	else if( window.external && ( navigator.platform == 'Win32' || ( window.ScriptEngine && ScriptEngine().indexOf('InScript') + 1 ) ) )
		{
		//IE Win32 or iCab - checking for AddFavorite produces errors for no
		//good reason, so I use a platform and browser detect.
		//adds the current page page as a favourite; if this is unwanted,
		//simply write the desired page in here instead of 'location.href'
		window.external.AddFavorite( window.location.href, document.title );
		}
	else if( window.opera && window.print )
		{

		//window.open('js/opera_dodaj_do_ulubionych.php','','width=150,height=50');
		//Opera 6+ - add as sidebar panel to Hotlist
		return true;
		}
	else if( document.layers )
		{
		//NS4 & Escape - tell them how to add a bookmark quickly (adds current page,
		//not target page)
		window.alert( 'Proszę kilknąć Ctrl+D aby dodać strone do ulubionych' );
		}
	else
		{
		//other browsers - tell them to add a bookmark (adds current page, not target page)
		window.alert( 'Proszę użyć menu przeglądarki by utworzyć dodać strone do ulubionych' );
		}
	//return false;
	}
//DODAJ DO ULUBIONYCH


function email_validate(src)  {
	var regex = /^[a-zA-Z0-9._-]+@([a-zA-Z0-9.-]+\.)+[a-zA-Z0-9.-]{2,4}$/;
	return regex.test(src);
};


function changePriceDelivery( id ) {
	document.getElementById('DeliveryPrice').innerHTML = document.getElementById('Delivery_'+id).value;
		
	changePrice();
}

function changePrice() {
	if ( document.getElementById('ProductPrice') ) {
		var ProductsPrice = document.getElementById('ProductPrice').value;
		var DeliveryPrice = document.getElementById('DeliveryPrice').innerHTML;
		
	} else {
		var ProductsPrice = 0;
		var DeliveryPrice = 0;
		
	}
	
	var Price = parseFloat(ProductsPrice) + parseFloat(DeliveryPrice);
	document.getElementById('LastPrice').innerHTML = RoundPrice(Price, 2) + ' zł';
	
}




	/**
	 * Przytnij liczbe do X miejsc po przecinku
	 */
	function RoundPrice( number, round ) {
		var round = round + 1;
		var number_string = number.toString();
		
		var return_string = '';
		var iterator;
	
		if ( number_string.length == 0 ) return number_string;
		
		for ( ix=0; ix < number_string.length; ix = ix + 1 ) {
			if ( number_string.charAt(ix) == '.' ) {
				iterator = round;
			}
		
			if ( iterator == undefined || iterator > 0 ) {
				if ( iterator != undefined && iterator > 0 ) {
					iterator = iterator - 1;
				}
				
				return_string = return_string + number_string.charAt(ix);
			} else {
				break;
			}
		}
		
		if ( iterator != undefined && iterator > 0 ) {
			for ( xx=0; xx < iterator; xx = xx + 1 ) {
				return_string = return_string + "0";
			}
		}
		
		return parseFloat( return_string );
	}

 
function rozwin_wiersz($id){		
	if (($("#wiersz_historii_"+$id).height() != 39)&&($("#wiersz_historii_"+$id).height() != 38)){	
		$("#wiersz_historii_"+$id).css("height", "39px");					
		document.getElementById("wiecej_szczegolow_"+$id).innerHTML='więcej szczegółów';		
		$("#wiersz_historii_"+$id).attr('class',"wiersz_historii");					
	}	
	else{		
		$("#wiersz_historii_"+$id).css("height", "auto");			
		document.getElementById("wiecej_szczegolow_"+$id).innerHTML='zwiń';
		$("#wiersz_historii_"+$id).attr('class',"wiersz_historii_rozwiniety");			
		$(".wiersz_historii_rozwiniety").css("background", "#eeeeee");
	}

}
