jQuery(document).ready(function() {

	/*
	var effect = function(el, on , n, o) {
		
		$.extend(o, {
			easing: "easeOutQuint"
		});
		
		
		if( el == "#sliderLeft" ){
			$(el).bind("click", function() {
				$("#sliderRight").css('display','block');
				$("#sliderLeft").css('display','none');
				$(on).addClass("current").hide(n, o, 600, function() {
				});
			});

		} else {
			$(el).bind("click", function() {
				$(on).show(n, o, 600, function() { $(this).removeClass("current"); });
				$("#sliderRight").css('display','none');
				$("#sliderLeft").css('display','block');
			});
		}
		
		
		
	};
	
	effect("#sliderLeft" ,"#theMenu" , "slide", { direction: "left" });
	effect("#sliderRight","#theMenu" , "slide", { direction: "left" });
	
	$("#sliderRight").css('display','none');
	$("#sliderLeft").css('display','block');
	
	*/
	if(parent.location.hash == '#all_sh'){
		jQuery('.zaawansowane').show();
	}
	
	var options = { };;
		
	jQuery("#sliderRight").bind("click", function() {
				//  jQuery("#slideLeft").toggle('slide',options,500);
					jQuery("#sliderRight").css('display','none');
				    //jQuery("#sliderLeft").css('display','block');
				    //jQuery("#slideLeft").css('display','block');
				    //jQuery("#slideLeft2").css('display','block');
				    
					jQuery("#slideLeft").show("slide", { direction: "left" }, 1000);
				//	jQuery("#slideLeft2").toggle('slide',options,500  );
				
			});
	
	jQuery("#sliderLeft").bind("click", function() {
					jQuery("#slideLeft").hide("slide", { direction: "left" }, 1000 , function(){ 
													
														jQuery("#sliderRight").css('display','block'); 
														});
					/*
					jQuery("#slideLeft2").toggle('slide',options,500 , 
											function(){ 
													//jQuery("#sliderLeft").css('display','none');
													jQuery("#sliderRight").css('display','block'); 
														});
					*/
					
					
					
			});
			
	//jQuery("#sliderRight").css('display','block');
	//jQuery("#sliderLeft").css('display','none');
	jQuery('.styleswitch').click(function()
      {
         switchStylestyle(this.getAttribute("rel"));
         return false;
      });
	
	//jQuery('.master-img-png').ifixpng(); 
	//jQuery(document).pngFix(); 
	
	setMenu();
});

function setMenu(){
	if ( jQuery("#theMenu").length > 0 ) {
							// w bosky/menu
							var tabs = jQuery("a.menuItem");
							var tabslength = tabs.length ;
							var tmp = jQuery("a.menuItem");
							for(var i=0; i<= tabslength ; i++) { 
								
								var name1 = tmp.eq(i).attr('name');
								
								if ( jQuery("#"+name1+"").length > 0 ) {
										
										jQuery("#"+name1+"_menu").attr('class','menuItem menuItemUnactive');
								} else {
										
										jQuery("#"+name1+"_menu").attr('class','menuItem menuItemActive');
								}
								
							} 
	}
}
 
function setCookie(c_name,value,expiredays)
{
	var exdate=new Date();
	exdate.setDate(exdate.getDate()+expiredays);
	document.cookie=c_name+ "=" +escape(value)+
	((expiredays==null) ? "" : ";expires="+exdate.toGMTString())+";path=/";
}

function getCookie(c_name)
{
	if (document.cookie.length>0)
	  {
	  c_start=document.cookie.indexOf(c_name + "=");
	  if (c_start!=-1)
	    { 
	    c_start=c_start + c_name.length+1; 
	    c_end=document.cookie.indexOf(";",c_start);
	    if (c_end==-1) c_end=document.cookie.length;
	    return unescape(document.cookie.substring(c_start,c_end));
	    } 
	  }
	return "";
}

function deleteSortable(){
				//$('div.groupWrapper').SortableDestroy();
				//$('.groupItem').SortableDestroy();
			//	$('#boksy_o_mnie').SortableDestroy();
			//	$('#boksy_kalendarz_lewa_blog').SortableDestroy();
			//	$('#boksy_linki').SortableDestroy();
			//	$('#boksy_notki_usera').SortableDestroy();
			//	$('#boksy_notki_ze_wszystkich').SortableDestroy();
			//	$('#boksy_notki_uzytkownika').SortableDestroy();
			//	$('#boksy_real_login').SortableDestroy();
			//	$('#boksy_profil_last').SortableDestroy();
			//	$('#boksy_polec_znajomemu').SortableDestroy();
				
};


function openClose() {
				
	// tip z tytulem
	jQuery('a.tip_title_blue').cluetip({positionBy: 'mouse', width: 110, splitTitle: '|', tracking: true, cluetipClass: 'title'});
				
	// tip profilu
	jQuery('a.tip_profil_blue').cluetip({positionBy: 'mouse', width: 110, splitTitle: '|', tracking: true});
						
	// tip profilu
	jQuery('span.tip_profil_blue').cluetip({positionBy: 'mouse', width: 140, splitTitle: '|', tracking: true});

// ------------------------------------- START - OTWIERANIE ZAMYKANIE BOKS�W -------------------------------------
	/*
						// otwieranie zamykanie "boksy_ostatnio_zalogowani" START
						if ( $("#s24_ostatnio_zalogowani_open").length > 0 ) {
							$( '#s24_ostatnio_zalogowani_open' ).unbind("click");
							$( '#s24_ostatnio_zalogowani_open' ).click(
								function(){
									$('#ostatnio_zalogowani').show();
									$('#s24_ostatnio_zalogowani_open').hide();
									$('#s24_ostatnio_zalogowani_close').show();
									$.cookie('TAB_ostatnio_zalogowani', '1', { path: '/', expires: 365 });
									
									xajax_save_boks_konfig( 'boksy_ostatnio_zalogowani' , getLayoutName() , "open_close" , '1');
									makeBigCol();
								}
							);
							
												$( '#s24_ostatnio_zalogowani_close' ).unbind("click");
												$( '#s24_ostatnio_zalogowani_close' ).click(
													function(){
														$('#ostatnio_zalogowani').hide();
														$('#s24_ostatnio_zalogowani_open').show();
														$('#s24_ostatnio_zalogowani_close').hide();
														$.cookie('TAB_ostatnio_zalogowani', '0', { path: '/', expires: 365 });
														
														xajax_save_boks_konfig( 'boksy_ostatnio_zalogowani' , getLayoutName() , "open_close" , '0');
														makeBigCol();
													}
												);
						}
						// otwieranie zamykanie "boksy_ostatnio_zalogowani" KONIEC
						
						// otwieranie zamykanie "news_nauka_studia" START
						var tmp = "news_nauka_studia";
						if ( $("#s24_"+tmp+"_open").length > 0 ) {
							$( '#s24_'+tmp+'_open' ).unbind("click");
							$( '#s24_'+tmp+'_open' ).click(
								function(){
									var tmp = "news_nauka_studia";
									$('#'+tmp).show();
									$('#s24_'+tmp+'_open').hide();
									$('#s24_'+tmp+'_close').show();
									$.cookie('TAB_'+tmp, '1', { path: '/', expires: 365 });
									
									xajax_save_boks_konfig( 'boksy_'+tmp , getLayoutName() , "open_close" , '1');
									makeBigCol();
								}
							); 
							
												$( '#s24_'+tmp+'_close' ).unbind("click");
												$( '#s24_'+tmp+'_close' ).click(
													function(){
														var tmp = "news_nauka_studia";
														$('#'+tmp).hide();
														$('#s24_'+tmp+'_open').show();
														$('#s24_'+tmp+'_close').hide();
														$.cookie('TAB_'+tmp, '0', { path: '/', expires: 365 });
														
														xajax_save_boks_konfig( 'boksy_'+tmp , getLayoutName() , "open_close" , '0');
														makeBigCol();
													}
												);
						}
						// otwieranie zamykanie "news_nauka_studia" KONIEC
						
						// otwieranie zamykanie "boksy_news_rozrywka_kultura" START
						var tmp = "news_rozrywka_kultura";
						if ( $("#s24_"+tmp+"_open").length > 0 ) {
							$( '#s24_'+tmp+'_open' ).unbind("click");
							$( '#s24_'+tmp+'_open' ).click(
								function(){
									var tmp = "news_rozrywka_kultura";
									$('#'+tmp).show();
									$('#s24_'+tmp+'_open').hide();
									$('#s24_'+tmp+'_close').show();
									$.cookie('TAB_'+tmp, '1', { path: '/', expires: 365 });
									
									xajax_save_boks_konfig( 'boksy_'+tmp , getLayoutName() , "open_close" , '1');
									makeBigCol();
								}
							); 
							
												$( '#s24_'+tmp+'_close' ).unbind("click");
												$( '#s24_'+tmp+'_close' ).click(
													function(){
														var tmp = "news_rozrywka_kultura";
														$('#'+tmp).hide();
														$('#s24_'+tmp+'_open').show();
														$('#s24_'+tmp+'_close').hide();
														$.cookie('TAB_'+tmp, '0', { path: '/', expires: 365 });
														
														xajax_save_boks_konfig( 'boksy_'+tmp , getLayoutName() , "open_close" , '0');
														makeBigCol();
													}
												);
						}
						// otwieranie zamykanie "boksy_news_rozrywka_kultura" KONIEC
						
						// otwieranie zamykanie "news_finanse_firma" START
						var tmp = "news_finanse_firma";
						if ( $("#s24_"+tmp+"_open").length > 0 ) {
							$( '#s24_'+tmp+'_open' ).unbind("click");
							$( '#s24_'+tmp+'_open' ).click(
								function(){
									var tmp = "news_finanse_firma";
									$('#'+tmp).show();
									$('#s24_'+tmp+'_open').hide();
									$('#s24_'+tmp+'_close').show();
									$.cookie('TAB_'+tmp, '1', { path: '/', expires: 365 });
									
									xajax_save_boks_konfig( 'boksy_'+tmp , getLayoutName() , "open_close" , '1');
									makeBigCol();
								}
							); 
							
												$( '#s24_'+tmp+'_close' ).unbind("click");
												$( '#s24_'+tmp+'_close' ).click(
													function(){
														var tmp = "news_finanse_firma";
														$('#'+tmp).hide();
														$('#s24_'+tmp+'_open').show();
														$('#s24_'+tmp+'_close').hide();
														$.cookie('TAB_'+tmp, '0', { path: '/', expires: 365 });
														
														xajax_save_boks_konfig( 'boksy_'+tmp , getLayoutName() , "open_close" , '0');
														makeBigCol();
													}
												);
						}
						// otwieranie zamykanie "news_finanse_firma" KONIEC
						
						// otwieranie zamykanie "news_praca_kariera" START
						var tmp = "news_praca_kariera";
						if ( $("#s24_"+tmp+"_open").length > 0 ) {
							$( '#s24_'+tmp+'_open' ).unbind("click");
							$( '#s24_'+tmp+'_open' ).click(
								function(){
									var tmp = "news_praca_kariera";
									$('#'+tmp).show();
									$('#s24_'+tmp+'_open').hide();
									$('#s24_'+tmp+'_close').show();
									$.cookie('TAB_'+tmp, '1', { path: '/', expires: 365 });
									
									xajax_save_boks_konfig( 'boksy_'+tmp , getLayoutName() , "open_close" , '1');
									makeBigCol();
								}
							); 
							
												$( '#s24_'+tmp+'_close' ).unbind("click");
												$( '#s24_'+tmp+'_close' ).click(
													function(){
														var tmp = "news_praca_kariera";
														$('#'+tmp).hide();
														$('#s24_'+tmp+'_open').show();
														$('#s24_'+tmp+'_close').hide();
														$.cookie('TAB_'+tmp, '0', { path: '/', expires: 365 });
														
														xajax_save_boks_konfig( 'boksy_'+tmp , getLayoutName() , "open_close" , '0');
														makeBigCol();
													}
												);
						}
						// otwieranie zamykanie "news_praca_kariera" KONIEC
						
						// otwieranie zamykanie "boksy_multimedia_right_filmy" START
						var tmp = "multimedia_right_filmy";
						if ( $("#s24_"+tmp+"_open").length > 0 ) {
							$( '#s24_'+tmp+'_open' ).unbind("click");
							$( '#s24_'+tmp+'_open' ).click(
								function(){
									var tmp = "multimedia_right_filmy";
									$('#'+tmp).show();
									$('#s24_'+tmp+'_open').hide();
									$('#s24_'+tmp+'_close').show();
									$.cookie('TAB_'+tmp, '1', { path: '/', expires: 365 });
									
									xajax_save_boks_konfig( 'boksy_'+tmp , getLayoutName() , "open_close" , '1');
									makeBigCol();
								}
							); 
							
												$( '#s24_'+tmp+'_close' ).unbind("click");
												$( '#s24_'+tmp+'_close' ).click(
													function(){
														var tmp = "multimedia_right_filmy";
														$('#'+tmp).hide();
														$('#s24_'+tmp+'_open').show();
														$('#s24_'+tmp+'_close').hide();
														$.cookie('TAB_'+tmp, '0', { path: '/', expires: 365 });
														
														xajax_save_boks_konfig( 'boksy_'+tmp , getLayoutName() , "open_close" , '0');
														makeBigCol();
													}
												);
						}
						// otwieranie zamykanie "boksy_multimedia_right_filmy" KONIEC
						
						// otwieranie zamykanie "boksy_multimedia_right_galeria" START
						var tmp = "multimedia_right_galeria";
						if ( $("#s24_"+tmp+"_open").length > 0 ) {
							$( '#s24_'+tmp+'_open' ).unbind("click");
							$( '#s24_'+tmp+'_open' ).click(
								function(){
									var tmp = "multimedia_right_galeria";
									$('#'+tmp).show();
									$('#s24_'+tmp+'_open').hide();
									$('#s24_'+tmp+'_close').show();
									$.cookie('TAB_'+tmp, '1', { path: '/', expires: 365 });
									
									xajax_save_boks_konfig( 'boksy_'+tmp , getLayoutName() , "open_close" , '1');
									makeBigCol();
								}
							); 
							
												$( '#s24_'+tmp+'_close' ).unbind("click");
												$( '#s24_'+tmp+'_close' ).click(
													function(){
														var tmp = "multimedia_right_galeria";
														$('#'+tmp).hide();
														$('#s24_'+tmp+'_open').show();
														$('#s24_'+tmp+'_close').hide();
														$.cookie('TAB_'+tmp, '0', { path: '/', expires: 365 });
														
														xajax_save_boks_konfig( 'boksy_'+tmp , getLayoutName() , "open_close" , '0');
														makeBigCol();
													}
												);
						}
						// otwieranie zamykanie "boksy_multimedia_right_galeria" KONIEC
						
						// otwieranie zamykanie "tag_right" START
						var tmp = "tag_right";
						if ( $("#s24_"+tmp+"_open").length > 0 ) {
							$( '#s24_'+tmp+'_open' ).unbind("click");
							$( '#s24_'+tmp+'_open' ).click(
								function(){
									var tmp = "tag_right";
									$('#'+tmp).show();
									$('#s24_'+tmp+'_open').hide();
									$('#s24_'+tmp+'_close').show();
									$.cookie('TAB_'+tmp, '1', { path: '/', expires: 365 });
									
									xajax_save_boks_konfig( 'boksy_'+tmp , getLayoutName() , "open_close" , '1');
									makeBigCol();
								}
							); 
							
												$( '#s24_'+tmp+'_close' ).unbind("click");
												$( '#s24_'+tmp+'_close' ).click(
													function(){
														var tmp = "tag_right";
														$('#'+tmp).hide();
														$('#s24_'+tmp+'_open').show();
														$('#s24_'+tmp+'_close').hide();
														$.cookie('TAB_'+tmp, '0', { path: '/', expires: 365 });
														
														xajax_save_boks_konfig( 'boksy_'+tmp , getLayoutName() , "open_close" , '0');
														makeBigCol();
													}
												);
						}
						// otwieranie zamykanie "tag_right" KONIEC
						
						// otwieranie zamykanie "ostatnio_zalogowani" START
						var tmp = "ostatnio_zalogowani";
						if ( $("#s24_"+tmp+"_open").length > 0 ) {
							$( '#s24_'+tmp+'_open' ).unbind("click");
							$( '#s24_'+tmp+'_open' ).click(
								function(){
									var tmp = "ostatnio_zalogowani";
									$('#'+tmp).show();
									$('#s24_'+tmp+'_open').hide();
									$('#s24_'+tmp+'_close').show();
									$.cookie('TAB_'+tmp, '1', { path: '/', expires: 365 });
									
									xajax_save_boks_konfig( 'boksy_'+tmp , getLayoutName() , "open_close" , '1');
									makeBigCol();
								}
							); 
							
												$( '#s24_'+tmp+'_close' ).unbind("click");
												$( '#s24_'+tmp+'_close' ).click(
													function(){
														var tmp = "ostatnio_zalogowani";
														$('#'+tmp).hide();
														$('#s24_'+tmp+'_open').show();
														$('#s24_'+tmp+'_close').hide();
														$.cookie('TAB_'+tmp, '0', { path: '/', expires: 365 });
														
														xajax_save_boks_konfig( 'boksy_'+tmp , getLayoutName() , "open_close" , '0');
														makeBigCol();
													}
												);
						}
						// otwieranie zamykanie "ostatnio_zalogowani" KONIEC
						
						// otwieranie zamykanie "notki_ze_wszystkich" START
						var tmp = "notki_ze_wszystkich";
						if ( $("#s24_"+tmp+"_open").length > 0 ) {
							$( '#s24_'+tmp+'_open' ).unbind("click");
							$( '#s24_'+tmp+'_open' ).click(
								function(){
									var tmp = "notki_ze_wszystkich";
									$('#'+tmp).show();
									$('#s24_'+tmp+'_open').hide();
									$('#s24_'+tmp+'_close').show();
									$.cookie('TAB_'+tmp, '1', { path: '/', expires: 365 });
									
									xajax_save_boks_konfig( 'boksy_'+tmp , getLayoutName() , "open_close" , '1');
									makeBigCol();
								}
							); 
							
												$( '#s24_'+tmp+'_close' ).unbind("click");
												$( '#s24_'+tmp+'_close' ).click(
													function(){
														var tmp = "notki_ze_wszystkich";
														$('#'+tmp).hide();
														$('#s24_'+tmp+'_open').show();
														$('#s24_'+tmp+'_close').hide();
														$.cookie('TAB_'+tmp, '0', { path: '/', expires: 365 });
														
														xajax_save_boks_konfig( 'boksy_'+tmp , getLayoutName() , "open_close" , '0');
														makeBigCol();
													}
												);
						}
						// otwieranie zamykanie "notki_ze_wszystkich" KONIEC
						
						// otwieranie zamykanie "shoutbox" START
						var tmp = "shoutbox";
						if ( $("#s24_"+tmp+"_open").length > 0 ) {
							$( '#s24_'+tmp+'_open' ).unbind("click");
							$( '#s24_'+tmp+'_open' ).click(
								function(){
									var tmp = "shoutbox";
									$('#'+tmp).show();
									$('#s24_'+tmp+'_open').hide();
									$('#s24_'+tmp+'_close').show();
									$.cookie('TAB_'+tmp, '1', { path: '/', expires: 365 });
									
									xajax_save_boks_konfig( 'boksy_'+tmp , getLayoutName() , "open_close" , '1');
									makeBigCol();
								}
							); 
							
												$( '#s24_'+tmp+'_close' ).unbind("click");
												$( '#s24_'+tmp+'_close' ).click(
													function(){
														var tmp = "shoutbox";
														$('#'+tmp).hide();
														$('#s24_'+tmp+'_open').show();
														$('#s24_'+tmp+'_close').hide();
														$.cookie('TAB_'+tmp, '0', { path: '/', expires: 365 });
														
														xajax_save_boks_konfig( 'boksy_'+tmp , getLayoutName() , "open_close" , '0');
														makeBigCol();
													}
												);
						}
						// otwieranie zamykanie "shoutbox" KONIEC
						
						// otwieranie zamykanie "forum" START
						var tmp = "forum";
						if ( $("#s24_"+tmp+"_open").length > 0 ) {
							$( '#s24_'+tmp+'_open' ).unbind("click");
							$( '#s24_'+tmp+'_open' ).click(
								function(){
									var tmp = "forum";
									$('#'+tmp).show();
									$('#s24_'+tmp+'_open').hide();
									$('#s24_'+tmp+'_close').show();
									$.cookie('TAB_'+tmp, '1', { path: '/', expires: 365 });
									
									xajax_save_boks_konfig( 'boksy_'+tmp , getLayoutName() , "open_close" , '1');
									makeBigCol();
								}
							); 
							
												$( '#s24_'+tmp+'_close' ).unbind("click");
												$( '#s24_'+tmp+'_close' ).click(
													function(){
														var tmp = "forum";
														$('#'+tmp).hide();
														$('#s24_'+tmp+'_open').show();
														$('#s24_'+tmp+'_close').hide();
														$.cookie('TAB_'+tmp, '0', { path: '/', expires: 365 });
														
														xajax_save_boks_konfig( 'boksy_'+tmp , getLayoutName() , "open_close" , '0');
														makeBigCol();
													}
												);
						}
						// otwieranie zamykanie "forum" KONIEC
		*/				
								
						// sortowanie "boksy_user_ostatnio_zalogowane" START
						if ( jQuery("#s24_coments_sort_asc").length > 0 ) {
							jQuery( '#s24_coments_sort_asc' ).unbind("click");
							jQuery( '#s24_coments_sort_asc' ).click(
								function(){
									
									jQuery('#s24_coments_sort_asc').addClass("global_c");
									jQuery('#s24_coments_sort_desc').removeClass("global_c");
									jQuery.cookie('coments_sort', '1', { path: '/', expires: 365, domain: '.com.pl' });
									
									xajax_save_boks_konfig( 'boksy_coments' , 'global' , "sort" , '1');
									//setTimeout("window.location.href = unescape(window.location.pathname);", 1200 );
									//makeBigCol();
								}
							);
							
												jQuery( '#s24_coments_sort_desc' ).unbind("click");
												jQuery( '#s24_coments_sort_desc' ).click(
													function(){
														
														jQuery('#s24_coments_sort_asc').removeClass("global_c");
														jQuery('#s24_coments_sort_desc').addClass("global_c");
														jQuery.cookie('coments_sort', '2', { path: '/', expires: 365, domain: '.com.pl' });
														
														xajax_save_boks_konfig( 'boksy_coments' , 'global' , "sort" , '2');
														//setTimeout("window.location.href = unescape(window.location.pathname);", 1200 );
														//makeBigCol();
													}
												);
						}
						
// -------------------------------------  KONIEC - OTWIERANIE ZAMYKANIE BOKS�W -------------------------------------

// ------------------------------------- START - OTWIERANIE ZAMYKANIE BOKS�W SPRAWDZENIE -------------------------------------				
							// sprawdzanie ktore taby maja byc zamkniete a ktore otwarte
							// lista tabow ? jak sprawdzac ktore taby sa aktualnie na stronie
							var tabs = new Array(	'ostatnio_zalogowani' , 'news_nauka_studia' , 'news_rozrywka_kultura', 'news_finanse_firma' ,
													'news_praca_kariera' , 'multimedia_right_filmy' ,'multimedia_right_galeria' , 'tag_right',
													 'notki_ze_wszystkich' , 'shoutbox' , 'forum' , 'imprezy' , 'studentka_miesiaca',
													'news_film' , 'news_muzyka' , 'news_dvd' , 'news_multimedia' , 'news_felieton' , 'news_przewodnik' , 
													'news_wywiady' , 'news_studencka_mapa_polski' , 'news_juwenalia' , 'news_polecamy' , 'news_raporty' ,
													'news_uczelnia' , 'news_studenckie_m' , 'news_magisterka' , 'news_po_magisterce' , 'news_studia_za_granica',
													'news_ocen_pl' , 'news_wielkie_z_wielkie_5' , 'news_oni_osiagneli_sukces' , 'news_wlasna_firma' , 'news_twoje_pieniadze',
													'news_kasa_na_firme' , 'news_szef' , 'news_praktyki_i_staze' , 'news_mlodzi_zdolni' , 'news_sciezki_kariery',
													'news_zawod' , 'news_kwalifikacje' , 'news_praca' , 'news_praca_za_granica' , 'news_testy_jezykowe',
													'news_rekrutacja' , 'news_trendy' , 'news_testy_zawodowe' , 'news_sporootym' , 'news_niezbednik' ,
													'news_profile_firm' , 'news_ogloszenia_o_prace' , 'news_certyfikaty' , 'news_zdaj_mature', 'news_rankingi',
													'lista_ogloszenia_drobne' , 'lista_sciagi' , 'lista_uczelnie' , 'lista_stancje' , 
													'fankluby_top_akademiki' , 'fankluby_top_uczelnie' , 'fankluby_top_kierunki' , 'fanklub_ostatnio_dolaczyli' ,
													
													'about_me', 'calendar_blog', 'last_note_user_left','fav_urls' , 'sonda' ,
													'fanklub_blog', 'fanklub_galeria', 'fanklub_komentarze', 'fanklub_opis' ,'fanklub_ostatnio_dolaczyli',
												 	'fanklub_sonda', 'fanklub_spotkania', 'fanklub_wojna_pokoj', 'fanklub_goscie', 'fanklub_forum',
												 	'fanklub_komentarze' , 'blog_naj_czytane' , 'blog_ostatnie_komentarze' , 'blog_naj_komentowane', 'ostatnio_dodane_zdjecia',
												 	'fankluby_top_respekt', 'fankluby_top_kasa' , 'fankluby_top_nowe' , 'fankluby_top_przyrost',
													'profil_moje_fankluby' , 'profil_kontakt' , 'profil_o_mnie' , 'profil_galeria' , 'profil_opis' , 'profil_znajomi',
													'notki_usera' , 'notki_uzytkownika','najpopularniejsi' ,'newsletter'
													); 
							var tabs_length = tabs.length;					
							for(i=0; i< tabs_length ; i++) { 
								//alert($.cookie(tabs[i]));
							   var str=tabs[i];
							   if (jQuery.cookie('TAB_'+str) == 0) {
							   		
									//str = str.replace(/TAB_/g, "");
									//alert(str);
									var t = jQuery('#'+str);
									if ( t.length > 0 ) {
										t.hide();
										jQuery('#s24_'+str+'_open').show();
										jQuery('#s24_'+str+'_close').hide();
									}
							   } 
							} 
							
// ------------------------------------- KONIEC - OTWIERANIE ZAMYKANIE BOKS�W SPRAWDZENIE -------------------------------------	
// ------------------------------------- START - PANELE USTAWIEN BOKSOW -------------------------------------	
							// -------------------- boksy_notki_ze_wszystkich - start ------------------------------
							if ( jQuery('#boksy_notki_ze_wszystkich').length > 0 ) {
								// Ostatnie 10 notek ze wszystkich blogow
							
							    var _CNAME1 = 'TAB_lnls_'+getLayoutName(); //TAB_last_note_left_settings
								// sprawdzenie ile obiektow powinno byc otwartych
								var ile = jQuery.cookie(_CNAME1);
						 		if (ile == null || ile == 0) ile = 2;
								for (var i=1;i<12;i++) {
									jQuery("div.notki_ze_wszystkich_settings > div.Nsetting").filter(":nth-child("+i+")").removeClass("global_c");
									if 	(i <= ile) {
										jQuery('#s24_last_note_'+i).show(); 
										
									} else {
										jQuery('#s24_last_note_'+i).hide();
									}
								}
								ile++;
								jQuery("div.notki_ze_wszystkich_settings > div.Nsetting").filter(":nth-child("+ile+")").addClass("global_c");
							
//								$( '#s24_notki_ze_wszystkich_settings_open' ).unbind("click");
//								$( '#s24_notki_ze_wszystkich_settings_open' ).click(
//									
//											function(){
//												$('#s24_notki_ze_wszystkich_settings').toggle(400);
//												
//											}
//					
//								);
								
								jQuery('div.notki_ze_wszystkich_settings > div.Nsetting').each(function() {jQuery(this).unbind("click")}   );
								jQuery('div.notki_ze_wszystkich_settings > div.Nsetting').each(
									
									function() {
										jQuery(this).click(
											function() {
											
												var r = jQuery(this).text();
												jQuery.cookie(_CNAME1, r, {domain: 'com.pl', path: '/', expires: 365 });
												
												// $boks_name , $layout_name , $nazwa_pola , $wartosc 
												xajax_save_boks_konfig( 'boksy_notki_ze_wszystkich' , getLayoutName() , "ilosc_obiektow_w_pionie" , r);
												
												for (var i=1;i<12;i++) {
													jQuery("div.notki_ze_wszystkich_settings > div.Nsetting").filter(":nth-child("+i+")").removeClass("global_c");  
													if 	(i <= r) {
														jQuery('#s24_last_note_'+i).show(); 
														
													} else {
														jQuery('#s24_last_note_'+i).hide();
													}
												}
												r++;
												jQuery("div.notki_ze_wszystkich_settings > div.Nsetting").filter(":nth-child("+r+")").addClass("global_c");
												makeBigCol();
											}
										);
									}
									
								);	
							
							}
							// -------------------- boksy_notki_ze_wszystkich - stop ------------------------------
					/*			
							// -------------------- boksy_google_maps - start ------------------------------
							if ($('#boksy_google_maps').length > 0) {
								$('#s24_google_maps_settings_open').unbind("click");
								$('#s24_google_maps_settings_open').click(function(){
									$('#s24_google_maps_settings').toggle(400);
									
								});
							}		
							
							// -------------------- boksy_google_maps - stop ------------------------------
							
							
							// -------------------- boksy_main_news_bottom2 - start ------------------------------
							var __NEWS_BOKS = new Array( 	"news_nauka_studia",
														"news_rozrywka_kultura",
														"news_praca_kariera",
								 						"news_finanse_firma" );
							
						
							var __NEWS_BOKS_int = 0;
							
							if ($("#boksy_"+__NEWS_BOKS[__NEWS_BOKS_int]).length > 0) {
									// otwieranie zamykanie "tabele" START
									$('#s24_'+__NEWS_BOKS[__NEWS_BOKS_int]+'_settings_open').unbind("click");
									$('#s24_'+__NEWS_BOKS[__NEWS_BOKS_int]+'_settings_open').click(function(){
									
										$('#s24_'+__NEWS_BOKS[__NEWS_BOKS_int]+'_settings').toggle(400);
										
									});
									
									$('#s24_'+__NEWS_BOKS[__NEWS_BOKS_int]+'_settings > div.Nsetting').each(function(){
										$(this).unbind("click")
									});
									$('#s24_'+__NEWS_BOKS[__NEWS_BOKS_int]+'_settings > div.Nsetting').each(function(){
										$(this).click(function(){
										
											var r = $(this).text();
											
											$.cookie('TAB_iowp_boksy_'+__NEWS_BOKS[__NEWS_BOKS_int], r, {
												domain: 'com.pl',
												path: '/',
												expires: 365
											});
											
											// $boks_name , $layout_name , $nazwa_pola , $wartosc 
											xajax_save_boks_konfig('boksy_'+__NEWS_BOKS[__NEWS_BOKS_int], getLayoutName(), "ilosc_obiektow_w_pionie", r);
											
											for (var i = 1; i < 12; i++) {
												$("#s24_"+__NEWS_BOKS[__NEWS_BOKS_int]+"_settings > div.Nsetting").filter(":nth-child(" + i + ")").css('color', '#367cc2');
												if (i <= r) {
													$('#s24_'+__NEWS_BOKS[__NEWS_BOKS_int]+'_bottom_' + i).show();
													
												}
												else {
													$('#s24_'+__NEWS_BOKS[__NEWS_BOKS_int]+'_bottom_' + i).hide();
												
												}
											}
											r++;
											$("#s24_"+__NEWS_BOKS[__NEWS_BOKS_int]+"_settings > div.Nsetting").filter(":nth-child(" + r + ")").css('color', '#ed1d24');
											
											makeBigCol();
											
										});
									});
									
									
									// sprawdzenie ile notek jest na stronie
									var ileMax = 11;
									
									// sprawdzenie ile obiektow powinno byc otwartych
									lnbs_pokaz_notki(__NEWS_BOKS[__NEWS_BOKS_int]);
									
									// ukrywa obrazki i czesc tekstu newsa 
									show_hide_element(__NEWS_BOKS[__NEWS_BOKS_int]);
									
									// Wylanczanie zdjec i opisow newsow
									$('#s24_'+__NEWS_BOKS[__NEWS_BOKS_int]+'_settings > div.taknie').each(function(){
										$(this).unbind("click")
									});
									$('#s24_'+__NEWS_BOKS[__NEWS_BOKS_int]+'_settings > #lnbs_foto_tak_'+__NEWS_BOKS[__NEWS_BOKS_int]).click(function(){
									
										$.cookie('TAB_'+__NEWS_BOKS[__NEWS_BOKS_int]+'_foto_setting_' + getLayoutName(), '1', {
											path: '/',
											expires: 365
										});
										$('.s24_'+__NEWS_BOKS[__NEWS_BOKS_int]+'_bottom > div.lnbs_foto_'+__NEWS_BOKS[__NEWS_BOKS_int]).show();
										xajax_save_boks_konfig('boksy_'+__NEWS_BOKS[__NEWS_BOKS_int], getLayoutName(), "show_hide_foto", '1');
										makeBigCol();
										$('#lnbs_foto_nie_'+__NEWS_BOKS[__NEWS_BOKS_int]).css('color', '#367cc2');
										$('#lnbs_foto_tak_'+__NEWS_BOKS[__NEWS_BOKS_int]).css('color', '#ed1d24');
										$('div.lnbs_foto_nofoto_'+__NEWS_BOKS[__NEWS_BOKS_int]).hide();
										show_hide_element_height_help(__NEWS_BOKS[__NEWS_BOKS_int]);
									});
									$('#s24_'+__NEWS_BOKS[__NEWS_BOKS_int]+'_settings > #lnbs_foto_nie_'+__NEWS_BOKS[__NEWS_BOKS_int]).click(function(){
									
										$.cookie('TAB_'+__NEWS_BOKS[__NEWS_BOKS_int]+'_foto_setting_' + getLayoutName(), '0', {
											path: '/',
											expires: 365
										});
										$('.s24_'+__NEWS_BOKS[__NEWS_BOKS_int]+'_bottom > div.lnbs_foto_'+__NEWS_BOKS[__NEWS_BOKS_int]).hide();
										xajax_save_boks_konfig('boksy_'+__NEWS_BOKS[__NEWS_BOKS_int], getLayoutName(), "show_hide_foto", '0');
										makeBigCol();
										$('#lnbs_foto_nie_'+__NEWS_BOKS[__NEWS_BOKS_int]).css('color', '#ed1d24');
										$('#lnbs_foto_tak_'+__NEWS_BOKS[__NEWS_BOKS_int]).css('color', '#367cc2');
										$('div.lnbs_foto_nofoto_'+__NEWS_BOKS[__NEWS_BOKS_int]).show();
										show_hide_element_height_help(__NEWS_BOKS[__NEWS_BOKS_int]);
									});
									$('#s24_'+__NEWS_BOKS[__NEWS_BOKS_int]+'_settings > #lnbs_short_text_tak_'+__NEWS_BOKS[__NEWS_BOKS_int]).click(function(){
									
										$.cookie('TAB_'+__NEWS_BOKS[__NEWS_BOKS_int]+'_short_text_setting_' + getLayoutName(), '1', {
											path: '/',
											expires: 365
										});
										$('.s24_'+__NEWS_BOKS[__NEWS_BOKS_int]+'_bottom >  div > div.lnbs_short_text_'+__NEWS_BOKS[__NEWS_BOKS_int]).show();
										$('.s24_'+__NEWS_BOKS[__NEWS_BOKS_int]+'_bottom >  div > div.lnbs_short_notext_'+__NEWS_BOKS[__NEWS_BOKS_int]).hide();
										xajax_save_boks_konfig('boksy_'+__NEWS_BOKS[__NEWS_BOKS_int], getLayoutName(), "show_hide_short_text", '1');
										makeBigCol();
										$('#lnbs_short_text_nie_'+__NEWS_BOKS[__NEWS_BOKS_int]).css('color', '#367cc2');
										$('#lnbs_short_text_tak_'+__NEWS_BOKS[__NEWS_BOKS_int]).css('color', '#ed1d24');
										show_hide_element_height_help(__NEWS_BOKS[__NEWS_BOKS_int]);
									});
									$('#s24_'+__NEWS_BOKS[__NEWS_BOKS_int]+'_settings > #lnbs_short_text_nie_'+__NEWS_BOKS[__NEWS_BOKS_int]).click(function(){
									
										$.cookie('TAB_'+__NEWS_BOKS[__NEWS_BOKS_int]+'_short_text_setting_' + getLayoutName(), '0', {
											path: '/',
											expires: 365
										});
										$('.s24_'+__NEWS_BOKS[__NEWS_BOKS_int]+'_bottom > div > div.lnbs_short_text_'+__NEWS_BOKS[__NEWS_BOKS_int]).hide();
										$('.s24_'+__NEWS_BOKS[__NEWS_BOKS_int]+'_bottom > div > div.lnbs_short_notext_'+__NEWS_BOKS[__NEWS_BOKS_int]).show();
										xajax_save_boks_konfig('boksy_'+__NEWS_BOKS[__NEWS_BOKS_int], getLayoutName(), "show_hide_short_text", '0');
										makeBigCol();
										$('#lnbs_short_text_nie_'+__NEWS_BOKS[__NEWS_BOKS_int]).css('color', '#ed1d24');
										$('#lnbs_short_text_tak_'+__NEWS_BOKS[__NEWS_BOKS_int]).css('color', '#367cc2');
										show_hide_element_height_help(__NEWS_BOKS[__NEWS_BOKS_int]);
										
									});
								
							}
							
							// KOPIA POWYŻSZEGO 
							
							var __NEWS_BOKS_int_1 = 1;
							
							if ($("#boksy_"+__NEWS_BOKS[__NEWS_BOKS_int_1]).length > 0) {
									// otwieranie zamykanie "tabele" START
									$('#s24_'+__NEWS_BOKS[__NEWS_BOKS_int_1]+'_settings_open').unbind("click");
									$('#s24_'+__NEWS_BOKS[__NEWS_BOKS_int_1]+'_settings_open').click(function(){
									
										$('#s24_'+__NEWS_BOKS[__NEWS_BOKS_int_1]+'_settings').toggle(400);
										
									});
									
									$('#s24_'+__NEWS_BOKS[__NEWS_BOKS_int_1]+'_settings > div.Nsetting').each(function(){
										$(this).unbind("click")
									});
									$('#s24_'+__NEWS_BOKS[__NEWS_BOKS_int_1]+'_settings > div.Nsetting').each(function(){
										$(this).click(function(){
										
											var r = $(this).text();
											
											$.cookie('TAB_iowp_boksy_'+__NEWS_BOKS[__NEWS_BOKS_int_1], r, {
												domain: 'com.pl',
												path: '/',
												expires: 365
											});
											
											// $boks_name , $layout_name , $nazwa_pola , $wartosc 
											xajax_save_boks_konfig('boksy_'+__NEWS_BOKS[__NEWS_BOKS_int_1], getLayoutName(), "ilosc_obiektow_w_pionie", r);
											
											for (var i = 1; i < 12; i++) {
												$("#s24_"+__NEWS_BOKS[__NEWS_BOKS_int_1]+"_settings > div.Nsetting").filter(":nth-child(" + i + ")").css('color', '#367cc2');
												if (i <= r) {
													$('#s24_'+__NEWS_BOKS[__NEWS_BOKS_int_1]+'_bottom_' + i).show();
													
												}
												else {
													$('#s24_'+__NEWS_BOKS[__NEWS_BOKS_int_1]+'_bottom_' + i).hide();
												
												}
											}
											r++;
											$("#s24_"+__NEWS_BOKS[__NEWS_BOKS_int_1]+"_settings > div.Nsetting").filter(":nth-child(" + r + ")").css('color', '#ed1d24');
											
											makeBigCol();
											
										});
									});
									
									
									// sprawdzenie ile notek jest na stronie
									var ileMax = 11;
									
									// sprawdzenie ile obiektow powinno byc otwartych
									lnbs_pokaz_notki(__NEWS_BOKS[__NEWS_BOKS_int_1]);
									
									// ukrywa obrazki i czesc tekstu newsa 
									show_hide_element(__NEWS_BOKS[__NEWS_BOKS_int_1]);
									
									// Wylanczanie zdjec i opisow newsow
									$('#s24_'+__NEWS_BOKS[__NEWS_BOKS_int_1]+'_settings > div.taknie').each(function(){
										$(this).unbind("click")
									});
									$('#s24_'+__NEWS_BOKS[__NEWS_BOKS_int_1]+'_settings > #lnbs_foto_tak_'+__NEWS_BOKS[__NEWS_BOKS_int_1]).click(function(){
									
										$.cookie('TAB_'+__NEWS_BOKS[__NEWS_BOKS_int_1]+'_foto_setting_' + getLayoutName(), '1', {
											path: '/',
											expires: 365
										});
										$('.s24_'+__NEWS_BOKS[__NEWS_BOKS_int_1]+'_bottom > div.lnbs_foto_'+__NEWS_BOKS[__NEWS_BOKS_int_1]).show();
										xajax_save_boks_konfig('boksy_'+__NEWS_BOKS[__NEWS_BOKS_int_1], getLayoutName(), "show_hide_foto", '1');
										makeBigCol();
										$('#lnbs_foto_nie_'+__NEWS_BOKS[__NEWS_BOKS_int_1]).css('color', '#367cc2');
										$('#lnbs_foto_tak_'+__NEWS_BOKS[__NEWS_BOKS_int_1]).css('color', '#ed1d24');
										$('div.lnbs_foto_nofoto_'+__NEWS_BOKS[__NEWS_BOKS_int_1]).hide();
										show_hide_element_height_help(__NEWS_BOKS[__NEWS_BOKS_int_1]);
									});
									$('#s24_'+__NEWS_BOKS[__NEWS_BOKS_int_1]+'_settings > #lnbs_foto_nie_'+__NEWS_BOKS[__NEWS_BOKS_int_1]).click(function(){
									
										$.cookie('TAB_'+__NEWS_BOKS[__NEWS_BOKS_int_1]+'_foto_setting_' + getLayoutName(), '0', {
											path: '/',
											expires: 365
										});
										$('.s24_'+__NEWS_BOKS[__NEWS_BOKS_int_1]+'_bottom > div.lnbs_foto_'+__NEWS_BOKS[__NEWS_BOKS_int_1]).hide();
										xajax_save_boks_konfig('boksy_'+__NEWS_BOKS[__NEWS_BOKS_int_1], getLayoutName(), "show_hide_foto", '0');
										makeBigCol();
										$('#lnbs_foto_nie_'+__NEWS_BOKS[__NEWS_BOKS_int_1]).css('color', '#ed1d24');
										$('#lnbs_foto_tak_'+__NEWS_BOKS[__NEWS_BOKS_int_1]).css('color', '#367cc2');
										$('div.lnbs_foto_nofoto_'+__NEWS_BOKS[__NEWS_BOKS_int_1]).show();
										show_hide_element_height_help(__NEWS_BOKS[__NEWS_BOKS_int_1]);
									});
									$('#s24_'+__NEWS_BOKS[__NEWS_BOKS_int_1]+'_settings > #lnbs_short_text_tak_'+__NEWS_BOKS[__NEWS_BOKS_int_1]).click(function(){
									
										$.cookie('TAB_'+__NEWS_BOKS[__NEWS_BOKS_int_1]+'_short_text_setting_' + getLayoutName(), '1', {
											path: '/',
											expires: 365
										});
										$('.s24_'+__NEWS_BOKS[__NEWS_BOKS_int_1]+'_bottom >  div > div.lnbs_short_text_'+__NEWS_BOKS[__NEWS_BOKS_int_1]).show();
										$('.s24_'+__NEWS_BOKS[__NEWS_BOKS_int_1]+'_bottom >  div > div.lnbs_short_notext_'+__NEWS_BOKS[__NEWS_BOKS_int_1]).hide();
										xajax_save_boks_konfig('boksy_'+__NEWS_BOKS[__NEWS_BOKS_int_1], getLayoutName(), "show_hide_short_text", '1');
										makeBigCol();
										$('#lnbs_short_text_nie_'+__NEWS_BOKS[__NEWS_BOKS_int_1]).css('color', '#367cc2');
										$('#lnbs_short_text_tak_'+__NEWS_BOKS[__NEWS_BOKS_int_1]).css('color', '#ed1d24');
										show_hide_element_height_help(__NEWS_BOKS[__NEWS_BOKS_int_1]);
									});
									$('#s24_'+__NEWS_BOKS[__NEWS_BOKS_int_1]+'_settings > #lnbs_short_text_nie_'+__NEWS_BOKS[__NEWS_BOKS_int_1]).click(function(){
									
										$.cookie('TAB_'+__NEWS_BOKS[__NEWS_BOKS_int_1]+'_short_text_setting_' + getLayoutName(), '0', {
											path: '/',
											expires: 365
										});
										$('.s24_'+__NEWS_BOKS[__NEWS_BOKS_int_1]+'_bottom > div > div.lnbs_short_text_'+__NEWS_BOKS[__NEWS_BOKS_int_1]).hide();
										$('.s24_'+__NEWS_BOKS[__NEWS_BOKS_int_1]+'_bottom > div > div.lnbs_short_notext_'+__NEWS_BOKS[__NEWS_BOKS_int_1]).show();
										xajax_save_boks_konfig('boksy_'+__NEWS_BOKS[__NEWS_BOKS_int_1], getLayoutName(), "show_hide_short_text", '0');
										makeBigCol();
										$('#lnbs_short_text_nie_'+__NEWS_BOKS[__NEWS_BOKS_int_1]).css('color', '#ed1d24');
										$('#lnbs_short_text_tak_'+__NEWS_BOKS[__NEWS_BOKS_int_1]).css('color', '#367cc2');
										show_hide_element_height_help(__NEWS_BOKS[__NEWS_BOKS_int_1]);
										
									});
								
							}
							
							var __NEWS_BOKS_int_2 = 2;
							
							if ($("#boksy_"+__NEWS_BOKS[__NEWS_BOKS_int_2]).length > 0) {
									// otwieranie zamykanie "tabele" START
									$('#s24_'+__NEWS_BOKS[__NEWS_BOKS_int_2]+'_settings_open').unbind("click");
									$('#s24_'+__NEWS_BOKS[__NEWS_BOKS_int_2]+'_settings_open').click(function(){
									
										$('#s24_'+__NEWS_BOKS[__NEWS_BOKS_int_2]+'_settings').toggle(400);
										
									});
									
									$('#s24_'+__NEWS_BOKS[__NEWS_BOKS_int_2]+'_settings > div.Nsetting').each(function(){
										$(this).unbind("click")
									});
									$('#s24_'+__NEWS_BOKS[__NEWS_BOKS_int_2]+'_settings > div.Nsetting').each(function(){
										$(this).click(function(){
										
											var r = $(this).text();
											
											$.cookie('TAB_iowp_boksy_'+__NEWS_BOKS[__NEWS_BOKS_int_2], r, {
												domain: 'com.pl',
												path: '/',
												expires: 365
											});
											
											// $boks_name , $layout_name , $nazwa_pola , $wartosc 
											xajax_save_boks_konfig('boksy_'+__NEWS_BOKS[__NEWS_BOKS_int_2], getLayoutName(), "ilosc_obiektow_w_pionie", r);
											
											for (var i = 1; i < 12; i++) {
												$("#s24_"+__NEWS_BOKS[__NEWS_BOKS_int_2]+"_settings > div.Nsetting").filter(":nth-child(" + i + ")").css('color', '#367cc2');
												if (i <= r) {
													$('#s24_'+__NEWS_BOKS[__NEWS_BOKS_int_2]+'_bottom_' + i).show();
													
												}
												else {
													$('#s24_'+__NEWS_BOKS[__NEWS_BOKS_int_2]+'_bottom_' + i).hide();
												
												}
											}
											r++;
											$("#s24_"+__NEWS_BOKS[__NEWS_BOKS_int_2]+"_settings > div.Nsetting").filter(":nth-child(" + r + ")").css('color', '#ed1d24');
											
											makeBigCol();
											
										});
									});
									
									
									// sprawdzenie ile notek jest na stronie
									var ileMax = 11;
									
									// sprawdzenie ile obiektow powinno byc otwartych
									lnbs_pokaz_notki(__NEWS_BOKS[__NEWS_BOKS_int_2]);
									
									// ukrywa obrazki i czesc tekstu newsa 
									show_hide_element(__NEWS_BOKS[__NEWS_BOKS_int_2]);
									
									// Wylanczanie zdjec i opisow newsow
									$('#s24_'+__NEWS_BOKS[__NEWS_BOKS_int_2]+'_settings > div.taknie').each(function(){
										$(this).unbind("click")
									});
									$('#s24_'+__NEWS_BOKS[__NEWS_BOKS_int_2]+'_settings > #lnbs_foto_tak_'+__NEWS_BOKS[__NEWS_BOKS_int_2]).click(function(){
									
										$.cookie('TAB_'+__NEWS_BOKS[__NEWS_BOKS_int_2]+'_foto_setting_' + getLayoutName(), '1', {
											path: '/',
											expires: 365
										});
										$('.s24_'+__NEWS_BOKS[__NEWS_BOKS_int_2]+'_bottom > div.lnbs_foto_'+__NEWS_BOKS[__NEWS_BOKS_int_2]).show();
										xajax_save_boks_konfig('boksy_'+__NEWS_BOKS[__NEWS_BOKS_int_2], getLayoutName(), "show_hide_foto", '1');
										makeBigCol();
										$('#lnbs_foto_nie_'+__NEWS_BOKS[__NEWS_BOKS_int_2]).css('color', '#367cc2');
										$('#lnbs_foto_tak_'+__NEWS_BOKS[__NEWS_BOKS_int_2]).css('color', '#ed1d24');
										$('div.lnbs_foto_nofoto_'+__NEWS_BOKS[__NEWS_BOKS_int_2]).hide();
										show_hide_element_height_help(__NEWS_BOKS[__NEWS_BOKS_int_2]);
									});
									$('#s24_'+__NEWS_BOKS[__NEWS_BOKS_int_2]+'_settings > #lnbs_foto_nie_'+__NEWS_BOKS[__NEWS_BOKS_int_2]).click(function(){
									
										$.cookie('TAB_'+__NEWS_BOKS[__NEWS_BOKS_int_2]+'_foto_setting_' + getLayoutName(), '0', {
											path: '/',
											expires: 365
										});
										$('.s24_'+__NEWS_BOKS[__NEWS_BOKS_int_2]+'_bottom > div.lnbs_foto_'+__NEWS_BOKS[__NEWS_BOKS_int_2]).hide();
										xajax_save_boks_konfig('boksy_'+__NEWS_BOKS[__NEWS_BOKS_int_2], getLayoutName(), "show_hide_foto", '0');
										makeBigCol();
										$('#lnbs_foto_nie_'+__NEWS_BOKS[__NEWS_BOKS_int_2]).css('color', '#ed1d24');
										$('#lnbs_foto_tak_'+__NEWS_BOKS[__NEWS_BOKS_int_2]).css('color', '#367cc2');
										$('div.lnbs_foto_nofoto_'+__NEWS_BOKS[__NEWS_BOKS_int_2]).show();
										show_hide_element_height_help(__NEWS_BOKS[__NEWS_BOKS_int_2]);
									});
									$('#s24_'+__NEWS_BOKS[__NEWS_BOKS_int_2]+'_settings > #lnbs_short_text_tak_'+__NEWS_BOKS[__NEWS_BOKS_int_2]).click(function(){
									
										$.cookie('TAB_'+__NEWS_BOKS[__NEWS_BOKS_int_2]+'_short_text_setting_' + getLayoutName(), '1', {
											path: '/',
											expires: 365
										});
										$('.s24_'+__NEWS_BOKS[__NEWS_BOKS_int_2]+'_bottom >  div > div.lnbs_short_text_'+__NEWS_BOKS[__NEWS_BOKS_int_2]).show();
										$('.s24_'+__NEWS_BOKS[__NEWS_BOKS_int_2]+'_bottom >  div > div.lnbs_short_notext_'+__NEWS_BOKS[__NEWS_BOKS_int_2]).hide();
										xajax_save_boks_konfig('boksy_'+__NEWS_BOKS[__NEWS_BOKS_int_2], getLayoutName(), "show_hide_short_text", '1');
										makeBigCol();
										$('#lnbs_short_text_nie_'+__NEWS_BOKS[__NEWS_BOKS_int_2]).css('color', '#367cc2');
										$('#lnbs_short_text_tak_'+__NEWS_BOKS[__NEWS_BOKS_int_2]).css('color', '#ed1d24');
										show_hide_element_height_help(__NEWS_BOKS[__NEWS_BOKS_int_2]);
									});
									$('#s24_'+__NEWS_BOKS[__NEWS_BOKS_int_2]+'_settings > #lnbs_short_text_nie_'+__NEWS_BOKS[__NEWS_BOKS_int_2]).click(function(){
									
										$.cookie('TAB_'+__NEWS_BOKS[__NEWS_BOKS_int_2]+'_short_text_setting_' + getLayoutName(), '0', {
											path: '/',
											expires: 365
										});
										$('.s24_'+__NEWS_BOKS[__NEWS_BOKS_int_2]+'_bottom > div > div.lnbs_short_text_'+__NEWS_BOKS[__NEWS_BOKS_int_2]).hide();
										$('.s24_'+__NEWS_BOKS[__NEWS_BOKS_int_2]+'_bottom > div > div.lnbs_short_notext_'+__NEWS_BOKS[__NEWS_BOKS_int_2]).show();
										xajax_save_boks_konfig('boksy_'+__NEWS_BOKS[__NEWS_BOKS_int_2], getLayoutName(), "show_hide_short_text", '0');
										makeBigCol();
										$('#lnbs_short_text_nie_'+__NEWS_BOKS[__NEWS_BOKS_int_2]).css('color', '#ed1d24');
										$('#lnbs_short_text_tak_'+__NEWS_BOKS[__NEWS_BOKS_int_2]).css('color', '#367cc2');
										show_hide_element_height_help(__NEWS_BOKS[__NEWS_BOKS_int_2]);
										
									});
								
							}
							var __NEWS_BOKS_int_3 = 3;
							
							if ($("#boksy_"+__NEWS_BOKS[__NEWS_BOKS_int_3]).length > 0) {
									// otwieranie zamykanie "tabele" START
									$('#s24_'+__NEWS_BOKS[__NEWS_BOKS_int_3]+'_settings_open').unbind("click");
									$('#s24_'+__NEWS_BOKS[__NEWS_BOKS_int_3]+'_settings_open').click(function(){
									
										$('#s24_'+__NEWS_BOKS[__NEWS_BOKS_int_3]+'_settings').toggle(400);
										
									});
									
									$('#s24_'+__NEWS_BOKS[__NEWS_BOKS_int_3]+'_settings > div.Nsetting').each(function(){
										$(this).unbind("click")
									});
									$('#s24_'+__NEWS_BOKS[__NEWS_BOKS_int_3]+'_settings > div.Nsetting').each(function(){
										$(this).click(function(){
										
											var r = $(this).text();
											
											$.cookie('TAB_iowp_boksy_'+__NEWS_BOKS[__NEWS_BOKS_int_3], r, {
												domain: 'com.pl',
												path: '/',
												expires: 365
											});
											
											// $boks_name , $layout_name , $nazwa_pola , $wartosc 
											xajax_save_boks_konfig('boksy_'+__NEWS_BOKS[__NEWS_BOKS_int_3], getLayoutName(), "ilosc_obiektow_w_pionie", r);
											
											for (var i = 1; i < 12; i++) {
												$("#s24_"+__NEWS_BOKS[__NEWS_BOKS_int_3]+"_settings > div.Nsetting").filter(":nth-child(" + i + ")").css('color', '#367cc2');
												if (i <= r) {
													$('#s24_'+__NEWS_BOKS[__NEWS_BOKS_int_3]+'_bottom_' + i).show();
													
												}
												else {
													$('#s24_'+__NEWS_BOKS[__NEWS_BOKS_int_3]+'_bottom_' + i).hide();
												
												}
											}
											r++;
											$("#s24_"+__NEWS_BOKS[__NEWS_BOKS_int_3]+"_settings > div.Nsetting").filter(":nth-child(" + r + ")").css('color', '#ed1d24');
											
											makeBigCol();
											
										});
									});
									
									
									// sprawdzenie ile notek jest na stronie
									var ileMax = 11;
									
									// sprawdzenie ile obiektow powinno byc otwartych
									lnbs_pokaz_notki(__NEWS_BOKS[__NEWS_BOKS_int_3]);
									
									// ukrywa obrazki i czesc tekstu newsa 
									show_hide_element(__NEWS_BOKS[__NEWS_BOKS_int_3]);
									
									// Wylanczanie zdjec i opisow newsow
									$('#s24_'+__NEWS_BOKS[__NEWS_BOKS_int_3]+'_settings > div.taknie').each(function(){
										$(this).unbind("click")
									});
									$('#s24_'+__NEWS_BOKS[__NEWS_BOKS_int_3]+'_settings > #lnbs_foto_tak_'+__NEWS_BOKS[__NEWS_BOKS_int_3]).click(function(){
									
										$.cookie('TAB_'+__NEWS_BOKS[__NEWS_BOKS_int_3]+'_foto_setting_' + getLayoutName(), '1', {
											path: '/',
											expires: 365
										});
										$('.s24_'+__NEWS_BOKS[__NEWS_BOKS_int_3]+'_bottom > div.lnbs_foto_'+__NEWS_BOKS[__NEWS_BOKS_int_3]).show();
										xajax_save_boks_konfig('boksy_'+__NEWS_BOKS[__NEWS_BOKS_int_3], getLayoutName(), "show_hide_foto", '1');
										makeBigCol();
										$('#lnbs_foto_nie_'+__NEWS_BOKS[__NEWS_BOKS_int_3]).css('color', '#367cc2');
										$('#lnbs_foto_tak_'+__NEWS_BOKS[__NEWS_BOKS_int_3]).css('color', '#ed1d24');
										$('div.lnbs_foto_nofoto_'+__NEWS_BOKS[__NEWS_BOKS_int_3]).hide();
										show_hide_element_height_help(__NEWS_BOKS[__NEWS_BOKS_int_3]);
									});
									$('#s24_'+__NEWS_BOKS[__NEWS_BOKS_int_3]+'_settings > #lnbs_foto_nie_'+__NEWS_BOKS[__NEWS_BOKS_int_3]).click(function(){
									
										$.cookie('TAB_'+__NEWS_BOKS[__NEWS_BOKS_int_3]+'_foto_setting_' + getLayoutName(), '0', {
											path: '/',
											expires: 365
										});
										$('.s24_'+__NEWS_BOKS[__NEWS_BOKS_int_3]+'_bottom > div.lnbs_foto_'+__NEWS_BOKS[__NEWS_BOKS_int_3]).hide();
										xajax_save_boks_konfig('boksy_'+__NEWS_BOKS[__NEWS_BOKS_int_3], getLayoutName(), "show_hide_foto", '0');
										makeBigCol();
										$('#lnbs_foto_nie_'+__NEWS_BOKS[__NEWS_BOKS_int_3]).css('color', '#ed1d24');
										$('#lnbs_foto_tak_'+__NEWS_BOKS[__NEWS_BOKS_int_3]).css('color', '#367cc2');
										$('div.lnbs_foto_nofoto_'+__NEWS_BOKS[__NEWS_BOKS_int_3]).show();
										show_hide_element_height_help(__NEWS_BOKS[__NEWS_BOKS_int_3]);
									});
									$('#s24_'+__NEWS_BOKS[__NEWS_BOKS_int_3]+'_settings > #lnbs_short_text_tak_'+__NEWS_BOKS[__NEWS_BOKS_int_3]).click(function(){
									
										$.cookie('TAB_'+__NEWS_BOKS[__NEWS_BOKS_int_3]+'_short_text_setting_' + getLayoutName(), '1', {
											path: '/',
											expires: 365
										});
										$('.s24_'+__NEWS_BOKS[__NEWS_BOKS_int_3]+'_bottom >  div > div.lnbs_short_text_'+__NEWS_BOKS[__NEWS_BOKS_int_3]).show();
										$('.s24_'+__NEWS_BOKS[__NEWS_BOKS_int_3]+'_bottom >  div > div.lnbs_short_notext_'+__NEWS_BOKS[__NEWS_BOKS_int_3]).hide();
										xajax_save_boks_konfig('boksy_'+__NEWS_BOKS[__NEWS_BOKS_int_3], getLayoutName(), "show_hide_short_text", '1');
										makeBigCol();
										$('#lnbs_short_text_nie_'+__NEWS_BOKS[__NEWS_BOKS_int_3]).css('color', '#367cc2');
										$('#lnbs_short_text_tak_'+__NEWS_BOKS[__NEWS_BOKS_int_3]).css('color', '#ed1d24');
										show_hide_element_height_help(__NEWS_BOKS[__NEWS_BOKS_int_3]);
									});
									$('#s24_'+__NEWS_BOKS[__NEWS_BOKS_int_3]+'_settings > #lnbs_short_text_nie_'+__NEWS_BOKS[__NEWS_BOKS_int_3]).click(function(){
									
										$.cookie('TAB_'+__NEWS_BOKS[__NEWS_BOKS_int_3]+'_short_text_setting_' + getLayoutName(), '0', {
											path: '/',
											expires: 365
										});
										$('.s24_'+__NEWS_BOKS[__NEWS_BOKS_int_3]+'_bottom > div > div.lnbs_short_text_'+__NEWS_BOKS[__NEWS_BOKS_int_3]).hide();
										$('.s24_'+__NEWS_BOKS[__NEWS_BOKS_int_3]+'_bottom > div > div.lnbs_short_notext_'+__NEWS_BOKS[__NEWS_BOKS_int_3]).show();
										xajax_save_boks_konfig('boksy_'+__NEWS_BOKS[__NEWS_BOKS_int_3], getLayoutName(), "show_hide_short_text", '0');
										makeBigCol();
										$('#lnbs_short_text_nie_'+__NEWS_BOKS[__NEWS_BOKS_int_3]).css('color', '#ed1d24');
										$('#lnbs_short_text_tak_'+__NEWS_BOKS[__NEWS_BOKS_int_3]).css('color', '#367cc2');
										show_hide_element_height_help(__NEWS_BOKS[__NEWS_BOKS_int_3]);
										
									});
								
							}
						// -------------------- boksy_main_news_bottom2 - stop ------------------------------
			*/			
// ------------------------------------- START - PANELE USTAWIEN BOKSOW -------------------------------------
						makeBigCol();
						setMenu();			
}
				
				// ukrywa obrazki i czesc tekstu w newsach
function show_hide_element_height_help( $string ){
		if (jQuery("#boksy_" + $string).length > 0) {
			if (jQuery.cookie('TAB_lnbs_short_text_setting_' + getLayoutName()) == 0 && jQuery.cookie('TAB_lnbs_foto_setting_' + getLayoutName()) == 0) {
				jQuery('.s24_last_news_bottom').css('height', '100%');
			}
			else 
				if (jQuery.cookie('TAB_lnbs_foto_setting_' + getLayoutName()) == 0) {
					jQuery('.s24_last_news_bottom').css('height', '100%');
				}
				else 
					if (jQuery.cookie('TAB_lnbs_short_text_setting_' + getLayoutName()) == 0) {
						jQuery('.s24_last_news_bottom').css('height', '100px');
					}
					else 
						if (jQuery.cookie('TAB_lnbs_short_text_setting_' + getLayoutName()) == 1 && jQuery.cookie('TAB_lnbs_foto_setting_' + getLayoutName()) == 1) {
							jQuery('.s24_last_news_bottom').css('height', '100%');
						}
		}
}

function show_hide_element( $string ){
						
					if ( jQuery("#boksy_"+$string).length > 0 ) {	
						if( jQuery.cookie('TAB_'+$string+'_foto_setting_'+getLayoutName()) == 1 ){
										
											
											jQuery('.s24_'+$string+'_bottom > div.lnbs_foto_'+$string).show();
											jQuery('#lnbs_foto_tak_'+$string).addClass("global_c");
											jQuery('#lnbs_foto_nie_'+$string).removeClass("global_c");
											jQuery('div.lnbs_foto_nofoto_'+$string).show();
											
									
						};
						
						if( jQuery.cookie('TAB_'+$string+'_short_text_setting_'+getLayoutName()) == 1 ){
										
											jQuery('.s24_'+$string+'_bottom > div > div.lnbs_short_notext_'+$string).hide();
											jQuery('.s24_'+$string+'_bottom > div > div.lnbs_short_text_'+$string).show();
											jQuery('#lnbs_short_text_tak_'+$string).addClass("global_c");
											jQuery('#lnbs_short_text_nie_'+$string).removeClass("global_c");
											
										
						};
						show_hide_element_height_help($string);
					}	
					
} 
				
				// pokazywanie odpowiednij ilosci notatek w main_news_bottom
function	lnbs_pokaz_notki($string){
						if ( jQuery("#boksy_"+$string).length > 0 ) {	
							// sprawdzenie ile obiektow powinno byc otwartych
							
							var ile = jQuery.cookie('TAB_iowp_boksy_'+$string);
							
						
							if( ile > 10 || ile == null ){ ile = 10 };
							
					 		
											for (var i=1;i<12;i++) {
												
												jQuery("#s24_"+$string+"_settings > div.Nsetting").filter(":nth-child("+i+")").removeClass("global_c");
												
												if 	(i <= ile) {
													
													jQuery('#s24_'+$string+'_bottom_'+i).show();       
												} else {
													
													jQuery('#s24_'+$string+'_bottom_'+i).hide();
													
												}
												
											}
											ile++;
											jQuery("#s24_"+$string+"_settings > div.Nsetting").filter(":nth-child("+ile+")").addClass("global_c");
											
						}
};

/*
Funkcja sprawdza czy dany bloczek jest jest juz wyswietlany, jesli tak to nie podejmowana jest zadna akcja
*/
function pre_xajax_get_boks($layout_name,$name,$id,$where,$save,$repeteS24){
	
	var $all_id = jQuery("#"+$id); 
	if( $all_id.length == 0 ){
		var $place = document.getElementById($where);
		$place.innerHTML = generateBoxHtml3($id) + $place.innerHTML ;
		xajax_get_boks($layout_name,$name,$id,$where,$save,$repeteS24);
		setTimeout("checkLoginPanel()",3000);
	};
	
}

// Sprawdzenie jakie obecnie sa dostepne tabele na stronie, do ktorych mozna wrzucac boksy.
function checkAvaiableTable(){
	var $table = [];
	
	for( var $i = 0 ; $i < 10 ; $i++ ){
		var $place = jQuery('#sort'+$i);
		if( $place.length > 0 ){
			$table[$i] = "sort"+$i;
		}
	}
	
	return $table;
}

function makeSortable($name){
					//alert(" makeSortable ");
					//deleteSortable();
					var tmp = jQuery('button.delete-box');
					tmp.unbind("click");
					tmp.click(function () { 
						 jQuery(this).parent().parent().parent().parent().replaceWith("");
						 saveUserBox();
						 setMenu();
						 checkLoginPanel();
						 makeBigCol();
					});
							
					/*		*/
					var els = ['#sort0', '#sort1', '#sort2'];
					var $els = jQuery(els.toString());
					
		
					$els.sortable( "destroy" );
					$els.sortable({
						items: '> .groupItem',
						handle: 'div.handle',
						cursor: 'move',
						//cursorAt: { top: 2, left: 2 },
						opacity: 0.7,
						helper: 'clone',
						appendTo: 'body',
						placeholder: 'sortHelper',
						distance: 3,	//Default: 1
						scrollSensitivity: 50,	//	Default: 20 
						tolerance:	'guess',	//Default: "guess" intersect  pointer
						revert: true ,
						connectWith: els,
						start: function(e,ui) {
							ui.helper.css("width", ui.item.width());
							//alert(ui.helper.html());
							
							ui.helper.html(generateBoxHtmlForHelper(ui.helper.css("width") , ui.helper.css("height")));
						},
						stop:  function()
							{
								
									setTimeout('checkLoginPanel()',1); 
									setTimeout('saveUserBox()',2);
									//setTimeout('makeBigCol()',3);
									setTimeout('makeSortable("makeSortable")',4);
									setTimeout('openClose()',5);
										
										
									/*	
								//console.time("checkLoginPanel");	// 40 28 ; 18 21 
									checkLoginPanel();
								//console.timeEnd("checkLoginPanel") ;	
								
								//console.time("saveUserBox"); // 3 1 ; 13 12 
									saveUserBox();
								//console.timeEnd("saveUserBox") ;
									
								//console.time("makeBigCol"); // 390 280 ; 208 205
									makeBigCol();
								//console.timeEnd("makeBigCol") ;
								
								console.time("makeSortable"); // 300 260 ; 215 227
									makeSortable("makeSortable");
								console.timeEnd("makeSortable") ;
								
								console.time("openClose"); // 460 430 ; 298 314
									openClose();
								console.timeEnd("openClose") ;
								*/
							},
						change: function(e, ui){
							/*
							if(ui.sender){
								var w = ui.element.width();
								ui.placeholder.width(w);
								ui.helper.css("width",ui.element.children().width());
								
							}
							*/
						}
					});
		
					/* stare sortowanie
						$('div.groupWrapper').Sortable(
						{
							accept: 'groupItem',
							helperclass: 'sortHelper',
							activeclass : 	'sortableactive',
							hoverclass : 	'sortablehover',
							handle: 'div.handle',
							opacity: 	0.5,
							tolerance: 'pointer',
							onChange : function(ser)
							{
							},
							onStart : function()
							{
								//$.iAutoscroller.start(this, document.getElementsByTagName('body'));
							},
							onStop : function()
							{
								//$.iAutoscroller.stop();
								//$(this).SortableDestroy();
								//$('div.groupWrapper').SortableAddItem(this);
								//$('groupWrapper').SortableAddItem(this);
								
								checkLoginPanel();
								saveUserBox();
								makeSortable("makeSortable");
								//setTimeout('makeSortable("makeSortable")',1500);
								openClose();
							}
						}
					);
					*/
}

// Sprawdza czy panel logowania jest dostepny i czy jest jako pierwszy w kolumnie
function checkLoginPanel(){

	var $table = checkAvaiableTable();
	var $loginPanel = jQuery("#boksy_real_login");
	
	if( $loginPanel.length == 0  ){
		
		pre_xajax_get_boks(getLayoutName(),"boksy_real_login","boksy_real_login",$table[0],true,true);
			
	} else {
		
		var $parent_id = jQuery("#boksy_real_login").parent().attr("id");
		if( $parent_id != ""){
			// jezeli nie jest pierwszy w kolumnie
			if( jQuery("#"+$parent_id+" :first-child").attr("id") != "boksy_real_login") {
					
					jQuery("#boksy_real_login").remove();
					
					pre_xajax_get_boks(getLayoutName(),"boksy_real_login","boksy_real_login",$parent_id,false,false);
					
					saveUserBox();
					
			}
		} else {
					jQuery("#boksy_real_login").remove();
					
					pre_xajax_get_boks(getLayoutName(),"boksy_real_login","boksy_real_login","sort0",false,false);
					
					saveUserBox();
		}
			
	}
	
	// funkcja w widoku danej strony
	setTimeout("checkStaticBoksForPage()",500);
}

// Sprawdza czy boks o podanym ID zajkume pozycje ( kolumna , wiersz )
function checkStaticBoks( $id , $kol , $row ){

	
	var $table = checkAvaiableTable();
	var $panel = jQuery("#"+$table[$kol]+" > #"+$id);
	
	if( $panel.length == 0  ){
		
		jQuery("#"+$id).remove();
	
		pre_xajax_get_boks(getLayoutName(),$id,$id,$table[$kol],true,true);
			
	} else {
		
		var $parent_id = jQuery("#"+$id).parent().attr("id");

			// jezeli nie jest na odpowiednim miejscu w kolumnie
			
			if( jQuery("#"+$parent_id+" .groupItem:nth-child("+$row+")" ).attr("id") != $id) {
					var $child = jQuery("#"+$parent_id+" > *");
					if( $child.length > $row ){
							// cos przenosimy 
							//alert($("#"+$parent_id+" .groupItem:nth-child("+$row+")" ).attr("id"));
							//alert( " testText ");
							
							var $tmp = jQuery("#"+$parent_id+" .groupItem:nth-child("+$row+") ").clone();
							if( $tmp.html() != null && $tmp.html()!="" ) { 
									
									for( var $i = 1 ; $i < $child.length +1 ; $i++ ){
										
										if( jQuery("#"+$parent_id+" .groupItem:nth-child("+$i+")").attr("id") == $id ){
												if( $i > $row ){
													//alert( $i +"  przenosimy do "+$row );
													/*	
													$("#"+$parent_id+" .groupItem:nth-child("+$row+")").html( $("#"+$parent_id+" .groupItem:nth-child("+$i+")").html() );
													$("#"+$parent_id+" .groupItem:nth-child("+$row+")").attr("id" , $("#"+$parent_id+" .groupItem:nth-child("+$i+")").attr("id") )
													$("#"+$parent_id+" .groupItem:nth-child("+$row+")").attr("class" , $("#"+$parent_id+" .groupItem:nth-child("+$i+")").attr("class") )
													
													$("#"+$parent_id+" .groupItem:nth-child("+$i+")").html($tmp.html()) ;
													$("#"+$parent_id+" .groupItem:nth-child("+$i+")").attr("id",$tmp.attr("id")) ;
													$("#"+$parent_id+" .groupItem:nth-child("+$i+")").attr("class",$tmp.attr("class")) ;
													*/
													
													jQuery("#"+$parent_id+" .groupItem:nth-child("+$i+")").after("<div id='"+$tmp.attr("id")+"' class='"+$tmp.attr("class")+"'>"+$tmp.html()+"</div>" );
													jQuery("#"+$parent_id+" .groupItem:nth-child("+$row+")").replaceWith('');
													setTimeout("openClose();" , 200 );
													setTimeout("makeSortable();" , 200 );
													setTimeout("saveUserBox();" , 200 );
												}
												break;
										}
									}
									
									
							}
					}
			}
			
	}
	
}

// Zapis ustawien boksow
function saveUserBox()
{
		
		// sprawdzenie ile jest kolumn 
		var $table = checkAvaiableTable();
		//checkLoginPanel();
		var $table_szer = [];
		var $i=0;
		var $table_place = [$table.length];
		
		for( $i ; $i < $table.length ; $i++){
			
			var $place = document.getElementById($table[$i]);
			
			if( $place != null ){
					// sprawdzanie ilosci "dzieci" jakie dana kolumna ma 
					//var $kids = $place.children;
					var $kids = jQuery("#"+$table[$i]+" > *");
					
					// sprawdzanie szerokosci kolumny
					$table_szer[$i] = (($place.parentNode).parentNode).style.width;
				
					if( $kids != null ){
					
							var $j = 0 ;
							var $jj = 0 ;
							var $arr = [$kids.length+1];
							$table_place[$i] = $arr;
							for( $j ; $j < $kids.length ; $j++){
									if( $kids[$j].id != "" && $kids[$j].id != null ){
										$table_place[$i][$jj] = $kids[$j].id ;
										
										$jj++;
									}
							}
							//if( $i != $table.length-1 ) {
								$table_place[$i][$jj] = "||";
								//alert($table_place[$i][$jj]);
							//}
					}
			}
			
		}
		
		// zapis ustawien strony ( szerokosci kolumn )
		// przygotowane dla zmiany ilosci kolumn i ich szerokosci
		//xajax_save_layout('blog',$table_szer);
		
		// zapis ustawien do bazy danych
		
		xajax_save_user_box2(getLayoutName(),$table_place);
		setCookie("www.dlaczego.com.pl_ustawienie_boksow_"+getLayoutName(),$table_place,300);
		
		return true;
}

// 4. funkcja z serii 
// Wyciaganie boksow uzytkownika wg ukladu ktory dostajemy
// lub z ciasteczek
// jezeli nie dostalismy layoutu i nie ma go w  ciasteczkach, wrzucany jest uklad domyslny.
function getUserBox( $layout_name,  $boksy_usera  )
{
		//alert("Boksy uzykownika"+$boksy_usera);
		var $table = checkAvaiableTable();
		
		var $i=0;
		var $j=0;
		if( $boksy_usera == null || $boksy_usera == "" ){
			var $table_place = getCookie("www.dlaczego.com.pl_ustawienie_boksow_"+getLayoutName());
		} else {
			var $table_place = $boksy_usera;
		}	
		 
		 /*
		if( $layout_name == "blog" ) {
				if( $table_place == "" )
				{
					$table_place  = 'boksy_o_mnie,boksy_kalendarz_lewa_blog,boksy_notki_ze_wszystkich,boksy_notki_usera';
					$table_place += '||boksy_notki_uzytkownika';			
					$table_place += '||boksy_real_login,boksy_profil_last,boksy_polec_znajomemu';
					
				} else {
					if($table_place.match("boksy_") == null ){
						$table_place  = 'boksy_o_mnie,boksy_kalendarz_lewa_blog,boksy_notki_ze_wszystkich,boksy_notki_usera';
						$table_place += '||boksy_notki_uzytkownika';			
						$table_place += '||boksy_real_login,boksy_profil_last,boksy_polec_znajomemu';
					}
				}		
		} 
		if( $layout_name == "moj"){
			
				if( $table_place == "" )
				{
					$table_place  = 'boksy_moj_o_mnie||||';
					
				} else {
					if($table_place.match("boksy_") == null ){
						$table_place  = 'boksy_moj_o_mnie||||';
					}
				}			
		}
		
		if( $layout_name == "strona_glowna"){
			
				if( $table_place == "" )
				{
					
						$table_place =	'boksy_reklama_3,boksy_ostatnio_zalogowani,boksy_ostatnio_dodane_zdjecia,boksy_najaktywniejsi_urzytkownicy,boksy_notki_ze_wszystkich';
						$table_place +=	'||boksy_main_news_bottom2';
						$table_place += '||boksy_real_login,boksy_moj_reklama_1,boksy_szukaj,boksy_multimedia_right,boksy_countdown_right,boksy_tabele,boksy_shoutbox,boksy_tag_right,boksy_moj_reklama_2';
			
				} else {
					if($table_place.match("boksy_") == null ){
						$table_place =	'boksy_reklama_3,boksy_ostatnio_zalogowani,boksy_ostatnio_dodane_zdjecia,boksy_najaktywniejsi_urzytkownicy,boksy_notki_ze_wszystkich';
						$table_place +=	'||boksy_main_news_bottom2';
						$table_place += '||boksy_real_login,boksy_moj_reklama_1,boksy_szukaj,boksy_multimedia_right,boksy_countdown_right,boksy_tabele,boksy_shoutbox,boksy_tag_right,boksy_moj_reklama_2';
				
					}
				}			
		}
		*/
		
		
		var $table_place = $table_place.split("||");
		
		for( $i ; $i < $table_place.length ; $i++){
				
				var $table_id = $table_place[$i];
				$table_id = $table_id.split(",");
				var $j = 0;
				var $place = document.getElementById($table[$i]);
					for( $j = $table_id.length -1 ; $j > -1 ; $j--){
							
							
							if( $place != null ){
									if( $table_id[$j] != "" ){
										
										var $boks_name = $table_id[$j].split("+");
										
										//var $juz = setTimeout('saveUserBox()',1000);
										
										if( $i == $table.length-1 && $j == 1 ){
											pre_xajax_get_boks($layout_name,$boks_name[0],$boks_name[0],$place.id,false,false);
											//$place.innerHTML = generateBoxHtml3($boks_name[0]) + $place.innerHTML ;
											//setTimeout("pre_xajax_get_boks('"+$boks_name[0]+"','"+$boks_name[0]+"','"+$place.id+"',false,false)",200*($table_id.length-$j)*($table_id.length-$j)+10*$i);
											//xajax_get_boks($boks_name[0],$boks_name[0],$place.id,false,false);
										} else {
											pre_xajax_get_boks($layout_name,$boks_name[0],$boks_name[0],$place.id,false,false);
											//$place.innerHTML = generateBoxHtml3($boks_name[0]) + $place.innerHTML ;
											//setTimeout("pre_xajax_get_boks('"+$boks_name[0]+"','"+$boks_name[0]+"','"+$place.id+"',false,false)",200*($table_id.length-$j)*($table_id.length-$j)+10*$i);
											//xajax_get_boks($boks_name[0],$boks_name[0],$place.id,false,false);
										}
										
										//$place.innerHTML= generateBoxHtml3($table_id[$j]) + $place.innerHTML ;
										//var $kids = $("#"+avaiable_paste_place[$i]+" > *");
									}
							}
					}
		}
		saveUserBox();
		openClose();
}

// funkcja uruchamiana przez xajax_get_layout() 
// Odpowiedzialna za wstrzykniecie odpowiedniej struktury tabeli na strone, przed umieszczeniem w nich boks�w.
//
// Druga funkcja z serji 
function makeLayout( $layout ,$col_nr , $layout_name )
{	
	
		var $i=0;
		var $place = jQuery('#container');
		if( $place != null ){
				$place.css("width","955px");
				$place.css("height","100%");
				var $newHTML = "<tr>";
				for( $i ; $i < $col_nr ; $i++){
						$newHTML += '<td class="ui-split-main-box" style="height: 100% !important ; min-width: 235px; width: '+$layout[$i]+'px !important;">';
						$newHTML += '<div class="ui-split-main'+$i+'" style="height: 100% !important;">';
						$newHTML += '<div id="sort'+$i+'" class="groupWrapper">';
						$newHTML += '</div>';
						$newHTML += '</div>';
						$newHTML += '</td>' ;
				}
				$newHTML += "</tr>";
				$place.html($newHTML);
		}
		
				// Kod potrzebny do zmieniania szerokosci kolumn
				/*
				$('div.ui-split-main1 , div.ui-split-main2').resizable({
					handles: 'e',
		
					minWidth: 205,
					maxWidth: 330
				});
				*/
				/*
				$('div.ui-split-side').resizable({
					handles: 'e',
					proxy: 'proxy',
					minWidth: 200,
					maxWidth: 200
				});
				*/
				
				xajax_get_user_box($layout_name);	
				//openClose();
				
				setTimeout("checkLoginPanel()",1500);
				setTimeout("openClose()",3000);
				
				makeSotable('makeLayout2');
		
}

// Osadzanie ram boksow
function generateBoxHtml3($id)
{	
	$code = '<div id="'+$id+'"  class="groupItem">';
		$code += '<div>';
	
	var $noHandle = noHandlePanelFor();
	var $found = false ;
	for(var i=0; i<$noHandle.length; i++){
		if($noHandle[i]==$id){
			$found = true;
		}
	}

			
		
			
			$code += '<div id="content_of_'+$id+'">';
			$code += '<div class="box">';
				$code += '<div class="content">';
							
					$code += '<div id="'+$id+'" style="text-align: center;">';
						$code += generateHtmlIMGLoading();
					$code += '</div>';

				$code += '</div>';
			$code += '</div>';
			$code += '</div>';
		$code += '</div>';
	$code += '</div>';
	
	return $code;
}

// Widok boksu w czasie przesuwania ( pusty boks o niezerowej wysokosci )
function generateBoxHtmlForHelper( $width , $height )
{	
	//ui.helper.css("width") , ui.helper.css("height")
	$code = '<div  class="groupItem" >';
		$code += '<div>';
			$code += '<div class="box">';
				$code += '<div class="content">';
				$code += '<div style="text-align: center; height: '+$height+';">';
				$code += '</div>';
			$code += '</div></div>';
		$code += '</div>';
	$code += '</div>';
	
	return $code;
}

// Wyrzucanie boksu o podanym ID 
function deleteEmptyBoks($id)
{
	jQuery('#'+$id).remove();
}

// Generowanie tresci
function generateBoxHtml1($text)
{	
	//$code = '<div>';
	//$code += '<div>'+noAdminSite()+'</div>';
	//$code = '<div>';
	$code = $text;
	//$code += '</div>';
	//$code += '</div>';
	
	return $code;
}

function generateHtmlIMGPlus($id)
{
	$code = "<img class='menuIMGPlus' style='height: 14px;' src='http://pij.sport24.pl/js/add.gif'>";
	return $code;
}

// Obrazek 'loadnig'
function generateHtmlIMGLoading()
{
	$code = "<img class='boksIMGLoading' style='height: 16px;' src='/img/images/whole_site/loading.gif'>";
	return $code;
}

// Umieszczanie boksa na stronie
function changeMenuItem($text,$id,$where)
{
	var $all_id = jQuery("#"+$id); 
	
	// Zabezpieczenie na wypadek podwojnego klikniecia ladowania boksu
	if( $all_id.length == 1 ){
				
				
				var $paste_place = jQuery("#"+$id);
				
				/* wybieranie bloczku o najmniejszej ilosci elementow
				
				var $nr = 0 ;
				for( $i=0 ; $i < avaiable_paste_place.length ; $i++){
					//alert(avaiable_paste_place[$i]);
					var $place = document.getElementById(avaiable_paste_place[$i]);
					//alert($place.id);
					if( $place != null ){
							//var $kids = $place.children;
							var $kids = $("#"+avaiable_paste_place[$i]+" > *");
							
							if( $i == 0 ){
								$nr = $kids.length;
			
								$paste_place = $place;
							} else {
									if( $nr > $kids.length ){
										$nr = $kids.length;
										$paste_place = $place;
									} 
							}
					}
				}
				*/
				if($paste_place.attr("id") != null){
						$paste_place.replaceWith( generateBoxHtml1($text)) ;
						
						openClose();
						makeSortable('changeMenuItem');	
						setMenu();			
						makeBigCol();
						
				}		
		};
		
}

// Funkcja odpowiedzialna za dopasowywanie wysokosci strony do aktualnej wysokosci boksow , 
// dla stron o ukladzie nie bedacym zwykla tabela.
function makeBigCol( ){

						//console.time("makeBigCol");
						var $layout = getLayoutName();
						
						if( $layout != 'blog' && $layout != 'brak' ){
								var $place  = jQuery("#in_wrapper");
								if( $place != null ) {
											var $odstepy = specjalneRamki();
											var $ramka_height 	= $odstepy[0];
											var $odstep_dol 	= $odstepy[1];
											var $ramka_dol 		= $odstepy[2];
											 	
											var $child0 = jQuery("#sort0 > *");
											var $hei0 = $ramka_height + $ramka_dol ;
											var $childlength0 = $child0.length;
											var tmp0 = jQuery("#sort0 .groupItem");
											for( var $i = 1 ; $i < $childlength0 +1 ; $i++ ){
												//$hei0 = $hei0 + $("#sort0 .groupItem:nth-child("+$i+")").height();
												$hei0 = $hei0 + tmp0.filter(":nth-child("+$i+")").height();
												
											}
											$hei0 = $hei0 + $childlength0 * 5;	
														  
											var $child1 = jQuery("#sort1 > *");
											var $hei1 = $ramka_height + $ramka_dol ;
											var $childlength1 = $child1.length;
											var tmp1 = jQuery("#sort1 .groupItem");
											for( var $i = 1 ; $i < $childlength1 +1 ; $i++ ){
												//$hei1 = $hei1 + $("#sort1 .groupItem:nth-child("+$i+")").height();
												$hei1 = $hei1 + tmp1.filter(":nth-child("+$i+")").height();
												
											}
											$hei1 = $hei1 + $childlength1 * 5;
											
											var $child2 = jQuery("#sort2 > *");
											var $hei2 = 0 ;
											var $childlength2 = $child2.length;
											var tmp2 = jQuery("#sort2 .groupItem");
											for( var $i = 1 ; $i < $childlength2 +1 ; $i++ ){
												//$hei2 = $hei2 + $("#sort2 .groupItem:nth-child("+$i+")").height();
												$hei2 = $hei2 + tmp2.filter(":nth-child("+$i+")").height();
															  
											}
											$hei2 = $hei2 + $childlength2 * 5;
											
											
											var $HMAX = 0 ;
											
											
											if( $hei0 >= $hei1 && $hei0 >= $hei2){
												$HMAX = $hei0;
												
												
											} else if($hei1 >= $hei0 && $hei1 >= $hei2){
												$HMAX = $hei1;
												
												
											} else{
												$HMAX = $hei2;
												
												
											}
											 
											 if( $layout == 'fanklub' || $layout == 'profil_main') {
											 
												 		// alert($HMAX + " z " +$hei0+ " " +$hei1+ " " +$hei2 );
														
															// Specjalnie pod IE7 zeby sie nie rozciagalo	
															
															$test = navigator.userAgent.match( /.*?(?:rv|it|ra|ie)[\/: ]([\d.]+)/ );
															if( $test == null ){
																//alert('ie');
															} else {
															}
																jQuery("#in_wrapper").css("height", 	$HMAX  + $odstep_dol + "px");
																jQuery("#wrapper").css("height", 	$HMAX  + $odstep_dol + "px");
																jQuery("#left").css("height", 	$HMAX  + $odstep_dol + "px");
																jQuery("#right").css("height", 	$HMAX  + $odstep_dol + "px");
																
																if( $hei0 >= $hei1 ) {
																	jQuery("#sort0").css("height", $hei0 - $ramka_height - $ramka_dol + $odstep_dol + "px");
																	jQuery("#sort1").css("height", $hei0 - $ramka_height - $ramka_dol + $odstep_dol + "px");
																} else {
																	jQuery("#sort0").css("height", $hei1 - $ramka_height - $ramka_dol + $odstep_dol + "px");
																	jQuery("#sort1").css("height", $hei1 - $ramka_height - $ramka_dol + $odstep_dol + "px");
																}
																jQuery("#sort2").css(	"height", 	 $HMAX  + $odstep_dol + "px");
																
																jQuery("#content").css(	"height", 	$HMAX  + $odstep_dol + "px");	
																
															
														
											 } else {
											 		
												 		// alert($HMAX + " z " +$hei0+ " " +$hei1+ " " +$hei2 );
														jQuery("#in_wrapper").css("height", 	$HMAX  + $odstep_dol + "px");
														jQuery("#sort0").css("height", 		$HMAX  - $ramka_height + $odstep_dol + "px");
														jQuery("#sort1").css("height", 		$HMAX  - $ramka_height + $odstep_dol + "px");
														jQuery("#sort2").css("height", 		$HMAX  + $odstep_dol + "px");
														jQuery("#content").css("height", 	$HMAX  + $odstep_dol + "px");			
											 		
											 }
											
							}
					}
					//console.timeEnd("makeBigCol");
}

function changeMenuItemBG($id,$action)
{
	/*
	if( $action =='show'){
		
		$elem = $('#'+$id);
		$elem.after(generateHtmlIMGPlus())
		$elem.css("color","red");
		$elem.css("cursor",'pointer');
		
	} else if($action =='hide') {
		$('#'+$id).css("color","black");
		$('.menuIMGPlus').remove();
	}
	*/
	
}	;

// Zakladka najaktywiejsi uzytkownicy , wybieranie odtwartej zakladki
function s24_main_top_close( $main_top , $s24_main_top )
{
	
		 jQuery('#main_top_akt').hide();
		 jQuery('#s24_main_top_akt_open').show();
		 jQuery('#s24_main_top_akt_close').hide();
		
		 jQuery('#main_top_kom').hide();
		 jQuery('#s24_main_top_kom_open').show();
		 jQuery('#s24_main_top_kom_close').hide();
		
		 jQuery('#main_top_odw').hide();
		 jQuery('#s24_main_top_odw_open').show();
		 jQuery('#s24_main_top_odw_close').hide();
		
		 jQuery('#main_top_ocena').hide();
		 jQuery('#s24_main_top_ocena_open').show();
		 jQuery('#s24_main_top_ocena_close').hide();
		
		 jQuery('#main_top_zna').hide();
		 jQuery('#s24_main_top_zna_open').show();
		 jQuery('#s24_main_top_zna_close').hide();
		 
		 jQuery('#'+$main_top).show();
		 jQuery('#'+$s24_main_top+'_open').hide();
		 jQuery('#'+$s24_main_top+'_close').show();
		 
}
function s24_change_size(id) {
	jQuery('#tresc_krotka').css('font-size', (id+1) + 'px');
	jQuery('#tresc_dluga').css('font-size', id + 'px');
	
	jQuery('#tresc_krotka').css('line-height' ,(id+4) + 'px');
	jQuery('#tresc_dluga').css('line-height' ,(id+3) + 'px');
	
	jQuery.cookie('s24_change_size', id , { path: '/', expires: 365, domain: '.dlaczego.com.pl' });
}
function check_s24_change_size() {
	
	id = jQuery.cookie('s24_change_size'); 
	id = parseInt( id );
	if( id != 0 && id != null && id != '' ){
		s24_change_size(id);
	}
	
}
//edycja tekstu
function editText(v, typ)
{
	document.getElementById('edit_'+v+'_tekst').value = (typ==1?document.getElementById('show_'+v).innerHTML:'');
	
	e = document.getElementById('edit_'+v+'_tekst').value;
	if (e.replace(/ć/g, "c")=='Kliknij aby dodac tekst!') e='';
	e = e.replace(/<BR>/g, "");
	e = e.replace(/<br>/g, "");
	document.getElementById('edit_'+v+'_tekst').value = e;
	
	//document.getElementById('edit_motto_tekst').value = e.replace(/ć/g, "c");
	document.getElementById('show_'+v).style.display = (typ==1?'none':'block');
	document.getElementById('edit_'+v).style.display = (typ==1?'block':'none');
}

function s24_news_kat(id_kategoria,id_lokalizacja,typ){
	if(typ == null){ typ = 'news';};
 	window.location.href = "/"+typ+"/index/" + id_kategoria + "/" + id_lokalizacja + "/0/";
}

function s24_dowcip_kat(id_kategoria,id_lokalizacja,typ){
	if(typ == null){ typ = 'news';};
 	window.location.href = "/"+typ+"/index/" + id_kategoria + "/0/0/";
}


 function s24_archiwum_kat(data,id_kategoria,id_lokalizacja,typ){
 if(typ == null){ typ = 'news';};
 window.location.href = "/"+typ+"/archiwum/" + data + "/0/" + id_kategoria + "/" + id_lokalizacja + "/0/";

}
function boksy_oc_box_open(name){
						jQuery('#'+name).show();
									jQuery('#s24_'+name+'_open').hide();
									jQuery('#s24_'+name+'_close').show();
									jQuery.cookie('TAB_'+name, '1', { path: '/', expires: 365 });
									
									xajax_save_boks_konfig( 'boksy_'+name , getLayoutName() , "open_close" , '1');
									makeBigCol();
}



function boksy_oc_box_close(name){
														jQuery('#'+name).hide();
														jQuery('#s24_'+name+'_open').show();
														jQuery('#s24_'+name+'_close').hide();
														jQuery.cookie('TAB_'+name, '0', { path: '/', expires: 365 });
														
														xajax_save_boks_konfig( 'boksy_'+name , getLayoutName() , "open_close" , '0');
														makeBigCol();
}

function box_open(name){
	jQuery('#'+name).show();
	jQuery('#'+name+'_open').hide();
	jQuery('#'+name+'_close').show();
}

function box_close(name){
	jQuery('#'+name).hide();
	jQuery('#'+name+'_open').show();;
	jQuery('#'+name+'_close').hide();
}

function selectCheck(v) {
	i=0;
	while (c = document.getElementById('id'+i))
	{
		c.checked = v.checked;
		i++;
	}
}
function switchStylestyle(styleName)
   {
      jQuery('link[@rel*=style][title]').each(function(i)
      {
    	 //console.log(this);
         this.disabled = true;
         if (this.getAttribute('title') == styleName) this.disabled = false;
      });
      
	  jQuery.cookie('kolor_dlaczego', styleName, { path: '/', expires: 365 , domain: '.dlaczego.com.pl' })
   }
 /**
  * Funkcja czysci wszystkie pola jakie znajduja sie w obiekcie o zadanym id
  * 
  * @param {Object String} str_form_name
  */  

function clearForm(form) {
  
  jQuery('#'+form+' :input').each(function() {
 	 var type = this.type;
 	 var tag = this.tagName.toLowerCase(); // normalize case
 
	 if (type == 'text' || type == 'password' || tag == 'textarea')
	   this.value = "";
	 
	 else if (type == 'checkbox' || type == 'radio')
	   this.checked = false;
	
	 else if (tag == 'select')
	   this.selectedIndex = -1;
  });
};

//oddanie głosu na sondzie typu yes/no
function sondaGlosuj(glos, id) 
{
	document.getElementById('sonda_odp'+id).value = glos;
	document.getElementById('sonda_odp'+id).form.submit();
}

//podświetla linie w sondzie typu yes/no
function sondaOver(glos, id) 
{
	document.getElementById('sonda_wynik'+glos+'_'+id).style.background = (glos==1?"#ff9494":"#9494FF");
}
//odświetla linie w sondzie typu yes/no
function sondaOut(glos, id)  
{
	document.getElementById('sonda_wynik'+glos+'_'+id).style.background = (glos==1?"#FF0000":"#0000FF");
} 

//sprawdzanie ilosci zaznaczen w sondzie typu checkbox
function sondaCheckbox(k, count, id) 
{
	i=0;
	zaz=0;
	while (a = document.getElementById('sonda_odp'+i+'_'+id))
	{
		if (a.checked) zaz++;
		i++;
	}

	if (count<zaz)
	{
		k.checked = false;
		alert('Możesz zaznaczyć maksymalnie '+count+' odpowiedzi!')
	}
}

// Zapisuje ustawinia mapy w cookie
function GMaps_cookie( zoom , lat , lng ){
	jQuery.cookie('GM_zoom', zoom, { path: '/', expires: 365 });
	jQuery.cookie('GM_coor_lat', lat, { path: '/', expires: 365 });
	jQuery.cookie('GM_coor_lng', lng, { path: '/', expires: 365 });
}

// Sprawdza czy podany tekst jest liczbą
function IsNumeric(sText)

{
   var ValidChars = "-+0123456789.";
   var IsNumber=true;
   var Char;

 
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;
   
   }
	
	function gm_szukaj_zaznacz( id , gm_map){
		var miejsce_tmp = jQuery('#'+id).val();
		var geocoder_tmp = new GClientGeocoder();
		geocoder_tmp.getLatLng( miejsce_tmp, 
				function(point) { if (!point) { 
						jQuery('#'+id+'_alert_1').show();
						setTimeout("jQuery('#"+id+"_alert_1').hide();",10000);
						return false;	
				} else { 
						gm_map.setCenter(new GLatLng( point.lat(), point.lng()),15);return true;
				}});
		
	}

/**
*
*  URL encode / decode
*  http://www.webtoolkit.info/
*
**/
 
var Url = {
 
 	
 
	// public method for url encoding
	encode : function (string) {
		return this._iso_8859_1_encode(string);
	},
 
	// public method for url decoding
	decode : function (string) {
		return this._utf8_decode(unescape(string));
	},
 
 	_iso_8859_1_encode: function (string) {
		
		
		var utftext = "";
		string = string.replace(/\r\n/g,"\n");
		 
		for (var n = 0; n < string.length; n++) {
 
			var c = string.charCodeAt(n);
 			
			if (c < 128) {
				utftext += String.fromCharCode(c);
			}
			else {
				
				switch(c)
					{
					case 261: utftext +="%B1"; break;
					case 321: utftext +="%A3"; break;
					case 346: utftext +="%A6"; break;
					case 377: utftext +="%AC"; break;
					case 379: utftext +="%AF"; break;
					case 322: utftext +="%B3"; break;
					case 347: utftext +="%B6"; break;
					case 378: utftext +="%BC"; break;
					case 380: utftext +="%BF"; break;
					case 262: utftext +="%C6"; break;
					case 280: utftext +="%CA"; break; 
					case 323: utftext +="%D1"; break;
					case 211: utftext +="%D3"; break;
					case 263: utftext +="%E6"; break;
					case 281: utftext +="%EA"; break;
					case 324: utftext +="%F1"; break;
					case 243: utftext +="%F3"; break;
					default:
					 utftext += String.fromCharCode(c);
					}
				
			}
 			
		}
 
		return utftext;
	},
 
	// private method for UTF-8 encoding
	_utf8_encode : function (string) {
		string = string.replace(/\r\n/g,"\n");
		var utftext = "";
 
		for (var n = 0; n < string.length; n++) {
 
			var c = string.charCodeAt(n);
 
			if (c < 128) {
				utftext += String.fromCharCode(c);
			}
			else if((c > 127) && (c < 2048)) {
				utftext += String.fromCharCode((c >> 6) | 192);
				utftext += String.fromCharCode((c & 63) | 128);
			}
			else {
				utftext += String.fromCharCode((c >> 12) | 224);
				utftext += String.fromCharCode(((c >> 6) & 63) | 128);
				utftext += String.fromCharCode((c & 63) | 128);
			}
 			
		}
 
		return utftext;
	},
 
	// private method for UTF-8 decoding
	_utf8_decode : function (utftext) {
		var string = "";
		var i = 0;
		var c = c1 = c2 = 0;
 
		while ( i < utftext.length ) {
 
			c = utftext.charCodeAt(i);
 
			if (c < 128) {
				string += String.fromCharCode(c);
				i++;
			}
			else if((c > 191) && (c < 224)) {
				//c2 = utftext.charCodeAt(i+1);
				//string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
				
				i += 2;
			}
			else {
				c2 = utftext.charCodeAt(i+1);
				c3 = utftext.charCodeAt(i+2);
				string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
				i += 3;
			}
 
		}
 
		return string;
	}
 
}


